/**
 * EE Terrain-Analyse & Machbarkeits-Popup
 *
 * Glassmorphism-styled terrain analysis popup with SVG cross-section,
 * data table, sidebar config panel and map legend.
 *
 * Consistent with EE Dark Design System (Apple-inspired).
 *
 * @module ee-terrain-popup
 * @since 2.25.0
 */

/* ==========================================================================
   5.2 — Terrain-specific CSS Custom Properties
   ========================================================================== */

:root {
  /* Status colours with glow */
  --terrain-ok:        #30d158;
  --terrain-ok-glow:   rgba(48, 209, 88, 0.25);
  --terrain-warn:      #ff9f0a;
  --terrain-warn-glow: rgba(255, 159, 10, 0.25);
  --terrain-error:     #ff453a;
  --terrain-error-glow:rgba(255, 69, 58, 0.25);

  /* SVG cross-section tokens */
  --terrain-ground-stroke:  rgba(255, 255, 255, 0.3);
  --terrain-ground-fill:    rgba(255, 255, 255, 0.04);
  --terrain-module-fill:    rgba(10, 132, 255, 0.15);
  --terrain-module-stroke:  #0a84ff;
  --terrain-grid-color:     rgba(255, 255, 255, 0.04);
  --terrain-dimension-color:rgba(255, 255, 255, 0.25);
  --terrain-label-color:    rgba(255, 255, 255, 0.5);
}

/* ==========================================================================
   5.3 — Glassmorphism Popup
   ========================================================================== */

.ee-terrain-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  opacity: 0;
  pointer-events: none;

  width: 720px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  overflow-x: hidden;

  /* Glassmorphism — consistent with existing EE design */
  background: linear-gradient(
    165deg,
    rgba(255, 255, 255, 0.10) 0%,
    rgba(255, 255, 255, 0.05) 30%,
    rgba(255, 255, 255, 0.03) 70%,
    rgba(255, 255, 255, 0.06) 100%
  );
  backdrop-filter: blur(50px) saturate(200%);
  -webkit-backdrop-filter: blur(50px) saturate(200%);

  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  box-shadow:
    0 25px 60px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 1px 0 rgba(255, 255, 255, 0.1) inset;

  z-index: 100250; /* Above Activity-Hub (100100), below TasksNotes (100300) */

  /* Smooth open animation */
  transition:
    transform 500ms cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 300ms ease-out;
}

.ee-terrain-popup.is-visible {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* Scrollbar styling */
.ee-terrain-popup::-webkit-scrollbar {
  width: 6px;
}
.ee-terrain-popup::-webkit-scrollbar-track {
  background: transparent;
}
.ee-terrain-popup::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}

/* Backdrop / Overlay */
.ee-terrain-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100249;
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease-out;
}

.ee-terrain-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ==========================================================================
   5.4 — Header with Navigation
   ========================================================================== */

.ee-terrain-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ee-terrain-header-left {
  flex: 1;
  min-width: 0;
}

.ee-terrain-title {
  font-family: -apple-system, 'SF Pro Display', system-ui, sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: rgba(255, 255, 255, 1.0);
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ee-terrain-subtitle {
  font-size: 13px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 2px;
}

/* Navigation Prev/Next */
.ee-terrain-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin: 0 16px;
}

.ee-terrain-nav-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 150ms ease;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}

.ee-terrain-nav-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 1.0);
}

.ee-terrain-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.ee-terrain-nav-counter {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.45);
  font-variant-numeric: tabular-nums;
  min-width: 50px;
  text-align: center;
}

/* Close Button */
.ee-terrain-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.45);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms ease;
  flex-shrink: 0;
  line-height: 1;
  padding: 0;
}

.ee-terrain-close:hover {
  background: rgba(255, 69, 58, 0.2);
  color: #ff453a;
}

/* ==========================================================================
   5.5 — SVG Container + Hover
   ========================================================================== */

