/* ── Reset & base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:        #2563eb;
  --blue-dark:   #1d4ed8;
  --blue-light:  #eff6ff;
  --blue-glow:   rgba(37,99,235,.18);
  --text:        #0f172a;
  --text-2:      #475569;
  --text-3:      #94a3b8;
  --surface:     #ffffff;
  --bg:          #f1f5f9;
  --border:      #e2e8f0;
  --border-2:    #cbd5e1;
  --radius-sm:   6px;
  --radius:      12px;
  --radius-lg:   18px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow:      0 4px 16px rgba(0,0,0,.10), 0 1px 4px rgba(0,0,0,.06);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.13), 0 2px 8px rgba(0,0,0,.07);
  --header-h:    54px;
  --panel-w:     340px;
  --search-w:    480px;
  --ease:        cubic-bezier(.4,0,.2,1);
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────── */
.site-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: 1rem;
  z-index: 400;
  flex-shrink: 0;
}

.logo {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -.03em;
  white-space: nowrap;
}
.logo span { color: var(--blue); }

.header-nav {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-left: auto;
}

/* country + lang switchers */
.country-switcher,
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.lang-dd { position: relative; }
.lang-dd-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .3rem .55rem;
  font-size: .82rem; font-weight: 600; color: var(--text-2);
  cursor: pointer; transition: border-color .15s var(--ease), color .15s var(--ease);
}
.lang-dd-btn:hover { color: var(--text); border-color: var(--border-2); }
.lang-dd-caret { color: var(--text-3); font-size: .7rem; margin-left: .1rem; }
.lang-flag {
  width: 20px; height: 15px; border-radius: 2px; object-fit: cover;
  display: block; box-shadow: 0 0 0 1px rgba(0,0,0,.08); flex: none;
}
.lang-dd-list {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 1200;
  margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  max-height: 72vh; overflow-y: auto; min-width: 175px;
}
.lang-dd-list[hidden] { display: none; }
.lang-dd-item {
  display: flex; align-items: center; gap: .55rem;
  padding: .4rem .55rem; border-radius: 6px; cursor: pointer;
  font-size: .85rem; color: var(--text); white-space: nowrap;
}
.lang-dd-item:hover { background: var(--bg); }
.lang-dd-item.active { background: var(--blue-light); color: var(--blue-dark); font-weight: 600; }

.btn-country,
.btn-lang {
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: .2rem .45rem;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-2);
  transition: background .15s var(--ease), color .15s var(--ease);
  white-space: nowrap;
  line-height: 1.6;
}
.btn-country:hover,
.btn-lang:hover {
  background: var(--surface);
  color: var(--text);
}
.btn-country.active,
.btn-lang.active {
  background: var(--surface);
  color: var(--blue);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.header-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
}

/* ── Map container ───────────────────────────────────────── */
main {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.map-layout {
  position: absolute;
  inset: 0;
  display: flex;
}

#map {
  flex: 1;
  height: 100%;
  z-index: 1;
}

/* ── Search overlay ──────────────────────────────────────── */
.search-overlay {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  width: min(var(--search-w), calc(100vw - 2rem));
}

.search-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: .4rem .4rem .4rem .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  border: 1.5px solid transparent;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.search-card:focus-within {
  border-color: var(--blue);
  box-shadow: var(--shadow-lg), 0 0 0 4px var(--blue-glow);
}

.search-icon {
  color: var(--text-3);
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: .95rem;
  color: var(--text);
  background: transparent;
  min-width: 0;
}
.search-input::placeholder { color: var(--text-3); }

.btn-primary {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: .5rem 1.1rem;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s var(--ease), transform .1s;
  flex-shrink: 0;
}
.btn-primary:hover  { background: var(--blue-dark); }
.btn-primary:active { transform: scale(.97); }
.btn-primary:disabled { opacity: .55; cursor: default; transform: none; }

