/* ============================================================
   Marktstammdaten Viewer — design system
   ============================================================ */
:root {
  /* palette */
  --bg: #fafbfc;
  --bg-elev: #ffffff;
  --bg-soft: #f1f5f9;
  --bg-sunken: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-soft: #94a3b8;

  --accent: #0f766e;       /* teal-700 */
  --accent-hover: #0d6963;
  --accent-soft: #ccfbf1;
  --accent-text: #134e4a;

  --success: #16a34a;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --warning-text: #92400e;

  --success-text: #166534;
  --danger-text: #991b1b;
  --danger-border: #fca5a5;
  --neutral-text: #475569;

  --fresh-bg: #d1fae5;
  --fresh-text: #065f46;
  --info-soft: #dbeafe;
  --info-text: #1e40af;

  /* overlays & focus */
  --overlay-heavy: rgba(15, 23, 42, 0.45);
  --overlay-light: rgba(15, 23, 42, 0.3);
  --accent-ring: rgba(15, 118, 110, 0.12);
  --accent-glow: rgba(15, 118, 110, 0.4);

  /* radius & shadow */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 999px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 1px rgba(15, 23, 42, 0.02);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, 0.18);

  /* typography */
  --font-mono: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;

  /* enrich feature accent (amber) */
  --enrich-accent: #d97706;
  --enrich-accent-hover: #b45309;

  /* sizing */
  --topbar-h: 48px;
  --sidebar-w: 300px;

  /* motion */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 180ms;
}

/* ============================================================
   reset & base
   ============================================================ */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

a {
  color: var(--accent);
  text-decoration: none;
}

/* Global focus-visible — consistent keyboard navigation ring */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

.hidden {
  display: none !important;
}

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

code {
  background: var(--bg-soft);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* ============================================================
   topbar
   ============================================================ */
.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  padding: 0 24px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, #14b8a6, #0f766e);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 16px -4px var(--accent-glow);
}
.logo svg {
  width: 20px;
  height: 20px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.brand-text strong {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.brand-accent {
  color: var(--accent);
}
.brand-tagline {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Data-freshness pill: shows record count + DB build date + age, colour-coded.
   Lives inside the brand block so it sits beside the app title. */
.data-freshness {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 500;
  margin-left: 14px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.data-freshness-fresh {
  background: var(--fresh-bg);
  color: var(--fresh-text);
}
.data-freshness-stale {
  background: var(--warning-soft);
  color: var(--warning-text);
}
.data-freshness-old {
  background: var(--danger-soft);
  color: var(--danger-text);
}
.data-freshness.hidden {
  display: none;
}
.data-freshness-sep {
  width: 1px;
  height: 14px;
  background: currentColor;
  opacity: 0.25;
  margin: 0 10px;
  flex-shrink: 0;
}

/* ============================================================
   buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--r-md);
  font-weight: 500;
  font-size: 14px;
  transition: transform var(--dur) var(--ease),
    background-color var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
  border: 1px solid transparent;
  user-select: none;
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 6px -2px var(--accent-glow);
}
.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover {
  background: var(--bg-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-lg {
  padding: 12px 22px;
  font-size: 15px;
}
.btn-block {
  display: flex;
  width: 100%;
}

.btn-link {
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  padding: 0;
}
.btn-link:hover {
  text-decoration: underline;
}

.btn-close {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  color: var(--text-muted);
  transition: background var(--dur);
}
.btn-close:hover {
  background: var(--bg-soft);
  color: var(--text);
}
.btn-close svg {
  width: 18px;
  height: 18px;
}

/* ============================================================
   viewer layout
   ============================================================ */
.viewer {
  flex: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 0;
}

/* ---------- sidebar ---------- */
.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-section {
  padding: 0 16px;
}
.sidebar-section + .sidebar-section {
  margin-top: 12px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding: 0 4px;
}
/* table picker */
.table-picker {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tp-group {
  margin-top: 10px;
}
.tp-group:first-child {
  margin-top: 0;
}
.tp-group-label {
  font-size: 11px;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 8px 4px;
  font-weight: 600;
}
.tp-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  font-size: 14px;
  color: var(--text);
  transition: background var(--dur);
  text-align: left;
  width: 100%;
}
.tp-item:hover {
  background: var(--bg-soft);
}
.tp-item.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 500;
}
.tp-item .tp-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tp-item .tp-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-sunken);
  padding: 2px 6px;
  border-radius: var(--r-full);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.tp-item.active .tp-count {
  background: rgba(15, 118, 110, 0.15);
  color: var(--accent-text);
}
.tp-item.dimmed {
  opacity: 0.45;
}
.tp-count.filtered {
  font-weight: 600;
  color: var(--accent);
}
.tp-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
.tp-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-hint {
  margin: 16px 16px 0;
  padding: 12px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--bg-sunken);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}
.sidebar-hint svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--accent);
  margin-top: 1px;
}
.sidebar-hint strong {
  display: block;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
  font-size: 12px;
}

/* ============================================================
   results
   ============================================================ */
.results {
  display: flex;
  flex-direction: column;
  min-width: 0;
  /* CRITICAL: grid children default to min-height:auto which lets the
     child table grow to its intrinsic height; forcing 0 lets the inner
     .table-wrap's `overflow: auto` actually kick in. */
  min-height: 0;
  padding: 20px 24px 24px;
  gap: 14px;
}

.results-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-wrap {
  flex: 1;
  position: relative;
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}
#search-input {
  width: 100%;
  /* Right padding leaves room for the .search-kbd badge */
  padding: 12px 44px 12px 42px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  font-size: 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur), box-shadow var(--dur);
}
#search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
#search-input::placeholder {
  color: var(--text-soft);
}
/* Tiny "press / to focus" hint, GitHub-style. Hidden as soon as the
   input is focused or non-empty so it never blocks the value. */
.search-kbd {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 7px;
  line-height: 1;
  transition: opacity var(--dur);
}
#search-input:focus ~ .search-kbd,
#search-input:not(:placeholder-shown) ~ .search-kbd {
  opacity: 0;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

.result-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--text-muted);
  padding: 0 2px;
}
.meta-count {
  color: var(--text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* table */
.table-wrap {
  position: relative;
  flex: 1;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: auto;
  min-height: 0;
}

#result-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

#result-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-sunken);
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  padding: 10px 16px;
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color var(--dur), transform 120ms var(--ease);
  z-index: 1;
}
#result-table thead th:hover {
  color: var(--text);
}
/* column drag & drop */
#result-table thead th[draggable="true"] {
  cursor: grab;
}
#result-table thead th.dragging {
  opacity: 0.4;
}
/* sort indicator is rendered inside .th-sort, no pseudo-element needed */

#result-table tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}
#result-table tbody tr {
  transition: background var(--dur);
  cursor: pointer;
}
#result-table tbody tr:hover {
  background: var(--bg-sunken);
}
#result-table tbody tr.selected {
  background: var(--accent-soft);
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  pointer-events: none;
  /* Sit above Leaflet tile layers (which default to z-index 400) so the
     empty-state icon + caption stay visible on no-geo tables. */
  z-index: 500;
}
#map-empty {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(2px);
}
.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--bg-sunken);
  display: grid;
  place-items: center;
  color: var(--text-soft);
}
.empty-icon svg {
  width: 28px;
  height: 28px;
}
.empty-text {
  font-size: 14px;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
}
.spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
/* Small inline spinner for use next to text */
.spinner-sm {
  width: 14px;
  height: 14px;
  border-width: 2px;
  vertical-align: -2px;
  margin-right: 4px;
}
/* Spinner on a primary (accent) background — flip the colors for contrast */
.spinner-on-accent {
  border-color: rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 4px 0;
}
.pagination-info {
  color: var(--text-muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  min-width: 140px;
  text-align: center;
}

/* ============================================================
   no-db state
   ============================================================ */
.no-db {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  background: var(--bg);
}
.no-db-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 48px 56px;
  max-width: 480px;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.no-db-icon {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--accent-soft), rgba(15, 118, 110, 0.08));
  color: var(--accent);
  display: grid;
  place-items: center;
  margin: 0 auto 20px;
}
.no-db-icon svg {
  width: 36px;
  height: 36px;
}
.no-db h1 {
  font-size: 22px;
  margin: 0 0 8px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.no-db p {
  color: var(--text-muted);
  margin: 0 0 28px;
  font-size: 14px;
}

/* ============================================================
   import overlay
   ============================================================ */
.import-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fadein var(--dur) var(--ease);
}
@keyframes fadein {
  from {
    opacity: 0;
  }
}

.import-card {
  background: var(--bg-elev);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: min(560px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: popin var(--dur) var(--ease);
}
@keyframes popin {
  from {
    transform: scale(0.96) translateY(8px);
    opacity: 0;
  }
}

.import-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 12px;
}
.import-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}
.import-body {
  padding: 0 24px 24px;
  overflow-y: auto;
}
.import-state {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.db-info {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
}
.import-explain {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0;
}

.progress-phase {
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.progress-phase::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.4;
    transform: scale(0.8);
  }
}

.progress-track {
  position: relative;
  height: 12px;
  border-radius: var(--r-full);
  background: var(--bg-soft);
  overflow: hidden;
}
.progress-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: linear-gradient(90deg, var(--accent), #14b8a6);
  border-radius: var(--r-full);
  transition: width 500ms var(--ease);
}
.progress-pct {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  mix-blend-mode: difference;
  color: #fff;
}

.progress-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.stat {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.stat strong {
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.records-table {
  margin-top: 4px;
}
.records-table summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 0;
  user-select: none;
}
.table-progress {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 0;
}
.tp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  font-size: 12px;
}
.tp-row:nth-child(even) {
  background: var(--bg-sunken);
}
.tp-row-name {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}
.tp-row-val {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.error-icon,
.done-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  margin: 0 auto;
}
.error-icon {
  background: var(--danger-soft);
  color: var(--danger);
}
.done-icon {
  background: var(--success-soft);
  color: var(--success);
}
.error-icon svg,
.done-icon svg {
  width: 28px;
  height: 28px;
}
.error-text {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px;
  font-size: 12px;
  font-family: var(--font-mono);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  color: var(--danger);
}
.done-summary {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}
#import-error h3,
#import-done h3 {
  text-align: center;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

/* ============================================================
   column picker
   ============================================================ */
