:root {
  --green: #16a34a;
  --green-dark: #15803d;
  --green-light: #dcfce7;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f9fafb;
  --card: #ffffff;
  --red: #dc2626;
  --amber: #d97706;
  --radius: 14px;
  --nav-h: 64px;
  --header-h: 52px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior: none;
}

#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; background: var(--bg); position: relative; }

/* ---------- Header ---------- */
header {
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  background: var(--green);
  color: #fff;
  position: sticky; top: 0; z-index: 400;
}
header .brand { font-weight: 800; font-size: 19px; letter-spacing: .2px; display: flex; align-items: center; gap: 6px; }
header .brand .pin { font-size: 20px; }
header .city {
  font-size: 12px; font-weight: 600; background: rgba(255,255,255,.22);
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}

/* ---------- Views / tabs ---------- */
.view { display: none; padding-bottom: calc(var(--nav-h) + 16px); }
.view.active { display: block; }
.view.active.flex-view { display: flex; flex-direction: column; height: calc(100dvh - var(--header-h)); padding-bottom: var(--nav-h); }

.pad { padding: 14px; }
h2 { font-size: 20px; margin: 4px 0 10px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
p.muted, .muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- Bottom nav ---------- */
nav.tabs {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 560px; height: var(--nav-h);
  background: #fff; border-top: 1px solid var(--line);
  display: flex; z-index: 500;
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs button {
  flex: 1; border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 0;
}
nav.tabs button .ic { font-size: 22px; line-height: 1; }
nav.tabs button.active { color: var(--green-dark); }
nav.tabs button .plus {
  background: var(--green); color: #fff; width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 24px; line-height: 1;
  margin-top: -14px; box-shadow: 0 2px 8px rgba(22,163,74,.45);
}

/* ---------- Filter chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 12px 8px; scrollbar-width: none; flex-shrink: 0; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 999px; padding: 7px 13px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.chip.active { background: var(--green); border-color: var(--green); color: #fff; }
.chip .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }

/* ---------- Map ---------- */
#map-wrap { position: relative; flex: 1; min-height: 0; }
#map { position: absolute; inset: 0; z-index: 1; }
#map .leaflet-container { font-family: inherit; }
.locate-btn {
  position: absolute; z-index: 450; right: 12px; bottom: 14px;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: #fff; font-size: 20px; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.map-empty {
  position: absolute; z-index: 450; left: 50%; transform: translateX(-50%); bottom: 14px;
  width: calc(100% - 96px); max-width: 420px;
  background: #fff; border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0,0,0,.18);
  padding: 14px; text-align: center;
}
.map-empty b { display: block; font-size: 15px; margin-bottom: 3px; }
.map-empty p { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.api-banner {
  background: #fef3c7; color: #92400e; font-size: 13px; font-weight: 600;
  padding: 8px 12px; text-align: center; flex-shrink: 0;
}

/* Category marker */
.dh-marker {
  background: #fff; border: 2px solid var(--green); border-radius: 50%;
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  font-size: 17px; box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.dh-marker.cash { border-color: var(--amber); }
.dh-marker.valuable { border-color: #7c3aed; }
.dh-marker.business { border-color: #2563eb; }

/* ---------- Recent finds strip ---------- */
.finds-strip { flex-shrink: 0; background: #fff; border-top: 1px solid var(--line); padding: 8px 0 6px; }
.finds-strip .strip-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 14px 6px; font-size: 14px; font-weight: 700; }
.finds-strip .strip-head a { font-size: 13px; color: var(--green-dark); font-weight: 600; text-decoration: none; cursor: pointer; }
.finds-row { display: flex; gap: 10px; overflow-x: auto; padding: 0 14px 4px; scrollbar-width: none; }
.finds-row::-webkit-scrollbar { display: none; }
.find-card { flex-shrink: 0; width: 150px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; cursor: pointer; }
.find-card img { width: 100%; height: 84px; object-fit: cover; display: block; background: var(--green-light); }
.find-card .fc-body { padding: 6px 8px; }
.find-card .fc-title { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.find-card .fc-meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Buttons ---------- */
.btn {
  display: block; width: 100%; border: 0; border-radius: 12px; cursor: pointer;
  padding: 14px 16px; font-size: 16px; font-weight: 700; text-align: center;
  background: var(--green); color: #fff;
}
.btn:active { transform: scale(.99); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.secondary { background: #fff; color: var(--green-dark); border: 1.5px solid var(--green); }
.btn.ghost { background: #f3f4f6; color: var(--ink); }
.btn.danger { background: #fff; color: var(--red); border: 1.5px solid var(--red); }
.btn.small { width: auto; padding: 8px 14px; font-size: 14px; border-radius: 999px; display: inline-block; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ---------- Forms ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
label.f-label { display: block; font-size: 14px; font-weight: 700; margin: 14px 0 6px; }
label.f-label:first-child { margin-top: 0; }
input[type=text], input[type=number], textarea, select {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px;
  padding: 12px; font-size: 16px; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--green); }
textarea { resize: vertical; min-height: 74px; }
.field-hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
.field-error { font-size: 13px; color: var(--red); margin-top: 4px; font-weight: 600; }
.radio-row { display: flex; gap: 10px; }
.radio-pill { flex: 1; }
.radio-pill input { display: none; }
.radio-pill span {
  display: block; text-align: center; padding: 11px; border: 1.5px solid var(--line);
  border-radius: 10px; font-weight: 700; font-size: 15px; cursor: pointer; background: #fff;
}
.radio-pill input:checked + span { border-color: var(--green); background: var(--green-light); color: var(--green-dark); }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; font-size: 15px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--green); flex-shrink: 0; margin-top: 1px; }
.note-box { background: #fef3c7; border: 1px solid #fcd34d; border-radius: 10px; padding: 11px 12px; font-size: 13.5px; color: #78350f; margin: 12px 0; }
.photo-box { border: 2px dashed var(--line); border-radius: var(--radius); overflow: hidden; text-align: center; background: #f9fafb; }
.photo-box img { width: 100%; max-height: 320px; object-fit: cover; display: block; }
.photo-box .photo-empty { padding: 26px 14px; }
.photo-box .photo-empty .big { font-size: 34px; }
.photo-actions { display: flex; gap: 10px; padding: 10px; }
.photo-actions .btn { flex: 1; }
#drop-map { height: 260px; border-radius: 10px; z-index: 1; }
#drop-map .leaflet-container { border-radius: 10px; }
.map-note { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* ---------- Bottom sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 50%; transform: translate(-50%, 100%); bottom: 0;
  width: 100%; max-width: 560px; max-height: 86dvh; overflow-y: auto;
  background: #fff; border-radius: 20px 20px 0 0; z-index: 601;
  transition: transform .25s ease; padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 24px rgba(0,0,0,.25);
}
.sheet.open { transform: translate(-50%, 0); }
.sheet .grab { width: 44px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 10px; }
.sheet img.hero { width: 100%; max-height: 300px; object-fit: cover; border-radius: 12px; display: block; background: var(--green-light); }
.sheet h2 { margin: 10px 0 2px; font-size: 21px; }
.sheet .meta-line { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tag { display: inline-block; background: #f3f4f6; border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 600; }
.tag.green { background: var(--green-light); color: var(--green-dark); }
.tag.amber { background: #fef3c7; color: #92400e; }
.tag.red { background: #fee2e2; color: #991b1b; }
.tag.purple { background: #ede9fe; color: #5b21b6; }
.sheet .hint-box { background: var(--green-light); border-radius: 10px; padding: 11px 12px; font-size: 15px; margin: 10px 0; }
.sheet .dropper { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--green); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; flex-shrink: 0; }
.badge-new { background: #2563eb; color: #fff; font-size: 11px; font-weight: 800; border-radius: 999px; padding: 2px 7px; text-transform: uppercase; letter-spacing: .4px; }
.safety-box { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 10px; padding: 11px 12px; font-size: 13.5px; color: #1e3a5f; margin: 12px 0; }
.safety-box b { display: block; margin-bottom: 3px; }
.sheet .close-x { position: absolute; top: 12px; right: 14px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: #f3f4f6; font-size: 16px; cursor: pointer; }

/* ---------- Activity / lists ---------- */
.act-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.act-item:last-child { border-bottom: 0; }
.act-item img.thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; flex-shrink: 0; background: var(--green-light); }
.act-item .ai-body { flex: 1; min-width: 0; }
.act-item .ai-title { font-weight: 700; font-size: 15px; }
.act-item .ai-meta { font-size: 13px; color: var(--muted); margin: 2px 0 8px; }
.act-item .ai-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.status { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; }
.status.active { color: var(--green-dark); }
.status.found { color: #2563eb; }
.status.closed { color: var(--muted); }
.empty-state { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty-state .big { font-size: 36px; }
.empty-state p { margin: 6px 0 12px; }

/* ---------- Profile ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin: 12px 0; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 6px; text-align: center; }
.stat .num { font-size: 24px; font-weight: 800; }
.stat .lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.rep-bar { height: 8px; background: #e5e7eb; border-radius: 99px; overflow: hidden; margin: 6px 0 2px; }
.rep-bar > div { height: 100%; background: var(--green); }
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; }
.switch { position: relative; width: 52px; height: 30px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: #d1d5db; border-radius: 99px; transition: .2s; cursor: pointer; }
.switch .slider:before { content: ""; position: absolute; width: 24px; height: 24px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider:before { transform: translateX(22px); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 700;
  display: none; align-items: flex-end; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff; width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
}
.modal h2 { margin-top: 0; }
.modal.centered { align-self: center; border-radius: 20px; margin: 0 14px; }
@media (min-width: 600px) {
  .modal { border-radius: 20px; margin: 0 14px 24px; }
}

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; transform: translate(-50%, 80px); bottom: calc(var(--nav-h) + 18px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; z-index: 900; opacity: 0; pointer-events: none;
  transition: transform .25s, opacity .25s; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- Success panel ---------- */
.success { text-align: center; padding: 26px 10px; }
.success .big { font-size: 52px; }
.success h2 { margin: 8px 0 4px; }

/* ---------- Hunting banner ---------- */
.hunt-banner {
  position: absolute; z-index: 450; left: 12px; right: 12px; top: 10px;
  background: #fff; border: 2px solid var(--green); border-radius: 12px;
  padding: 10px 12px; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.hunt-banner .hb-body { flex: 1; min-width: 0; }
.hunt-banner .hb-title { font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hunt-banner .hb-sub { font-size: 12.5px; color: var(--muted); }

.spin { display: inline-block; width: 18px; height: 18px; border: 3px solid #d1d5db; border-top-color: var(--green); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -4px; }
@keyframes spin { to { transform: rotate(360deg); } }
