:root {
  --bg: #ffffff;
  --ink: #16202a;
  --muted: #5c6b78;
  --border: #d9e0e6;
  --accent: #1c6e5a;
  --accent-ink: #ffffff;
  --panel-bg: #ffffff;
  --shadow: 0 4px 16px rgba(20, 30, 40, 0.16);
  --radius: 10px;
  --warn-bg: #fff4d6;
  --warn-ink: #6b4f00;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}

#map {
  position: absolute;
  inset: 0;
}

#topbar {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.brand {
  margin: 0;
  background: var(--panel-bg);
  padding: 10px 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}

#search-form {
  flex: 1;
  min-width: 220px;
  display: flex;
  background: var(--panel-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

#search-input {
  flex: 1;
  border: none;
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
}

#search-form button {
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0 16px;
  cursor: pointer;
  font-size: 14px;
}

#language-select {
  background: var(--panel-bg);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.02em;
}

#filters-toggle {
  background: var(--panel-bg);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}

#filters-toggle[aria-expanded="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}

#search-results {
  position: absolute;
  top: 62px;
  left: 12px;
  width: 340px;
  max-width: calc(100vw - 24px);
  max-height: 40vh;
  overflow-y: auto;
  background: var(--panel-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 9;
}

#search-results button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 14px;
}

#search-results button:hover {
  background: #f2f6f4;
}

#search-results .empty,
#search-results .note {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--muted);
}

#filters-panel {
  position: absolute;
  top: 62px;
  right: 12px;
  width: 280px;
  max-width: calc(100vw - 24px);
  background: var(--panel-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  z-index: 9;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
}

#filters-panel h2 {
  margin: 0 0 12px;
  font-size: 15px;
}

#filters-panel label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

#filters-panel input,
#filters-panel select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--ink);
}

.filter-hint {
  display: block;
  font-size: 11px;
  color: #93a0aa;
  margin-top: 4px;
  font-weight: 400;
}

.filter-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.filter-actions button {
  flex: 1;
  padding: 9px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  background: var(--accent);
  color: var(--accent-ink);
}

.filter-actions button.secondary {
  background: #eef1f3;
  color: var(--ink);
}

#company-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 100vw;
  background: var(--panel-bg);
  box-shadow: var(--shadow);
  z-index: 20;
  overflow-y: auto;
  padding: 20px;
}

#company-panel-close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: #eef1f3;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}

#company-panel-content h2 {
  margin: 0 32px 4px 0;
  font-size: 19px;
}

#company-panel-content .orgnr {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 14px;
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-right: 6px;
  margin-bottom: 6px;
}

.badge.legal-entity {
  background: #e3f0ec;
  color: var(--accent);
}

.badge.workplace {
  background: #eae6f7;
  color: #5232a8;
}

.badge.demo {
  background: var(--warn-bg);
  color: var(--warn-ink);
}

.badge.inactive {
  background: #fbe4e2;
  color: #8a2a20;
}

.badge.country {
  background: #e6edf5;
  color: #2c4a6e;
}

.field-group {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 14px;
}

.field-group h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin: 0 0 8px;
}

.field-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  padding: 4px 0;
}

.field-row .label {
  color: var(--muted);
  flex-shrink: 0;
}

.field-row .value {
  text-align: right;
}

.source-tag {
  display: block;
  font-size: 10px;
  color: #93a0aa;
  text-align: right;
  margin-top: 1px;
}

#status-banner {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 10;
  background: var(--warn-bg);
  color: var(--warn-ink);
  padding: 10px 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 13px;
  max-width: 420px;
}

#loading-indicator {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 10;
  background: var(--panel-bg);
  padding: 8px 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--muted);
}

.maplibregl-popup-content {
  font-family: inherit;
  font-size: 13px;
}

@media (max-width: 640px) {
  #company-panel {
    width: 100%;
  }
  #search-results,
  #filters-panel {
    width: calc(100vw - 24px);
  }
}