.col-picker {
  position: fixed;
  inset: 0;
  background: var(--overlay-heavy);
  backdrop-filter: blur(3px);
  z-index: 1700;
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fadein var(--dur);
}
.col-picker-card {
  background: var(--bg-elev);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: min(440px, 100%);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: popin var(--dur) var(--ease);
}
.col-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 12px;
}
.col-picker-head h3 {
  margin: 0;
  font-size: 16px;
}
.col-picker-search {
  padding: 0 24px 12px;
}
.col-picker-search input {
  width: 100%;
  padding: 9px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  font-size: 13px;
}
.col-picker-search input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
.col-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px;
}
.col-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--dur);
  user-select: none;
}
.col-item:hover {
  background: var(--bg-soft);
}
.col-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}
.col-item-name {
  flex: 1;
  font-size: 13px;
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
}
.col-item-type {
  font-size: 11px;
  color: var(--text-soft);
  text-transform: uppercase;
}
.col-picker-foot {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

/* ============================================================
   detail drawer
   ============================================================ */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 1500; /* above Leaflet's control-container (z=1000) */
}
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay-light);
  animation: fadein var(--dur);
}
.drawer-panel {
  position: absolute;
  right: 0;
  top: 0;
  height: 100vh;
  width: min(540px, 92vw);
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  box-shadow: -24px 0 48px -24px rgba(15, 23, 42, 0.2);
  display: flex;
  flex-direction: column;
  animation: slidein 300ms var(--ease);
}
@keyframes slidein {
  from {
    transform: translateX(100%);
  }
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}
.drawer-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 380px;
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px 32px;
}
.drawer-field {
  display: grid;
  grid-template-columns: 38% 1fr;
  gap: 8px 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.drawer-field:last-child {
  border-bottom: 0;
}
.drawer-field-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.drawer-field-value {
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}
.drawer-field-value.null {
  color: var(--text-soft);
  font-style: italic;
}

/* ============================================================
   toasts
   ============================================================ */
.toasts {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  animation: slideup var(--dur) var(--ease);
  pointer-events: auto;
  max-width: 360px;
}
.toast.error {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}
.toast.success {
  border-color: var(--success);
  background: var(--success-soft);
  color: var(--success);
}
@keyframes slideup {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
}

/* ============================================================
   Header column popover (per-column filter)
   ============================================================ */
.th-inner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.th-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
.th-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.th-sort {
  font-size: 11px;
  color: var(--accent);
  width: 10px;
  text-align: center;
}
.th-filter {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  color: var(--text-soft);
  opacity: 0.35;
  transition: opacity var(--dur), background var(--dur), color var(--dur);
}
#result-table thead th:hover .th-filter {
  opacity: 0.85;
  color: var(--text-muted);
}
#result-table thead th .th-filter.active {
  opacity: 1;
  background: var(--accent);
  color: #fff;
}
.th-filter svg {
  width: 11px;
  height: 11px;
  stroke-width: 2.5;
}
#result-table thead th.filtered {
  background: linear-gradient(180deg, var(--accent-soft), var(--bg-sunken));
}

.header-popover {
  position: fixed;
  z-index: 150;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: hp-pop 140ms var(--ease);
  max-height: 70vh;
  overflow: hidden;
}
@keyframes hp-pop {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
}
.hp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.hp-name {
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hp-sort {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.hp-sort button {
  padding: 4px 8px;
  font-size: 11px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: background var(--dur), border-color var(--dur), color var(--dur);
}
.hp-sort button svg {
  width: 12px;
  height: 12px;
}
.hp-sort button:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong);
}
.hp-sort button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.hp-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}
.hp-loading {
  display: grid;
  place-items: center;
  padding: 24px;
}
.hp-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.hp-range {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 6px;
  align-items: center;
}
.hp-range input {
  width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.hp-range input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}
.hp-range-sep {
  color: var(--text-soft);
  font-size: 13px;
}
.hp-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.hp-chip {
  padding: 4px 9px;
  font-size: 11px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--dur);
}
.hp-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.hp-hint {
  font-size: 11px;
  color: var(--text-soft);
  font-style: italic;
}
.hp-search {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  font-size: 13px;
}
.hp-search:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
.hp-list {
  display: flex;
  flex-direction: column;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.hp-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  cursor: pointer;
  transition: background var(--dur);
  border-bottom: 1px solid var(--border);
}
.hp-item:last-child {
  border-bottom: 0;
}
.hp-item:hover {
  background: var(--bg-sunken);
}
.hp-item.selected {
  background: var(--accent-soft);
}
.hp-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.hp-item-label {
  flex: 1;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hp-item-count {
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  background: var(--bg-soft);
  padding: 2px 6px;
  border-radius: var(--r-full);
}
.hp-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}
.hp-text-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
}
.hp-text-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}
.hp-op {
  display: flex;
  gap: 4px;
}
.hp-op button {
  flex: 1;
  padding: 5px 8px;
  font-size: 11px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--dur);
}
.hp-op button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.hp-foot {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.btn-sm:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ============================================================
   View toggle (Tabelle / Karte)
   ============================================================ */
.view-toggle {
  display: inline-flex;
  gap: 0;
  padding: 3px;
  background: var(--bg-soft);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}
.vt-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 7px;
  color: var(--text-muted);
  font-weight: 500;
  transition: all var(--dur);
}
.vt-btn svg {
  width: 14px;
  height: 14px;
}
.vt-btn:hover {
  color: var(--text);
}
.vt-btn.active {
  background: var(--bg-elev);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

/* ============================================================
   Map view
   ============================================================ */
.map-wrap {
  position: relative;
  z-index: 1;
  flex: 1;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  min-height: 0;
}
.map-wrap.hidden {
  display: none !important;
}
.map {
  position: absolute;
  inset: 0;
  background: var(--bg-sunken);
}

.map-info {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1000;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: 12px;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  max-width: 280px;
  line-height: 1.4;
}
.map-info-text {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.map-info-head {
  font-size: 12.5px;
  color: var(--text);
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}
.map-info-head strong {
  font-weight: 600;
  color: var(--accent-text);
}
.map-info-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.map-info-row strong {
  color: var(--text);
  font-weight: 600;
}
.map-info-label { flex: 1; }
.map-info-dot {
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  margin-top: 4px;
  display: inline-block;
}
.map-info-dot-marker {
  border-radius: 50%;
  background: #0f766e;
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.18);
}
.map-info-dot-plz {
  border-radius: 2px;
  background: rgba(15, 118, 110, 0.22);
  border: 1px solid #0f766e;
}
.map-info-inline-hint {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.leaflet-control-zoom { display: none !important; }

/* Unified map control panel */
.map-controls {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.map-controls-divider {
  height: 1px;
  background: var(--border);
}
.map-ctrl-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.map-ctrl-btn + .map-ctrl-btn {
  border-top: 1px solid var(--border-faint, rgba(0,0,0,0.06));
}
.map-ctrl-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 120ms var(--ease);
}
.map-ctrl-btn.active {
  color: var(--accent-text);
  background: var(--accent-faint);
}
.map-ctrl-btn.active svg {
  opacity: 1;
}
.map-ctrl-btn:hover {
  background: var(--surface-hover);
}

/* Dark map theme overrides */
/* Satellite theme: only adapt marker borders for contrast, all UI overlays stay light */
.map-wrap[data-map-theme="dark"] .mastr-marker-inner {
  border-color: rgba(255, 255, 255, 0.7);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* Custom MaStR marker — circle with category icon */
.mastr-marker {
  background: transparent;
  border: none;
}
.mastr-marker-inner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.35);
  transition: transform 120ms var(--ease);
}
.mastr-marker:hover .mastr-marker-inner {
  transform: scale(1.15);
  box-shadow: 0 4px 12px var(--overlay-heavy);
}
.mastr-marker-inner svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Custom marker popup */
.leaflet-popup-content-wrapper {
  border-radius: var(--r-md) !important;
}
.leaflet-popup-content {
  margin: 12px 16px !important;
  font-family: inherit;
}
.marker-popup-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.marker-popup-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 2px 0;
  gap: 12px;
}
.marker-popup-label {
  color: var(--text-muted);
}
.marker-popup-value {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.marker-popup-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--accent);
  font-weight: 500;
  font-size: 12px;
  cursor: pointer;
}
.marker-popup-link:hover {
  text-decoration: underline;
}

/* Tweak Leaflet's default marker cluster colors to match the theme */
.marker-cluster-small {
  background-color: rgba(20, 184, 166, 0.4);
}
.marker-cluster-small div {
  background-color: rgba(15, 118, 110, 0.9);
  color: #fff;
}
.marker-cluster-medium {
  background-color: rgba(13, 148, 136, 0.4);
}
.marker-cluster-medium div {
  background-color: rgba(15, 118, 110, 0.95);
  color: #fff;
}
.marker-cluster-large {
  background-color: var(--accent-glow);
}
.marker-cluster-large div {
  background-color: rgba(15, 118, 110, 1);
  color: #fff;
}
.marker-cluster {
  font-weight: 600;
  font-family: -apple-system, "Segoe UI", Inter, sans-serif;
}

/* ============================================================
   Active filter pills (above the result table)
   ============================================================ */
.filter-pills {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: 8px;
}
.filter-pills.hidden {
  display: none !important;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
}
.pill-x {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  line-height: 1;
  border-radius: var(--r-full);
  margin-left: 2px;
  background: rgba(15, 118, 110, 0.14);
  transition: background var(--dur);
}
.pill-x:hover {
  background: var(--accent);
  color: #fff;
}
.pill-x svg {
  width: 11px;
  height: 11px;
  stroke: currentColor;
}
.pill-clear {
  background: transparent;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  padding: 4px 12px;
}
.pill-clear:hover {
  background: var(--bg-soft);
  border-color: var(--text-muted);
}

/* ============================================================
   responsive — ≤960 px: tablet / landscape phone
   Sidebar is hidden entirely; table picker moves into a bottom sheet
   (triggered by the pill in the toolbar). Table view still renders —
   card-view only kicks in on proper phones at ≤640 px.
   ============================================================ */
@media (max-width: 960px) {
  .viewer {
    grid-template-columns: 1fr;
  }
  .progress-stats {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   scrollbar polish
   ============================================================ */
*::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--r-full);
  border: 3px solid var(--bg);
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* ============================================================
   Freemium UI — upgrade pill, lizenz badge, truncation hint
   ============================================================ */
.free-upgrade-pill {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 4px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.15s;
}
.free-upgrade-pill:hover {
  border-color: var(--accent);
}
.free-upgrade-pill.hidden { display: none; }
.free-upgrade-label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 10px;
  opacity: 0.7;
}
.free-upgrade-sep {
  width: 1px;
  height: 12px;
  background: currentColor;
  opacity: 0.2;
  margin: 0 8px;
}
.free-upgrade-limit {
  color: var(--text-soft);
}
.free-upgrade-limit strong {
  font-weight: 600;
  color: var(--text);
}

