:root {
  --bg: #f5f3ee; --card: #ffffff; --ink: #1d221f; --muted: #6a716c; --line: #e2ddd3;
  --accent: #2f6b4f; --accent-ink: #fff; --warn: #c7771a; --bad: #b8322a; --ok: #2f8a4f;
  --top: #1f2a24; --top-ink: #f1efe8; --shadow: 0 2px 10px rgba(0,0,0,.08);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151917; --card: #1f2522; --ink: #e8e6df; --muted: #9aa29c; --line: #313a35;
    --accent: #5fae86; --accent-ink: #0d1310; --top: #0f1311; --shadow: 0 2px 10px rgba(0,0,0,.4); }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--accent); }
.hidden { display: none !important; }

.top { position: fixed; top: 0; left: 0; right: 0; height: 52px; z-index: 1000; display: flex; align-items: center;
  justify-content: space-between; padding: 0 14px; background: var(--top); color: var(--top-ink); }
.brand { color: var(--top-ink); text-decoration: none; font-weight: 700; font-size: 17px; }
.top-right { display: flex; gap: 10px; align-items: center; }
.live { width: 9px; height: 9px; border-radius: 50%; background: #777; }
.live.on { background: #4ade80; box-shadow: 0 0 6px #4ade80; }

main { position: fixed; top: 52px; bottom: 62px; left: 0; right: 0; overflow-y: auto; }
main.full { overflow: hidden; }
.page { max-width: 900px; margin: 0 auto; padding: 16px; }
h2 { margin: 4px 0 12px; font-size: 20px; }
h3 { margin: 18px 0 8px; font-size: 16px; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; height: 62px; z-index: 1000; display: flex;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-decoration: none; color: var(--muted); font-size: 11px; position: relative; }
.tabs a span { font-size: 20px; }
.tabs a.active { color: var(--accent); font-weight: 600; }
.badge { position: absolute; top: 6px; left: 55%; background: var(--bad); color: #fff; border-radius: 9px;
  font-size: 10px; padding: 1px 5px; }

.fab { position: fixed; right: 18px; bottom: 78px; z-index: 1001; width: 58px; height: 58px; border-radius: 50%;
  border: none; background: var(--accent); color: var(--accent-ink); font-size: 30px; box-shadow: 0 4px 14px rgba(0,0,0,.3); cursor: pointer; }
.fab-menu { position: fixed; right: 18px; bottom: 146px; z-index: 1001; display: flex; flex-direction: column; gap: 8px; }
.fab-menu button { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 22px;
  padding: 10px 16px; font-size: 15px; box-shadow: var(--shadow); cursor: pointer; text-align: left; }

#map { position: absolute; inset: 0; }
.map-legend { position: absolute; left: 10px; bottom: 10px; z-index: 500; background: var(--card); color: var(--ink);
  border-radius: 10px; padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow); max-width: 60%; }
.map-legend label { display: flex; gap: 6px; align-items: center; margin: 2px 0; cursor: pointer; }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; border: 2px solid #fff; vertical-align: middle; }
.map-btn { position: absolute; right: 10px; top: 10px; z-index: 500; }
.stats { display: flex; gap: 6px; flex-wrap: wrap; position: absolute; left: 50px; right: 60px; top: 10px; z-index: 500; pointer-events: none; }
.stat { background: var(--card); border-radius: 8px; padding: 4px 8px; font-size: 12px; box-shadow: var(--shadow); }
.stat b { font-size: 14px; }

.cat-marker { width: 44px; height: 44px; border-radius: 50%; border: 3px solid #999; background: #ccc center/cover;
  box-shadow: 0 1px 5px rgba(0,0,0,.5); }
.col-marker { font-size: 26px; text-shadow: 0 0 3px #fff; }
.alert-marker { font-size: 24px; }
.s-marker { width: 12px; height: 12px; border-radius: 50%; background: #7c6cf0; border: 2px solid #fff; }

.leaflet-popup-content { margin: 10px; min-width: 180px; }
.pop img { width: 100%; border-radius: 8px; max-height: 160px; object-fit: cover; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; box-shadow: var(--shadow); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.cat-card { padding: 0; overflow: hidden; cursor: pointer; text-decoration: none; color: inherit; }
.cat-card img, .cat-card .noimg { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--line); }
.cat-card .noimg { display: flex; align-items: center; justify-content: center; font-size: 40px; }
.cat-card .info { padding: 8px 10px; }
.cat-card .name { font-weight: 600; }
.list > * + * { margin-top: 8px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); font-size: 13px; }

.pill { display: inline-block; border-radius: 10px; padding: 1px 8px; font-size: 12px; font-weight: 600; color: #fff; background: #888; }
.st-neutered_returned, .st-neutered { background: var(--ok); }
.st-needs_tnr { background: var(--warn); }
.st-trapped { background: #3b74c4; }
.st-adopted { background: #8a4fc4; }
.st-deceased { background: #555; }
.st-unknown { background: #888; }
.fed-ok { color: var(--ok); } .fed-warn { color: var(--warn); } .fed-bad { color: var(--bad); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 16px; padding: 5px 11px;
  font-size: 13px; cursor: pointer; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

form label, .field { display: block; margin: 10px 0 4px; font-weight: 600; font-size: 13px; }
input, select, textarea { width: 100%; font: inherit; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); }
textarea { min-height: 70px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn { display: inline-block; border: none; border-radius: 9px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); text-decoration: none; text-align: center; }
.btn.ghost { background: transparent; border: 1px solid currentColor; color: inherit; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.warn { background: var(--bad); color: #fff; }
.btn.block { display: block; width: 100%; margin-top: 14px; }
.btn:disabled { opacity: .6; cursor: wait; }

.modal { position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 700px) { .modal { align-items: center; } }
.modal-box { position: relative; background: var(--bg); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  border-radius: 16px 16px 0 0; padding: 18px 16px 24px; }
@media (min-width: 700px) { .modal-box { border-radius: 16px; } }
.modal-x { position: absolute; right: 10px; top: 10px; border: none; background: var(--line); color: var(--ink);
  width: 32px; height: 32px; border-radius: 50%; font-size: 16px; cursor: pointer; z-index: 2; }
.mini-map { height: 220px; border-radius: 10px; margin-top: 6px; border: 1px solid var(--line); }
.photo-pick { display: flex; align-items: center; justify-content: center; min-height: 150px; border: 2px dashed var(--line);
  border-radius: 12px; cursor: pointer; overflow: hidden; background: var(--card); }
.photo-pick img { width: 100%; max-height: 300px; object-fit: contain; }
.loc-status { font-size: 13px; margin-top: 4px; }

.match { display: grid; grid-template-columns: 90px 1fr; gap: 10px; align-items: start; }
.match img { width: 90px; height: 90px; object-fit: cover; border-radius: 10px; }
.big-pct { font-size: 30px; font-weight: 800; line-height: 1; }
.pct-hi { color: var(--ok); } .pct-mid { color: var(--warn); } .pct-lo { color: var(--muted); }
.bars { display: grid; grid-template-columns: 95px 1fr 38px; gap: 3px 6px; font-size: 12px; align-items: center; margin-top: 6px; }
.bar { height: 7px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.vs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vs figure { margin: 0; text-align: center; font-size: 12px; }
.vs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; }
.popup-head { text-align: center; margin-bottom: 10px; }

.toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); z-index: 3000; background: var(--top); color: var(--top-ink);
  padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 90%; }
.timeline { border-left: 3px solid var(--line); padding-left: 12px; }
.timeline > div { margin-bottom: 8px; }
.hero { width: 100%; max-height: 340px; object-fit: cover; border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { padding: 6px; border-bottom: 1px solid var(--line); text-align: left; }
