:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #f97316;
  --accent-ink: #9a3412;
  --top: #111827;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --info: #2563eb;
  --s-paagaar: #f97316;
  --s-planlagt: #6366f1;
  --s-ferdig: #16a34a;
  --s-pause: #64748b;
  --shadow: 0 6px 24px rgba(15, 23, 42, .14);
  --r: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: Inter, system-ui, sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }
.hidden { display: none !important; }

/* Top bar */
.topbar { position: fixed; inset: 0 0 auto 0; height: 56px; background: var(--top); color: #fff; display: flex; align-items: center; gap: 16px; padding: 0 16px; z-index: 20; }
.brand { font-weight: 700; font-size: 17px; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.logo { color: var(--accent); }
.tag { font-size: 11px; font-weight: 500; background: #374151; padding: 2px 6px; border-radius: 6px; color: #d1d5db; }
.search { position: relative; flex: 1; max-width: 560px; }
.search input { width: 100%; height: 38px; border-radius: 8px; border: 0; padding: 0 12px; background: #1f2937; color: #fff; outline: none; }
.search input:focus { background: #fff; color: var(--ink); }
.search-results { position: absolute; top: 44px; left: 0; right: 0; background: #fff; color: var(--ink); border-radius: 8px; box-shadow: var(--shadow); overflow: hidden; }
.search-results div { padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.search-results div:hover, .search-results div.sel { background: #fff7ed; }
.search-results small { color: var(--muted); display: block; }
.top-actions { display: flex; gap: 8px; margin-left: auto; }
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px; padding: 7px 12px; white-space: nowrap; }
.btn.ghost { background: transparent; color: #e5e7eb; border-color: #374151; }
.btn.ghost.on, .btn.ghost:hover { background: #374151; color: #fff; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.btn.small { padding: 4px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

/* Map */
#map { position: fixed; inset: 56px 0 0 0; }

/* Panels */
.panel { position: fixed; top: 56px; bottom: 0; background: var(--panel); z-index: 10; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.panel.left { left: 0; width: 360px; }
.panel.right { right: 0; width: 440px; overflow-y: auto; padding: 18px 18px 40px; }
.left-toggle { display: none; position: fixed; top: 66px; left: 10px; z-index: 11; border: 0; background: #fff; border-radius: 8px; box-shadow: var(--shadow); width: 38px; height: 38px; }
.close { position: absolute; top: 10px; right: 12px; border: 0; background: transparent; font-size: 24px; color: var(--muted); line-height: 1; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; background: transparent; padding: 12px 4px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); }
.tab-body { overflow-y: auto; padding: 14px; flex: 1; }

h2 { font-size: 19px; margin: 0 0 4px; padding-right: 26px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.grow { flex: 1; }

/* Lists */
.card { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; margin-bottom: 8px; cursor: pointer; background: #fff; }
.card:hover { border-color: #fdba74; background: #fffbf7; }
.card.active { border-color: var(--accent); box-shadow: 0 0 0 2px #fed7aa; }
.card .title { font-weight: 600; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; color: #fff; white-space: nowrap; }
.chip.Pågår { background: var(--s-paagaar); } .chip.Planlagt { background: var(--s-planlagt); } .chip.Ferdig { background: var(--s-ferdig); } .chip.Pause { background: var(--s-pause); }
.chip.light { background: #f1f5f9; color: var(--ink); }
.chip.ok { background: #dcfce7; color: #166534; } .chip.warn { background: #fef3c7; color: #92400e; } .chip.bad { background: #fee2e2; color: #991b1b; } .chip.info { background: #dbeafe; color: #1e40af; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.filters button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 3px 10px; font-size: 12px; }
.filters button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }

.bar { height: 8px; background: #eef2f7; border-radius: 99px; position: relative; overflow: hidden; margin-top: 6px; }
.bar > span { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 99px; }
.bar > i { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); }

/* Address result */
.addr-box { background: #fff7ed; border: 1px solid #fed7aa; border-radius: var(--r); padding: 10px 12px; margin-bottom: 12px; }
.addr-box .title { font-weight: 600; }

/* Detail panel */
.subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 14px -18px 14px; padding: 0 12px; overflow-x: auto; }
.subtabs button { border: 0; background: transparent; padding: 9px 9px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.subtabs button.active { color: var(--ink); border-bottom-color: var(--accent); }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.kpi { border: 1px solid var(--line); border-radius: var(--r); padding: 10px; }
.kpi b { display: block; font-size: 20px; margin-top: 2px; }
.kpi.alert b { color: var(--bad); }
dl.info { display: grid; grid-template-columns: 130px 1fr; gap: 6px 10px; margin: 0; }
dl.info dt { color: var(--muted); }
dl.info dd { margin: 0; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 6px; }
.timeline li::before { content: ""; position: absolute; left: -26px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid #cbd5e1; }
.timeline li.done::before { background: var(--ok); border-color: var(--ok); }
.timeline li.late::before { border-color: var(--bad); }

.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.gallery figure { margin: 0; cursor: pointer; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.gallery img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.gallery figcaption { font-size: 11px; padding: 5px 7px; color: var(--muted); }

.compare { position: relative; aspect-ratio: 4/3; border-radius: 8px; overflow: hidden; user-select: none; }
.compare img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.compare .top { clip-path: inset(0 50% 0 0); }
.compare .handle { position: absolute; top: 0; bottom: 0; left: 50%; width: 3px; background: #fff; box-shadow: 0 0 6px rgba(0,0,0,.4); pointer-events: none; }
.compare input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: ew-resize; margin: 0; }
.compare .lbl { position: absolute; bottom: 8px; font-size: 11px; background: rgba(0,0,0,.6); color: #fff; padding: 2px 6px; border-radius: 4px; }

.entry { border-left: 3px solid var(--line); padding: 2px 0 2px 10px; margin-bottom: 12px; }
.check-row { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.check-row .ico { width: 26px; height: 26px; border-radius: 7px; flex: none; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: #f1f5f9; }
.check-row .ico.ok { background: #dcfce7; color: #166534; } .check-row .ico.warn { background: #fef3c7; color: #92400e; } .check-row .ico.bad { background: #fee2e2; color: #991b1b; } .check-row .ico.info { background: #dbeafe; color: #1e40af; }
.check-row .t { font-weight: 600; }
.check-row .src { font-size: 11px; color: var(--muted); }
.spinner { width: 14px; height: 14px; border: 2px solid #cbd5e1; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Layers */
.layer { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.layer input[type=checkbox] { margin-top: 3px; accent-color: var(--accent); }
.layer .t { font-weight: 500; }
.layer input[type=range] { width: 100%; accent-color: var(--accent); }
.layer.soon { opacity: .55; }
.basemaps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.basemaps button { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 8px 4px; font-size: 12px; }
.basemaps button.on { border-color: var(--accent); background: #fff7ed; font-weight: 600; }

/* Kalkyle */
.tools { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.tools button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 10px 6px; text-align: left; }
.tools button b { display: block; }
.tools button span { font-size: 11px; color: var(--muted); }
.tools button.on { border-color: var(--accent); background: #fff7ed; }
.result { background: #f8fafc; border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin-top: 10px; }
.big { font-size: 24px; font-weight: 700; }
table.t { width: 100%; border-collapse: collapse; font-size: 12px; }
table.t td, table.t th { padding: 5px 4px; border-bottom: 1px solid var(--line); text-align: left; }
table.t td.num, table.t th.num { text-align: right; white-space: nowrap; }
table.t input { width: 72px; border: 1px solid var(--line); border-radius: 5px; padding: 3px 5px; text-align: right; }
.formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.formgrid label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.formgrid label.full { grid-column: span 2; }

/* Map overlays */
.hint { position: fixed; top: 68px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 99px; z-index: 15; font-size: 13px; box-shadow: var(--shadow); }
.mk { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); cursor: pointer; }
.mk.machine { background: #eab308; color: #422006; border-radius: 7px; }
.mk.machine.Parkert { background: #a3a3a3; color: #fff; }
.mk.person { background: #0ea5e9; width: 24px; height: 24px; font-size: 10px; }
.mk.addr { background: var(--ink); width: 18px; height: 18px; border: 3px solid var(--accent); }
.maplibregl-popup-content { font-family: Inter, system-ui, sans-serif; border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); }
.legend { position: fixed; bottom: 30px; right: 10px; z-index: 5; background: #fff; border-radius: 8px; box-shadow: var(--shadow); padding: 8px 10px; font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; margin-right: 8px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.6); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal-card { background: #fff; border-radius: 12px; max-width: 820px; width: 100%; max-height: 90vh; overflow: auto; padding: 18px; position: relative; }
.modal-card img { width: 100%; border-radius: 8px; display: block; }

.profile svg { width: 100%; height: auto; display: block; }

@media (max-width: 900px) {
  .panel.left { width: 100%; max-width: 360px; transform: translateX(-100%); transition: transform .2s; }
  .panel.left.open { transform: none; }
  .left-toggle { display: block; }
  .panel.left .tabs { padding-left: 52px; }
  .panel.right { width: 100%; top: 40%; border-radius: 14px 14px 0 0; }
  .top-actions .btn { padding: 7px 8px; font-size: 12px; }
  #btn-norge { display: none; }
  .brand .tag { display: none; }
}
@media (max-width: 600px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .brand { font-size: 0; } .brand .logo { font-size: 18px; }
  #btn-check { font-size: 0; padding: 7px 10px; } #btn-check::before { content: "⌖"; font-size: 16px; }
  .legend { display: none; }
}