.lizenz-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--accent-soft);
  color: var(--accent-text);
  border: 1px solid #5eead4;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.lizenz-badge-label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
}
.lizenz-badge-date {
  color: var(--accent-text);
  opacity: 0.85;
}
.lizenz-badge.warn {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  color: var(--danger-text);
}
.lizenz-badge.warn .lizenz-badge-date {
  color: var(--danger-text);
}
.lizenz-badge.expired {
  background: var(--bg-soft);
  border-color: var(--border);
  color: var(--text-muted);
}

/* Inline truncation hint inside the result count */
.result-count-truncated {
  color: var(--text-muted);
  font-weight: 500;
}
.result-count-truncated .truncated-cta {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
}
.result-count-truncated .truncated-cta:hover {
  color: var(--accent-hover);
}
.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

/* ============================================================
   Generic modal — used for export confirm dialog
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1800;
  display: grid;
  place-items: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay-heavy);
  backdrop-filter: blur(2px);
}
.modal-card {
  position: relative;
  background: var(--bg-elev);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  width: min(520px, 92vw);
  max-height: 92vh;
  overflow: auto;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 {
  margin: 0;
  font-size: 16px;
}
.modal-body {
  padding: 18px 20px 20px 20px;
}
.modal-text p {
  margin: 0 0 10px 0;
  line-height: 1.55;
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  justify-content: flex-end;
}

/* ============================================================
   Global footer — data-license attribution + Impressum on every page
   ============================================================ */
.app-footer {
  flex-shrink: 0;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 14px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}
.app-footer a {
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color var(--dur), border-color var(--dur);
}
.app-footer a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.app-footer .sep {
  color: var(--text-soft);
  user-select: none;
}
/* Long/short variants for the data-attribution line — full wording on
   desktop, compact "(BNetzA)" on phones so the line does not wrap hässlich. */
.app-footer .fn-short { display: none; }
.app-footer .fn-long { display: inline; }
/* Auth pages: sticky footer at bottom, transparent so gradients show */
.auth-body .app-footer {
  position: sticky;
  bottom: 0;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding: 14px 24px;
}

/* ============================================================
   saved views
   ============================================================ */
.views-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.view-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background var(--dur);
  user-select: none;
}
.view-item:hover {
  background: var(--bg-soft);
}
.view-item.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 500;
}
.view-item.dragging {
  opacity: 0.3;
  background: var(--accent-soft);
}
.views-list > .view-item {
  transition: transform 150ms var(--ease);
}
.view-grip {
  color: var(--text-soft);
  cursor: grab;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  opacity: 0;
  transition: opacity var(--dur);
}
.view-item:hover .view-grip {
  opacity: 0.6;
}
.view-grip svg {
  width: 12px;
  height: 12px;
}
.view-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.view-del {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  color: var(--text-soft);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--dur), color var(--dur), background var(--dur);
}
.view-item:hover .view-del {
  opacity: 1;
}
.view-del:hover {
  color: var(--danger);
  background: var(--danger-soft);
}
.view-del svg {
  width: 10px;
  height: 10px;
}
.view-label.editing {
  outline: none;
  cursor: text;
  box-shadow: 0 1.5px 0 var(--accent);
}

/* view save split-button */
.view-save-group {
  display: inline-flex;
  align-items: stretch;
}
.view-save-group .btn:first-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.view-save-dropdown {
  padding: 9px 6px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left: 1px solid var(--border) !important;
}
.view-save-dropdown svg {
  width: 14px;
  height: 14px;
}
.view-save-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  min-width: 180px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  z-index: 100;
  padding: 4px;
}
.view-save-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  text-align: left;
}
.view-save-menu button:hover {
  background: var(--bg-soft);
}

/* view name prompt */
.view-name-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-light);
  backdrop-filter: blur(2px);
  z-index: 2100;
  display: grid;
  place-items: center;
  animation: fadein var(--dur) var(--ease);
}
.view-name-card {
  background: var(--bg-elev);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  width: min(380px, 90vw);
  animation: popin var(--dur) var(--ease);
}
.view-name-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 14px;
  margin-bottom: 16px;
  transition: border-color var(--dur);
}
.view-name-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.view-name-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 900px) {
  .view-save-group { display: none; }
}

/* ============================================================
   Enrich feature — Stammdaten anreichern
   ============================================================ */

/* Topbar button — warm accent to stand out as the killer feature */
.btn-enrich {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: linear-gradient(135deg, var(--enrich-accent), #ea580c);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  box-shadow: 0 1px 3px rgba(217, 119, 6, 0.3);
}
.btn-enrich:hover {
  background: linear-gradient(135deg, #b45309, #c2410c);
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.4);
  transform: translateY(-1px);
}
.btn-enrich svg {
  width: 16px;
  height: 16px;
}

/* Overlay */
.enrich-overlay {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--overlay-heavy);
  animation: fadeIn var(--dur) var(--ease);
}
.enrich-overlay.hidden { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.enrich-card {
  background: var(--bg-elev);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  transition: width 300ms var(--ease);
  overflow-y: auto;
  animation: slideUp 250ms var(--ease);
  display: flex;
  flex-direction: column;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

.enrich-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.enrich-head h2 {
  margin: 0;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.enrich-title-icon {
  width: 22px;
  height: 22px;
  color: var(--enrich-accent);
}

.enrich-body {
  padding: 24px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.enrich-state { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.enrich-state.hidden { display: none; }

/* Dropzone */
.enrich-dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--r-lg);
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  margin-bottom: 20px;
}
.enrich-dropzone:hover,
.enrich-dropzone.drag-over {
  border-color: var(--enrich-accent);
  background: rgba(217, 119, 6, 0.04);
}
.enrich-dropzone.has-file {
  border-color: var(--success);
  background: var(--success-soft);
  border-style: solid;
}
.dropzone-icon {
  width: 40px;
  height: 40px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.enrich-dropzone.has-file .dropzone-icon { color: var(--success); }
.dropzone-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dropzone-text strong { font-size: 14px; }
.dropzone-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* Consent checkbox */
.enrich-consent-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1.5;
  margin-bottom: 12px;
}
.enrich-consent-check input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--enrich-accent);
}
.enrich-consent-check a {
  color: var(--accent);
}

/* Explanation text below dropzone */
.enrich-explain {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin: 0 0 16px;
  line-height: 1.5;
}

/* Free hint */
.enrich-free-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}
.enrich-free-hint a {
  color: var(--enrich-accent);
  font-weight: 600;
  text-decoration: none;
}
.enrich-free-hint.hidden { display: none; }

/* Running state */
.enrich-file-info {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text);
}
.enrich-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}
.enrich-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.step-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--dur);
}
.step-icon.step-pending {
  border: 2px solid var(--border-strong);
  background: transparent;
}
.step-icon.step-active {
  border: 2px solid var(--enrich-accent);
  background: var(--enrich-accent);
  animation: pulse-glow 1.2s infinite;
}
.step-icon.step-done {
  border: 2px solid var(--success);
  background: var(--success);
}
.step-icon.step-done::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.3); }
  50% { box-shadow: 0 0 0 6px rgba(217, 119, 6, 0); }
}

.enrich-progress-bar { margin-bottom: 8px; }
.enrich-progress-text {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* Done state: summary + actions */
.enrich-summary {
  text-align: center;
  margin-bottom: 16px;
}
.enrich-summary-main {
  font-size: 28px;
  font-weight: 700;
  color: var(--success-text);
  margin-bottom: 4px;
}
.enrich-summary-detail {
  font-size: 13px;
  color: var(--text-muted);
}

.enrich-done-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}
.enrich-done-actions .btn {
  width: auto;
  padding: 10px 24px;
}

/* Preview table */
.enrich-card.expanded {
  width: min(95vw, calc(100vw - 32px));
  height: calc(100vh - 32px);
}

.enrich-preview-section {
  margin-top: 8px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.enrich-preview-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-muted);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}
