:root {
  --bg: #f6f7f8;
  --panel: #ffffff;
  --text: #1f2328;
  --muted: #6b7280;
  --border: #e3e5e8;
  --accent: #d9480f;
  --topbar: #1f2a37;
  --sidebar-w: 320px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }

.topbar {
  height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: var(--topbar);
  color: #fff;
}
.brand { font-weight: 600; }
.version {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .15);
}

.layout {
  display: flex;
  height: calc(100% - 44px);
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

.map-wrap { flex: 1; position: relative; min-width: 0; }
.map { position: absolute; inset: 0; }

/* --- Søgefelt over kortet --- */
.search {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 6;
  width: 380px;
  max-width: calc(100% - 70px);
}
.search input {
  width: 100%;
  height: 40px;
  padding: 0 36px 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  background: var(--panel);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
  outline: none;
}
.search input:focus { border-color: var(--accent); }
.search input::-webkit-search-cancel-button { display: none; }
.search.is-loading input { background-image: linear-gradient(90deg, transparent, rgba(217,72,15,.12), transparent);
  background-size: 200% 100%; animation: search-load 1s linear infinite; }
@keyframes search-load { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.search-clear {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 28px;
  height: 28px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
}
.search-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 4px 0;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .25);
}
.search-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
}
.search-list li.is-active { background: #fff4d6; }
.search-list .search-empty { color: var(--muted); cursor: default; }
.search-icon { width: 16px; height: 16px; flex-shrink: 0; display: inline-flex; }
.search-icon svg { width: 100%; height: 100%; }
.search-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-bfe { flex-shrink: 0; color: var(--muted); font-size: 11px; }
.search-list li + li { border-top: 1px solid var(--border); }

/* --- Objektinfo-vindue over kortet --- */
.infopanel {
  position: absolute;
  top: 60px;
  left: 10px;
  z-index: 5;
  width: 380px;
  max-width: calc(100% - 70px);
  max-height: calc(100% - 70px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .25);
  overflow: hidden;
}
.infopanel[hidden] { display: none; }
.infopanel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.infopanel-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.infopanel-close {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: var(--topbar);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.infopanel-close:hover { background: var(--accent); }
.infopanel-body { padding: 12px 14px; overflow-y: auto; }
.infopanel-section { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); }
.infopanel-section h3 {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}
.panel h2 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.muted { color: var(--muted); margin: 0; }
.error { color: #b42318; margin: 0; }

/* --- Lagtræ --- */
.lt-group { margin-bottom: 6px; }
.lt-group > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 4px 0;
  list-style-position: inside;
}
.lt-layer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0 4px 18px;
  cursor: pointer;
}
.lt-swatch, .lt-legend-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: inline-flex;
}
.lt-swatch svg, .lt-legend-icon svg { width: 100%; height: 100%; }
.lt-legend {
  list-style: none;
  margin: 0 0 4px;
  padding: 0 0 0 42px;
  font-size: 12px;
  color: var(--muted);
}
.lt-legend li { display: flex; align-items: center; gap: 6px; padding: 1px 0; }
.lt-basemap { padding-left: 0; }
.lt-subgroup > summary { cursor: pointer; padding: 3px 0; color: var(--text); }
.lt-subgroup .lt-basemap { padding-left: 18px; }
.lt-hint { display: none; margin-left: auto; font-size: 12px; color: var(--muted); }
.lt-out-of-range { color: var(--muted); }
.lt-out-of-range .lt-hint { display: inline; }

.lt-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0 6px 40px;
  color: var(--muted);
  font-size: 13px;
}
.lt-select { font: inherit; padding: 2px 4px; }

.lt-config-error { font-size: 12px; margin: 0 0 8px; white-space: pre-wrap; }
.lt-warning { color: #b42318; }
.lt-warning-text { margin: -2px 0 4px 42px; font-size: 11px; color: #b42318; }
.lt-wms-legend { padding: 0 0 6px 42px; }
.lt-wms-legend[hidden] { display: none; }
.lt-wms-legend img { display: block; max-width: 100%; }

/* --- Samlet ejendom --- */
.ej-list { list-style: none; margin: 4px 0 10px; padding: 0; }
.ej-list li {
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.ej-list li[data-id] { cursor: pointer; }
.ej-list li[data-id]:hover { background: #fff4d6; }
.ej-list .ej-area { color: var(--muted); white-space: nowrap; }
.ej-sub { margin: 10px 0 2px; font-weight: 600; }
.ej-owners { list-style: none; margin: 4px 0 6px; padding: 0; }
.ej-owners li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.ej-owner-head { display: flex; justify-content: space-between; gap: 8px; }
.ej-owner-name { font-weight: 600; }
.ej-owner-line { color: var(--text); font-size: 13px; }
.ej-owner-line a { color: #1c7ed6; }
.ej-owner-tags { color: var(--muted); font-size: 12px; margin-top: 2px; }
.ej-source { color: var(--muted); font-size: 11px; margin: 0 0 6px; }

/* --- Objektinfo --- */
.fi-others-title { margin: 10px 0 4px; color: var(--muted); font-size: 12px; }
.fi-others { display: flex; flex-wrap: wrap; gap: 6px; }
.fi-others button {
  font: inherit;
  font-size: 12px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  cursor: pointer;
}
.fi-others button:hover { border-color: var(--accent); }
.featureinfo table { width: 100%; border-collapse: collapse; }
.featureinfo th, .featureinfo td {
  text-align: left;
  vertical-align: top;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.featureinfo th { width: 40%; font-weight: 500; color: var(--muted); padding-right: 8px; }
.featureinfo .fi-html { width: 100%; height: 260px; border: 1px solid var(--border); border-radius: 4px; }
.featureinfo .fi-text { white-space: pre-wrap; font-size: 12px; margin: 0; }
.featureinfo a { color: #1c7ed6; }
.featureinfo .fi-title { font-weight: 600; margin: 0 0 6px; }

@media (max-width: 700px) {
  .layout { flex-direction: column-reverse; }
  .sidebar { width: 100%; height: 40%; border-right: 0; border-top: 1px solid var(--border); }
  .infopanel { left: 8px; right: 8px; width: auto; max-width: none; max-height: 70%; }
  .search { left: 8px; right: 56px; width: auto; max-width: none; }
}
