:root {
  /* Beenposters palet */
  --brand: #698c7d;          /* salviegrøn — primær */
  --brand-dark: #567366;
  --brand-tint: #eef3f1;     /* svag salvie-baggrund */
  --brand-tint-2: #dfe9e5;
  --accent: #a3e635;         /* lime-accent */
  --forest: #1a2e05;         /* dybgrøn */
  --ink: #1c1c1c;
  --muted: #737373;
  --line: #e7e5e4;
  --bg: #fafafa;
  --panel: #ffffff;
  --shadow: 0 2px 8px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.18);
  --radius: 12px;
  --sidebar-w: 360px;

  --cat-slot: #7c3aed;
  --cat-kirke: #4f46e5;
  --cat-natur: #16a34a;
  --cat-museum: #ea580c;
  --cat-strand: #0891b2;
  --cat-by: #475569;
  --cat-taarn: #d97706;
  --cat-forlystelse: #db2777;
  --cat-sevaerdighed: #2563eb;
  --cat-poi: #0f766e;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
#app { display: flex; flex-direction: column; height: 100dvh; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 1000;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-flag {
  width: 30px; height: 22px; border-radius: 3px;
  background:
    linear-gradient(to right, transparent 9px, #fff 9px, #fff 14px, transparent 14px),
    linear-gradient(to bottom, transparent 8px, #fff 8px, #fff 13px, transparent 13px),
    var(--brand);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.brand-text h1 {
  font-family: Fraunces, Georgia, "Times New Roman", serif;
  font-size: 19px; margin: 0; line-height: 1; letter-spacing: .2px; font-weight: 600;
}
.brand-text p { font-size: 11px; margin: 2px 0 0; color: var(--muted); letter-spacing: 1.2px; text-transform: uppercase; }
/* Plakat-vælgeren ser ud som en overskrift, ikke en formular */
.poster-select {
  font-family: Fraunces, Georgia, serif; font-weight: 600; font-size: 19px;
  color: var(--ink); background: transparent; border: none; padding: 2px 22px 2px 0;
  cursor: pointer; max-width: 260px; line-height: 1.1;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path d='M1 1l5 5 5-5' fill='none' stroke='%23737373' stroke-width='2' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat; background-position: right center;
}
.poster-select:hover { color: var(--brand); }
.poster-select:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; border-radius: 4px; }
@media (max-width: 760px) { .poster-select { font-size: 16px; max-width: 170px; } }

.progress-wrap { display: flex; align-items: center; gap: 8px; margin-left: auto; min-width: 160px; }
.progress-bar { flex: 1; height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--brand), var(--accent)); transition: width .4s ease; }
.progress-label { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }

.topbar-actions { display: flex; gap: 8px; }
.menu-toggle { display: none; }

/* ---------- Buttons ---------- */
.icon-btn, .ghost-btn, .primary-btn, .link-btn {
  font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid transparent;
}
.icon-btn { background: none; border: none; font-size: 22px; padding: 4px 8px; }
.ghost-btn { background: #fff; border: 1px solid var(--line); padding: 7px 12px; font-size: 13px; color: var(--ink); }
.ghost-btn:hover { background: var(--line); }
.primary-btn { background: var(--brand); color: #fff; padding: 9px 14px; font-size: 14px; font-weight: 600; border: none; }
.primary-btn:hover { background: var(--brand-dark); }
.primary-btn:disabled { opacity: .55; cursor: default; }
.link-btn { background: none; border: none; color: var(--brand); font-size: 13px; padding: 6px 0; text-align: left; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.main { flex: 1; display: flex; min-height: 0; position: relative; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--panel);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0;
}
.map { flex: 1; min-width: 0; z-index: 1; height: 100%; }

/* ---------- Tabs ---------- */
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1; padding: 12px 4px; background: none; border: none; cursor: pointer;
  font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent;
}
.tab.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--brand); }
.tab-panel { display: none; flex-direction: column; min-height: 0; flex: 1; }
.tab-panel.active { display: flex; }