.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}
.legend-enriched { background: #d1fae5; }
.legend-overwritten { background: var(--warning-soft); }
.legend-nomatch { background: #fde2e2; }

.enrich-preview-wrap {
  overflow-x: auto;
  overflow-y: auto;
  flex: 1;
  min-height: 120px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.enrich-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}
.enrich-preview-table th {
  position: sticky;
  top: 0;
  background: var(--bg-soft);
  padding: 6px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  border-bottom: 1px solid var(--border);
  z-index: 1;
}
.enrich-preview-table th.col-comment {
  background: #4a4a4a;
  color: #fff;
}
.enrich-preview-table td {
  padding: 4px 10px;
  border-bottom: 1px solid var(--border);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.enrich-preview-table td.cell-enriched { background: #d1fae5; }
.enrich-preview-table td.cell-overwritten { background: var(--warning-soft); }
.enrich-preview-table td.cell-nomatch { background: #fde2e2; color: var(--danger-text); }
.enrich-preview-table tr.row-nomatch { background: #fde2e2; }
.enrich-preview-table tr.row-nomatch td { color: var(--danger-text); }

/* Overwritten cells: cursor hint */
.enrich-preview-table td.has-old-value {
  cursor: help;
}

/* Instant JS tooltip (positioned on body, not clipped by scroll containers) */
.enrich-tooltip {
  position: fixed;
  transform: translate(-50%, -100%);
  background: #1e293b;
  color: #fff;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.enrich-tooltip.visible {
  opacity: 1;
}

/* Error state */
.enrich-error-text {
  margin: 16px 0;
  font-size: 14px;
}
.enrich-error-text p { margin: 0 0 8px; }
.enrich-error-tip {
  padding: 10px 14px;
  background: var(--info-soft);
  border-radius: var(--r-sm);
  color: var(--info-text);
  font-size: 13px;
}

/* Responsive */
@media (max-width: 640px) {
  .btn-enrich span { display: none; }

  /* Fullscreen take-over auf Phones, analog zum Contact-Modal. Notch /
     Dynamic Island / Home-Indicator werden via env(safe-area-inset-*)
     respektiert. */
  .enrich-overlay {
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
  }
  .enrich-card {
    width: 100%;
    max-width: none;
    max-height: none;
    min-height: 100vh;
    min-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .enrich-head {
    padding: 16px 20px 14px;
    padding-left: calc(20px + env(safe-area-inset-left, 0px));
    padding-right: calc(20px + env(safe-area-inset-right, 0px));
    position: sticky;
    top: 0;
    background: var(--bg-elev);
    z-index: 2;
  }
  .enrich-body {
    padding: 20px;
    padding-left: calc(20px + env(safe-area-inset-left, 0px));
    padding-right: calc(20px + env(safe-area-inset-right, 0px));
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }
}

/* ============================================================
   Landing Page — view switch
   ============================================================ */

/* View toggle: landing vs explorer. Default = landing. */
body.view-explorer .landing-only { display: none !important; }
body.view-explorer #landing { display: none !important; }
body.view-landing .explorer-only { display: none !important; }
body.view-landing #viewer { display: none !important; }
/* Landing darf niemals horizontal überlaufen — sonst zoomt iOS Safari beim
   View-Switch zurück zur Landing raus, um die breitere layout viewport zu
   zeigen.
   Ensure body handles both modes cleanly.
   Landing needs `height: auto` — the global `html, body { height: 100% }`
   (required for the explorer's full-height table layout) would otherwise
   lock the body to the viewport and the sticky topbar would release at
   ~scrollY 750px because its containing block ends there. */
body.view-landing {
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: 100vh;
}

/* ============================================================
   Landing — topbar overrides
   ============================================================ */
/* Landing topbar: identical look to explorer — solid white, same border */
/* No transparency tricks, no scroll transitions — prevents visual "ping" on switch */

/* Sticky footer — always at bottom of viewport */
body.view-landing .app-footer {
  position: sticky;
  bottom: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Mobile footer: drop sticky (eats viewport), stack lines cleanly, hide
   the middle-dot separators that wrap awkwardly at narrow widths */
@media (max-width: 640px) {
  body.view-landing .app-footer,
  .auth-body .app-footer {
    position: static;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .app-footer {
    gap: 6px 10px;
    padding: 16px 18px 20px;
    font-size: 11px;
    line-height: 1.5;
  }
  .app-footer .sep { display: none; }
  .app-footer .fn-long { display: none; }
  .app-footer .fn-short { display: inline; }
  .app-footer > span:first-child {
    flex-basis: 100%;
    text-align: center;
  }
  .app-footer > span:nth-child(3) {
    flex-basis: 100%;
    text-align: center;
    margin-bottom: 4px;
  }
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-link {
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--r-sm);
  transition: color var(--dur), background var(--dur);
}
.nav-link:hover {
  color: var(--text);
  background: var(--bg-soft);
}

/* Hamburger */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  width: 40px;
  height: 40px;
  padding: 8px;
  background: none;
  border: none;
  cursor: pointer;
}
/* Beim Morph zum X müssen oberer und unterer Balken exakt auf die Mittel-
   linie wandern, sonst wird das X schief. Distanz = halbe Stack-Höhe
   zwischen den Balken = (gap 6px + bar-height 2.5px) = 8.5px. */
.hamburger span {
  display: block;
  width: 24px;
  height: 2.5px;
  background: var(--text);
  border-radius: 3px;
  transition: transform 0.2s, opacity 0.2s;
  transform-origin: center;
}
.hamburger.open span:nth-child(1) {
  transform: translateY(8.5px) rotate(45deg);
}
.hamburger.open span:nth-child(2) {
  /* scaleX(0) zusätzlich zur opacity: sonst schauen links/rechts noch ein
     paar Pixel des mittleren Balkens über die rotierten X-Arme hinaus,
     weil ein 24px-Strich bei 45° nur ~17px horizontal abdeckt. */
  opacity: 0;
  transform: scaleX(0);
}
.hamburger.open span:nth-child(3) {
  transform: translateY(-8.5px) rotate(-45deg);
}

/* Mobile nav overlay */
.mobile-nav-overlay {
  position: fixed;
  inset: 0;
  top: var(--topbar-h);
  z-index: 19;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(8px);
  padding: 24px;
}
.mobile-nav-overlay.hidden { display: none; }
.mobile-nav-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mobile-nav-link {
  display: block;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--r-md);
  transition: background 0.15s;
}
.mobile-nav-link:hover {
  background: var(--bg-soft);
}

/* ============================================================
   Landing — Hero
   ============================================================ */
.landing {
  flex: 1;
}
.lp-container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 32px;
}

.lp-hero {
  padding: 100px 0 80px;
  text-align: center;
  background:
    radial-gradient(ellipse at 15% -5%, rgba(204, 251, 241, 0.45) 0%, transparent 50%),
    radial-gradient(ellipse at 90% 15%, rgba(254, 243, 199, 0.3) 0%, transparent 45%),
    var(--bg);
}
.lp-hero-title {
  font-size: clamp(32px, 5vw, 56px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.08;
  margin: 0 auto;
  max-width: 780px;
  color: var(--text);
}
.lp-hero-sub {
  font-size: clamp(16px, 2vw, 19px);
  color: var(--text-muted);
  max-width: 620px;
  margin: 24px auto 0;
  line-height: 1.6;
}
.lp-hero-ctas {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 36px;
}
.lp-hero-ctas .btn {
  min-width: 240px;
}
.lp-hero-stats {
  display: flex;
  justify-content: center;
  gap: 48px;
  margin-top: 40px;
  padding-top: 36px;
  border-top: 1px solid var(--border);
}
.lp-stat {
  text-align: center;
}
.lp-stat strong {
  display: block;
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.lp-stat span {
  font-size: 13px;
  color: var(--text-muted);
}

/* ============================================================
   Landing — Sections (shared)
   ============================================================ */
.lp-section {
  padding: 80px 0;
}
.lp-section-head {
  text-align: center;
  margin-bottom: 48px;
}
.lp-section-head h2 {
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 700;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}
.lp-section-head p {
  margin: 0 auto;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1.6;
  max-width: 660px;
}
/* Scroll reveal */
.landing .anim {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.65s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.65s cubic-bezier(0.16, 1, 0.3, 1);
}
.landing .anim.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   Landing — Product Preview
   ============================================================ */
.lp-preview-window {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  pointer-events: none;
  max-width: 940px;
  margin: 0 auto;
}
.lp-preview-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border);
}
/* Preview bar icon spacing */
.lp-preview-bar-title {
  margin-left: 8px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.lp-preview-body {
  display: flex;
  min-height: 260px;
}
.lp-preview-sidebar {
  width: 170px;
  flex-shrink: 0;
  background: var(--bg-sunken);
  border-right: 1px solid var(--border);
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lp-preview-group {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-soft);
  padding: 10px 12px 4px;
}
.lp-preview-group:first-child {
  padding-top: 0;
}
.lp-preview-tab {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
}
.lp-preview-tab.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 500;
}
.lp-preview-view {
  font-style: italic;
  font-size: 11px;
}
.lp-preview-table-wrap {
  flex: 1;
  overflow: hidden;
  padding: 0;
}
.lp-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.lp-preview-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sunken);
}
.lp-preview-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--bg-soft);
  color: var(--text);
  white-space: nowrap;
}
.lp-preview-table code {
  font-size: 11px;
  background: var(--bg-soft);
  padding: 2px 6px;
  border-radius: 4px;
}
.lp-preview-fade td {
  opacity: 0.35;
}
.lp-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
}
.lp-status-active {
  background: var(--success-soft);
  color: var(--success-text);
}
.lp-status-plan {
  background: var(--info-soft);
  color: var(--info-text);
}
/* ============================================================
   Landing — Enrichment Feature (Killer)
   ============================================================ */
.lp-enrich-section {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(204, 251, 241, 0.3) 0%, transparent 60%),
    var(--bg);
}
.lp-enrich-flow {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  margin-bottom: 56px;
}

.lp-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}
.lp-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}
/* Legend dot colors */
.lp-legend-enriched { background: rgba(22, 163, 74, 0.35); }
.lp-legend-replaced { background: rgba(217, 119, 6, 0.35); }
.lp-legend-nomatch  { background: rgba(220, 38, 38, 0.18); }

/* Standalone legend below file transformation */
.lp-enrich-legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: -44px;
  margin-bottom: 32px;
  font-size: 12px;
}
/* Trust */
.lp-enrich-trust {
  text-align: center;
}
.lp-trust-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 16px;
}
.lp-compat-label {
  font-size: 12px;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  margin: 0 0 10px;
}
.lp-compat-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.lp-compat-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   Landing — Enrich flow: file transformation visual
   ============================================================ */
.ef-file {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 320px;
  flex-shrink: 0;
}
.ef-file-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px 10px 0 0;
  border-bottom: none;
}
.ef-bar-dots {
  display: flex;
  gap: 5px;
}
.ef-bar-dots i {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-soft);
  opacity: 0.35;
}
.ef-bar-name {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono, monospace);
}
.ef-bar-after {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.ef-sheet {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 0 0 10px 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.ef-file-after .ef-sheet {
  border-color: var(--accent);
  box-shadow: 0 4px 16px -4px rgba(15, 118, 110, 0.2);
}
.ef-srow {
  display: grid;
  grid-template-columns: 18px 1fr 1fr 1fr;
  gap: 6px;
  align-items: center;
}
.ef-shead {
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.ef-shead span {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.ef-rn {
  font-size: 10px;
  color: var(--text-soft);
  text-align: center;
}
/* Shared cell style for the fake spreadsheet */
.ef-val, .ef-gap, .ef-new, .ef-fix, .ef-nomatch {
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ef-val {
  background: var(--bg-soft);
  color: var(--text-muted);
}
.ef-gap {
  border: 1.5px dashed rgba(217, 119, 6, 0.45);
  background: rgba(217, 119, 6, 0.06);
  min-height: 18px;
}
.ef-new {
  background: rgba(22, 163, 74, 0.18);
  color: #166534;
}
.ef-fix {
  background: rgba(217, 119, 6, 0.15);
  color: #92400e;
}
.ef-nomatch {
  background: rgba(220, 38, 38, 0.08);
  color: #991b1b;
}
.ef-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-top: 12px;
}
.ef-sublabel {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Connector with animated dots + badge */
.ef-connector {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 36px;
  margin: 0 20px;
}
.ef-conn-dots {
  display: flex;
  gap: 8px;
}
.ef-conn-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: ef-flow 2.2s ease-in-out infinite;
}
/* Left dots: start of wave */
.ef-conn-dots:first-child span:nth-child(1) { animation-delay: 0s; }
.ef-conn-dots:first-child span:nth-child(2) { animation-delay: 0.2s; }
.ef-conn-dots:first-child span:nth-child(3) { animation-delay: 0.4s; }
/* Right dots: continue wave after passing through badge */
.ef-conn-dots:last-child span:nth-child(1) { animation-delay: 0.75s; }
.ef-conn-dots:last-child span:nth-child(2) { animation-delay: 0.95s; }
.ef-conn-dots:last-child span:nth-child(3) { animation-delay: 1.15s; }
@keyframes ef-flow {
  0%, 10% { opacity: 0.08; transform: scale(0.6); }
  30%, 40% { opacity: 1; transform: scale(1); }
  60%, 100% { opacity: 0.08; transform: scale(0.6); }
}
.ef-conn-badge {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 16px -4px rgba(15, 118, 110, 0.4);
  animation: ef-pulse 2.5s ease-in-out infinite;
}
.ef-conn-badge svg {
  width: 20px;
  height: 20px;
}
@keyframes ef-pulse {
  0%, 100% { box-shadow: 0 4px 16px -4px rgba(15, 118, 110, 0.4); }
  50% { box-shadow: 0 4px 28px -2px rgba(15, 118, 110, 0.55); }
}

/* ============================================================
   Landing — Persona Grid
   ============================================================ */
.lp-persona-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  max-width: 960px;
  margin: 0 auto;
}
.lp-persona-card,
.lp-feature-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur), box-shadow var(--dur);
}
.lp-persona-card:hover,
.lp-feature-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.lp-persona-icon,
.lp-feature-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  margin-bottom: 16px;
}
.lp-persona-icon svg,
.lp-feature-icon svg {
  width: 22px;
  height: 22px;
}
.lp-persona-card h3,
.lp-feature-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
}
.lp-persona-card p,
.lp-feature-card p {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.55;
}