.search-status {
  position: absolute;
  top: calc(100% + .4rem);
  left: 0;
  right: 0;
  text-align: center;
  font-size: .82rem;
  color: var(--text-2);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: .3rem .75rem;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.search-status:not(:empty) {
  opacity: 1;
  pointer-events: auto;
}

/* ── Detail panel ────────────────────────────────────────── */
.detail-panel {
  position: absolute;
  top: 1rem;
  right: 1rem;
  bottom: 1rem;
  width: var(--panel-w);
  z-index: 200;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  transform: translateX(calc(var(--panel-w) + 2rem));
  opacity: 0;
  transition: transform .3s var(--ease), opacity .25s var(--ease);
  pointer-events: none;
}
.detail-panel.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

/* Panel close button */
.panel-close {
  position: absolute;
  top: .75rem;
  right: .75rem;
  background: var(--bg);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  transition: background .15s, color .15s;
  z-index: 1;
}
.panel-close:hover { background: var(--border); color: var(--text); }

/* Panel sections */
.panel-section {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.panel-section:last-child { border-bottom: none; }

/* ── Value display ───────────────────────────────────────── */
.value-display,
.parcel-display { display: none; }
.value-display.visible,
.parcel-display.visible { display: block; }

.value-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
  margin-bottom: .5rem;
  display: block;
}
.value-main {
  display: flex;
  align-items: baseline;
  gap: .35rem;
  margin-bottom: 1rem;
}
.value-number {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--blue);
  letter-spacing: -.04em;
  line-height: 1;
}
.value-unit {
  font-size: .95rem;
  color: var(--text-2);
  font-weight: 500;
}
.value-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .35rem .75rem;
  font-size: .83rem;
}
.value-meta dt {
  color: var(--text-3);
  font-weight: 500;
}
.value-meta dd {
  color: var(--text);
  font-weight: 600;
}

/* Parcel-only */
.parcel-display .value-label {
  font-size: .8rem;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: .75rem;
}
.no-price-note {
  font-size: .78rem;
  color: var(--text-3);
  font-style: italic;
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}

/* No value */
#no-value-msg {
  display: none;
  background: #fef9c3;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  font-size: .85rem;
  color: #92400e;
}
#no-value-msg.visible { display: block; }

/* ── Methodology section ─────────────────────────────────── */
.meta-section { display: none; }
.meta-section.visible { display: block; }

.meta-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
  margin-bottom: .35rem;
  margin-top: .9rem;
  display: block;
}
.meta-label:first-child { margin-top: 0; }
.meta-section p,
.meta-section a {
  font-size: .82rem;
  color: var(--text-2);
  line-height: 1.5;
}
.meta-section a {
  color: var(--blue);
  text-decoration: none;
}
.meta-section a:hover { text-decoration: underline; }
.disclaimer {
  font-size: .78rem !important;
  color: var(--text-3) !important;
  font-style: italic;
}

/* ── PPR extras (Ireland) + BORIS extras (Germany) ──────── */
.ppr-extras { padding: 0 1.25rem 1.25rem; }

.brw-note {
  font-size: .78rem;
  color: var(--text-2);
  line-height: 1.5;
  margin-top: .6rem;
  padding: .5rem .65rem;
  background: var(--bg);
  border-left: 3px solid var(--border-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.brw-pdf-link {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .78rem;
  color: var(--blue);
  text-decoration: none;
  margin-top: .65rem;
}
.brw-pdf-link:hover { text-decoration: underline; }

/* ── Zone cards (DE multi-zone) ──────────────────────────── */
.zone-header {
  font-size: .75rem;
  color: var(--text-3);
  margin-bottom: .75rem;
}
.zone-prompt {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: .75rem;
}
.zone-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  margin-bottom: .75rem;
}
.zone-card {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: .7rem .75rem;
  cursor: default;
  transition: border-color .15s, background .15s;
}
.zone-card:hover {
  border-color: var(--blue);
  background: var(--blue-light);
}
.zone-card-icon { font-size: 1rem; margin-bottom: .2rem; display: block; }
.zone-card-label {
  font-size: .72rem;
  color: var(--text-2);
  line-height: 1.3;
  margin-bottom: .3rem;
}
.zone-card-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--blue);
  letter-spacing: -.03em;
  line-height: 1;
}
.zone-card-unit {
  font-size: .7rem;
  color: var(--text-3);
  font-weight: 500;
}
.zone-card-total {
  font-size: .72rem;
  color: var(--blue);
  font-weight: 600;
  margin-top: .25rem;
}
.zone-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  margin-top: .35rem;
}
.zone-tag {
  font-size: .65rem;
  padding: .15rem .4rem;
  border-radius: 99px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  white-space: nowrap;
}

