:root {
  --brand: #003865;
  --brand-dark: #00294a;
  --accent: #2f7fc0;
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1b2430;
  --muted: #6b7686;
  --line: #e4e8ee;
  --radius: 14px;
  --bar-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --shadow: 0 1px 2px rgba(16, 32, 56, .06), 0 4px 16px rgba(16, 32, 56, .06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.5; overscroll-behavior-y: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
[hidden], .hidden { display: none !important; }

/* ---------- Splash ---------- */
.splash {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: linear-gradient(160deg, var(--brand) 0%, var(--brand-dark) 100%); color: #fff;
  transition: opacity .4s ease;
}
.splash.fade { opacity: 0; pointer-events: none; }
.splash-logo { width: 150px; height: 150px; animation: pop .6s cubic-bezier(.2, .9, .3, 1.3) both; }
.splash-name { font-size: 26px; font-weight: 700; letter-spacing: .3px; animation: rise .6s .15s ease both; }
.splash-spinner { width: 26px; height: 26px; margin-top: 18px; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Top bar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  padding-top: var(--safe-top);
  background: var(--brand); color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.12);
}
.bar { height: var(--bar-h); display: flex; align-items: center; gap: 4px; padding: 0 6px 0 10px; }
.bar-sub, .bar-search { padding-left: 2px; }
.bar-actions { display: flex; align-items: center; margin-left: auto; }
.bar-title { flex: 1; min-width: 0; margin: 0; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs { display: flex; gap: 4px; background: rgba(255,255,255,.12); border-radius: 999px; padding: 4px; }
.tab { padding: 6px 16px; border-radius: 999px; font-weight: 600; font-size: 15px; color: rgba(255,255,255,.8); transition: background .2s, color .2s; }
.tab.active { background: #fff; color: var(--brand); }

.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; flex-shrink: 0; position: relative; }
.icon-btn:active { background: rgba(255,255,255,.15); }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.dark { color: var(--text); }
.icon-btn.dark:active { background: var(--line); }
#btn-filter.active::after { content: ""; position: absolute; top: 9px; right: 9px; width: 9px; height: 9px; border-radius: 50%; background: #ffb547; border: 2px solid var(--brand); }

#search-input {
  flex: 1; height: 40px; margin-right: 8px; border: 0; border-radius: 10px; padding: 0 14px;
  font-size: 16px; background: rgba(255,255,255,.95); color: var(--text); outline: none;
}

/* ---------- Layout ---------- */
.view { min-height: 100%; padding-bottom: calc(96px + var(--safe-bottom)); }
body.has-bar .view { padding-top: calc(var(--bar-h) + var(--safe-top)); }
.page { max-width: 760px; margin: 0 auto; padding: 16px; }
.page-title { margin: 6px 4px 14px; font-size: 22px; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list > li + li { border-top: 1px solid var(--line); }
.row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 15px 16px; text-align: left; min-height: 56px; transition: background .15s; }
.row:active { background: #eef3f9; }
.row-text { flex: 1; min-width: 0; font-weight: 500; }
.row-icon { width: 40px; height: 40px; object-fit: contain; border-radius: 8px; background: #f6f8fb; flex-shrink: 0; }
.count { font-size: 13px; color: var(--muted); background: var(--bg); padding: 2px 9px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.chev { width: 9px; height: 9px; border-right: 2px solid #b3bcc8; border-top: 2px solid #b3bcc8; transform: rotate(45deg); flex-shrink: 0; margin-right: 4px; }
.check { color: var(--accent); font-weight: 700; }
.empty { padding: 28px 20px; text-align: center; color: var(--muted); }
.loading-row { padding: 30px; display: flex; justify-content: center; }
mark { background: #fff1b8; color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- Picker ---------- */
.picker { max-width: 760px; margin: 0 auto; padding: calc(16px + var(--safe-top)) 16px 16px; }
.picker-head { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 12px 0 14px; }
.picker-head h1 { margin: 6px 4px 14px; font-size: 26px; }
.picker-head .icon-btn { margin-left: -8px; }

.field { width: 100%; height: 48px; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 14px; font-size: 16px; background: #fff; color: var(--text); outline: none; transition: border-color .15s; }
.field:focus { border-color: var(--accent); }
.field-error { color: #c0392b; font-size: 14px; min-height: 20px; margin: 6px 2px 8px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 50px; padding: 0 22px; border-radius: 12px; font-weight: 600; font-size: 16px; text-decoration: none; background: var(--line); color: var(--text); }
.btn.primary { background: var(--brand); color: #fff; box-shadow: 0 4px 14px rgba(0, 56, 101, .3); }
.btn.primary:active { background: var(--brand-dark); }
.btn.block { display: flex; width: 100%; }
.btn.small { height: 38px; margin-top: 12px; }
.btn:disabled { opacity: .6; }
.btn .ext { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.link { color: var(--accent); font-weight: 600; font-size: 15px; padding: 4px 0; }

/* ---------- Document ---------- */
.doc { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-top: 16px; padding: 22px 20px 24px; }
@media (max-width: 600px) {
  .doc { margin: 0; border-radius: 0; box-shadow: none; padding-bottom: 90px; }
  body:has(.doc) { background: var(--card); }
}
.doc-title { font-size: 24px; line-height: 1.25; margin: 0 0 16px; }
.doc-body { overflow-wrap: anywhere; }
.doc-body img { max-width: 100%; height: auto; }
.doc-body table { width: 100%; border-collapse: collapse; display: block; overflow-x: auto; }
.doc-body td, .doc-body th { border: 1px solid var(--line); padding: 6px 8px; }
.doc-body a, .infobox a, .source a { color: var(--accent); }
.doc-body h2 { font-size: 19px; margin: 24px 0 8px; }
.doc-body h3 { font-size: 17px; margin: 20px 0 6px; }

/* togglehide / hiddentext */
.togglehide { display: block; position: relative; padding: 12px 4px 12px 30px; margin-top: 4px; border-top: 1px solid var(--line); font-weight: 600; cursor: pointer; user-select: none; }
.togglehide > .toggle-chev { position: absolute; left: 8px; top: 20px; margin: 0; }
.togglehide > p:first-of-type, .togglehide > div:first-of-type { margin-top: 0; }
.togglehide > p:last-child { margin-bottom: 0; }
.hiddentext { padding: 0 4px 12px 30px; animation: rise .2s ease both; }
.toggle-chev { width: 8px; height: 8px; border-right: 2px solid currentColor; border-top: 2px solid currentColor; transform: rotate(45deg); transition: transform .2s ease; flex-shrink: 0; margin: 0 4px; color: var(--accent); }
.togglehide.open .toggle-chev, .infobox[open] summary .toggle-chev { transform: rotate(135deg); }

.doc-cta { margin: 28px 0 8px; }
.cta-sub { text-align: center; color: var(--muted); font-size: 14px; margin: 8px 0 0; }

.infobox { margin-top: 22px; border-radius: 12px; background: #eef4fb; border: 1px solid #d6e4f3; overflow: hidden; }
.infobox summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 14px 16px; font-weight: 600; cursor: pointer; }
.infobox summary::-webkit-details-marker { display: none; }
.infobox summary .toggle-chev { margin-left: auto; }
.info-i { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font: italic 700 13px/22px Georgia, serif; text-align: center; flex-shrink: 0; }
.infobox-body { padding: 0 16px 14px; font-size: 15px; }
.source { margin: 18px 0 0; font-size: 14px; text-align: center; }

/* ---------- Map ---------- */
.map-wrap { position: fixed; left: 0; right: 0; bottom: 0; top: calc(var(--bar-h) + var(--safe-top)); }
#map { width: 100%; height: 100%; }
.iw { max-width: 240px; font-size: 14px; line-height: 1.45; }
.iw-title { display: block; font-size: 15px; }
.iw-cat { font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.iw-body p { margin: 4px 0; }
.iw a { color: var(--accent); font-weight: 600; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.checklist label .count { margin-left: auto; }

/* ---------- Municipality badge ---------- */
.muni-badge {
  position: fixed; z-index: 40;
  right: 14px; bottom: calc(14px + var(--safe-bottom));
  width: 58px; height: 58px; padding: 6px; object-fit: contain;
  background: #fff; border-radius: 16px; box-shadow: 0 4px 18px rgba(16, 32, 56, .2);
  pointer-events: none;
}
body:has(#map-wrap:not([hidden])) .muni-badge { bottom: calc(28px + var(--safe-bottom)); }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 200; background: rgba(10, 20, 35, .45); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .2s; }
.modal-backdrop.show { opacity: 1; }
.modal { width: 100%; max-width: 520px; max-height: 85vh; overflow-y: auto; background: #fff; border-radius: 20px 20px 0 0; padding: 10px 20px calc(20px + var(--safe-bottom)); transform: translateY(30px); transition: transform .25s ease; }
.modal-backdrop.show .modal { transform: none; }
@media (min-width: 600px) { .modal-backdrop { align-items: center; } .modal { border-radius: 20px; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-right: -10px; }
.modal-head h2 { font-size: 20px; margin: 0; }
.modal-sub { color: var(--muted); margin: 0 0 16px; font-size: 14px; }

.segmented { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg { flex: 1; height: 40px; border-radius: 9px; font-weight: 600; color: var(--muted); transition: background .15s, color .15s; }
.seg.active { background: #fff; color: var(--brand); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

.filter-tools { display: flex; gap: 20px; margin: 8px 0; }
.checklist { list-style: none; padding: 0; margin: 0 0 16px; }
.checklist li + li { border-top: 1px solid var(--line); }
.checklist label { display: flex; align-items: center; gap: 12px; padding: 12px 2px; cursor: pointer; }
.checklist input { width: 20px; height: 20px; accent-color: var(--brand); flex-shrink: 0; }

/* ---------- Misc ---------- */
.spinner { display: inline-block; width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
.loading-overlay { position: fixed; inset: 0; z-index: 300; background: rgba(243, 245, 248, .92); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); z-index: 400; transform: translate(-50%, 20px); background: #1b2430; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 40px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Install ---------- */
.install-banner {
  position: fixed; z-index: 45; left: 12px; right: 12px; bottom: calc(12px + var(--safe-bottom));
  display: flex; align-items: center; gap: 10px; padding: 10px 6px 10px 10px;
  background: #fff; border-radius: 16px; box-shadow: 0 6px 24px rgba(16, 32, 56, .22);
  animation: rise .3s ease both;
}
.install-banner img { width: 44px; height: 44px; flex-shrink: 0; }
.ib-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.ib-text strong { font-size: 15px; }
.ib-text span { font-size: 13px; color: var(--muted); }
.ib-btn { height: 38px; padding: 0 14px; font-size: 15px; box-shadow: none; }
.ib-close { width: 36px; height: 36px; }
.ib-close svg { width: 18px; height: 18px; }
body.has-install .muni-badge { bottom: calc(86px + var(--safe-bottom)); }
body.has-install .view { padding-bottom: calc(170px + var(--safe-bottom)); }
.install-link { text-align: center; margin: 22px 0 0; }

.guide { list-style: none; padding: 0; margin: 4px 0 20px; }
.guide li { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; }
.guide li + li { border-top: 1px solid var(--line); }
.guide small { color: var(--muted); }
.guide-n { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.guide-ic { width: 22px; height: 22px; vertical-align: -5px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.footer-link { text-align: center; margin: 18px 0 0; font-size: 14px; }
.footer-link a { color: var(--muted); }

/* ---------- Solution button ("Gå til løsning" and <a class="startbut">) ---------- */
:root { --solution: #4aa14a; --solution-dark: #3d873d; }
.doc a.solution-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 50px; margin: 0; padding: 12px 22px; box-sizing: border-box;
  border-radius: 12px; background: var(--solution); color: #fff;
  font-weight: 600; font-size: 16px; line-height: 1.3; text-align: center; text-decoration: none;
  box-shadow: 0 4px 14px rgba(74, 161, 74, .3);
}
.doc a.solution-btn:active { background: var(--solution-dark); }
.doc a.solution-btn .ext { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.doc-body a.startbut { margin: 18px 0; }