/* ============================================================
   Landing — Feature Grid
   ============================================================ */
.lp-feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  max-width: 960px;
  margin: 0 auto;
}

/* ============================================================
   Landing — Kontakt
   ============================================================ */
.lp-contact-section {
  background: var(--bg-sunken);
}
.lp-contact-card {
  max-width: 520px;
  margin: 0 auto;
  text-align: center;
  padding: 32px 28px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.lp-contact-card h2 {
  margin: 0 0 12px;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.lp-contact-card p {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.55;
}
.lp-contact-mail {
  display: inline-block;
  font-size: 17px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.01em;
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur);
}
.lp-contact-mail:hover {
  border-bottom-color: var(--accent);
}

/* ============================================================
   Landing — FAQ
   ============================================================ */
.lp-faq-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 720px;
  margin: 0 auto;
}
.lp-faq-item {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 0;
}
.lp-faq-item summary {
  padding: 20px 24px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  user-select: none;
}
.lp-faq-item summary::-webkit-details-marker { display: none; }
.lp-faq-item summary::after {
  content: "+";
  font-size: 20px;
  font-weight: 400;
  color: var(--text-soft);
  flex-shrink: 0;
  transition: transform var(--dur);
}
.lp-faq-item[open] summary::after {
  content: "\2212";
}
.lp-faq-item p {
  margin: 0;
  padding: 0 24px 20px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
}

/* ============================================================
   Landing — Section CTA (inline between sections)
   ============================================================ */
.lp-section-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 40px;
}

/* ============================================================
   Landing — Persona "also" text
   ============================================================ */
.lp-persona-also {
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 24px;
}

/* ============================================================
   Landing — Final CTA Section
   ============================================================ */
.lp-final-cta-section {
  background:
    radial-gradient(ellipse at 50% 100%, rgba(204, 251, 241, 0.35) 0%, transparent 60%),
    var(--bg);
}
.lp-final-cta {
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
}
.lp-final-cta h2 {
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 700;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}
.lp-final-cta p {
  font-size: 16px;
  color: var(--text-muted);
  margin: 0 0 32px;
  line-height: 1.6;
}
.lp-final-cta-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

/* ============================================================
   Landing — Responsive (Mobile)
   ============================================================ */
@media (max-width: 768px) {
  /* Header */
  .topbar-nav { display: none; }
  body.view-landing .hamburger { display: flex; }
  /* Tagline "Alle Energiedaten · Tagesaktuell" wraps unter das Logo und
     bricht den Brand-Block, wenn der Header-Platz knapp wird. Auf Landing-
     Mobile reduzieren wir auf Logo + Wortmarke; die Subtitle ist auf der
     Seite selbst prominent genug. */
  body.view-landing .brand-tagline { display: none; }
  body.view-landing .brand-text strong { white-space: nowrap; }

  /* Hero */
  .lp-hero { padding: 72px 0 56px; }
  .lp-hero-ctas {
    flex-direction: column;
    gap: 12px;
  }
  .lp-hero-ctas .btn { width: 100%; }
  .lp-hero-stats {
    gap: 24px;
    flex-wrap: wrap;
  }

  /* Preview */
  .lp-preview-sidebar { display: none; }
  .lp-preview-table-wrap { overflow: hidden; }
  /* Preview: hide Ort + Status columns so table fits; truncate long names */
  .lp-preview-table th:nth-child(3),
  .lp-preview-table td:nth-child(3),
  .lp-preview-table th:nth-child(5),
  .lp-preview-table td:nth-child(5) { display: none; }
  .lp-preview-table td:nth-child(2) {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .lp-preview-table th,
  .lp-preview-table td { padding: 9px 12px; font-size: 12px; }

  /* Sections */
  .lp-section { padding: 56px 0; }
  .lp-container { padding: 0 20px; }
  .lp-section-head { margin-bottom: 32px; }

  /* Enrichment flow: vertical stack on mobile */
  .lp-enrich-flow {
    flex-direction: column;
    align-items: center;
    gap: 0;
    margin-bottom: 40px;
  }
  .ef-file { width: 100%; max-width: 100%; }
  .ef-connector {
    flex-direction: column;
    padding-top: 0;
    margin: 16px 0;
  }
  .ef-conn-dots { flex-direction: column; }

  /* Persona grid */
  .lp-persona-grid {
    grid-template-columns: 1fr;
    max-width: 440px;
    margin: 0 auto;
  }

  /* Feature grid */
  .lp-feature-grid {
    grid-template-columns: 1fr;
    max-width: 440px;
    margin: 0 auto;
  }

  /* FAQ */
  .lp-faq-item summary { padding: 16px 18px; font-size: 14px; }
  .lp-faq-item p { font-size: 13px; padding: 0 18px 16px; }

  /* Section CTAs */
  .lp-section-cta { flex-direction: column; gap: 12px; }
  .lp-section-cta .btn { width: 100%; }

  /* Final CTA */
  .lp-final-cta-buttons { flex-direction: column; gap: 12px; }
  .lp-final-cta-buttons .btn { width: 100%; }
}

@media (max-width: 480px) {
  .lp-hero-stats {
    flex-direction: column;
    gap: 16px;
  }
  .lp-persona-grid { gap: 14px; }
  .lp-persona-card { padding: 20px 18px; }
  .chips span { font-size: 11px; padding: 4px 10px; }

  /* Enrich legend wraps on phones */
  .lp-enrich-legend { flex-wrap: wrap; gap: 8px 12px; margin-top: -16px; }
}

/* ============================================================
   Mobile Explorer — Card View (all rules live inside the
   max-width: 640px block further down; this class is hidden
   by default so the card-list container stays inert on desktop)
   ============================================================ */
.card-view { display: none; }

/* Mobile bottom-sheet for sidebar */
.mobile-table-pill {
  display: none;
}
@media (max-width: 960px) {
  /* Hide desktop sidebar, show pill + bottom sheet */
  body.view-explorer .sidebar {
    display: none;
  }
  body.view-explorer .viewer {
    grid-template-columns: 1fr;
  }
  .mobile-table-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    min-height: 38px;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--dur), transform var(--dur);
  }
  .mobile-table-pill:active {
    transform: scale(0.97);
    border-color: var(--accent);
  }
  .mobile-table-pill svg {
    width: 14px;
    height: 14px;
    color: var(--accent);
  }
  .mobile-table-pill svg:last-child { color: var(--text-soft); }
  .mobile-table-pill strong {
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
  }
}

/* Bottom sheet */
.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--overlay-light);
  opacity: 0;
  transition: opacity 0.2s;
}
.bottom-sheet-overlay.visible {
  opacity: 1;
}
.bottom-sheet-overlay.hidden { display: none; }
.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 101;
  background: var(--bg-elev);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.12);
  max-height: 60vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s var(--ease);
  padding: 8px 0 24px;
}
.bottom-sheet.visible {
  transform: translateY(0);
}
.bottom-sheet.hidden { display: none; }
.bottom-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
  margin: 8px auto 16px;
}

/* Mobile toolbar adjustments (tablet + phone) */
@media (max-width: 960px) {
  .results { padding: 16px 16px 20px; gap: 12px; }
  .results-toolbar { flex-wrap: wrap; gap: 10px; }
  .search-wrap { flex: 1 1 100%; }
  .toolbar-actions { flex-wrap: wrap; gap: 8px; }
  .view-toggle { order: -1; }
  .pagination { font-size: 13px; }
  .search-kbd { display: none; }

  /* Mobile: reduce table font */
  #result-table { font-size: 12px; }
  #result-table thead th { padding: 8px 10px; font-size: 11px; }
  #result-table tbody td { padding: 8px 10px; }
}

/* ============================================================
   MOBILE EXPLORER — the lite, executive-grade experience
   Activates on phones in BOTH orientations:
     • Portrait phones: (max-width: 640)
     • Landscape phones: (max-width: 960) and (max-height: 520)
   Tables become a swipable card list, filters/column picker become
   bottom sheets, drawer takes over the whole screen.
   ============================================================ */