.ee-terrain-svg-container {
  padding: 20px 28px;
  position: relative;
}

.ee-terrain-svg {
  width: 100%;
  height: auto;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: block;
}

/* Pole hover effect */
.ee-terrain-pole {
  transition: stroke-width 150ms ease, filter 150ms ease;
  cursor: pointer;
}

.ee-terrain-pole:hover,
.ee-terrain-pole.is-highlighted {
  stroke-width: 5 !important;
  filter: drop-shadow(0 0 8px currentColor);
}

/* Pole foot/head circles */
.ee-terrain-pole-foot,
.ee-terrain-pole-head {
  transition: r 150ms ease;
}

/* Hover tooltip */
.ee-terrain-tooltip {
  position: absolute;
  padding: 10px 14px;
  background: linear-gradient(
    165deg,
    rgba(30, 30, 40, 0.95) 0%,
    rgba(20, 20, 28, 0.98) 100%
  );
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 150ms ease, transform 150ms ease;
  z-index: 10;
  white-space: nowrap;
  font-family: -apple-system, 'SF Pro Display', system-ui, sans-serif;
}

.ee-terrain-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.ee-terrain-tooltip-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 6px;
}

.ee-terrain-tooltip-row {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.6;
}

.ee-terrain-tooltip-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 1.0);
}

/* ==========================================================================
   5.6 — Status Badges with Glow + Pulse
   ========================================================================== */

.ee-terrain-status-section {
  padding: 12px 28px 8px;
}

.ee-terrain-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  font-family: -apple-system, 'SF Pro Display', system-ui, sans-serif;
}

.ee-terrain-status-badge--ok {
  background: linear-gradient(135deg,
    rgba(48, 209, 88, 0.15) 0%,
    rgba(48, 209, 88, 0.08) 100%
  );
  border: 1px solid rgba(48, 209, 88, 0.3);
  color: var(--terrain-ok);
  box-shadow: 0 0 16px var(--terrain-ok-glow);
}

.ee-terrain-status-badge--warning {
  background: linear-gradient(135deg,
    rgba(255, 159, 10, 0.15) 0%,
    rgba(255, 159, 10, 0.08) 100%
  );
  border: 1px solid rgba(255, 159, 10, 0.3);
  color: var(--terrain-warn);
  box-shadow: 0 0 16px var(--terrain-warn-glow);
}

.ee-terrain-status-badge--error {
  background: linear-gradient(135deg,
    rgba(255, 69, 58, 0.15) 0%,
    rgba(255, 69, 58, 0.08) 100%
  );
  border: 1px solid rgba(255, 69, 58, 0.3);
  color: var(--terrain-error);
  box-shadow: 0 0 16px var(--terrain-error-glow);
}

/* Pulsating dot in badge */
.ee-terrain-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  position: relative;
  flex-shrink: 0;
}

.ee-terrain-status-badge--error .ee-terrain-status-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.4;
  animation: ee-terrain-pulse 2s ease-in-out infinite;
}

@keyframes ee-terrain-pulse {
  0%, 100% { transform: scale(1); opacity: 0.4; }
  50%      { transform: scale(1.6); opacity: 0; }
}

.ee-terrain-status-text {
  margin-left: 8px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.65);
  font-weight: 400;
}

/* ==========================================================================
   5.7 — Data Table with Sticky Header
   ========================================================================== */

.ee-terrain-table-container {
  padding: 0 28px 24px;
}

.ee-terrain-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  font-family: -apple-system, 'SF Pro Display', system-ui, sans-serif;
}