/* ---------- Places panel ---------- */
.panel-controls { padding: 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.search-input { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.filter-row { display: flex; gap: 8px; }
.mini-select { flex: 1; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; background: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 12px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; color: var(--muted); white-space: nowrap;
}
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.place-list { overflow-y: auto; flex: 1; }
.place-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.place-item:hover { background: var(--bg); }
.place-item.visited .place-name { text-decoration: line-through; color: var(--muted); }
.place-check {
  width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line);
  display: grid; place-items: center; flex-shrink: 0; font-size: 14px; color: #fff; background: #fff;
}
.place-item.visited .place-check { background: var(--cat-natur); border-color: var(--cat-natur); }
.place-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.place-body { flex: 1; min-width: 0; }
.place-name { font-size: 14px; font-weight: 500; }
.place-meta { font-size: 11.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.place-add {
  background: none; border: 1px solid var(--line); border-radius: 6px; cursor: pointer;
  width: 26px; height: 26px; font-size: 16px; color: var(--brand); flex-shrink: 0;
}
.place-add:hover { background: var(--brand-tint); }
.panel-footer { padding: 10px 12px; border-top: 1px solid var(--line); }

/* ---------- Route panel ---------- */
.route-builder, .nearby-builder { padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 0; line-height: 1.5; }
.route-field { display: flex; flex-direction: column; gap: 5px; }
.route-field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.full-select { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: #fff; }
.waypoint-row { display: flex; gap: 6px; align-items: center; }
.waypoint-row .full-select { flex: 1; }
.remove-wp { background: none; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; padding: 8px 10px; color: var(--muted); }
.route-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.route-summary { font-size: 14px; }
.route-summary .big { font-size: 22px; font-weight: 700; color: var(--ink); }
.route-summary .sub { color: var(--muted); font-size: 12.5px; }
.route-steps .leg { font-size: 12.5px; padding: 8px 0; border-bottom: 1px dashed var(--line); color: var(--muted); }

/* ---------- Nearby ---------- */
.nearby-results { display: flex; flex-direction: column; }
.nearby-item { display: flex; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.nearby-item:hover { background: var(--bg); }
.nearby-icon { font-size: 18px; width: 24px; text-align: center; }
.nearby-body { flex: 1; min-width: 0; }
.nearby-name { font-size: 13.5px; font-weight: 500; }
.nearby-sub { font-size: 11.5px; color: var(--muted); }
.nearby-dist { font-size: 11.5px; color: var(--brand); font-weight: 600; white-space: nowrap; }

/* ---------- Map markers ---------- */
.pin {
  position: relative;
  width: 26px; height: 26px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  box-shadow: 0 2px 5px rgba(0,0,0,.35); border: 2px solid #fff; display: grid; place-items: center;
}
.pin span { transform: rotate(45deg); font-size: 12px; line-height: 1; }
.pin.visited { filter: saturate(.5) brightness(1.05); }
.pin.visited::after {
  content: "✓"; position: absolute; top: -8px; right: -8px; background: var(--cat-natur); color: #fff;
  width: 16px; height: 16px; border-radius: 50%; font-size: 10px; display: grid; place-items: center;
  transform: rotate(45deg); border: 1.5px solid #fff;
}
.poi-pin {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid #fff; background: var(--cat-poi);
  box-shadow: 0 1px 4px rgba(0,0,0,.35); display: grid; place-items: center; font-size: 10px;
}
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; }
.popup-title { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.popup-meta { color: var(--muted); font-size: 11.5px; margin-bottom: 8px; }
.popup-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.popup-actions button { font-size: 12px; padding: 5px 9px; border-radius: 6px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.popup-actions button.on { background: var(--cat-natur); color: #fff; border-color: var(--cat-natur); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 3000;
}
.modal-backdrop.hidden { display: none; }
.modal { background: #fff; border-radius: var(--radius); padding: 20px; width: min(420px, 92vw); box-shadow: var(--shadow-lg); }
.modal h3 { margin: 0 0 14px; font-family: Fraunces, Georgia, serif; font-weight: 600; font-size: 19px; }
.modal label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 10px 0 4px; }
.modal input, .modal select { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal .note { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 13.5px; box-shadow: var(--shadow-lg); z-index: 4000; max-width: 90vw;
}
.toast.hidden { display: none; }

.spinner { display: inline-block; width: 15px; height: 15px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { padding: 24px 16px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- Familie ---------- */
.mbadges { display: inline-flex; align-items: center; margin-right: 4px; flex-shrink: 0; }
.mbadges .mbadge { margin-left: -5px; }
.mbadge {
  width: 19px; height: 19px; border-radius: 50%; color: #fff; font-size: 9px; font-weight: 700;
  display: inline-grid; place-items: center; border: 1.5px solid #fff; box-shadow: 0 1px 2px rgba(0,0,0,.18);
}
.mbadge.more { background: var(--muted); }
.popup-fam { font-size: 12px; color: var(--ink); margin: 0 0 8px; line-height: 1.4; }
.popup-fam.muted { color: var(--muted); font-style: italic; }
.joincode {
  font-size: 28px; font-weight: 800; letter-spacing: 6px; text-align: center; color: var(--brand);
  background: var(--brand-tint); border: 1px dashed var(--brand); border-radius: 10px; padding: 12px; cursor: pointer; user-select: all;
}
.joincode:hover { background: var(--brand-tint-2); }
.fam-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.fam-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.fam-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fam-count { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
.fam-barwrap { width: 70px; height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; flex-shrink: 0; }
.fam-bar { display: block; height: 100%; border-radius: 999px; }
.color-select { width: 70px; }
.color-swatches { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 2px; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; cursor: pointer; padding: 0;
  box-shadow: 0 0 0 1px var(--line); transition: transform .12s ease, box-shadow .12s ease;
}
.swatch:hover { transform: scale(1.08); }
.swatch.on { box-shadow: 0 0 0 3px var(--ink); transform: scale(1.12); }

/* ---------- Min placering ---------- */
.map-wrap { position: relative; flex: 1; min-width: 0; display: flex; }
/* Filter direkte på kortet: Alle / Mangler / Besøgt */
.map-filter {
  position: absolute; top: 12px; right: 12px; z-index: 500;
  display: flex; background: #fff; border-radius: 999px; padding: 3px;
  box-shadow: 0 2px 8px rgba(0,0,0,.22); border: 1px solid var(--line);
}
.mf-btn {
  border: none; background: none; cursor: pointer; font: inherit; font-size: 12.5px;
  padding: 6px 13px; border-radius: 999px; color: var(--muted); white-space: nowrap; line-height: 1;
}
.mf-btn:hover { color: var(--ink); }
.mf-btn.active { background: var(--brand); color: #fff; font-weight: 600; }
@media (max-width: 760px) {
  .map-filter { top: 10px; right: 10px; }
  .mf-btn { padding: 6px 10px; font-size: 12px; }
}

.locate-btn {
  position: absolute; right: 12px; bottom: 28px; z-index: 500;
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line);
  background: #fff; font-size: 19px; cursor: pointer; box-shadow: var(--shadow);
  display: grid; place-items: center;
}
.locate-btn:hover { background: var(--line); }
.locate-btn.busy { opacity: .6; }
.me-dot {
  width: 18px; height: 18px; border-radius: 50%; background: #2563eb; border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.2), 0 2px 6px rgba(0,0,0,.35);
}
.local-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); cursor: pointer; }
.local-toggle input { width: 16px; height: 16px; }

/* ---------- Dyreplakaten: klistermærker ---------- */
.species-panel { padding: 12px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.species-panel.hidden { display: none; }
.species-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.species {
  position: relative; background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 4px 6px; cursor: grab; display: flex; flex-direction: column; align-items: center; gap: 4px;
  font: inherit; transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.species:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--brand); }
.species:active { cursor: grabbing; }
.species img { width: 46px; height: 46px; object-fit: contain; pointer-events: none; }
.species-name { font-size: 10.5px; line-height: 1.2; text-align: center; color: var(--muted); }
.species.armed { border-color: var(--brand); background: var(--brand-tint); box-shadow: 0 0 0 2px var(--brand); }
.species-count {
  position: absolute; top: 4px; right: 4px; background: var(--brand); color: #fff;
  font-size: 9.5px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 999px;
  display: grid; place-items: center; padding: 0 4px;
}
/* markør på kortet for et set dyr */
.sight-pin {
  width: 42px; height: 42px; border-radius: 50%; background: #fff; border: 2px solid var(--brand);
  box-shadow: 0 2px 6px rgba(0,0,0,.3); display: grid; place-items: center; overflow: hidden;
}
.sight-pin img { width: 34px; height: 34px; object-fit: contain; }
/* tællende nål når observationer samles */
.sight-cluster {
  width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-weight: 700; border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35);
  background: var(--brand);
}
.sight-cluster.s { font-size: 13px; }
.sight-cluster.m { font-size: 15px; background: var(--brand-dark); }
.sight-cluster.l { font-size: 17px; background: var(--forest); }
.marker-cluster, .marker-cluster div { background: none !important; border: none !important; }

.map-armed { cursor: crosshair !important; }
.map-drop { outline: 3px dashed var(--brand); outline-offset: -6px; }
.popup-sight img { width: 54px; height: 54px; object-fit: contain; display: block; margin: 0 auto 6px; }

/* admin: adgangsstyring */
.ac-user { border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.ac-head { display: flex; flex-direction: column; margin-bottom: 8px; }
.ac-head b { font-size: 13.5px; }
.ac-user .chip { font-size: 11px; padding: 4px 8px; }

/* eksport-dialog */
.export-box { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-top: 12px; }
.export-box b { font-size: 13.5px; }
.export-box .note { margin: 6px 0 10px; }
#export-btn.hidden { display: none; }

/* ---------- Billeder ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; min-height: 60px; }
.photo-cell { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--bg); }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; display: block; }
.photo-who {
  position: absolute; left: 4px; bottom: 4px; display: flex; align-items: center; gap: 4px;
  background: rgba(0,0,0,.55); color: #fff; font-size: 10px; padding: 2px 6px 2px 3px; border-radius: 999px;
}
.photo-who .mbadge { width: 14px; height: 14px; font-size: 7px; border-width: 1px; }
.photo-del {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; cursor: pointer; line-height: 1;
}
.photo-del:hover { background: var(--brand); }
.photo-count { font-size: 11px; color: var(--muted); white-space: nowrap; flex-shrink: 0; margin-right: 2px; }
.popup-photos { display: flex; gap: 4px; margin: 0 0 8px; }
.popup-photos img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; cursor: pointer; }

.lightbox {
  position: fixed; inset: 0; z-index: 5000; background: rgba(0,0,0,.9);
  display: grid; place-items: center; padding: 20px; cursor: zoom-out;
}
.lightbox.hidden { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: var(--shadow-lg); }

/* ---------- Login-gate ---------- */
.auth-gate {
  position: fixed; inset: 0; z-index: 2500; padding: 20px;
  background: linear-gradient(160deg, #698c7d, #1a2e05);
  display: grid; place-items: center;
}
.auth-gate.hidden { display: none; }
.auth-card {
  background: #fff; border-radius: 18px; padding: 30px 26px; width: min(380px, 92vw);
  text-align: center; box-shadow: var(--shadow-lg);
}
.auth-logo { border-radius: 18px; margin-bottom: 14px; }
.auth-card h2 {
  font-family: Fraunces, Georgia, serif; font-weight: 600;
  margin: 0 0 6px; font-size: 22px; letter-spacing: .2px;
}
.auth-sub { color: var(--muted); font-size: 13.5px; line-height: 1.5; margin: 0 0 18px; }
.auth-card input {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; margin-bottom: 10px;
}
.auth-card .primary-btn { width: 100%; padding: 12px; font-size: 15px; }
.auth-msg { font-size: 13px; color: var(--brand); margin: 12px 0 0; min-height: 18px; }
.auth-hint { font-size: 11.5px; color: var(--muted); margin: 0 0 8px; text-align: left; min-height: 14px; }
.auth-toggle { font-size: 13px; color: var(--muted); margin: 14px 0 0; }
.auth-toggle a { color: var(--brand); font-weight: 600; text-decoration: none; }
.auth-toggle a:hover { text-decoration: underline; }
.auth-fine { font-size: 11.5px; color: var(--muted); margin: 14px 0 0; line-height: 1.5; }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .menu-toggle { display: block; }
  .progress-wrap { min-width: 110px; }
  .brand-text p { display: none; }
  .sidebar {
    position: absolute; inset: 0 auto 0 0; width: min(88vw, 360px); z-index: 1500;
    transform: translateX(-102%); transition: transform .25s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
}