/* Shared phone polish for the explorer view */
@media (max-width: 640px), (max-width: 960px) and (max-height: 520px) {
  /* --- Normal document flow on phones ---
     Desktop forces a flex/grid chain (html/body = 100% → viewer → results
     → table-wrap) so the table can scroll internally under a sticky
     header. On phones we let the body grow and scroll naturally; the
     card list expands, the topbar / pagination stick to the viewport,
     and the app footer lands cleanly at the end of the document. */
  html, body.view-explorer {
    height: auto;
    min-height: 100%;
  }
  body.view-explorer { display: block; }

  body.view-explorer .viewer {
    display: block;
    min-height: 0;
    flex: none;
  }
  body.view-explorer .results {
    display: block;
    padding: 12px 12px 18px;
    min-height: 0;
  }
  /* Tidy vertical rhythm in block flow — replaces the flex gap. */
  body.view-explorer .results > * + * { margin-top: 10px; }
  body.view-explorer .table-wrap {
    flex: none;
    min-height: 0;
    height: auto;
  }

  /* --- Topbar: compact, clean, trustworthy --- */
  body.view-explorer .topbar {
    padding: 0 12px;
    gap: 8px;
  }
  body.view-explorer .brand {
    gap: 8px;
    min-width: 0;
    flex: 0 1 auto;
    overflow: hidden;
  }
  body.view-explorer .brand-text { display: none !important; }
  body.view-explorer .logo {
    width: 30px;
    height: 30px;
    border-radius: 8px;
  }
  body.view-explorer .logo svg { width: 16px; height: 16px; }
  body.view-explorer .brand-tagline {
    display: none;
  }

  /* Freshness badge: show only date text on mobile, no pill/dot */
  body.view-explorer .data-freshness {
    padding: 0;
    margin-left: 8px;
    width: auto;
    height: auto;
    border-radius: 0;
    overflow: visible;
    box-shadow: none;
    background: none !important;
    border: none !important;
    font-size: 11px;
    color: var(--text-muted) !important;
    font-weight: 400;
  }
  body.view-explorer .data-freshness .data-freshness-sep,
  body.view-explorer .data-freshness #data-freshness-records { display: none !important; }
  body.view-explorer .data-freshness #data-freshness-date { display: inline !important; font-size: 11px; }

  /* Topbar right cluster: free pill hidden, lizenz hidden, enrich becomes icon-only */
  body.view-explorer .topbar-right { gap: 8px; flex-shrink: 0; }
  body.view-explorer .free-upgrade-pill,
  body.view-explorer .lizenz-badge,
  body.view-explorer #btn-login,
  body.view-explorer #btn-logout,
  body.view-explorer #btn-admin,
  body.view-explorer #btn-open-import { display: none !important; }

  body.view-explorer .btn-enrich {
    padding: 8px 10px;
    font-size: 0;
    gap: 0;
    border-radius: 10px;
  }
  body.view-explorer .btn-enrich svg {
    width: 18px;
    height: 18px;
  }

  /* Toolbar: search full width, action row below */
  body.view-explorer .results-toolbar {
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 0;
  }
  body.view-explorer .search-wrap {
    flex: 1 1 100%;
    order: 1;
  }
  body.view-explorer #search-input {
    padding: 12px 16px 12px 42px;
    font-size: 15px;     /* ≥16 prevents iOS autozoom; 15 is visually cleaner */
    border-radius: 12px;
  }
  body.view-explorer .toolbar-actions {
    order: 2;
    flex: 1 1 100%;
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }
  body.view-explorer .toolbar-actions::-webkit-scrollbar { display: none; }
  body.view-explorer .toolbar-actions .btn,
  body.view-explorer .toolbar-actions .view-toggle,
  body.view-explorer .toolbar-actions .mobile-table-pill,
  body.view-explorer .toolbar-actions .view-save-group {
    flex-shrink: 0;
  }
  body.view-explorer .toolbar-actions .btn {
    padding: 9px 14px;
    font-size: 13px;
    min-height: 38px;
  }

  /* Action row order on phones (left → right):
     1) table pill (change category)   2) view toggle (table/map)
     3) filter button                  4) export (pushed right, default order)  */
  body.view-explorer .mobile-table-pill { order: -3; }
  body.view-explorer .view-toggle { order: -2; }
  /* `.mobile-filter-btn { order: -1 }` is set further below in the dedicated
     filter-button block so its flex order stays alongside its main styling. */
  body.view-explorer .view-toggle .vt-btn {
    padding: 7px 12px;
    font-size: 12px;
  }
  /* Compact Excel btn: icon only on small phones */
  body.view-explorer #btn-export {
    font-size: 0;
    gap: 0;
    padding: 9px 12px;
  }
  body.view-explorer #btn-export svg {
    width: 16px;
    height: 16px;
  }
  /* Columns button: hidden entirely on phones — the card renderer always
     picks the key fields; users filter via the dedicated mobile filter button */
  body.view-explorer #btn-columns { display: none; }
  /* Save view button: hide — saved views are a power-user feature, managed on desktop */
  body.view-explorer .view-save-group { display: none; }

  /* Result meta row: cleaner typography */
  body.view-explorer .result-meta {
    flex-wrap: wrap;
    gap: 6px 10px;
    font-size: 12px;
    padding: 2px 4px;
  }
  body.view-explorer .filter-pills {
    margin-left: 0;
    flex: 1 1 100%;
    order: 2;
  }
  body.view-explorer .pill {
    font-size: 11px;
    padding: 3px 4px 3px 9px;
  }

  /* --- Card list replaces the table --- */
  body.view-explorer #table-wrap {
    background: transparent;
    border: 0;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
  }
  /* Hide the actual table inside table-wrap on mobile */
  body.view-explorer #result-table { display: none; }

  .card-view {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 2px 0 4px;
  }
  .card-view.hidden { display: none; }

  .card-view-item {
    position: relative;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition:
      transform 120ms var(--ease),
      border-color var(--dur),
      box-shadow var(--dur);
    overflow: hidden;
  }
  .card-view-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 14px;
    bottom: 14px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
    opacity: 0.8;
  }
  .card-view-item[data-cat="sun"]::before    { background: #f59e0b; }
  .card-view-item[data-cat="wind"]::before   { background: #0ea5e9; }
  .card-view-item[data-cat="leaf"]::before   { background: #16a34a; }
  .card-view-item[data-cat="wave"]::before   { background: #06b6d4; }
  .card-view-item[data-cat="flame"]::before  { background: #ef4444; }
  .card-view-item[data-cat="earth"]::before  { background: #a3a3a3; }
  .card-view-item[data-cat="atom"]::before   { background: #8b5cf6; }
  .card-view-item[data-cat="battery"]::before{ background: #10b981; }
  .card-view-item[data-cat="gas"]::before    { background: #f97316; }

  .card-view-item:active {
    transform: scale(0.985);
    border-color: var(--accent);
    box-shadow: 0 4px 12px -4px var(--accent-glow);
  }

  .card-view-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
  }
  .card-view-cat {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    background: var(--accent-soft);
    color: var(--accent-text);
  }
  .card-view-item[data-cat="sun"]     .card-view-cat { background: #fef3c7; color: #b45309; }
  .card-view-item[data-cat="wind"]    .card-view-cat { background: #e0f2fe; color: #0369a1; }
  .card-view-item[data-cat="leaf"]    .card-view-cat { background: #dcfce7; color: #166534; }
  .card-view-item[data-cat="wave"]    .card-view-cat { background: #cffafe; color: #0e7490; }
  .card-view-item[data-cat="flame"]   .card-view-cat { background: #fee2e2; color: #b91c1c; }
  .card-view-item[data-cat="earth"]   .card-view-cat { background: #f5f5f4; color: #52525b; }
  .card-view-item[data-cat="atom"]    .card-view-cat { background: #ede9fe; color: #6d28d9; }
  .card-view-item[data-cat="battery"] .card-view-cat { background: #d1fae5; color: #047857; }
  .card-view-item[data-cat="gas"]     .card-view-cat { background: #ffedd5; color: #c2410c; }
  .card-view-cat svg {
    width: 16px;
    height: 16px;
  }
  .card-view-title-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .card-view-title {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.3;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    letter-spacing: -0.005em;
  }
  .card-view-id {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    letter-spacing: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .card-view-chevron {
    flex-shrink: 0;
    color: var(--text-soft);
    opacity: 0.55;
    margin-top: 4px;
  }
  .card-view-chevron svg {
    width: 18px;
    height: 18px;
  }

  /* Metrics row: inline dot-separated facts */
  .card-view-metrics {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 0;
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.4;
    padding-left: 42px; /* align with title past category icon */
    min-width: 0;
  }
  .card-view-metric {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .card-view-metric.primary {
    color: var(--text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }
  .card-view-metric + .card-view-metric::before {
    content: "·";
    margin: 0 8px;
    color: var(--text-soft);
    font-weight: 600;
  }

  /* Status badge on bottom */
  .card-view-badge {
    align-self: flex-start;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--r-full);
    background: var(--bg-sunken);
    color: var(--text-muted);
    margin-left: 42px;
    text-transform: none;
    letter-spacing: 0;
  }
  .card-view-badge.active {
    background: var(--accent-soft);
    color: var(--accent-text);
  }
  .card-view-badge.plan {
    background: #fef3c7;
    color: #92400e;
  }
  .card-view-badge.stopped {
    background: var(--danger-soft);
    color: var(--danger-text);
  }

  /* Empty state inside card view */
  body.view-explorer #table-wrap .empty-state {
    margin: 32px 16px;
  }

  /* --- Pagination: fat, thumb-friendly --- */
  body.view-explorer .pagination {
    position: sticky;
    bottom: 0;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 10px 4px 6px;
    margin: 8px -8px -12px;
    gap: 8px;
    border-top: 1px solid var(--border);
  }
  body.view-explorer .pagination .btn {
    flex: 1;
    justify-content: center;
    min-height: 42px;
    font-size: 13px;
    font-weight: 600;
    padding: 0 14px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
  }
  body.view-explorer .pagination .btn:active:not(:disabled) {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-text);
  }
  body.view-explorer #pagination-info {
    font-size: 12px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  /* --- Drawer: full screen, slide from bottom --- */
  .drawer-panel {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100svh !important;
    height: 100vh !important;
    top: 0 !important;
    right: 0 !important;
    border-left: 0 !important;
    border-radius: 16px 16px 0 0;
    animation: drawerSlideUp 280ms var(--ease) !important;
  }
  @keyframes drawerSlideUp {
    from { transform: translateY(100%); }
  }
  .drawer-head {
    padding: 12px 16px;
    gap: 12px;
    background: var(--bg-elev);
    position: sticky;
    top: 0;
    z-index: 1;
    box-shadow: 0 1px 0 var(--border);
  }
  .drawer-head h3 {
    font-size: 14px;
    max-width: calc(100vw - 80px);
  }
  .drawer-head .btn-close {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-sunken);
  }
  .drawer-body { padding: 16px 18px 48px; }
  .drawer-field {
    grid-template-columns: 42% 1fr;
    padding: 9px 0;
    gap: 6px 12px;
    font-size: 13px;
  }
  .drawer-field-label {
    font-size: 11px;
  }

  /* --- Header popover becomes a bottom sheet --- */
  .header-popover {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 85svh;
    max-height: 85vh;
    padding: 18px 18px 24px;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.18);
    animation: sheetSlideUp 260ms var(--ease) !important;
    gap: 14px;
  }
  .header-popover::before {
    content: "";
    display: block;
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--border-strong);
    margin: -4px auto 6px;
  }
  .hp-head { padding-bottom: 12px; }
  .hp-name { font-size: 15px; }
  .hp-sort button { padding: 8px 12px; font-size: 12px; }
  .hp-list { max-height: 42vh; }
  .hp-item { padding: 11px 12px; }
  .hp-item-label { font-size: 13px; }
  .hp-range input { padding: 11px 12px; font-size: 15px; }
  .hp-text-input { padding: 12px 14px; font-size: 15px; }
  .hp-op button { padding: 9px 10px; font-size: 12px; }
  .hp-foot { padding-top: 12px; gap: 10px; }
  .hp-foot .btn-sm {
    flex: 1;
    padding: 11px 14px;
    font-size: 13px;
    min-height: 42px;
  }
  @keyframes sheetSlideUp {
    from { transform: translateY(100%); }
  }

  /* --- Column picker as bottom sheet --- */
  .col-picker {
    padding: 0;
    align-items: flex-end;
  }
  .col-picker-card {
    width: 100vw;
    max-width: 100vw;
    max-height: 85svh;
    max-height: 85vh;
    border-radius: 18px 18px 0 0;
    animation: sheetSlideUp 260ms var(--ease);
  }
  .col-picker-card::before {
    content: "";
    display: block;
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--border-strong);
    margin: 8px auto 0;
  }
  .col-picker-head { padding: 14px 20px 10px; }
  .col-picker-head h3 { font-size: 15px; }
  .col-picker-search { padding: 0 20px 12px; }
  .col-picker-search input { padding: 11px 14px; font-size: 15px; }
  .col-list { padding: 0 10px; }
  .col-item { padding: 11px 12px; }
  .col-item-name { font-size: 13px; }
  .col-picker-foot { padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px)); gap: 10px; }
  .col-picker-foot .btn { flex: 1; min-height: 42px; font-size: 13px; }

  /* --- Table picker bottom sheet: polish --- */
  .bottom-sheet {
    max-height: 72vh;
    max-height: 72svh;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }
  .bottom-sheet-content {
    padding: 0 12px 8px;
  }
  .bottom-sheet .tp-group { margin-top: 16px; padding: 0 !important; }
  .bottom-sheet .tp-group-label {
    padding: 6px 12px 6px;
    font-size: 10px;
  }
  .bottom-sheet .tp-item {
    padding: 13px 14px;
    font-size: 15px;
    min-height: 48px;
    border-radius: 12px;
  }
  .bottom-sheet .tp-item .tp-icon {
    width: 22px;
    height: 22px;
  }
  .bottom-sheet .tp-item .tp-icon svg {
    width: 20px;
    height: 20px;
  }
  .bottom-sheet .tp-item .tp-count { font-size: 11px; padding: 3px 9px; }

  /* --- Map view on mobile ---
     Normal block-flow means .map-wrap has no intrinsic height. Give it
     an explicit viewport-relative height so Leaflet can measure and
     paint tiles correctly when the user flips to map mode. 100svh uses
     the small-viewport height (excludes the browser's dynamic UI chrome)
     so the map doesn't get clipped under the address bar on scroll. */
  body.view-explorer .map-wrap {
    border-radius: 12px;
    border: 1px solid var(--border);
    height: calc(100svh - 220px);
    min-height: 420px;
  }
  .map-info {
    top: auto !important;
    bottom: 12px !important;
    left: 12px !important;
    right: 12px !important;
    max-width: none !important;
    font-size: 11.5px;
    padding: 9px 12px;
    border-radius: 12px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background: color-mix(in srgb, var(--bg-elev) 90%, transparent);
    box-shadow: 0 6px 20px -6px rgba(15, 23, 42, 0.25);
  }
  .map-controls {
    top: 8px !important;
    left: 8px !important;
  }

  /* Leaflet: hide zoom controls (pinch works better on mobile) */
  .leaflet-control-zoom { display: none !important; }

  /* --- Import overlay / enrich overlay — full screen --- */
  .import-card {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100svh;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0 !important;
  }

  /* --- Empty / no-db state --- */
  .no-db-card {
    padding: 32px 22px;
  }

  /* --- Hide mobile nav overlay from explorer (only shows on landing) --- */
  body.view-explorer .mobile-nav-overlay { display: none !important; }
}

/* Tiny phones (iPhone SE landscape, old Android): ultra compact */
@media (max-width: 380px) {
  body.view-explorer .brand-text strong { font-size: 13px; }
  body.view-explorer .logo { width: 28px; height: 28px; }
  body.view-explorer .btn-enrich { padding: 7px 9px; }
  body.view-explorer .btn-enrich svg { width: 16px; height: 16px; }
  body.view-explorer .mobile-table-pill strong { max-width: 120px; }
  body.view-explorer .results { padding: 10px 10px 16px; }
  .card-view-item { padding: 12px 14px 12px 16px; border-radius: 12px; }
  .card-view-title { font-size: 13.5px; }
  .card-view-metrics,
  .card-view-badge { padding-left: 40px; }
  .drawer-field { grid-template-columns: 46% 1fr; }
}

/* Mobile filter/sort column picker — visible on phones only */
.mobile-filter-btn { display: none; }
@media (max-width: 640px), (max-width: 960px) and (max-height: 520px) {
  body.view-explorer .mobile-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 600;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    color: var(--text);
    min-height: 38px;
    position: relative;
    order: -1;
  }
  body.view-explorer .mobile-filter-btn svg {
    width: 14px;
    height: 14px;
  }
  body.view-explorer .mobile-filter-btn.has-active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-text);
  }
  body.view-explorer .mobile-filter-btn .filter-count {
    display: inline-grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 2px;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
  }
}

/* Filter sheet — reuses .bottom-sheet structure but with more chrome */
.filter-sheet {
  max-height: 82vh;
  max-height: 82svh;
  padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
}
.filter-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 12px;
  border-bottom: 1px solid var(--border);
}
.filter-sheet-head strong {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.filter-sheet-active {
  padding: 12px 16px 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px solid var(--border);
}
.filter-sheet-active.hidden { display: none; }
.filter-sheet-search {
  padding: 12px 16px 8px;
}
.filter-sheet-search input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-sunken);
  font-size: 14px;
}
.filter-sheet-search input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
.filter-sheet-cols {
  overflow-y: auto;
  padding: 2px 10px 10px;
  max-height: 50vh;
}
.filter-sheet-col {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 13px 12px;
  border-radius: 10px;
  background: transparent;
  border: none;
  color: var(--text);
  text-align: left;
  font-size: 14px;
  min-height: 48px;
  cursor: pointer;
  transition: background var(--dur);
}
.filter-sheet-col:hover,
.filter-sheet-col:active {
  background: var(--bg-soft);
}
.filter-sheet-col-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.filter-sheet-col-type {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-soft);
  padding: 2px 7px;
  background: var(--bg-soft);
  border-radius: 8px;
  flex-shrink: 0;
}
.filter-sheet-col.active-filter .filter-sheet-col-type {
  background: var(--accent);
  color: #fff;
}
.filter-sheet-col-chevron {
  color: var(--text-soft);
  flex-shrink: 0;
}
.filter-sheet-col-chevron svg {
  width: 16px;
  height: 16px;
}

/* Scrim behind mobile bottom-sheet popovers (header filters).
   Lives in the DOM permanently, only .hidden controls visibility. */
.mobile-sheet-scrim {
  position: fixed;
  inset: 0;
  z-index: 149;   /* one below .header-popover (z 150) */
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 1;
  transition: opacity 180ms var(--ease);
}
.mobile-sheet-scrim.hidden { display: none; }
/* Scrim only shows when the phone layout is active. On tablets/desktop
   the popover is anchored to the column header, no scrim needed. */
@media (min-width: 961px), (min-width: 641px) and (min-height: 521px) {
  .mobile-sheet-scrim { display: none !important; }
}

/* Landscape phones: shrink topbar further so table gets more vertical room */
@media (max-width: 900px) and (max-height: 480px) and (orientation: landscape) {
  :root { --topbar-h: 44px; }
  body.view-explorer .brand-text { display: none; }
  body.view-explorer .results { padding: 10px 12px 14px; gap: 8px; }
  body.view-explorer #search-input { padding: 10px 14px 10px 40px; font-size: 14px; }
  body.view-explorer .pagination { padding: 6px 4px 4px; }
  .card-view { gap: 8px; }
  .card-view-item { padding: 12px 14px 12px 16px; }
}

/* ── Analytics View ─────────────────────────── */
@keyframes analyticsFadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.analytics-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  min-height: 0;
}
.analytics-wrap.hidden { display: none !important; }

/* ── KPI Cards ── */
.analytics-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.analytics-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  transition: box-shadow .2s var(--ease);
  animation: analyticsFadeUp .4s var(--ease) both;
}
.analytics-card:nth-child(2) { animation-delay: .04s; }
.analytics-card:nth-child(3) { animation-delay: .08s; }
.analytics-card:nth-child(4) { animation-delay: .12s; }
.analytics-card:hover { box-shadow: var(--shadow-md); }
.analytics-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.analytics-card-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.analytics-card-icon svg { width: 15px; height: 15px; }
.analytics-card-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 500;
}
.analytics-card-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.3px;
  line-height: 1.15;
}
.analytics-card-value .unit {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}
.analytics-card-sub {
  font-size: 11px;
  color: var(--text-soft);
  margin-top: 4px;
}
.analytics-card-yoy {
  margin-top: 3px;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Chart Containers ── */
.analytics-chart-wide {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 14px;
  animation: analyticsFadeUp .4s var(--ease) .15s both;
}
.analytics-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 12px;
}
.analytics-chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.analytics-chart-subtitle {
  font-size: 11px;
  color: var(--text-soft);
  margin-top: 2px;
}
.analytics-chart-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.analytics-chart-block {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  animation: analyticsFadeUp .4s var(--ease) .2s both;
}