.ee-terrain-table thead th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.45);
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  user-select: none;
  transition: color 150ms ease;
  position: sticky;
  top: 0;
  background: rgba(10, 10, 15, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.ee-terrain-table thead th:hover {
  color: rgba(255, 255, 255, 0.85);
}

/* Sort indicator */
.ee-terrain-table thead th[data-sort-dir="asc"]::after {
  content: ' \2191';
}
.ee-terrain-table thead th[data-sort-dir="desc"]::after {
  content: ' \2193';
}

.ee-terrain-table tbody tr {
  transition: background 150ms ease;
}

.ee-terrain-table tbody tr:hover,
.ee-terrain-table tbody tr.is-highlighted {
  background: rgba(255, 255, 255, 0.06);
}

.ee-terrain-table tbody td {
  padding: 10px 12px;
  color: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-variant-numeric: tabular-nums;
}

/* Status dot in table */
.ee-terrain-table-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
}

.ee-terrain-table-dot--ok      { background: var(--terrain-ok); }
.ee-terrain-table-dot--warning  { background: var(--terrain-warn); }
.ee-terrain-table-dot--error    { background: var(--terrain-error); }

/* ==========================================================================
   5.8 — Sidebar Config Panel
   ========================================================================== */

.ee-terrain-config {
  padding: 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin: 12px 0;
}

/* Floating variant: REMOVED — terrain config panel is now in the toolbar/legend */

.ee-terrain-config-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ee-terrain-config-row {
  margin-bottom: 14px;
}

.ee-terrain-config-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ee-terrain-config-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.85);
}

/* Custom Range Slider (Apple-Style) */
.ee-terrain-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg,
    var(--terrain-ok) 0%,
    var(--terrain-warn) 60%,
    var(--terrain-error) 100%
  );
  outline: none;
  margin: 8px 0 4px;
}

.ee-terrain-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.ee-terrain-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

.ee-terrain-slider::-webkit-slider-thumb:active {
  transform: scale(1.05);
}

.ee-terrain-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

/* Toggle Switch */
.ee-terrain-toggle {
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: background 250ms ease, border-color 250ms ease;
  flex-shrink: 0;
}

.ee-terrain-toggle.is-active {
  background: #30d158;
  border-color: transparent;
}

.ee-terrain-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: transform 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ee-terrain-toggle.is-active .ee-terrain-toggle-knob {
  transform: translateX(18px);
}

/* Colour-scale preview */
.ee-terrain-colorscale {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg,
    var(--terrain-ok) 0%,
    #ffd60a 40%,
    var(--terrain-warn) 70%,
    var(--terrain-error) 100%
  );
  margin: 12px 0 4px;
}

.ee-terrain-colorscale-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.02em;
}

/* Config action buttons */
.ee-terrain-config-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.ee-terrain-config-btn {
  flex: 1;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 150ms ease;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.65);
  font-family: -apple-system, 'SF Pro Display', system-ui, sans-serif;
}

.ee-terrain-config-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 1.0);
}

.ee-terrain-config-btn--primary {
  background: rgba(10, 132, 255, 0.2);
  border-color: rgba(10, 132, 255, 0.3);
  color: #0a84ff;
}

.ee-terrain-config-btn--primary:hover {
  background: rgba(10, 132, 255, 0.3);
}

/* Counter badges */
.ee-terrain-counter-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  margin-left: 8px;
}

.ee-terrain-counter-badge span {
  font-variant-numeric: tabular-nums;
}

.ee-terrain-counter-badge .count-ok    { color: var(--terrain-ok); }
.ee-terrain-counter-badge .count-warn  { color: var(--terrain-warn); }
.ee-terrain-counter-badge .count-error { color: var(--terrain-error); }

/* ==========================================================================
   5.9 — Map Legend
   ========================================================================== */

.ee-terrain-legend {
  /* Flows normally inside #layerLegendContainer sidebar */
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0;

  font-family: -apple-system, 'SF Pro Display', system-ui, sans-serif;
  min-width: 200px;
}

@keyframes ee-terrain-legend-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ee-terrain-legend-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 8px;
}