/* Parcel info strip */
.parcel-strip {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  font-size: .78rem;
  color: var(--text-2);
  margin-bottom: .6rem;
  line-height: 1.6;
}
.parcel-strip strong { color: var(--text); font-weight: 600; }

.brw-disclaimer {
  font-size: .72rem;
  color: var(--text-3);
  font-style: italic;
  margin-top: .5rem;
  display: flex;
  gap: .3rem;
  align-items: flex-start;
  line-height: 1.4;
}

.source-links {
  font-size: .75rem;
  margin-top: .4rem;
  display: flex;
  flex-wrap: wrap;
  gap: .25rem .6rem;
}
.source-links a {
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}
.source-links a:hover { text-decoration: underline; }

.trend-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .78rem;
  font-weight: 700;
  padding: .25rem .6rem;
  border-radius: 99px;
  margin-bottom: .9rem;
}
.trend-up   { background: #dcfce7; color: #166534; }
.trend-down { background: #fee2e2; color: #991b1b; }

.tx-count {
  font-weight: 400;
  color: var(--text-3);
  font-size: .75rem;
}

/* ── Country badge ───────────────────────────────────────── */
.country-badge-section {
  padding: .6rem 1.25rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem .6rem;
}
.country-badge:empty + .country-badge-section,
.country-badge-section:empty { display: none; }
.country-badge {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-2);
}

/* ── Data-quality badge ──────────────────────────────────── */
.quality-badge {
  display: inline-flex;
  align-items: center;
  gap: .3em;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .01em;
  padding: .2em .6em;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
  cursor: help;
}
.quality-badge[hidden] { display: none; }
.quality-badge::before {
  content: "";
  width: .5em;
  height: .5em;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.quality-badge.tier-official_parcel   { color: #15803d; background: #f0fdf4; border-color: #bbf7d0; }
.quality-badge.tier-market_regional   { color: #1d4ed8; background: #eff6ff; border-color: #bfdbfe; }
.quality-badge.tier-estimate_regional { color: #b45309; background: #fffbeb; border-color: #fde68a; }
.quality-badge.tier-cadastral_only    { color: #475569; background: #f1f5f9; border-color: #cbd5e1; }

/* ── Unsupported country message ─────────────────────────── */
#unsupported-msg {
  display: none;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  font-size: .85rem;
  color: #0369a1;
}
#unsupported-msg.visible { display: block; }

/* ── Ad placeholder ──────────────────────────────────────── */
.ad-placeholder {
  background: var(--bg);
  border-radius: var(--radius-sm);
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: .75rem;
}
.ad-placeholder:empty::after { content: 'Werbung'; }

/* ── Footer ──────────────────────────────────────────────── */
.site-footer {
  height: 36px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 400;
}
.footer-nav {
  display: flex;
  gap: 1.25rem;
}
.footer-nav a {
  color: var(--text-3);
  text-decoration: none;
  font-size: .78rem;
  transition: color .15s;
}
.footer-nav a:hover { color: var(--blue); }

/* ── Map loading spinner ─────────────────────────────────── */
.map-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(37,99,235,.2);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  background: var(--surface);
  box-shadow: var(--shadow);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Leaflet attribution tweak ───────────────────────────── */
.leaflet-control-attribution {
  font-size: .68rem !important;
  background: rgba(255,255,255,.75) !important;
  backdrop-filter: blur(4px);
  border-radius: var(--radius-sm) !important;
}

/* ── Scrollbar ───────────────────────────────────────────── */
.detail-panel::-webkit-scrollbar { width: 4px; }
.detail-panel::-webkit-scrollbar-track { background: transparent; }
.detail-panel::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; }

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 700px) {
  :root { --panel-w: 100vw; }

  .search-overlay {
    top: .75rem;
    left: .75rem;
    right: .75rem;
    transform: none;
    width: auto;
  }

  .detail-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 55vh;
    transform: translateY(100%);
  }
  .detail-panel.open { transform: translateY(0); }

  .btn-country { font-size: .72rem; padding: .18rem .38rem; }
  .logo { font-size: .85rem; }
}

@media (max-width: 440px) {
  .lang-switcher { display: none; }
}