/* ── Inline Empty State (per Kachel, wenn Filter keine Daten liefert) ── */
.analytics-empty-inline {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 240px;
  padding: 24px 16px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}
.analytics-empty-inline svg {
  width: 32px;
  height: 32px;
  color: var(--text-soft);
  stroke-width: 1.5;
}
#analytics-yearly-wrap .analytics-empty-inline { min-height: 300px; }

/* ── Toggle Buttons ── */
.analytics-toggle {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-soft);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.analytics-toggle-btn {
  padding: 5px 12px;
  font-size: 11px;
  border-radius: 6px;
  color: var(--text-muted);
  font-weight: 500;
  cursor: pointer;
  transition: all .2s var(--ease);
}
.analytics-toggle-btn:hover:not(.active) {
  color: var(--text);
  background: rgba(0,0,0,.03);
}
.analytics-toggle-btn.active {
  background: var(--bg-elev);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* ── Top 5 List ── */
.analytics-top5-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}
.analytics-top5-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  transition: background .2s var(--ease);
}
.analytics-top5-item:hover {
  background: var(--bg-soft);
}
.analytics-top5-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(15,118,110,.07) 0%, rgba(15,118,110,.02) 100%);
  transition: width .6s var(--ease);
  pointer-events: none;
}
.analytics-top5-rank {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.analytics-top5-rank.top3 {
  background: var(--accent-soft);
  color: var(--accent);
}
.analytics-top5-rank.rest {
  background: var(--bg-soft);
  color: var(--text-soft);
}
.analytics-top5-info {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}
.analytics-top5-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.analytics-top5-mastr {
  font-size: 10px;
  color: var(--text-muted);
  font-family: ui-monospace, "SF Mono", "Cascadia Code", monospace;
}
.analytics-top5-power {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  position: relative;
  z-index: 1;
}

/* ── Status Donut ── */
.analytics-donut-row {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 14px;
}
.analytics-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.analytics-donut-center-count {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  letter-spacing: -.3px;
}
.analytics-donut-center-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 500;
  margin-top: 2px;
}
.analytics-status-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.analytics-legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.analytics-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}
.analytics-legend-info { flex: 1; }
.analytics-legend-label { font-size: 11px; color: var(--text); font-weight: 500; }
.analytics-legend-pct {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 32px;
  text-align: right;
  flex-shrink: 0;
}
.analytics-legend-bar-track {
  height: 4px;
  background: var(--bg-soft);
  border-radius: 2px;
  margin-top: 3px;
  overflow: hidden;
}
.analytics-legend-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width .6s var(--ease);
}

