:root {
  --green: #1f4d2b;
  --green-2: #2f7a43;
  --leaf: #3fa45b;
  --amber: #c98a00;
  --blue: #2a6fb5;
  --grey: #7a8580;
  --red: #b3261e;
  --bg: #f4f6f3;
  --card: #ffffff;
  --text: #17201a;
  --muted: #5d6a62;
  --border: #d9e0db;
  --radius: 14px;
  --tabbar-h: 62px;
  --topbar-h: 48px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101512;
    --card: #1a221d;
    --text: #e8eee9;
    --muted: #a3b0a7;
    --border: #2c3a31;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
}
a { color: var(--green-2); }
h2 { margin: 0 0 12px; font-size: 1.3rem; }
h3 { margin: 0 0 8px; font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--red); }
.warn { background: #fff3d6; color: #5a4100; padding: 10px 12px; border-radius: 10px; }
@media (prefers-color-scheme: dark) { .warn { background: #3a2f12; color: #ffe2a0; } }

.topbar {
  position: fixed; inset: 0 0 auto 0; height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 14px 0; display: flex; align-items: center; justify-content: space-between;
  background: var(--green); color: #fff; z-index: 1000;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .2px; }
.brand img { width: 26px; height: 26px; }
.test-badge { background: #e8eaed !important; margin-right: 6px; }
.net-badge { background: var(--amber); color: #000; border-radius: 99px; padding: 2px 10px; font-size: .8rem; font-weight: 600; }

main { position: fixed; top: calc(var(--topbar-h) + env(safe-area-inset-top)); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); left: 0; right: 0; }
.view { display: none; position: absolute; inset: 0; overflow-y: auto; }
.view.active { display: block; }
#view-map { overflow: hidden; }
#map { position: absolute; inset: 0; }
.page { padding: 16px; max-width: 720px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }

.tabbar {
  position: fixed; inset: auto 0 0 0; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); display: flex; background: var(--card); border-top: 1px solid var(--border); z-index: 1000;
}
.tabbar button {
  flex: 1; border: 0; background: none; color: var(--muted); font-size: 1.25rem; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; position: relative; cursor: pointer;
}
.tabbar button span { font-size: .72rem; }
.tabbar button.active { color: var(--green-2); font-weight: 600; }
.tabbar b { position: absolute; top: 6px; right: calc(50% - 22px); background: var(--red); color: #fff; font-size: .7rem; border-radius: 99px; padding: 0 6px; }

.status-card {
  position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 900; background: var(--card); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: 0 6px 24px rgba(0,0,0,.25); max-width: 560px; margin: 0 auto;
}
.status-line { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--grey); flex: none; }
.dot.INSIDE { background: var(--leaf); box-shadow: 0 0 0 4px rgba(63,164,91,.25); }
.dot.AT { background: var(--amber); }
.dot.PROTECTED_NOT_FOREST { background: var(--blue); }
.status-areas { margin-top: 4px; font-size: .9rem; }
.status-meta { color: var(--muted); font-size: .8rem; margin: 2px 0 10px; }
.btn-capture { width: 100%; font-size: 1.05rem; padding: 14px; }

.fab-small {
  position: absolute; right: 12px; top: 12px; z-index: 900; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: var(--card); color: var(--text); font-size: 1.3rem; box-shadow: 0 2px 10px rgba(0,0,0,.25); cursor: pointer;
}

.btn, .btn-primary {
  border-radius: 10px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; border: 1px solid var(--border);
  background: var(--card); color: var(--text);
}
.btn-primary { background: var(--green-2); color: #fff; border-color: var(--green-2); }
.btn-primary:disabled, .btn:disabled { opacity: .5; cursor: default; }
.btn.small { padding: 6px 10px; font-size: .85rem; }
.btn.danger { color: var(--red); border-color: var(--red); }

dialog.sheet {
  border: 0; border-radius: 18px 18px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); width: 100%; max-width: 560px;
  margin: auto auto 0; background: var(--card); color: var(--text); max-height: 92vh; overflow-y: auto;
}
dialog.sheet::backdrop { background: rgba(0,0,0,.45); }
@media (min-width: 700px) { dialog.sheet { border-radius: 18px; margin: auto; } }
.sheet label { display: block; margin: 12px 0 4px; font-size: .9rem; }
.sheet input[type=email], .sheet input[inputmode], .sheet textarea {
  width: 100%; font: inherit; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); margin-top: 4px;
}
.sheet label.check { display: flex; gap: 8px; align-items: flex-start; font-size: .85rem; }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.hint { font-size: .85rem; color: var(--muted); }

.capture-status { font-size: .9rem; padding: 8px 10px; border-radius: 10px; background: var(--bg); margin-bottom: 10px; }
.photo-strip { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 8px; }
.photo-strip figure { margin: 0; position: relative; flex: none; }
.photo-strip img { height: 110px; border-radius: 10px; display: block; }
.photo-strip button { position: absolute; top: 4px; right: 4px; border: 0; border-radius: 50%; width: 26px; height: 26px; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; }

fieldset.chips { border: 0; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
fieldset.chips legend { font-size: .9rem; margin-bottom: 6px; }
.chips label { margin: 0; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips span { display: inline-block; padding: 7px 12px; border: 1px solid var(--border); border-radius: 99px; font-size: .88rem; cursor: pointer; }
.chips input:checked + span { background: var(--green-2); color: #fff; border-color: var(--green-2); }
.chips input:focus-visible + span { outline: 2px solid var(--green-2); outline-offset: 2px; }

.report { display: flex; gap: 10px; align-items: flex-start; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 10px; margin-bottom: 8px; }
.report img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex: none; }
.report .body { flex: 1; min-width: 0; }
.report .actions { display: flex; gap: 6px; margin-top: 6px; }
.report .queue-note { width: 100%; box-sizing: border-box; margin-top: 6px; font: inherit; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); }
.badge { display: inline-block; font-size: .72rem; padding: 2px 8px; border-radius: 99px; background: var(--bg); border: 1px solid var(--border); margin-right: 4px; }
.badge.published { background: #dff3e4; color: #14532d; border-color: #b7e2c2; }
.badge.rejected { background: #fde2e1; color: #7f1d1d; border-color: #f5b5b2; }
.badge.pending, .badge.in_review { background: #fff1cc; color: #5a4100; border-color: #f1d98a; }
.badge.error { background: #fde2e1; color: #7f1d1d; }

progress { width: 100%; margin-top: 8px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom));
  background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 3000; max-width: 90vw; font-size: .92rem;
}

.leaflet-container { background: #dfe7df; font: inherit; }
