/* Palette bleu marine / blanc / rouge */
:root {
  --brand: #0d2b5c;
  --brand-2: #1f4a9a;
  --brand-soft: #e5ebf6;
  --accent: #e30613;
  --on-brand: #ffffff;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --text: #0f1a2e;
  --muted: #5a6478;
  --line: #d9dfe9;
  --danger: #d0101c;
  --shadow: 0 6px 24px rgba(13, 30, 70, .14), 0 1px 3px rgba(13, 30, 70, .08);
  --radius: 14px;
  --tabbar-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #7fa2e8;
    --brand-2: #a3bdf2;
    --brand-soft: #1b2847;
    --accent: #ff4b55;
    --on-brand: #0a1530;
    --bg: #0b1120;
    --surface: #131b2e;
    --surface-2: #1b253b;
    --text: #e8edf7;
    --muted: #9aa6bd;
    --line: #27324a;
    --danger: #ff5c66;
    --shadow: 0 6px 24px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg:not(.leaflet-zoom-animated) { width: 20px; height: 20px; flex: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
a { color: var(--brand); }
[hidden] { display: none !important; }

/* ---------- structure ---------- */
.app { display: grid; height: 100dvh; grid-template-rows: auto 1fr auto; grid-template-areas: "top" "main" "tabs"; }
.topbar { grid-area: top; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: #0d2b5c; color: #fff; border-bottom: 4px solid var(--accent); z-index: 1001; }
.topbar .brand p { color: rgba(255,255,255,.75); }
.topbar .sync { color: rgba(255,255,255,.8); }
.topbar .role-badge { background: rgba(255,255,255,.14); color: #fff; }
.topbar .role-badge.admin { background: var(--accent); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand h1 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.brand p { margin: 0; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand > div { min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex: none; }
.role-badge { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); }
.role-badge.admin { background: #fde9cf; color: #8a4b00; }
@media (prefers-color-scheme: dark) { .role-badge.admin { background: #3d2a10; color: #f6b866; } }
.sync { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.sync i { width: 8px; height: 8px; border-radius: 50%; background: #aaa; }
.sync.ok i { background: #1f9d55; }
.sync.off i { background: var(--danger); }
.sync.pending i { background: #e08a00; }

.tabs { grid-area: tabs; display: flex; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 1001; }
.tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 4px 8px; border: 0; background: none; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.tabs button svg { width: 24px; height: 24px; }
.tabs button.active { color: var(--brand); }
.tabs button.active svg { background: var(--brand-soft); border-radius: 99px; width: 48px; padding: 0 12px; }

.main { grid-area: main; position: relative; min-height: 0; display: grid; }
.map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: var(--surface-2); }
.panel { position: absolute; inset: 0; z-index: 1100; background: var(--bg); overflow-y: auto; display: none; -webkit-overflow-scrolling: touch; }
.app:not([data-view="carte"]) .panel { display: block; }
.view { display: none; padding: 16px 16px 32px; max-width: 760px; margin: 0 auto; }
.app[data-view="liste"] #view-liste,
.app[data-view="aide"] #view-aide,
.app[data-view="admin"] #view-admin { display: block; }

/* Bureau : barre latérale + panneau + carte côte à côte */
@media (min-width: 960px) {
  .app { grid-template-columns: 88px 1fr; grid-template-rows: auto 1fr; grid-template-areas: "top top" "tabs main"; }
  .tabs { flex-direction: column; border-top: 0; border-right: 1px solid var(--line); padding: 8px 0; gap: 2px; }
  .tabs button { flex: none; padding: 12px 4px; }
  .main { grid-template-columns: auto 1fr; }
  .panel { position: relative; inset: auto; width: 420px; border-right: 1px solid var(--line); grid-column: 1; grid-row: 1; }
  .map-wrap { grid-column: 2; grid-row: 1; }
  .app[data-view="carte"] .panel { display: none; }
  .view { padding: 20px 20px 40px; }
}

/* ---------- carte : contrôles flottants ---------- */
.map-filters { position: absolute; top: 12px; left: 12px; right: 12px; z-index: 500; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.map-filters > * { pointer-events: auto; }
.select { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; background: var(--surface); border-radius: 99px; padding: 0 6px 0 14px; box-shadow: var(--shadow); max-width: 100%; }
.select svg { color: var(--brand); width: 18px; height: 18px; }
.select select { border: 0; background: transparent; padding: 11px 26px 11px 0; font-weight: 600; appearance: none; -webkit-appearance: none; min-width: 0; max-width: 100%; text-overflow: ellipsis;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 13px) 50%, calc(100% - 8px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.select select:focus { outline: none; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; border: 1px solid transparent; background: var(--surface); color: var(--text); padding: 6px 12px; border-radius: 99px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow); }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.chip.off { opacity: .45; box-shadow: none; border-color: var(--line); }
.chip .n { color: var(--muted); font-weight: 500; }

.map-stats { position: absolute; left: 12px; bottom: 16px; z-index: 500; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); padding: 8px 12px; font-size: 12.5px; color: var(--muted); max-width: calc(100% - 160px); }
.map-stats b { color: var(--text); font-size: 15px; }
.map-stats .bar { display: flex; height: 6px; border-radius: 4px; overflow: hidden; margin-top: 6px; background: var(--surface-2); min-width: 140px; }
.map-stats .bar span { background: var(--c); }

.map-tools { position: absolute; right: 12px; bottom: 90px; z-index: 500; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.layer-switch { display: flex; flex-direction: column; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.layer-switch button { border: 0; background: none; padding: 9px 14px; font-size: 13px; font-weight: 600; color: var(--muted); text-align: left; }
.layer-switch button.active { background: var(--brand); color: #fff; }
.round { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow); display: grid; place-items: center; }
.round[aria-pressed="false"] { color: var(--muted); opacity: .7; }
.round.active { color: var(--brand); }

.fab { position: absolute; right: 12px; bottom: 20px; z-index: 600; display: flex; align-items: center; gap: 8px; border: 0; border-radius: 99px; padding: 14px 20px 14px 16px; background: var(--brand); color: #fff; font-weight: 700; font-size: 15px; box-shadow: 0 8px 24px rgba(13, 43, 92, .4); }
@media (prefers-color-scheme: dark) { .fab { color: var(--on-brand); } }
.fab svg { width: 22px; height: 22px; }
.place-hint { position: absolute; left: 50%; top: 110px; transform: translateX(-50%); z-index: 700; background: var(--text); color: var(--bg); padding: 10px 10px 10px 16px; border-radius: 99px; font-weight: 600; font-size: 14px; display: flex; gap: 10px; align-items: center; box-shadow: var(--shadow); white-space: nowrap; }
.place-hint button { border: 0; border-radius: 99px; padding: 6px 12px; background: var(--bg); color: var(--text); font-weight: 600; }

/* marqueurs */
.pin { width: 22px; height: 22px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--c); border: 2.5px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.pin.sel { outline: 3px solid var(--brand-2); outline-offset: 2px; }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #2a7de1; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(42,125,225,.25), 0 1px 4px rgba(0,0,0,.4); }
.circo-label { background: none; border: 0; box-shadow: none; font-weight: 800; font-size: 13px; color: #0d2b5c; text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 6px #fff; white-space: nowrap; }
.circo-label::before { display: none; }
.cluster { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 13px; border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.leaflet-container { font-family: var(--font); }
.leaflet-control-attribution { font-size: 10px; }
.leaflet-top.leaflet-left { top: 108px; }
.leaflet-control-attribution { max-width: 60vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- éléments communs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); padding: 11px 16px; border-radius: 12px; font-weight: 600; text-decoration: none; color: var(--text); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: var(--on-brand); } }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.big { padding: 15px 18px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > .btn { flex: 1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.view h2 { font-size: 22px; letter-spacing: -.01em; margin-bottom: 4px; }
.view > .lead { color: var(--muted); margin: 0 0 16px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 22px 0 8px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 700; background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c); }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=search], textarea, select.input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
textarea { min-height: 76px; resize: vertical; }
input:focus, textarea:focus, select.input:focus { outline: 2px solid var(--brand-2); outline-offset: 0; border-color: transparent; }

.status-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.status-pick button { display: flex; align-items: center; gap: 8px; padding: 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); font-weight: 600; text-align: left; font-size: 14px; }
.status-pick button .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c); flex: none; }
.status-pick button.sel { border-color: var(--c); background: color-mix(in srgb, var(--c) 12%, var(--surface)); }

.photo-input { display: flex; align-items: center; gap: 12px; }
.photo-input img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; }
.photo-input input { display: none; }

/* ---------- feuille modale ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(10, 20, 18, .45); z-index: 2000; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 92dvh; overflow-y: auto; z-index: 2001; background: var(--bg); border-radius: 20px 20px 0 0; box-shadow: var(--shadow); padding-bottom: env(safe-area-inset-bottom); animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet-body { padding: 22px 16px 24px; }
.sheet-close { position: sticky; top: 10px; float: right; margin: 10px 10px 0 0; width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--surface-2); display: grid; place-items: center; z-index: 1; }
.sheet h3 { font-size: 20px; margin-bottom: 4px; padding-right: 40px; }
@media (min-width: 700px) {
  .sheet { left: 50%; top: 50%; bottom: auto; transform: translate(-50%, -50%); width: 560px; border-radius: 20px; max-height: 88dvh; animation: none; }
}
.hero-photo { width: 100%; max-height: 260px; object-fit: cover; border-radius: 12px; margin: 12px 0; display: block; background: var(--surface-2); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; margin: 12px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; word-break: break-word; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: grid; grid-template-columns: 14px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); margin-top: 4px; }
.timeline img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; margin-top: 6px; }
.timeline .del { border: 0; background: none; color: var(--danger); font-size: 12.5px; padding: 0; margin-left: 8px; }

/* ---------- Scanner ---------- */
.gps-card { display: flex; align-items: center; gap: 14px; }
.gps-ring { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; position: relative; }
.gps-ring.live::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--brand-2); animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { from { transform: scale(.85); opacity: 1; } to { transform: scale(1.25); opacity: 0; } }
.gps-ring svg { width: 26px; height: 26px; }
.acc { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.acc.good { background: #dff3e8; color: #17703f; }
.acc.mid { background: #fdf0d8; color: #8a5600; }
.acc.bad { background: #fbe2e2; color: #a02c2c; }
@media (prefers-color-scheme: dark) { .acc.good { background: #183a28; color: #7fd8a3; } .acc.mid { background: #3a2c12; color: #f2c069; } .acc.bad { background: #3d1c1c; color: #f29999; } }
.nearest { border: 2px solid var(--brand-2); }
.nearest .dist { font-size: 34px; font-weight: 800; letter-spacing: -.02em; }
.near-list { list-style: none; padding: 0; margin: 0; }
.near-list li { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.near-list li:last-child { border-bottom: 0; }
.near-list .d { margin-left: auto; font-weight: 700; white-space: nowrap; }

/* ---------- Liste ---------- */
.search { position: relative; margin-bottom: 12px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 40px; }
.list-group h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 6px; display: flex; justify-content: space-between; }
.item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; background: var(--surface); padding: 12px 14px; border-radius: 12px; margin-bottom: 6px; border: 1px solid var(--line); }
.item .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); flex: none; }
.item .t { font-weight: 600; }
.item .s { font-size: 12.5px; color: var(--muted); }
.item .when { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }

/* ---------- Aide ---------- */
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 16px 46px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: -2px; width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 800; display: grid; place-items: center; }
@media (prefers-color-scheme: dark) { .steps li::before { color: var(--on-brand); } }
.steps li b { display: block; margin-bottom: 2px; }
details.faq { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; margin-bottom: 8px; }
details.faq summary { font-weight: 600; padding: 13px 0; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
details.faq summary::after { content: "+"; font-size: 20px; line-height: 1; color: var(--muted); }
details.faq[open] summary::after { content: "–"; }
details.faq > div { padding: 0 0 14px; color: var(--muted); }
.roles { display: grid; gap: 8px; }
.roles > div { display: grid; grid-template-columns: 110px 1fr; gap: 10px; align-items: start; }
.legend { display: grid; gap: 8px; }
.legend > div { display: flex; gap: 10px; align-items: center; }
.legend .pin { width: 16px; height: 16px; border-width: 2px; }

/* ---------- Admin ---------- */
.link-row { display: grid; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.link-row:last-child { border-bottom: 0; }
.link-row code { display: block; font-size: 12px; background: var(--surface-2); padding: 8px 10px; border-radius: 8px; word-break: break-all; }
.link-row .row .btn { padding: 8px 10px; font-size: 13px; }
table.stats { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.stats th, table.stats td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: right; }
table.stats th:first-child, table.stats td:first-child { text-align: left; }
table.stats th { font-size: 12px; color: var(--muted); font-weight: 600; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch input { width: 46px; height: 26px; appearance: none; -webkit-appearance: none; background: var(--line); border-radius: 99px; position: relative; cursor: pointer; flex: none; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { left: 23px; }

/* rôles : masquage */
.app:not(.can-contrib) .contrib-only,
body:not(.can-contrib) .contrib-only { display: none !important; }
.app:not(.is-admin) .admin-only,
body:not(.is-admin) .admin-only { display: none !important; }

/* ---------- accès / toast ---------- */
.lock { position: fixed; inset: 0; z-index: 3000; background: var(--bg); display: grid; place-items: center; padding: 16px; }
.lock-card { max-width: 420px; text-align: center; }
.lock-card h2 { margin: 14px 0 8px; font-size: 22px; }
.lock-card p { color: var(--muted); }
.lock-card form { display: grid; gap: 10px; margin-top: 18px; }
.lock-err { color: var(--danger) !important; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 24px); transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 14px; z-index: 4000; opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Scan plein écran (caméra + GPS) ---------- */
.scan { position: fixed; inset: 0; z-index: 2500; background: #000; color: #fff; overflow: hidden; }
.scan video, .scan #scan-still { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px; padding-top: max(12px, env(safe-area-inset-top)); background: linear-gradient(rgba(0,0,0,.55), transparent); z-index: 2; }
.scan-btn { width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(0,0,0,.45); color: #fff; display: grid; place-items: center; backdrop-filter: blur(6px); flex: none; }
.scan-btn svg { width: 22px; height: 22px; }
.scan-btn.on { background: #ffd23f; color: #000; }
.scan-gps { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.5); backdrop-filter: blur(6px); padding: 9px 14px; border-radius: 99px; font-size: 13.5px; font-weight: 600; min-width: 0; }
.scan-gps span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scan-gps i { width: 9px; height: 9px; border-radius: 50%; background: #aaa; flex: none; animation: blink 1s infinite; }
.scan-gps.good i { background: #34d27b; animation: none; }
.scan-gps.mid i { background: #ffb020; animation: none; }
.scan-gps.bad i { background: #ff5c5c; }
@keyframes blink { 50% { opacity: .3; } }
.scan-frame { position: absolute; left: 50%; top: 45%; width: min(74vw, 340px); aspect-ratio: 4 / 3; transform: translate(-50%, -50%); pointer-events: none; }
.scan-frame i { position: absolute; width: 38px; height: 38px; border: 4px solid #fff; filter: drop-shadow(0 0 4px rgba(0,0,0,.5)); }
.scan-frame i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 14px 0 0 0; }
.scan-frame i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 14px 0 0; }
.scan-frame i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 14px; }
.scan-frame i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 14px 0; }
.scan-hint { position: absolute; left: 16px; right: 16px; bottom: calc(150px + env(safe-area-inset-bottom)); text-align: center; font-weight: 600; font-size: 15px; text-shadow: 0 1px 4px rgba(0,0,0,.8); z-index: 2; }
.scan-bottom { position: absolute; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 18px 12px; padding-bottom: max(26px, calc(env(safe-area-inset-bottom) + 14px)); background: linear-gradient(transparent, rgba(0,0,0,.6)); z-index: 2; }
.shutter { width: 84px; height: 84px; border-radius: 50%; border: 5px solid #fff; background: transparent; padding: 5px; }
.shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: transform .1s; }
.shutter:active span { transform: scale(.88); background: var(--accent); }
.scan-side { justify-self: center; display: flex; flex-direction: column; align-items: center; gap: 4px; border: 0; background: none; color: #fff; font-size: 12px; font-weight: 600; cursor: pointer; text-shadow: 0 1px 3px rgba(0,0,0,.7); }
.scan-side svg { width: 26px; height: 26px; padding: 10px; box-sizing: content-box; border-radius: 50%; background: rgba(0,0,0,.45); }
.scan-result { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; background: var(--bg); color: var(--text); border-radius: 22px 22px 0 0; padding: 20px 16px; padding-bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px)); max-height: 78dvh; overflow-y: auto; animation: up .2s ease-out; box-shadow: 0 -8px 30px rgba(0,0,0,.35); }
.scan-result h3 { font-size: 21px; margin: 8px 0 4px; }
.sr-pos { font-size: 13px; color: var(--muted); }
.sr-sub { margin: 0 0 12px; color: var(--muted); }
.sr-q { font-weight: 700; margin: 14px 0 8px; }
.sr-name { margin-bottom: 8px; }
.scan-result .status-pick button { padding: 16px 12px; font-size: 15px; }
.sr-loading { display: flex; align-items: center; gap: 12px; font-weight: 600; padding: 12px 0; }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.linkbtn { border: 0; background: none; color: var(--brand); font-weight: 600; padding: 12px 0 0; font-size: 14px; text-decoration: underline; }
.shake { animation: shake .4s; outline: 2px solid var(--danger) !important; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@media (min-width: 700px) { .scan-result { left: 50%; width: 520px; transform: translateX(-50%); } }

/* point mis en évidence après un scan */
.pulse { width: 80px; height: 80px; border-radius: 50%; position: relative; }
.pulse::before, .pulse::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 4px solid var(--c); animation: ring 1.6s ease-out infinite; }
.pulse::after { animation-delay: .8s; }
@keyframes ring { from { transform: scale(.2); opacity: 1; } to { transform: scale(1); opacity: 0; } }

/* sélecteur segmenté (Liste) */
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: none; padding: 10px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* ---------- Téléphone ---------- */
body { overscroll-behavior: none; }
.tab-scan b { display: grid; place-items: center; width: 58px; height: 58px; margin-top: -26px; border-radius: 50%; background: var(--brand); color: #fff; box-shadow: 0 6px 18px rgba(13, 43, 92, .45); border: 4px solid var(--surface); }
@media (prefers-color-scheme: dark) { .tab-scan b { color: var(--on-brand); } }
.tabs button.tab-scan svg, .tabs button.tab-scan.active svg { width: 28px; height: 28px; background: none; padding: 0; }
.tabs button.tab-scan { color: var(--brand); }
@media (min-width: 960px) { .tab-scan b { margin-top: 0; width: 52px; height: 52px; } }

@media (max-width: 959px) {
  /* le bouton Scanner central remplace le bouton flottant */
  .fab { display: none; }
  .leaflet-control-zoom { display: none; }
  .map-tools { bottom: 16px; }
  .map-stats { bottom: 16px; max-width: calc(100% - 150px); }
  .layer-switch { flex-direction: row; }
  .layer-switch button { padding: 10px 11px; }
  .map-tools { flex-direction: row; align-items: flex-end; flex-wrap: wrap-reverse; justify-content: flex-end; max-width: calc(100% - 24px); }
  .map-stats { bottom: 74px; }
  /* évite le zoom automatique d'iOS quand on touche un champ */
  input[type=text], input[type=search], textarea, select, .select select { font-size: 16px; }
  .btn { min-height: 46px; }
  .sheet::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; }
}
@media (max-width: 420px) {
  .brand p { display: none; }
  .sync span { display: none; }
  .tabs button { font-size: 11px; }
}

/* ---------- Actions : en bon état / signaler un problème / annotation ---------- */
.act { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.act .btn { min-height: 58px; font-size: 15px; line-height: 1.2; text-align: left; justify-content: flex-start; padding: 12px; }
.act .btn svg { width: 22px; height: 22px; }
.act-ok { background: var(--c); border-color: var(--c); color: #fff; }
.act-pb { border: 2px solid var(--c); color: var(--c); background: var(--surface); }
.act-pb.sel { background: color-mix(in srgb, var(--c) 12%, var(--surface)); }
.pb-box { margin-top: 12px; padding: 12px; border-radius: 14px; border: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.pb-box .sr-q { margin-top: 0; }
.motifs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.motifs button { border: 1.5px solid var(--line); background: var(--surface); border-radius: 99px; padding: 10px 14px; font-weight: 600; font-size: 14px; }
.motifs button.sel { border-color: var(--accent); background: var(--accent); color: #fff; }
.act-send { background: var(--c); border-color: var(--c); color: #fff; min-height: 52px; font-size: 16px; }
.act-note { margin-bottom: 12px; }
.act-note textarea { min-height: 60px; }
.annot { display: flex; gap: 6px; align-items: flex-start; font-size: 13.5px; margin-top: 4px; padding: 6px 10px; background: var(--surface-2); border-radius: 8px; }
.annot svg { width: 16px; height: 16px; margin-top: 2px; color: var(--muted); }
fieldset:disabled .act, fieldset:disabled .act-note { opacity: .5; }

/* ---------- Ordinateur ou téléphone ---------- */
html.ordi .only-mobile, html.mobile .only-ordi { display: none !important; }
/* sur ordinateur, le bouton « Ajouter un panneau » reste visible même dans une fenêtre étroite */
html.ordi .fab { display: flex !important; }
html.ordi .leaflet-control-zoom { display: block !important; }
html.ordi .tab-scan b { margin-top: 0; }
@media (min-width: 960px) {
  html.ordi .sheet { width: 600px; }
  html.ordi .view { max-width: none; }
}
@media (max-width: 959px) { html.ordi .map-tools { bottom: 84px; } html.ordi .map-stats { bottom: 16px; } }

/* ---------- Itinéraire ---------- */
.pill-btn { display: inline-flex; align-items: center; gap: 6px; height: 46px; padding: 0 16px; border-radius: 99px; border: 0; background: var(--surface); color: var(--brand); font-weight: 700; box-shadow: var(--shadow); }
body.routing .pill-btn { background: var(--brand); color: var(--on-brand); }
body.routing .fab, body.routing .map-stats { display: none !important; }
.route-bar { position: absolute; z-index: 800; left: 12px; right: 12px; bottom: 12px; background: var(--surface); color: var(--text); border-radius: 18px; box-shadow: var(--shadow); padding: 12px 14px 14px; display: grid; gap: 10px; max-height: 60%; overflow-y: auto; border-top: 4px solid var(--accent); }
@media (min-width: 700px) { .route-bar { right: auto; width: 400px; } }
.rb-head { display: flex; align-items: center; gap: 10px; }
.rb-head > svg { width: 26px; height: 26px; color: var(--brand); }
.rb-sum { font-weight: 700; font-size: 15px; color: var(--brand); }
.rb-x { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--surface-2); display: grid; place-items: center; flex: none; }
.rb-modes { margin: 0; }
.rb-quick { display: flex; gap: 6px; flex-wrap: wrap; }
.rb-quick .chip { box-shadow: none; border-color: var(--line); }
.rb-from { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.rb-from input { width: 20px; height: 20px; accent-color: var(--brand); }
body.routing .map-tools { bottom: auto; top: 108px; }
@media (max-width: 959px) { body.routing .map-tools { top: 100px; } body.routing .layer-switch { display: none; } }
.pin.pickable { cursor: copy; }
.stop { width: 30px; height: 30px; border-radius: 50%; background: var(--c); color: #fff; font-weight: 800; font-size: 14px; display: grid; place-items: center; border: 3px solid #fff; box-shadow: 0 0 0 2px #0d2b5c, 0 3px 8px rgba(0,0,0,.35); }
.stop.done { background: #8b95a7; }
.steps-list { list-style: none; padding: 0; margin: 12px 0 0; }
.steps-list li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.steps-list li.done b { text-decoration: line-through; color: var(--muted); }
.steps-list .stop { flex: none; box-shadow: 0 0 0 2px #0d2b5c; }
.steps-list .row .btn { padding: 8px 10px; min-height: 0; font-size: 13px; flex: 0 1 auto; }
@media (max-width: 959px) {
  body.routing .map-tools { top: 112px; }
  .route-bar { gap: 8px; padding: 10px 12px 12px; max-height: 52%; }
  .route-bar .seg button { padding: 8px; }
  .route-bar .btn { min-height: 44px; }
}

/* ---------- Choix du guidage ---------- */
.guide-opts { display: grid; gap: 10px; margin-top: 12px; }
.guide-opt { display: flex; align-items: flex-start; gap: 14px; text-align: left; padding: 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); }
.guide-opt svg { width: 28px; height: 28px; color: var(--brand); flex: none; margin-top: 2px; }
.guide-opt b { display: block; font-size: 16px; margin-bottom: 2px; }
.guide-opt small { color: var(--muted); font-size: 13px; line-height: 1.35; display: block; }
.guide-opt.last { border-color: var(--brand); background: var(--brand-soft); }
.guide-opt:hover { border-color: var(--brand-2); }

/* ---------- Guidage dans l'application ---------- */
body.nav .map-filters, body.nav .map-tools, body.nav .map-stats, body.nav .fab, body.nav .route-bar, body.nav .tabs, body.nav .leaflet-control-zoom { display: none !important; }
.nav-top { position: absolute; z-index: 850; top: 12px; left: 12px; right: 12px; display: flex; align-items: center; gap: 14px; background: #0d2b5c; color: #fff; padding: 14px 16px; border-radius: 18px; box-shadow: var(--shadow); border-bottom: 4px solid var(--accent); }
.nav-top b { display: block; font-size: 18px; line-height: 1.25; }
.nav-top small { display: block; opacity: .75; font-size: 13px; }
.nt-d { display: block; font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.nt-ico { width: 56px; height: 56px; border-radius: 14px; background: rgba(255,255,255,.12); display: grid; place-items: center; flex: none; }
.nt-ico svg { width: 38px; height: 38px; transition: transform .3s; }
.nav-bottom { position: absolute; z-index: 850; left: 12px; right: 12px; bottom: 12px; background: var(--surface); color: var(--text); border-radius: 18px; box-shadow: var(--shadow); padding: 14px; display: grid; gap: 10px; max-height: 70%; overflow-y: auto; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.nb-row { display: flex; align-items: center; gap: 10px; }
.nb-name { display: block; font-size: 18px; }
@media (min-width: 700px) { .nav-top, .nav-bottom { right: auto; width: 440px; } }

/* ---------- Cases à cocher de la Liste ---------- */
.item-row { display: flex; align-items: stretch; gap: 6px; margin-bottom: 6px; }
.item-row .item { margin-bottom: 0; flex: 1; min-width: 0; }
.item-row.on .item { border-color: var(--brand-2); background: var(--brand-soft); }
.check { display: grid; place-items: center; width: 46px; flex: none; cursor: pointer; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check span { width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--muted); display: grid; place-items: center; }
.check input:checked + span { background: var(--brand); border-color: var(--brand); }
.check input:checked + span::after { content: ""; width: 6px; height: 12px; border: solid var(--on-brand); border-width: 0 3px 3px 0; transform: rotate(45deg) translate(-1px, -1px); }
.check input:focus-visible + span { outline: 2px solid var(--brand-2); outline-offset: 2px; }
.small-link { padding: 0; font-size: 12px; text-transform: none; letter-spacing: 0; }
.list-group h4 { align-items: center; }
.list-route { position: sticky; bottom: 0; margin: 12px -16px -32px; padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); background: var(--surface); border-top: 3px solid var(--accent); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; box-shadow: 0 -6px 20px rgba(13,30,70,.12); }
.list-route > span { flex: 1; min-width: 120px; }
.list-route .btn { min-height: 44px; }

/* ---------- Droits : niveaux d'administration ---------- */
body:not(.can-gest) .gest-only { display: none !important; }
html.ordi body:not(.can-gest) .tab-scan { display: none !important; }
.app[data-view="signalements"] #view-signalements { display: block; }
.tabs button { position: relative; }
.tab-badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 800; font-style: normal; display: grid; place-items: center; border: 2px solid var(--surface); }
.role-badge.gest { background: #f0b429; color: #3b2a00; }
.topbar .role-badge.gest { background: #f0b429; color: #3b2a00; }

/* ---------- Fenêtre des signalements ---------- */
.sig-card { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 14px; padding: 14px; margin-bottom: 10px; display: grid; gap: 8px; }
.sig-card.done { border-left-color: #1f9d55; opacity: .9; }
.sig-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.sig-head b { font-size: 16px; }
.sig-motif { display: inline-block; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-weight: 700; font-size: 13px; padding: 3px 10px; border-radius: 99px; }
.sig-photo { width: 100%; max-height: 200px; object-fit: cover; border-radius: 10px; }
.sig-card .row .btn { padding: 9px 12px; min-height: 0; font-size: 13.5px; flex: 0 1 auto; }
.sig-treat { display: grid; gap: 8px; padding: 10px; background: var(--surface-2); border-radius: 10px; }
.sig-treat textarea { min-height: 54px; }
.sig-tools { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }

/* ---------- Sélecteur de niveau d'accès (barre du haut) ---------- */
.role-switch { position: relative; }
button.role-badge { display: inline-flex; align-items: center; gap: 4px; border: 0; cursor: pointer; padding: 6px 8px 6px 12px; font-size: 12.5px; }
button.role-badge svg { width: 16px; height: 16px; transition: transform .15s; }
button.role-badge[aria-expanded="true"] svg { transform: rotate(180deg); }
button.role-badge:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.role-menu { position: absolute; right: 0; top: calc(100% + 10px); width: min(320px, calc(100vw - 24px)); background: var(--surface); color: var(--text); border-radius: 16px; box-shadow: 0 12px 40px rgba(5, 15, 40, .35); padding: 8px; z-index: 3500; border-top: 4px solid var(--accent); animation: up .15s ease-out; }
.rm-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 10px 8px; }
.rm-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; background: none; padding: 10px; border-radius: 12px; }
.rm-item:hover { background: var(--surface-2); }
.rm-item.cur { background: var(--brand-soft); }
.rm-item.locked { opacity: .55; }
.rm-txt { flex: 1; min-width: 0; }
.rm-txt b { display: block; font-size: 15px; }
.rm-txt small { display: block; color: var(--muted); font-size: 12.5px; }
.rm-state { font-weight: 800; color: var(--brand); width: 20px; text-align: center; }
.rm-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.lvl-admin { background: var(--accent); }
.lvl-gestionnaire { background: #f0b429; }
.lvl-contributeur { background: var(--brand-2); }
.lvl-lecteur { background: #8b95a7; }
.rm-add { border-top: 1px solid var(--line); margin-top: 6px; padding: 10px 6px 4px; display: grid; gap: 6px; }
.rm-row { display: flex; gap: 6px; }
.rm-row input { flex: 1; min-width: 0; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; }
.rm-row .btn { padding: 8px 14px; min-height: 0; }
.rm-forget { border: 0; background: none; color: var(--muted); font-size: 12.5px; text-decoration: underline; padding: 8px 10px 4px; }
@media (max-width: 420px) { button.role-badge span { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } }

/* ---------- Listes déroulantes lisibles (circonscriptions, etc.) ----------
   Le menu ouvert d'une liste native reprend le fond de la liste : un fond transparent
   donnait un texte clair sur fond blanc sous Windows. Couleurs explicites partout. */
select, .select select, select.input { background-color: var(--surface); color: var(--text); color-scheme: light dark; }
select option, select optgroup { background-color: var(--surface); color: var(--text); font-weight: 500; }
select option:checked { background-color: var(--brand-soft); color: var(--text); font-weight: 700; }
.select { border: 1px solid var(--line); }
.select:focus-within { outline: 2px solid var(--brand-2); outline-offset: 1px; }

/* ---------- Fenêtre « Exporter les données » ---------- */
.exp-sec { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
.exp-types, .exp-formats { display: grid; gap: 8px; }
.exp-formats { grid-template-columns: 1fr 1fr; }
.exp-types button, .exp-formats button { text-align: left; border: 2px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 12px; }
.exp-types button b, .exp-formats button b { display: block; font-size: 15px; }
.exp-types button small, .exp-formats button small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.3; }
.exp-types button.sel, .exp-formats button.sel { border-color: var(--brand-2); background: var(--brand-soft); }
.exp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.exp-grid .field { margin-bottom: 10px; }
.exp-grid input[type=date] { width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); color-scheme: light dark; }
.exp-count { text-align: center; margin: 16px 0 10px; color: var(--muted); }
.exp-count b { color: var(--text); font-size: 18px; }
a.btn.disabled { opacity: .5; }
@media (max-width: 420px) { .exp-grid { grid-template-columns: 1fr; } }

/* ---------- Connexion : choix du niveau + mot de passe ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.lock-card { width: 100%; max-width: 420px; }
.lvl-pick { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; text-align: left; }
.lvl-opt { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); cursor: pointer; }
.lvl-opt b { display: block; font-size: 15px; }
.lvl-opt small { display: block; color: var(--muted); font-size: 12.5px; }
.lvl-opt input { position: absolute; opacity: 0; pointer-events: none; }
.lvl-opt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.lvl-opt:has(input:focus-visible) { outline: 2px solid var(--brand-2); outline-offset: 2px; }
.lock-pw input { width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 18px; text-align: center; letter-spacing: .2em; }
.lock-err:not([hidden]) { display: block; margin-top: 12px; font-weight: 600; }
.rm-item.ask { background: var(--surface-2); outline: 2px solid var(--brand-2); }
.pw-row { display: grid; gap: 8px; }
.pw-warn { display: inline-block; margin-left: 6px; font-size: 11.5px; font-weight: 700; color: #fff; background: var(--accent); padding: 1px 8px; border-radius: 99px; }