.ee-terrain-legend-bar {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg,
    var(--terrain-ok),
    #ffd60a,
    var(--terrain-warn),
    var(--terrain-error)
  );
  margin-bottom: 4px;
}

.ee-terrain-legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
}

.ee-terrain-legend-stats {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.ee-terrain-legend-stat {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.ee-terrain-legend-stat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Empty/loading state */
.ee-terrain-empty {
  padding: 40px 28px;
  text-align: center;
  color: rgba(255, 255, 255, 0.45);
  font-size: 14px;
}

.ee-terrain-empty-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* ── Loading State ── */
.ee-terrain-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  color: rgba(255,255,255,0.7);
  font-size: 14px;
}

.ee-terrain-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: rgba(255,255,255,0.8);
  border-radius: 50%;
  animation: ee-terrain-spin 0.8s linear infinite;
}

@keyframes ee-terrain-spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   6.0 — Terrain Overview Button (in legend)
   ========================================================================== */

.terrain-overview-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(10, 132, 255, 0.3);
  background: rgba(10, 132, 255, 0.12);
  color: #0a84ff;
  font-size: 12px;
  font-weight: 600;
  font-family: -apple-system, 'SF Pro Display', system-ui, sans-serif;
  cursor: pointer;
  transition: all 150ms ease;
  width: 100%;
  justify-content: center;
}

.terrain-overview-btn:hover {
  background: rgba(10, 132, 255, 0.22);
  border-color: rgba(10, 132, 255, 0.5);
}

.terrain-overview-btn svg {
  flex-shrink: 0;
}

/* ==========================================================================
   6.1 — Terrain Overview Modal (Gesamtprofil)
   ========================================================================== */

.ee-terrain-overview-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100300;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: ee-terrain-overview-fadein 250ms ease-out;
}

@keyframes ee-terrain-overview-fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.ee-terrain-overview-modal {
  position: relative;
  width: 95vw;
  max-width: 95vw;
  height: 85vh;
  max-height: 85vh;
  border-radius: 20px;
  background: linear-gradient(
    165deg,
    rgba(22, 22, 34, 0.96) 0%,
    rgba(16, 16, 24, 0.98) 100%
  );
  backdrop-filter: blur(60px);
  -webkit-backdrop-filter: blur(60px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04);
  overflow: hidden;  /* KEIN Scrollen */
  display: flex;
  flex-direction: column;
  animation: ee-terrain-overview-slidein 350ms cubic-bezier(0.34, 1.3, 0.64, 1);
}

@keyframes ee-terrain-overview-slidein {
  from { opacity: 0; transform: scale(0.92) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.ee-terrain-overview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.ee-terrain-overview-title {
  font-size: 18px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
  font-family: -apple-system, 'SF Pro Display', system-ui, sans-serif;
}

.ee-terrain-overview-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.6);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms ease;
}

.ee-terrain-overview-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.9);
}

.ee-terrain-overview-summary {
  display: flex;
  gap: 16px;
  padding: 8px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.ee-terrain-overview-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-family: -apple-system, 'SF Pro Display', system-ui, sans-serif;
}

