:root {
  --bg: #f7f8fa;
  --card-bg: #ffffff;
  --text: #1a1d23;
  --muted: #5f6570;
  --border: #e3e5e9;
  --accent: #1f3f66;
  --accent-dark: #14304f;
  --brand-green: #8fcaa8;
  --brand-green-dark: #3f8f68;
  --brand-gray: #8b8f96;
  --active: #167c3d;
  --inactive: #b3261e;
  --radius: 8px;
  --radius-sm: 4px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 8px 20px;
  text-align: center;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.01em;
}
.logo-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
}
.logo-text { color: var(--accent); }
.logo-green { color: var(--brand-green-dark); }
.logo-gray { color: var(--brand-gray); font-weight: 600; }
.logo-tagline {
  margin: 2px 0 0;
  color: var(--brand-gray);
  font-size: 0.75rem;
  max-height: 20px;
  overflow: hidden;
  opacity: 1;
  transition: max-height 0.2s ease, margin 0.2s ease, opacity 0.15s ease;
}

/* JS (app.js) togglar denna klass baserat på scrollposition. */
.site-header--scrolled .logo-tagline {
  max-height: 0;
  margin-top: 0;
  opacity: 0;
}

.hero {
  text-align: center;
  padding: 40px 0 28px;
}

.hero h1 {
  font-size: 2rem;
  margin: 0 0 12px;
}

.lead {
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0 auto 28px;
  max-width: 560px;
}

.search-form {
  position: relative;
  width: 100%;
}

.search-top {
  margin: 0 0 24px;
  padding: 12px 0;
}

/* Fastnar direkt under headern vid skroll (mobil har sin egen bottom-sticky
   variant nedan). --header-height sätts av app.js utifrån headerns
   faktiska höjd, så det stämmer även när taglinen kollapsar. */
@media (min-width: 641px) {
  .search-top {
    position: sticky;
    top: var(--header-height, 49px);
    z-index: 40;
    background: var(--bg);
    transition: box-shadow 0.15s ease;
  }

  /* JS togglar denna när sidan skrollats, så det fastnade läget inte bara
     "klipper" mot innehållet under utan får en mjuk skugga neråt. */
  .search-top--stuck {
    box-shadow: 0 10px 14px -10px rgba(0, 0, 0, 0.18);
  }
}

.search-box {
  display: flex;
  gap: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
}

.search-form--hero .search-box { padding: 10px; }

.search-box input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
  padding: 12px 14px;
  background: transparent;
  color: var(--text);
}

.search-form--hero .search-box input { font-size: 1.1rem; }

.search-box button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 0 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
}
.search-box button:hover { background: var(--accent-dark); }
.search-box button svg { display: block; }

.suggestions {
  list-style: none;
  margin: 6px 0 0;
  padding: 6px;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  z-index: 20;
  max-height: 340px;
  overflow-y: auto;
}

.suggestions li a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
}
.suggestions li a:hover,
.suggestions li a.active { background: var(--bg); }

.suggestions .s-name { font-weight: 600; }
.suggestions .s-meta { color: var(--muted); font-size: 0.9rem; white-space: nowrap; }

.company-card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-top: 8px;
  overflow: hidden;
}

/* Statusfärgad topp-remsa (bordertopp + svag toning mot vitt) istället för
   en fristående "pill"-badge - känns mer som en del av kortet. */
.company-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 40px;
  border-top: 4px solid var(--brand-gray);
  background: linear-gradient(to bottom, rgba(139, 143, 150, 0.12), rgba(139, 143, 150, 0));
  pointer-events: none;
}
.company-card--active::before {
  border-top-color: var(--active);
  background: linear-gradient(to bottom, rgba(22, 124, 61, 0.12), rgba(22, 124, 61, 0));
}
.company-card--inactive::before {
  border-top-color: var(--inactive);
  background: linear-gradient(to bottom, rgba(179, 38, 30, 0.12), rgba(179, 38, 30, 0));
}

.company-card__header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.company-card__header h1 {
  font-size: 1.5rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.type-icon { flex: none; }

.status-label {
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}
.status-label--active { color: var(--active); }
.status-label--inactive { color: var(--inactive); }
.status-label--neutral { color: var(--brand-gray); }

.company-facts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 24px 0 0;
  padding: 0;
}
.company-facts > div {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.company-facts dt {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 4px;
}
.company-facts dd { margin: 0; font-weight: 500; }

.company-verksamhet { color: var(--text); }
.company-names { color: var(--muted); }

.company-map {
  height: 280px;
  width: 100%;
  margin-top: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
}
/* Leaflet renderar sin egen inline-styling på sina barn-element; se bara
   till att kartans div respekterar vårt kort-hörnradie. */
.company-map.leaflet-container {
  border-radius: var(--radius-sm);
  font: inherit;
}


.results h1 { font-size: 1.3rem; }
.result-list { list-style: none; padding: 0; }
.result-list li {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
}
.result-list a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--text);
  flex-wrap: wrap;
}
.result-name { font-weight: 600; }
.result-meta { color: var(--muted); font-size: 0.9rem; }

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 20px;
}
.site-footer a { color: var(--muted); }

@media (max-width: 640px) {
  .company-facts { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.5rem; }
  .company-card { padding: 18px; }

  /* Startsidans sökruta är huvudsyftet med sidan, så den får stanna
     centrerad på skärmen istället för att flyttas ner som en sticky-rad. */
  .hero {
    min-height: 70vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .logo-tagline { display: none; }

  /* Search box hoppar ner till en sticky rad längst ner på skärmen på
     underliggande sidor, så nästa sökning är ett tumtryck bort. */
  main:has(.search-top) { padding-bottom: 92px; }

  .search-form--compact {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    margin: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.08);
  }

  .search-box input,
  .search-box button {
    font-size: 1rem;
    min-height: 48px;
  }

  .search-form--compact .suggestions {
    top: auto;
    bottom: 100%;
    margin: 0 0 8px;
  }
}
