/* =========================================================================
   Befaring – liste, kart med panel og mobilverktøy
   ========================================================================= */

/* ---------- Liste ---------- */
.bf-liste { max-width: 1180px; margin: 0 auto; padding: 24px 20px 60px; }
.bf-lhead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.bf-lhead h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.bf-lhead p { margin: 4px 0 0; color: var(--muted); }
.bf-tips { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; margin-bottom: 14px;
  background: linear-gradient(135deg, #ecfdf5, #eff6ff); border: 1px solid #d1fae5; }
.bf-tips svg.ik { width: 26px; height: 26px; color: #059669; flex-shrink: 0; }
.bf-tips b { display: block; font-size: 14px; }
.bf-tips span { font-size: 13px; color: var(--ink-2); }
.bf-sok { display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 42px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); margin-bottom: 14px; max-width: 420px; }
.bf-sok svg.ik { color: var(--muted); }
.bf-sok input { border: 0; outline: 0; background: none; font: inherit; flex: 1; min-width: 0; color: var(--ink); }
.bf-kort { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.bf-k { display: flex; flex-direction: column; gap: 5px; padding: 16px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); text-decoration: none; color: var(--ink);
  transition: border-color .15s, box-shadow .15s, transform .15s; }
.bf-k:hover { border-color: var(--accent-line-2); box-shadow: 0 10px 24px -14px rgba(15, 23, 42, .35); transform: translateY(-1px); }
.bf-k > b { font-size: 16px; letter-spacing: -.01em; }
.bf-k-top { display: flex; justify-content: space-between; align-items: center; }
.bf-k-type { font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: #059669; }
.bf-k-bunn { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.bf-k-bunn span { display: inline-flex; align-items: center; gap: 5px; }
.bf-k-bunn svg.ik { width: 14px; height: 14px; }
.bf-tom { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 36px 16px; text-align: center; color: var(--muted); }
.bf-tom svg.ik { width: 34px; height: 34px; color: #cbd5e1; }
.bf-tom b { color: var(--ink); font-size: 15px; }
.bf-tom span { font-size: 13px; max-width: 360px; }
.bf-laster { display: grid; place-items: center; height: 60vh; }

/* ---------- Befaring: panel + kart ---------- */
.page-main:has(.bf-vis) { padding: 60px 0 0; max-width: none; margin: 0; overflow: hidden; height: 100vh; height: 100dvh; box-sizing: border-box; }
.bf-vis { display: grid; grid-template-columns: 420px minmax(0, 1fr); height: 100%; }
.bf-panel { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); }
.bf-phead { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 12px 16px 10px; border-bottom: 1px solid var(--line-2); }
.bf-tilbake { grid-column: 1 / -1; display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 13px; font-weight: 550; text-decoration: none; }
.bf-tilbake:hover { color: var(--accent); }
.bf-tilbake svg.ik { width: 16px; height: 16px; }
.bf-ptittel h2 { margin: 0; font-size: 18px; letter-spacing: -.015em; line-height: 1.25; }
.bf-phead-act { display: flex; align-items: center; gap: 6px; align-self: start; }
.bf-faner { display: flex; gap: 2px; padding: 6px 10px 0; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.bf-faner button { border: 0; background: none; padding: 9px 10px; font: inherit; font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.bf-faner button b { font-size: 11px; margin-left: 4px; padding: 1px 6px; border-radius: 99px; background: var(--soft); color: var(--ink-2); }
.bf-faner button b:empty { display: none; }
.bf-faner button.on { color: var(--accent); border-bottom-color: var(--accent); }
.bf-innhold { flex: 1; overflow-y: auto; padding: 14px 16px 24px; }

.bf-kartfelt { position: relative; min-height: 0; }
#bf-map { position: absolute; inset: 0; }
.bf-lagvalg { position: absolute; left: 12px; bottom: 30px; z-index: 3; display: flex; gap: 2px; padding: 3px; border-radius: 11px; background: rgba(255, 255, 255, .94); box-shadow: var(--shadow); }
.bf-lagvalg button { border: 0; background: none; padding: 6px 10px; border-radius: 8px; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.bf-lagvalg button.on { background: var(--ink); color: #fff; }
.bf-verktoy { position: absolute; top: 12px; left: 12px; z-index: 3; display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: rgba(255, 255, 255, .95); box-shadow: var(--shadow); backdrop-filter: blur(8px); }
.bf-verktoy button { display: inline-flex; align-items: center; gap: 7px; border: 0; background: none; padding: 8px 11px; border-radius: 10px; font: inherit; font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer; white-space: nowrap; }
.bf-verktoy button:hover { background: var(--soft); }
.bf-verktoy button.on { background: #dcfce7; color: #166534; box-shadow: inset 0 0 0 1px #86efac; }
.bf-maaler { position: absolute; top: 66px; left: 12px; z-index: 4; width: 340px; max-width: calc(100% - 24px); padding: 14px; border-radius: 16px; background: #fff;
  box-shadow: 0 18px 40px -16px rgba(15, 23, 42, .45); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.bf-maaler.hidden { display: none; }
.bf-maaler .row { gap: 6px; }
.bf-mt { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 3px; border-radius: 11px; background: var(--soft); }
.bf-mt button { display: flex; flex-direction: column; align-items: center; gap: 3px; border: 0; background: none; padding: 7px 2px; border-radius: 9px; font: inherit; font-size: 11.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.bf-mt button.on { background: #fff; color: #166534; box-shadow: 0 1px 3px rgba(15, 23, 42, .15); }
.bf-mv { display: flex; flex-direction: column; gap: 2px; }
.bf-mv b { font-size: 28px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: #14532d; }
.bf-mv span { font-size: 12.5px; color: var(--muted); }

/* GPS */
.bf-gps { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.bf-gps .grow { flex: 1; }
.bf-gpsdot { width: 11px; height: 11px; border-radius: 50%; background: #94a3b8; box-shadow: 0 0 0 0 rgba(148, 163, 184, .6); animation: bf-puls 1.6s infinite; }
.bf-gpsdot.ok { background: #16a34a; box-shadow: 0 0 0 0 rgba(22, 163, 74, .6); }
.bf-gpsdot.bad { background: #dc2626; }
@keyframes bf-puls { 70% { box-shadow: 0 0 0 9px rgba(0, 0, 0, 0); } 100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); } }
.bf-gpsv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.bf-gpsv div { padding: 8px 10px; border-radius: 10px; background: var(--soft); }
.bf-gpsv span { display: block; font-size: 11.5px; color: var(--muted); }
.bf-gpsv b { font-size: 18px; font-variant-numeric: tabular-nums; }

/* ---------- Kort i panelet ---------- */
.bf-sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px; }
.bf-sum div { padding: 10px 12px; border-radius: 12px; background: var(--soft); border: 1px solid var(--line-2); }
.bf-sum span { display: block; font-size: 11.5px; color: var(--muted); }
.bf-sum b { font-size: 16px; font-variant-numeric: tabular-nums; }
.bf-liste-p { display: flex; flex-direction: column; gap: 8px; }
.bf-pk { display: flex; gap: 11px; padding: 11px 12px; border-radius: 13px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.bf-pk:hover { border-color: var(--accent-line-2); }
.bf-pk.valgt { border-color: #f97316; box-shadow: 0 0 0 2px #fed7aa; }
.bf-pk-ik { width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0; display: grid; place-items: center; background: #fff7ed; color: #c2410c; font-size: 14px; }
.bf-pk-ik b { font-size: 14px; }
.bf-pk-ik svg.ik { width: 17px; height: 17px; }
.bf-pk-txt { flex: 1; min-width: 0; }
.bf-pk-top { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.bf-metode { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 6px; background: #ecfdf5; color: #047857; }
.bf-pk-v { font-size: 19px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.bf-pk-t { font-size: 13.5px; color: var(--ink-2); }
.bf-pk-t.big { font-size: 14px; color: var(--ink); white-space: pre-wrap; }
.bf-pk-e { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.bf-pk-meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.bf-pk-act { display: flex; flex-direction: column; gap: 2px; }
.bf-pk-act .x svg.ik { width: 15px; height: 15px; }
.bf-prof { width: 100%; max-width: 340px; height: auto; display: block; margin: 4px 0; }
.bf-lagre .bf-prof { max-width: 420px; }
.bf-lagre > span:last-child { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.bf-prof .a { fill: #dbeafe; }
.bf-prof .l { fill: none; stroke: #2563eb; stroke-width: 2; }
.bf-prof text { font-size: 10px; fill: #64748b; }
.bf-bm { margin: 4px 0; }
.bf-bm-l { display: inline-block; margin-right: 8px; font-weight: 600; color: #c2410c; }

/* Bilder med målelinjer */
.bf-bimg { position: relative; display: block; border-radius: 10px; overflow: hidden; background: #0f172a; line-height: 0; cursor: zoom-in; }
.bf-bimg img { width: 100%; height: auto; display: block; }
.bf-bimg svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.bf-bimg line { stroke: #ea580c; stroke-width: 3; vector-effect: non-scaling-stroke; stroke-linecap: round; }
.bf-bimg line.ref { stroke: #e2e8f0; stroke-dasharray: 6 4; }
.bf-bimg.stor { cursor: default; max-height: 70vh; }
.bf-bimg.stor img { max-height: 70vh; object-fit: contain; }
.bf-bknapper { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.bf-galleri { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.bf-galleri figure { margin: 0; position: relative; border-radius: 12px; border: 1px solid var(--line); padding: 5px; background: var(--panel); }
.bf-galleri figure.valgt { border-color: #f97316; box-shadow: 0 0 0 2px #fed7aa; }
.bf-galleri .bf-bimg { aspect-ratio: 4 / 3; }
.bf-galleri .bf-bimg img { height: 100%; object-fit: cover; }
.bf-galleri figcaption { font-size: 12px; padding: 5px 3px 2px; color: var(--ink-2); min-height: 18px; }
.bf-g-act { position: absolute; top: 9px; right: 9px; display: flex; gap: 4px; }
.bf-g-act .x { background: rgba(255, 255, 255, .92); border-radius: 8px; }
.bf-bm-liste { padding-left: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.bf-bm-liste b { color: #c2410c; margin-right: 4px; }

/* Notater og sjekkliste */
.bf-notat { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.bf-notat .grow, .bf-bmal .grow { flex: 1; }
#bf-tale.on, #nh-tale.on { background: #fee2e2; color: #b91c1c; }
.bf-sjsum { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.bf-sjsum .ok { color: #15803d; } .bf-sjsum .bad { color: #b91c1c; }
.bf-sj { display: flex; flex-direction: column; gap: 6px; }
.bf-sjr { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); }
.bf-sjr.ok { border-left: 4px solid #16a34a; } .bf-sjr.avvik { border-left: 4px solid #dc2626; background: #fffafa; } .bf-sjr.na { border-left: 4px solid #cbd5e1; }
.bf-sjt { font-size: 13.5px; }
.bf-sjv { display: flex; gap: 3px; align-items: center; }
.bf-sjv button[data-s] { border: 1px solid var(--line); background: var(--panel); padding: 6px 10px; border-radius: 9px; font: inherit; font-size: 12.5px; font-weight: 650; cursor: pointer; color: var(--ink-2); min-width: 44px; }
.bf-sjv button[data-s="ok"].on { background: #16a34a; border-color: #16a34a; color: #fff; }
.bf-sjv button[data-s="avvik"].on { background: #dc2626; border-color: #dc2626; color: #fff; }
.bf-sjv button[data-s="na"].on { background: #64748b; border-color: #64748b; color: #fff; }
.bf-sjr [data-m] { grid-column: 1 / -1; }

/* Ny befaring */
.bf-adr { display: flex; gap: 6px; }
.bf-adr .input { flex: 1; }
.bf-forslag { display: flex; flex-direction: column; margin-top: 4px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.bf-forslag:empty { display: none; }
.bf-forslag button { text-align: left; border: 0; border-bottom: 1px solid var(--line-2); background: var(--panel); padding: 9px 12px; font: inherit; font-size: 13.5px; cursor: pointer; }
.bf-forslag button:hover { background: var(--soft); }

/* Lagre måling */
.bf-lagre { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 12px; background: #f0fdf4; border: 1px solid #bbf7d0; margin-bottom: 12px; }
.bf-lagre > span { font-size: 12.5px; color: #166534; font-weight: 600; }
.bf-lagre > b { font-size: 26px; letter-spacing: -.02em; color: #14532d; font-variant-numeric: tabular-nums; }
.lbl { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.bf-hurtig { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.bf-hurtig .chip, .bf-bmal-ref .chip { cursor: pointer; border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); font-size: 12.5px; padding: 5px 11px; }
.bf-hurtig .chip:hover { border-color: var(--accent-line-2); }

/* ---------- Vater ---------- */
.bf-vater { display: flex; flex-direction: column; gap: 12px; }
.bf-v-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding-right: 34px; }
.bf-v-top h2 { margin: 0; }
.bf-seg, .bf-steg { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--soft); }
.bf-seg button, .bf-steg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.bf-seg button.on, .bf-steg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(15, 23, 42, .15); }
.bf-steg button b { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; background: #cbd5e1; color: #fff; font-size: 11px; }
.bf-steg button.on b { background: #ea580c; }
.bf-steg button:disabled { opacity: .45; cursor: default; }
.bf-v-skive { position: relative; width: min(280px, 72vw); aspect-ratio: 1; margin: 6px auto; border-radius: 50%;
  background: radial-gradient(circle, #f0fdf4 0%, #dcfce7 60%, #bbf7d0 100%); border: 3px solid #86efac; overflow: hidden; }
.bf-v-ring { position: absolute; inset: 30%; border-radius: 50%; border: 2px solid rgba(22, 101, 52, .35); }
.bf-v-ring.r2 { inset: 44%; border-color: rgba(22, 101, 52, .6); }
.bf-v-kryss::before, .bf-v-kryss::after { content: ""; position: absolute; background: rgba(22, 101, 52, .25); }
.bf-v-kryss::before { left: 50%; top: 6%; bottom: 6%; width: 1px; }
.bf-v-kryss::after { top: 50%; left: 6%; right: 6%; height: 1px; }
.bf-v-boble { position: absolute; left: 39%; top: 39%; width: 22%; height: 22%; border-radius: 50%; transition: transform .08s linear;
  background: radial-gradient(circle at 35% 30%, #fff 0%, #fde68a 30%, #f59e0b 100%); box-shadow: 0 4px 10px rgba(0, 0, 0, .2); }
.bf-v-boble.vatert { background: radial-gradient(circle at 35% 30%, #fff 0%, #86efac 30%, #16a34a 100%); }
.bf-v-kant { position: absolute; inset: 0; width: 100%; height: 100%; }
.bf-v-kant .h { stroke: rgba(22, 101, 52, .3); stroke-width: 2; stroke-dasharray: 4 4; }
.bf-v-kant .l { stroke: #ea580c; stroke-width: 5; stroke-linecap: round; transition: transform .08s linear; }
.bf-v-tall { text-align: center; }
.bf-v-tall b { display: block; font-size: 44px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.bf-v-tall span { color: var(--muted); font-size: 14px; }

/* ---------- Mål i bilde ---------- */
.bf-bmal { display: flex; flex-direction: column; gap: 10px; }
.bf-bmal-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.bf-bmal-top h2 { margin: 0; }
.bf-bmal-flate { position: relative; display: flex; justify-content: center; background: #0f172a; border-radius: 12px; padding: 6px; touch-action: none; user-select: none; -webkit-user-select: none; }
.bf-bmal-flate canvas#bm-c { display: block; touch-action: none; cursor: crosshair; border-radius: 6px; }
.bf-lupe { position: absolute; width: 150px; height: 150px; pointer-events: none; z-index: 2; filter: drop-shadow(0 8px 16px rgba(0, 0, 0, .45)); }
.bf-lupe.hidden { display: none; }
.bf-bmal-ref { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.bf-bmal-ref:empty { display: none; }
.bf-bmal-ref .chip { cursor: pointer; border: 1px solid var(--line); background: var(--panel); }
.bf-bmal-ref .chip.on { background: #334155; border-color: #334155; color: #fff; }
.bf-egen { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.bf-egen .input { width: 80px; padding: 5px 8px; }
.bf-bmal-liste { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.bf-bmal-liste:empty { display: none; }
.bf-bmal-liste li { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 10px; background: #fff7ed; }
.bf-bmal-liste b { width: 22px; height: 22px; border-radius: 50%; background: #ea580c; color: #fff; display: grid; place-items: center; font-size: 12px; flex-shrink: 0; }
.bf-bmal-liste span { font-weight: 700; min-width: 70px; font-variant-numeric: tabular-nums; }
.bf-bmal-liste .input { flex: 1; }

/* ---------- Mobil ---------- */
.bf-mobilbar { display: none; }
@media (max-width: 760px) {
  .bf-liste { padding: 16px 14px 90px; }
  .bf-lhead h1 { font-size: 22px; }
  .bf-ny { position: fixed; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 20; height: 52px; padding: 0 20px; border-radius: 26px; box-shadow: 0 12px 28px -10px rgba(var(--accent-rgb), .8); font-size: 15px; }
  .bf-kort { grid-template-columns: 1fr; }

  .bf-vis { grid-template-columns: minmax(0, 1fr); grid-template-rows: 46% minmax(0, 1fr) auto; }
  .bf-panel, .bf-kartfelt { min-width: 0; }
  .bf-kartfelt { grid-row: 1; }
  .bf-panel { grid-row: 2; border-right: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; margin-top: -14px; z-index: 5; box-shadow: 0 -10px 24px -18px rgba(15, 23, 42, .5); }
  .bf-panel::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: #cbd5e1; margin: 8px auto 0; }
  .bf-phead { padding: 6px 14px 8px; }
  .bf-tilbake span { display: none; }
  .bf-tilbake { position: absolute; }
  .bf-ptittel { padding-left: 26px; }
  .bf-ptittel h2 { font-size: 16px; }
  .bf-phead-act .btn span { display: none; }
  .bf-innhold { padding: 12px 14px 18px; }
  .bf-verktoy { display: none; }
  .bf-lagvalg { bottom: 22px; }
  .bf-mobilbar { grid-row: 3; display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: #0f172a; z-index: 6; }
  .bf-mobilbar button { display: flex; flex-direction: column; align-items: center; gap: 3px; border: 0; background: none; color: #cbd5e1; font: inherit; font-size: 10.5px; font-weight: 600; padding: 7px 0; border-radius: 10px; }
  .bf-mobilbar button svg.ik { width: 22px; height: 22px; }
  .bf-mobilbar button.on { background: rgba(34, 197, 94, .2); color: #86efac; }
  .bf-mobilbar button:active { background: rgba(255, 255, 255, .08); }
  .bf-maaler { top: auto; bottom: 10px; left: 8px; right: 8px; width: auto; max-width: none; border-radius: 16px; padding: 12px; }
  body.bf-maler .bf-vis { grid-template-rows: 1fr 0 auto; }
  body.bf-maler .bf-panel { display: none; }
  .bf-mt button { padding: 8px 2px; }
  .bf-maaler .btn { padding: 10px 12px; }
  .bf-galleri { grid-template-columns: 1fr 1fr; gap: 8px; }
  .bf-sjr { grid-template-columns: 1fr; }
  .bf-sjv button[data-s] { flex: 1; padding: 9px 4px; }
  .bf-sjv { width: 100%; }
}