.ee-terrain-overview-stat--total { color: rgba(255, 255, 255, 0.7); }
.ee-terrain-overview-stat--ok    { color: #30d158; }
.ee-terrain-overview-stat--warn  { color: #ff9f0a; }
.ee-terrain-overview-stat--error { color: #ff453a; }

.ee-terrain-overview-stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ee-terrain-overview-body {
  flex: 1;
  min-height: 0;    /* flex-item darf schrumpfen */
  overflow: hidden;  /* KEIN Scrollen */
  padding: 8px 24px;
  display: flex;
  flex-direction: column;
}

/* Row section */
.ee-terrain-overview-row {
  margin-bottom: 20px;
}

.ee-terrain-overview-row-title {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
  font-family: -apple-system, 'SF Pro Display', system-ui, sans-serif;
}

/* Table cards grid */
.ee-terrain-overview-tables {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.ee-terrain-overview-card {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: all 150ms ease;
  font-family: -apple-system, 'SF Pro Display', system-ui, sans-serif;
}

.ee-terrain-overview-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.ee-terrain-overview-card--ok {
  border-left: 3px solid #30d158;
}

.ee-terrain-overview-card--warning {
  border-left: 3px solid #ff9f0a;
}

.ee-terrain-overview-card--error {
  border-left: 3px solid #ff453a;
}

.ee-terrain-overview-card-title {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 4px;
}

.ee-terrain-overview-card-detail {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  font-variant-numeric: tabular-nums;
}

.ee-terrain-overview-card-detail strong {
  color: rgba(255, 255, 255, 0.75);
}

/* Height profile chart */
.ee-terrain-overview-chart {
  margin-bottom: 20px;
  padding: 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.ee-terrain-overview-chart svg {
  width: 100%;
  height: auto;
  display: block;
}

.ee-terrain-overview-chart-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 4px;
  font-family: -apple-system, 'SF Pro Display', system-ui, sans-serif;
}

.ee-terrain-overview-chart-subtitle {
  font-size: 10px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.25);
  margin-bottom: 10px;
  font-family: -apple-system, 'SF Pro Display', system-ui, sans-serif;
}

/* --- Heatmap (top-down view) --- */
.ee-terrain-heatmap-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  min-height: 0;  /* flex-item darf schrumpfen */
  overflow: hidden;
}

.ee-terrain-heatmap-svg {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.15);
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
}

.ee-terrain-heatmap-tooltip {
  position: absolute;
  z-index: 100;
  background: rgba(20, 20, 30, 0.95);
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
  font-family: -apple-system, 'SF Pro Display', system-ui, sans-serif;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.12);
  pointer-events: none;
  max-width: 260px;
  white-space: nowrap;
}

.ee-terrain-table-rect rect {
  transition: fill-opacity 120ms ease, stroke-width 120ms ease;
}

.ee-terrain-overview-elev-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 24px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  font-family: -apple-system, 'SF Pro Display', system-ui, sans-serif;
  flex-shrink: 0;  /* Footer darf nicht schrumpfen */
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.ee-terrain-overview-elev-sep {
  color: rgba(255, 255, 255, 0.2);
}

.ee-terrain-overview-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 6px 24px 12px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  font-family: -apple-system, 'SF Pro Display', system-ui, sans-serif;
  flex-shrink: 0;  /* Footer darf nicht schrumpfen */
}

.ee-terrain-overview-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.ee-terrain-overview-legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

/* ==========================================================================
   5.10 — Responsive Design
   ========================================================================== */

/* Tablet (< 900px) */
@media (max-width: 900px) {
  .ee-terrain-popup {
    width: 95vw;
    max-height: 92vh;
    border-radius: 16px;
  }

  .ee-terrain-header {
    padding: 18px 20px 12px;
  }

  .ee-terrain-svg-container {
    padding: 12px 20px;
  }

  .ee-terrain-table-container {
    padding: 0 20px 20px;
  }

  .ee-terrain-table {
    font-size: 12px;
  }

  .ee-terrain-table thead th,
  .ee-terrain-table tbody td {
    padding: 8px 8px;
  }
}

/* Small tablets / large phones (< 600px) */
@media (max-width: 600px) {
  .ee-terrain-popup {
    width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    top: 0;
    left: 0;
    transform: translateY(100%);
    transition:
      transform 400ms cubic-bezier(0.34, 1.56, 0.64, 1),
      opacity 200ms ease-out;
  }

  .ee-terrain-popup.is-visible {
    transform: translateY(0);
  }

  /* Horizontal scroll for table */
  .ee-terrain-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .ee-terrain-nav-counter {
    min-width: auto;
  }

  .ee-terrain-header {
    flex-wrap: wrap;
    gap: 8px;
  }
}
