/* Carnet des nids — carte plein écran, commandes au pouce en bas, feuilles qui montent du bas */
:root {
  --bg: #eef2f6; --surface: #ffffff; --ink: #14202e; --muted: #5a6878; --line: #d3dbe4;
  --accent: #1f4f8a; --accent-ink: #ffffff; --soft: #e2eaf3;
  --hir: #1f4f8a; --mar: #9b3f1f; --pending: #a0521a; --danger: #a12a2a; --ok: #2d6a3e;
  --shadow: 0 6px 24px rgba(16, 32, 52, .18);
  --f: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1620; --surface: #18222f; --ink: #e6edf5; --muted: #9aa8b8; --line: #2b3a4b;
    --accent: #7fb0ec; --accent-ink: #0c1520; --soft: #1f2d3d;
    --hir: #7fb0ec; --mar: #e08a62; --pending: #e6a066; --danger: #f08a8a; --ok: #7fcf91;
    --shadow: 0 6px 24px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.45 var(--f); -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); font-size: .9rem; }
.mono { font-family: var(--mono); font-size: .82rem; }
.err { color: var(--danger); font-size: .9rem; margin: 0; min-height: 1.2em; }

/* boutons */
.btn { min-height: 46px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: var(--surface); }
.btn.wide { width: 100%; min-height: 54px; font-size: 1.05rem; }
.btn:disabled { opacity: .55; }

/* connexion */
.login { min-height: 100%; display: grid; place-items: center; padding: calc(24px + var(--safe-t)) max(16px, var(--safe-r)) calc(24px + var(--safe-b)) max(16px, var(--safe-l)); }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px 22px; display: grid; gap: 14px; }
.login-card .logo { width: 48px; height: 48px; color: var(--accent); }
.login-card h1 { margin: 0; font-size: 1.6rem; line-height: 1.1; }
.login-card p { margin: 0; }

/* carte */
#app { position: fixed; inset: 0; }
#map { position: absolute; inset: 0; background: var(--soft); }
.leaflet-container { font: inherit; }
.leaflet-top.leaflet-right { top: calc(64px + var(--safe-t)); right: var(--safe-r); }
.leaflet-bottom.leaflet-left { bottom: var(--safe-b); left: var(--safe-l); }

.bar { position: absolute; z-index: 1000; top: calc(10px + var(--safe-t)); left: max(10px, var(--safe-l)); right: max(10px, var(--safe-r));
  display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 999px; padding: 6px 6px 6px 18px; box-shadow: var(--shadow); }
.bar .title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.bar .title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .title .muted { font-size: .8rem; }
.sync { font-size: .78rem; font-weight: 700; color: var(--pending); background: var(--soft); border-radius: 999px; padding: 4px 10px; white-space: nowrap; }

.fab { position: absolute; z-index: 1000; border: 0; border-radius: 999px; box-shadow: var(--shadow); cursor: pointer; font-weight: 700; }
.fab.add { left: 50%; transform: translateX(-50%); bottom: calc(20px + var(--safe-b)); min-height: 56px; padding: 0 26px; font-size: 1.05rem;
  background: var(--accent); color: var(--accent-ink); }
.fab.locate { right: max(12px, var(--safe-r)); bottom: calc(92px + var(--safe-b)); min-height: 48px; padding: 0 14px 0 12px;
  background: var(--surface); color: var(--ink); display: flex; align-items: center; gap: 8px; }