/* ── Analytics Hero (slug pages) ──────────────── */
.analytics-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #f0fdfa 0%, #ecfdf5 50%, #f0fdf4 100%);
  border: 1px solid #99f6e4;
  border-radius: var(--r-lg);
  animation: analyticsFadeUp .45s var(--ease) both;
}
.analytics-hero.hidden { display: none !important; }
.analytics-hero-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #ccfbf1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.analytics-hero-icon svg { width: 22px; height: 22px; stroke: #0f766e; }
.analytics-hero-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}
.analytics-hero-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Analytics CTA (slug pages) ──────────────── */
.analytics-cta {
  margin-top: 20px;
}
.analytics-cta.hidden { display: none !important; }
.analytics-cta-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 28px;
  background: linear-gradient(135deg, #f0fdfa 0%, #ecfdf5 50%, #f0fdf4 100%);
  border: 1px solid #99f6e4;
  border-radius: var(--r-lg);
}
.analytics-cta-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.analytics-cta-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}
.analytics-cta-enrich {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.analytics-cta-enrich:hover {
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(15,118,110,.1);
}

/* ── Analytics NBP (Netzbetreiberprüfung) section ──────────────── */
.analytics-nbp-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  animation: analyticsFadeUp .4s var(--ease) .25s both;
}
.analytics-nbp-section.hidden { display: none !important; }
.analytics-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.analytics-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.1px;
}
.analytics-section-sub {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 2px;
}
.analytics-nbp-section .analytics-cards { margin-bottom: 14px; }

/* ── Analytics Responsive ─────────────────────── */
@media (max-width: 960px) {
  .analytics-cards { grid-template-columns: repeat(2, 1fr); }
  .analytics-chart-row { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .analytics-wrap { padding: 10px; }
  .analytics-cards { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .analytics-card { padding: 12px 14px; }
  .analytics-card-value { font-size: 22px; }
  .analytics-card-icon { width: 26px; height: 26px; }
  .analytics-card-icon svg { width: 13px; height: 13px; }
  .analytics-chart-wide { padding: 14px; }
  .analytics-chart-block { padding: 14px 16px; }
  .analytics-chart-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .analytics-donut-row { flex-direction: column; align-items: stretch; }
  .analytics-donut-row > div:first-child { align-self: center; }
  .analytics-hero { padding: 14px 16px; gap: 10px; }
  .analytics-hero-title { font-size: 15px; }
  .analytics-cta-inner { flex-direction: column; align-items: flex-start; padding: 16px; }
  .analytics-top5-item { padding: 6px 8px; }
  .analytics-chart-title { font-size: 12px; }
}
@media (max-width: 480px) {
  .analytics-card-value { font-size: 20px; }
  .analytics-card-label { font-size: 10px; }
  .analytics-donut-center-count { font-size: 16px; }
}

/* ── PLZ Tooltip ──────────────────────────────── */
/* Specificity note: Leaflet's own stylesheet loads after ours, so scope via
 * .leaflet-tooltip.plz-tooltip to win the cascade. Light theme matches the
 * info card up top. */
.leaflet-tooltip.plz-tooltip {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  box-shadow: var(--shadow-md);
  font-variant-numeric: tabular-nums;
  min-width: 180px;
  white-space: normal;
  opacity: 1;
}
.leaflet-tooltip.plz-tooltip::before {
  border-top-color: var(--bg-elev) !important;
}
.leaflet-tooltip.plz-tooltip .plz-tt-head {
  font-weight: 600;
  font-size: 12.5px;
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  color: var(--accent-text);
}
.leaflet-tooltip.plz-tooltip .plz-tt-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  white-space: nowrap;
}
.leaflet-tooltip.plz-tooltip .plz-tt-label {
  color: var(--text-muted);
  font-size: 11.5px;
}
.leaflet-tooltip.plz-tooltip .plz-tt-val {
  font-weight: 600;
  color: var(--text);
}

/* ── Landing Page: Analytics Showcase ─────────── */
.lp-analytics-section {
  background: linear-gradient(180deg, var(--bg) 0%, #f0fdfa 100%);
}
.lp-section-sub {
  font-size: 17px;
  color: var(--text-muted);
  max-width: 640px;
  margin: 8px auto 0;
  line-height: 1.6;
}
.lp-analytics-preview {
  margin-top: 40px;
  display: flex;
  justify-content: center;
}
.lp-analytics-mockup {
  width: 100%;
  max-width: 800px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 24px;
  box-shadow: var(--shadow-lg);
}
.lp-analytics-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.lp-amock-card {
  background: var(--bg-soft);
  border-radius: var(--r-md);
  padding: 14px;
}
.lp-amock-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 500;
}
.lp-amock-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-top: 4px;
}
.lp-amock-value span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}
.lp-amock-chart {
  background: var(--bg-soft);
  border-radius: var(--r-md);
  padding: 16px;
}
.lp-amock-chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}
.lp-amock-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
}
.lp-amock-bar {
  flex: 1;
  background: linear-gradient(180deg, #0f766e, #14b8a6);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height .6s cubic-bezier(.16,1,.3,1);
}
.lp-amock-bar-partial {
  opacity: .45;
  border: 1.5px dashed #0f766e;
  background: repeating-linear-gradient(45deg, transparent, transparent 3px, rgba(15,118,110,.12) 3px, rgba(15,118,110,.12) 6px);
}
.lp-amock-years {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 10px;
  color: var(--text-soft);
}
@media (max-width: 640px) {
  .lp-analytics-cards { grid-template-columns: repeat(2, 1fr); }
  .lp-analytics-mockup { padding: 16px; }
  .lp-amock-value { font-size: 20px; }
  .lp-amock-bars { height: 80px; gap: 4px; }
}

/* ============================================================
   Netzbetreiber-Selector (Stadtwerke-Filter im Header)
   ============================================================ */
.netz-selector {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0;
}
.netz-selector-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px 12px;
  border-radius: var(--r-md);
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  line-height: 1;
  height: 35px;
  max-width: 260px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.netz-selector-btn:hover {
  background: var(--bg-elev);
  border-color: var(--accent);
}
.netz-selector-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.netz-selector-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--accent);
}
.netz-selector-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.netz-selector-chevron {
  width: 13px;
  height: 13px;
  opacity: 0.6;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.netz-selector[data-state="open"] .netz-selector-chevron {
  transform: rotate(180deg);
}
.netz-selector[data-state="active"] .netz-selector-btn {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  padding-right: 8px;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.netz-selector[data-state="active"] .netz-selector-icon {
  color: #fff;
}
.netz-selector[data-state="active"] .netz-selector-chevron {
  display: none;
}
.netz-selector-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 35px;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-left: 1px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
  padding: 0;
}
.netz-selector-copy:hover {
  background: var(--accent-hover, var(--accent));
  filter: brightness(0.92);
}
.netz-selector-copy svg { width: 13px; height: 13px; }
.netz-selector-copy.hidden { display: none; }
.netz-selector-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 35px;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-left: 1px solid rgba(255, 255, 255, 0.25);
  border-top-right-radius: var(--r-md);
  border-bottom-right-radius: var(--r-md);
  cursor: pointer;
  padding: 0;
}
.netz-selector-clear:hover {
  background: var(--accent-hover, var(--accent));
  filter: brightness(0.92);
}
.netz-selector-clear svg {
  width: 14px;
  height: 14px;
}
.netz-selector-clear.hidden {
  display: none;
}

/* Dropdown-Popover unter dem Selector */
.netz-selector-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 340px;
  max-width: calc(100vw - 24px);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: 0 18px 38px -12px rgba(15, 23, 42, 0.28), 0 4px 10px -2px rgba(15, 23, 42, 0.18);
  z-index: 50;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.netz-selector-popover .nsp-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-base);
  position: relative;
}
.netz-selector-popover .nsp-search input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.netz-selector-popover .nsp-search input:focus {
  border-color: var(--accent);
}
.netz-selector-popover .nsp-search svg {
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}
.netz-selector-popover .nsp-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
}
.netz-selector-popover .nsp-item {
  width: 100%;
  text-align: left;
  display: block;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: transparent;
  border: 0;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  line-height: 1.35;
}
.netz-selector-popover .nsp-item:hover,
.netz-selector-popover .nsp-item.focused {
  background: var(--bg-base);
}
.netz-selector-popover .nsp-item strong {
  display: block;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.netz-selector-popover .nsp-item span {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.netz-selector-popover .nsp-empty {
  padding: 18px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}
.netz-selector-popover .nsp-foot {
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-base);
}

/* Mobile: Selector wird platzsparend verkleinert */
@media (max-width: 960px) {
  .netz-selector-btn {
    max-width: 180px;
    font-size: 12px;
    padding: 7px 10px;
  }
  .netz-selector-popover {
    right: auto;
    left: 0;
    width: 300px;
  }
}
@media (max-width: 640px) {
  .netz-selector {
    flex-shrink: 1;
    min-width: 0;
  }
  .netz-selector-btn {
    max-width: none;
  }
  .netz-selector-btn .netz-selector-label {
    max-width: 100px;
  }
  /* Active NB: hide freshness badge too, NB chip needs the space */
  .topbar:has(.netz-selector[data-state="active"]) .data-freshness { display: none !important; }
  .netz-selector-popover {
    position: fixed;
    left: 12px;
    right: 12px;
    width: auto;
    top: 56px;
  }
}