.fab.locate svg { width: 22px; height: 22px; color: var(--accent); }
.fab.locate.active { background: var(--accent); color: var(--accent-ink); }
.fab.locate.active svg { color: var(--accent-ink); }
.fab.locate.busy svg { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.crosshair { position: absolute; z-index: 900; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px; pointer-events: none; color: var(--danger);
  filter: drop-shadow(0 0 2px var(--surface)) drop-shadow(0 0 2px var(--surface)); }

/* feuilles */
.sheet, .panel { position: absolute; z-index: 1100; left: 0; right: 0; bottom: 0; background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: var(--shadow);
  padding: 16px max(16px, var(--safe-r)) calc(16px + var(--safe-b)) max(16px, var(--safe-l)); max-height: calc(100% - 70px - var(--safe-t)); overflow-y: auto; overscroll-behavior: contain; }
.sheet > form, .panel > * { max-width: 640px; margin-inline: auto; }
.sheet.small { display: grid; gap: 8px; }
.sheet.small > * { width: 100%; max-width: 640px; margin-inline: auto; }
.panel { top: calc(var(--safe-t) + 0px); max-height: none; border-radius: 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sheet-title { font-size: 1.2rem; font-weight: 700; margin: 0; }
.row { display: flex; gap: 10px; }
.row .btn { flex: 1; }
form { display: grid; gap: 14px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 0; padding: 12px; display: grid; gap: 10px; min-width: 0; }
legend { font-weight: 700; padding: 0 6px; }
label { display: grid; gap: 4px; font-weight: 700; font-size: .92rem; }
input[type=text], input[type=password], input[type=number], input[type=date], textarea {
  width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); padding: 10px 12px; font-weight: 400; }
textarea { resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.species { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.species label { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; min-height: 54px; font-weight: 400; background: var(--bg); cursor: pointer; }
.species input { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.species label:has(input:checked) { border-color: var(--accent); background: var(--soft); font-weight: 700; }
.species i { display: block; font-size: .78rem; color: var(--muted); font-weight: 400; }

.counts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stepper { display: grid; gap: 4px; font-weight: 700; font-size: .85rem; }
.stepper > div { display: grid; grid-template-columns: 40px 1fr 40px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg); }
.stepper button { border: 0; background: var(--soft); font-size: 1.25rem; font-weight: 700; min-height: 48px; cursor: pointer; }
.stepper input { border: 0; border-radius: 0; min-height: 48px; text-align: center; padding: 0; font-family: var(--mono); font-size: 1.05rem; width: 100%; background: var(--bg); }

.photo-btn { display: flex; align-items: center; justify-content: center; min-height: 52px; border: 1px dashed var(--accent); border-radius: 10px; color: var(--accent); cursor: pointer; }
.photo-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs button { border: 0; padding: 0; background: none; position: relative; cursor: pointer; }
.thumbs img { width: 68px; height: 68px; object-fit: cover; border-radius: 8px; display: block; }
.thumbs button::after { content: "×"; position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); color: var(--bg); font-size: 15px; line-height: 22px; text-align: center; }

/* liste */
.stats { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 10px auto; color: var(--muted); font-size: .9rem; }
.stats b { color: var(--ink); font-family: var(--mono); font-weight: 500; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { min-height: 38px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); padding: 0 14px; cursor: pointer; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--soft); font-weight: 700; }
.list { display: grid; gap: 10px; }
.item { display: grid; grid-template-columns: 72px 1fr; gap: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: var(--surface); text-align: left; cursor: pointer; width: 100%; }
.item .ph { width: 72px; height: 72px; border-radius: 8px; object-fit: cover; background: var(--soft); display: grid; place-items: center; font-size: .7rem; color: var(--muted); text-align: center; }
.item .b { min-width: 0; display: grid; gap: 2px; }
.sp { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.item h3 { margin: 0; font-size: 1rem; overflow-wrap: anywhere; }
.nests { font-size: .9rem; display: flex; flex-wrap: wrap; gap: 0 12px; }
.nests b { font-family: var(--mono); font-weight: 500; }
.badge { font-size: .74rem; font-weight: 700; color: var(--pending); }
.exports { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px auto 8px; }
.empty { border: 1px dashed var(--line); border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }

/* popup */
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--ink); }
.leaflet-popup-content { margin: 12px 14px; min-width: 210px; }
.pop { display: grid; gap: 4px; }
.pop h3 { margin: 0; font-size: 1rem; }
.pop .thumbs img { width: 64px; height: 64px; }
.pop .acts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.pop .acts a, .pop .acts button { background: none; border: 0; padding: 2px 0; color: var(--accent); font-weight: 700; text-decoration: underline; cursor: pointer; font-size: .88rem; }
.pop .acts .danger { color: var(--danger); }

.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #2a7de1; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(42,125,225,.35); }

.toast { position: absolute; z-index: 1300; left: 50%; transform: translateX(-50%); bottom: calc(90px + var(--safe-b)); background: var(--ink); color: var(--bg);
  border-radius: 999px; padding: 10px 18px; font-weight: 700; max-width: calc(100% - 32px); text-align: center; }

@media (max-width: 420px) { .two { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- comptes (v2) ---------- */
.bar .btn { min-height: 42px; padding: 0 14px; }
.bar #btnAccount { max-width: 9.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; line-height: 40px; }
.bar #btnAccount.in { background: var(--soft); border-color: var(--soft); }
.narrow { max-width: 440px; margin-inline: auto; display: grid; gap: 14px; }
.stack { display: grid; gap: 12px; }
.small { font-size: .82rem; margin: 0; }
.hint { font-weight: 400; color: var(--muted); font-size: .82rem; }
.linkbtn { background: none; border: 0; padding: 4px 0; color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.danger-text { color: var(--danger); }
.locline { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.locline p { margin: 0; }
select { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); padding: 10px 12px; font-weight: 400; }

/* photos existantes en modification */
.thumbs .old.removed img { opacity: .3; }
.thumbs .old.removed::after { content: "↺"; background: var(--accent); color: var(--accent-ink); }

/* administration */
.card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 12px; background: var(--surface); margin-bottom: 14px; }
.card-title { margin: 0; font-weight: 700; font-size: 1.05rem; }
.temp { border-color: var(--ok); }
.temp .pw { font-family: var(--mono); font-size: 1.15rem; letter-spacing: .03em; background: var(--soft); border-radius: 8px; padding: 10px 12px; user-select: all; overflow-wrap: anywhere; }
.temp p { margin: 0; }
.user { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 6px; background: var(--surface); }
.user.off { opacity: .6; }
.user .top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.user .top strong { font-size: 1rem; }
.pill { font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; border-radius: 999px; padding: 2px 8px; background: var(--soft); color: var(--muted); }
.pill.admin { background: var(--accent); color: var(--accent-ink); }
.pill.warn { color: var(--pending); }
.user .acts { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.user .acts .danger { color: var(--danger); }
.confirm-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: .9rem; }
