/* =========================
   DASHBOARD LAYOUT
========================= */

/* =========================
   DASHBOARD CONTAINER
========================= */

.dashboard-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 8px 0 32px;
  overflow: visible;
}

/* Tighter gap between hero intro and personas section */
.page-content > .about-hero {
  padding-bottom: 20px;
}
.page-content > .about-section {
  padding-top: 28px;
}

/* =========================
   ANALYSIS CARD (base)
========================= */

.analysis-card {
  border: 1px solid var(--border);
  background: var(--surface2);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.analysis-card:hover {
  border-color: var(--border2);
  box-shadow: 0 10px 30px rgba(0,0,0,0.06);
  transform: translateY(-2px);
}

.analysis-card.field-group-card:hover,
.analysis-card.overview-map-card:hover {
  border-color: var(--border);
  box-shadow: none;
  transform: none;
}

/* =========================
   FIELD GROUP CARD
========================= */

.field-group-card {
  cursor: default;
  position: relative;
  overflow: hidden !important;
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  background: var(--surface2);
  border-radius: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field-group-card:hover {
  border-color: var(--border);
  box-shadow: none;
  transform: none;
}

.field-group-card--scroll-target {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(95, 167, 100, 0.25);
  animation: field-scroll-highlight 4s ease forwards;
}

@keyframes field-scroll-highlight {
  0%, 85% {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(95, 167, 100, 0.25);
  }
  100% {
    border-color: var(--border);
    box-shadow: none;
  }
}

/* ── Col 1: Info ── */
.fgc-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 22px 16px 16px 20px;
}

.fgc-meta-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.fgc-count {
  margin-top: auto;
  font-size: 0.72rem;
  color: var(--text-dim);
  opacity: 0.7;
  padding-top: 6px;
}

/* ── Col 2: Chart ── */
.fgc-chart {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  padding: 8px 10px 8px 4px;
  position: relative;
  min-width: 0;
}

.fgc-sparkline {
  width: 100%;
  flex: 1;
  min-height: 130px;
  display: block;
}

/* ── Col 3: Actions ── */
.fgc-actions {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  padding: 22px 20px 16px 16px;
}

.fgc-latest {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fgc-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.fgc-latest-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
}

.fgc-latest-value {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.fgc-trend-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.fgc-trend-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.fgc-explore-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;

  background: var(--accent);
  color: var(--bg, #fff);
  border: none;

  padding: 8px 14px;
  border-radius: 8px;

  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.03em;

  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
}

.fgc-explore-btn:hover {
  opacity: 0.87;
  transform: translateY(-2px);
}

/* trend inside actions col */
.fgc-actions .field-trend {
  font-size: 0.78rem;
  font-weight: 700;
}

/* =========================
   TREND BADGES
========================= */

.field-trend {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  margin-left: 4px;
}
.trend-up   { color: #22c55e; }
.trend-down { color: #ef4444; }
.trend-flat { color: #9ca3af; }

/* =========================
   HEADER TEXT
========================= */

.analysis-title {
  font-family: var(--font-display);
  font-size: 1.0rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
  line-height: 1.3;
}

.analysis-meta {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.7;
}

/* =========================
   CARD BUTTONS ROW
========================= */

.card-btn-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

/* =========================
   BUTTONS
========================= */

.btn-primary {
  background: #C94F4F;
  color: white;
  border: none;
  padding: 0.75rem 1.2rem;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.2s;
}
.btn-primary:hover { background: #b34040; }

.btn-secondary {
  padding: 0.5rem 0.85rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.btn-secondary:hover {
  background: #f9f9f9;
  border-color: var(--accent);
  transform: translateY(-1px);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff0f0;
  color: #C94F4F;
  border: 1px solid #C94F4F;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
}
.btn-danger:hover {
  background: #C94F4F;
  color: #fff;
  transform: translateY(-2px);
}

/* End Comparison button */
.btn-end-compare {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid #C94F4F;
  background: #fff0f0;
  color: #C94F4F;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
}
.btn-end-compare:hover {
  background: #C94F4F;
  color: #fff;
  transform: translateY(-2px);
}

/* New-analysis CTA inside field modal */
.btn-new-analysis {
  font-family: var(--font-display);
  font-weight: 700; 
  font-size: 0.9rem;
  padding: 12px 28px; 
  border-radius: 8px; 
  border: none;
  background: var(--accent); 
  color: var(--bg); cursor: pointer;
  letter-spacing: 0.04em; 
  transition: opacity 0.2s;
  text-decoration: none; 
  display: inline-block;
}
.btn-new-analysis:hover {
  opacity: 0.87; 
  transform: translateY(-2px);
}

/* =========================
   ACTION BAR
========================= */

.dashboard-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-bottom: 1.5rem;
}

/* =========================
   COMPARE CHART WRAPPER
========================= */

#compare-chart-wrapper {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
}

/* =========================
   DETAIL MODAL — OVERLAY
========================= */

.detail-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 16px;
}

/* Detail (edit) modal floats above the field modal */
#detail-modal { z-index: 1000; }

/* =========================
   DETAIL MODAL — CARD
========================= */

.detail-card {
  width: min(720px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 28px;
  padding: 32px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  scrollbar-width: thin;
  scrollbar-color: #d1d5db transparent;
}

.detail-card::-webkit-scrollbar { width: 6px; }
.detail-card::-webkit-scrollbar-thumb { background: #374151; border-radius: 4px; }

/* Field modal card is a bit wider */
.field-modal-card { width: min(860px, 100%); }

/* Header */
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
}

.detail-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
}

.field-modal-meta {
  font-size: 0.83rem;
  color: #9ca3af;
  margin: 0;
  line-height: 1.5;
}

/* Input grid */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.detail-full { grid-column: 1 / -1; }

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #9ca3af;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.detail-field input,
.detail-field textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  resize: vertical;
}

.detail-field input:focus,
.detail-field textarea:focus { border-color: #C94F4F; }

.detail-field textarea { min-height: 80px; }

/* =========================
   STAT CARDS
========================= */

.detail-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}

.field-stats-grid { grid-template-columns: repeat(4, 1fr); }

.detail-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 16px;
  text-align: center;
}

.detail-stat-card span {
  font-size: 0.75rem;
  color: #9ca3af;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.detail-stat-card strong {
  display: block;
  font-size: 1.6rem;
  font-weight: 700;
  margin-top: 6px;
  color: var(--text);
}

/* =========================
   CHART WRAPPER (modals)
========================= */

.detail-chart-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 28px;
}

/* =========================
   MINI SATELLITE MAP
========================= */

.detail-map-section {
  margin-bottom: 28px;
}

.detail-map-wrapper {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  height: 320px;
  position: relative;
}

#detail-map {
  width: 100%;
  height: 100%;
}

/* Override Leaflet's default z-index so it sits below the modal stack */
.leaflet-pane         { z-index: 1 !important; }
.leaflet-top,
.leaflet-bottom       { z-index: 2 !important; }
.leaflet-control      { z-index: 3 !important; }

/* =========================
   FIELD SECTION LABELS
========================= */

.field-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ca3af;
  margin-bottom: 12px;
}

/* =========================
   ANALYSES LIST (field modal)
========================= */

.field-analyses-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 28px;
}

.field-analysis-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  flex-wrap: wrap;
  transition: border-color 0.15s;
}

.field-analysis-row-info {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.row-date {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  min-width: 96px;
}

.row-badges {
  display: flex;
  gap: 6px;
}

.badge-min,
.badge-avg,
.badge-max {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-min { background: rgba(239,68,68,0.15);  color: #ef4444; }
.badge-avg { background: rgba(245,158,11,0.15); color: #f59e0b; }
.badge-max { background: rgba(34,197,94,0.15);  color: #22c55e; }

.field-analysis-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.field-analysis-row-actions .btn-secondary,
.field-analysis-row-actions .btn-danger {
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
}

/* =========================
   DETAIL MODAL ACTIONS
========================= */

.detail-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.btn-save {
  font-family: var(--font-display);
  font-weight: 700; 
  font-size: 0.9rem;
  padding: 12px 28px; 
  border-radius: 8px; 
  border: none;
  background: var(--accent); 
  color: var(--bg); cursor: pointer;
  letter-spacing: 0.04em; 
  transition: opacity 0.2s;
  text-decoration: none; 
  display: inline-block;
}
.btn-save:hover {
  opacity: 0.87; 
  transform: translateY(-2px);
}

.btn-close-modal {
  background: #1f2937;
  color: #9ca3af;
  border: 1px solid #374151;
  padding: 0.75rem 1.4rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

/* =========================
   FILTER BAR
========================= */

.dashboard-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  margin-bottom: 8px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1 1 160px;
}

.filter-group--btn {
  flex: 0 0 auto;
  justify-content: flex-end;
}

.filter-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.filter-input,
.filter-select {
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.18s;
  width: 100%;
  box-sizing: border-box;
}

.filter-input:focus,
.filter-select:focus { 
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(95,167,100,0.10);
 }

.btn-reset {
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s, color 0.18s;
}
.btn-reset:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.filter-summary {
  font-size: 0.84rem;
  color: var(--text-dim);
  margin: 8px 0 16px;
  padding: 8px 14px;
  background: var(--surface);
  border-left: 3px solid var(--accent2);
  border-radius: 6px;
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 700px) {
  .field-group-card {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }
  .fgc-chart {
    padding: 12px 16px 10px;
  }
  .fgc-sparkline {
    min-height: 90px;
  }
  .fgc-actions {
    padding: 14px 16px;
  }
  .fgc-combined-toggle {
    grid-template-columns: 1fr;
  }
  .fgc-combined-toggle-left {
    grid-column: 1;
  }
  .fgc-toggle-trailing {
    grid-column: 1;
    padding: 8px 0 0;
    justify-content: flex-end;
  }
  .fgc-combined-toggle.open .fgc-toggle-trailing {
    justify-content: stretch;
  }
}

@media (max-width: 600px) {
  .detail-grid           { grid-template-columns: 1fr; }
  .detail-stats-grid     { grid-template-columns: 1fr 1fr; }
  .field-stats-grid      { grid-template-columns: 1fr 1fr; }
  .detail-card           { padding: 20px; }
  .dashboard-actions     { flex-direction: column; align-items: stretch; }
  .field-analysis-row    { flex-direction: column; align-items: flex-start; }
  .field-analysis-row-actions { width: 100%; justify-content: flex-start; }
  .detail-map-wrapper    { height: 220px; }
}

@media (max-width: 400px) {
  .field-stats-grid { grid-template-columns: 1fr; }
}

.btn-new-analysis {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;

  padding: 12px 28px;
  border-radius: 8px;
  border: none;

  background: var(--accent);
  color: var(--bg);

  cursor: pointer;

  letter-spacing: 0.04em;

  transition:
    opacity 0.2s,
    transform 0.2s;
}

.btn-new-analysis:hover {
  opacity: 0.87;
  transform: translateY(-2px);
}

.btn-close-modal {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;

  padding: 12px 28px;
  border-radius: 8px;

  border: 1px solid var(--border2);
  background: var(--surface);

  color: var(--text-dim);

  cursor: pointer;

  letter-spacing: 0.04em;

  transition: opacity 0.2s, transform 0.2s, border-color 0.2s, color 0.2s;
}

.btn-close-modal:hover {
  border-color: var(--border);
  color: var(--text);
  opacity: 0.87;
  transform: translateY(-2px);
}

.btn-close-modal:active {
  transform: translateY(0);
}

.btn-close-x {
  width: 32px;
  height: 32px;

  border-radius: 8px;

  border: 1px solid var(--border2);
  background: var(--surface);

  color: var(--text-dim);

  display: flex;
  align-items: center;
  justify-content: center;

  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1;

  cursor: pointer;

  transition: opacity 0.2s, transform 0.2s, border-color 0.2s, color 0.2s;
}

.btn-close-x:hover {
  border-color: var(--border);
  color: var(--text);
  opacity: 0.87;
  transform: translateY(-2px);
}

.btn-close-x:active {
  transform: translateY(0);
}

/* ========================================
   KPI SUMMARY CARDS
======================================== */

.dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 18px;

  margin-bottom: 28px;
}

.kpi-label {
  font-size: 0.72rem;

  text-transform: uppercase;
  letter-spacing: 0.08em;

  color: var(--text-dim);
}

.kpi-main {
  display: flex;
  justify-content: flex-start;
  align-items: baseline;
  gap: 6px;
  min-height: 36px;
  flex-wrap: nowrap;
}

.kpi-value {
  font-family: var(--font-display);

  font-size: 1.45rem;
  font-weight: 700;

  color: var(--text);

  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}

.kpi-link {
  font-weight: 700;
  font-size: 1.45rem;
  cursor: pointer;
  color: var(--text);
  padding: 2px 4px;
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
}

.kpi-link:hover {
  background: rgba(255,255,255,0.12);
}

.kpi-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 18px;

  padding: 16px 18px;
  height: 110px;

  display: flex;
  flex-direction: column;
  justify-content: space-between;

  overflow: visible;
}

.kpi-unit {
  font-size: 0.9rem;
  color: var(--text-dim);
  font-weight: 500;
}

.kpi-main .kpi-unit {
  font-size: 1.05rem;
}

.field-id-badge {
  position: absolute;
  top: 12px;
  right: 12px;

  font-size: 0.75rem;
  font-weight: 700;

  color: var(--text-dim);
  background: rgba(255,255,255,0.06);
  padding: 4px 8px;
  border-radius: 8px;
}

/* ONLY interactive cards */
.kpi-card--best,
.kpi-card--worst {
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

/* Hover ONLY for these 2 */
.kpi-card--best:hover,
.kpi-card--worst:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 10px 30px rgba(95,167,100,0.15);
}

/* =========================
   DASHBOARD CONTROL ROW
========================= */

.dashboard-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

/* left + right grouping */
.controls-left,
.controls-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Toolbar row: same height as Download All / Compare Fields */
.dashboard-controls .btn-filter-toggle,
.dashboard-controls .btn-secondary,
.dashboard-controls .btn-control,
.dashboard-controls .btn-end-compare {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25;
  box-sizing: border-box;
}

/* FILTER TOGGLE */
.btn-filter-toggle {
  padding: 0.5rem 0.85rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.btn-filter-toggle:hover {
  background: #f9f9f9;
  border-color: var(--accent);
  transform: translateY(-1px);
}

.btn-filter-toggle:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(95,167,100,0.10);
}

.btn-control {
  background: white;
  color: #1f2937;
  border: 1px solid rgba(0,0,0,0.08);
  padding: 10px 14px;
  border-radius: 10px;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-control:hover {
  background: #f3f4f6;
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* =========================
   TOOLTIP (data-tooltip)
========================= */

.btn-tooltip {
  position: relative;
}

.btn-tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #f9fafb;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  padding: 4px 9px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 10;
}

.btn-tooltip::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 1px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1f2937;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 10;
}

.btn-tooltip:hover::after,
.btn-tooltip:hover::before {
  opacity: 1;
}

.btn-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(95,167,100,0.10);
}

.controls-left {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
}

#filter-panel {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: 520px;
  z-index: 1000;
}

.sort-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.sort-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  min-width: 180px;
  z-index: 1000;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
}

.sort-option {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.sort-option:hover {
  background: var(--surface);
}

/* =====================================================
   OVERVIEW MAP CARD
===================================================== */
.overview-map-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

#global-overview-map {
  border: 1px solid var(--border);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

/* =========================
   OC CLASSIFICATION INFO POPUP (Dashboard)
========================= */

.save-popup {
  position: fixed;
  inset: 0;

  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);

  display: grid;
  place-items: center;
  padding:
    calc(var(--nav-h) + var(--popup-gap))
    20px
    var(--popup-gap);
  box-sizing: border-box;
  overflow: hidden;

  opacity: 0;
  pointer-events: none;

  transition: opacity 0.25s ease;

  z-index: 5000;
}

.save-popup.visible {
  opacity: 1;
  pointer-events: all;
}

.save-popup-card {
  width: 420px;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;

  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;

  box-shadow:
    0 20px 50px rgba(0,0,0,0.35),
    0 0 0 1px rgba(255,255,255,0.03);

  overflow: hidden;

  transform: translateY(20px) scale(0.98);
  transition: transform 0.25s ease;
}

.save-popup.visible .save-popup-card {
  transform: translateY(0) scale(1);
}

.save-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;

  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.save-popup-header h3 {
  margin: 0;

  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;

  color: var(--text);
}

.save-popup-content {
  padding: 20px;

  display: flex;
  flex-direction: column;
  gap: 18px;

  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Class info card specifics ── */

.class-info-card {
  width: 440px;
}

.class-info-content {
  font-size: 0.82rem;
  line-height: 1.75;
  color: var(--text-dim);
}

.class-info-note {
  margin: 0 0 14px;
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.6;
}

.class-info-tiers {
  margin: 0 0 4px;
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.class-info-tiers li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text);
  line-height: 1.4;
}

.legend-swatch {
  width: 28px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
  display: inline-block;
}

.class-info-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.class-info-meta-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.class-info-meta span:not(.class-info-meta-label) {
  font-size: 0.78rem;
  color: var(--text);
}

.class-info-meta a {
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.2s;
}

.class-info-meta a:hover {
  opacity: 0.75;
  text-decoration: underline;
}

/* ── Close button (reused from app.css pattern) ── */

.btn-close-x {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: opacity 0.2s, transform 0.2s, border-color 0.2s, color 0.2s;
}

.btn-close-x:hover {
  border-color: var(--border);
  color: var(--text);
  opacity: 0.87;
  transform: translateY(-2px);
}

.btn-close-x:active {
  transform: translateY(0);
}

/* =====================================================
   compare-toggle.css — Field Comparison Toggle Section
===================================================== */

/* ── Wrapper ─────────────────────────────────────── */

.compare-toggle-section {
  margin-bottom: 24px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}

/* ── Header / Toggle button ──────────────────────── */

.compare-toggle-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;

  padding: 16px 20px;

  background: transparent;
  border: none;
  cursor: pointer;

  text-align: left;
  transition: background 0.18s ease;
}

.compare-toggle-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.compare-toggle-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text);
  flex-shrink: 0;
}

.compare-toggle-meta {
  flex: 1;
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compare-toggle-chevron {
  font-size: 0.82rem;
  color: var(--text-dim);
  flex-shrink: 0;
  transition: transform 0.2s ease;
  line-height: 1;
}

/* ── Body (collapsed by default) ─────────────────── */

.compare-toggle-body {
  display: none;
  flex-direction: column;
  gap: 16px;

  padding: 0 20px 20px;

  border-top: 1px solid var(--border);
}

.compare-toggle-body.open {
  display: flex;
  overflow: visible;
}

/* ── Selected fields bar ─────────────────────────── */

.compare-fields-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 32px;
  align-items: center;
  padding-top: 16px;
}

.compare-fields-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ── Field chips ─────────────────────────────────── */

.compare-field-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  padding: 4px 10px 4px 12px;

  border-radius: 999px;
  border: 1px solid var(--border2);
  background: var(--bg);

  font-size: 0.75rem;
  color: var(--text);
  font-family: var(--font-data);

  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compare-chip-remove {
  flex-shrink: 0;
  width: 16px;
  height: 16px;

  border: none;
  background: transparent;
  color: var(--text-dim);

  font-size: 0.65rem;
  line-height: 1;
  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;
  padding: 0;

  transition: background 0.15s, color 0.15s;
}

.compare-chip-remove:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* ── Chart area ──────────────────────────────────── */

.compare-chart-inner {
  width: 100%;
  position: relative;
  overflow: visible;
}

.compare-chart-inner canvas {
  width: 100% !important;
  height: 340px !important;
  display: block;
}

/* ── Compact checkbox on field cards ─────────────── */

.compare-label-compact {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  font-size: 0.75rem;
  color: var(--text-dim);
  transition: color 0.15s;
}

.compare-label-compact:hover {
  color: var(--text);
}

.compare-label-compact input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.compare-label-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

/* ── Hidden / toggled-off chip state ─────────────── */

.compare-field-chip {
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}

.compare-field-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.compare-field-chip--off {
  opacity: 0.35;
  text-decoration: line-through;
  border-color: var(--border);
}

.compare-field-chip--off:hover {
  opacity: 0.65;
  text-decoration: none;
  color: var(--text);
  border-color: var(--border2);
}

/* ── 3-Spalten Hauptbereich ── */
.fgc-main {
  display: grid;
  grid-template-columns: 1fr 1.5fr 0.85fr;
  gap: 0;
  padding: 20px;
  align-items: stretch;
  min-height: 160px;
  flex-shrink: 0;
}

/* Toggle: volle Breite, kein negativer Margin nötig */
.fgc-analyses-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 20px;
  background: transparent;
  border: none;
  border-top: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  width: 100%;
  box-sizing: border-box;
  border-radius: 0 0 var(--radius, 12px) var(--radius, 12px);
}

.fgc-analyses-toggle:hover {
  background: rgba(255,255,255,0.03);
}

.fgc-analyses-toggle.open {
  border-radius: 0;
}

.fgc-analyses-toggle-label {
  font-family: var(--font-data);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.fgc-analyses-chevron {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1;
}

/* Body: volle Breite */
.fgc-analyses-body {
  display: none;
  flex-direction: column;
  width: 100%;
  border-radius: 0 0 var(--radius, 12px) var(--radius, 12px);
  overflow: hidden;
}

.fgc-analyses-body.open {
  display: flex;
}

.fgc-analyses-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  transition: background 0.12s;
}

.fgc-analyses-row:hover {
  background: rgba(255,255,255,0.02);
}

.fgc-analyses-row-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.fgc-analyses-row-right {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* =====================================================
   FGC Combined Toggle + Body
===================================================== */

/* ── Toggle: volle Breite, nach unten ── */
.fgc-combined-toggle {
  display: grid;
  grid-template-columns: 1fr 1.5fr 0.85fr;
  align-items: center;
  gap: 0;
  width: 100%;
  padding: 11px 20px;
  background: transparent;
  border: none;
  border-top: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  font-family: var(--font-data);
  font-size: 0.75rem;
  color: var(--text-dim);
  border-radius: 0 0 16px 16px;
  box-sizing: border-box;
}

.fgc-combined-toggle-left {
  grid-column: 1 / 3;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.fgc-toggle-trailing {
  grid-column: 3;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 20px 0 16px;
  box-sizing: border-box;
  min-width: 0;
}

.fgc-combined-toggle.open .fgc-toggle-trailing {
  justify-content: flex-start;
  padding-top: 6px;
}

.fgc-combined-toggle:hover {
  background: rgba(255,255,255,0.03);
}

.fgc-combined-toggle.open {
  border-radius: 0;
}

.fgc-combined-toggle-sep {
  color: var(--border2);
}

.fgc-events-count-label {
  flex: 1;
  text-align: left;
  min-width: 0;
}

.fgc-toggle-hint {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
}

.fgc-combined-toggle.open .fgc-toggle-hint {
  display: none;
}

.fgc-field-download-btn {
  display: none;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25;
  box-sizing: border-box;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.fgc-field-download-btn:hover {
  background: #f3f4f6;
  border-color: var(--accent);
  transform: translateY(-1px);
}

.fgc-combined-toggle.open .fgc-field-download-btn {
  display: inline-flex;
  margin-top: 20px;
}

.fgc-analyses-chevron {
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1;
}

/* ── Combined body: einspaltig, Analysen dann Events ── */
.fgc-combined-body {
  display: none;
  width: 100%;
  position: static;
  border-top: none;
  border-radius: 0 0 16px 16px;
  overflow: hidden;
  flex-direction: column;
  max-height: 0;
  transition: max-height 0.25s ease;
}

.fgc-combined-body.open {
  display: flex;
  max-height: 700px;
  overflow-y: auto;
}

.fgc-section-header {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 10px 20px 6px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}

.fgc-section-header:first-child {
  border-top: none;
  border-bottom: none;
  background: transparent;
  padding-top: 8px;
}

.fgc-section-header--events {
  margin-top: 0;
  border-top: 1px solid var(--border);
}

.fgc-analysis-row:has(+ .fgc-section-header--events) {
  border-bottom: none;
}

/* Einheitliche Listenzeilen */
.fgc-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  line-height: 1.4;
  transition: background 0.12s;
}

.fgc-list-row:last-child {
  border-bottom: none;
}

.fgc-list-row:hover {
  background: rgba(255,255,255,0.02);
}

.fgc-list-row-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
  flex: 1;
}

.fgc-list-date {
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--text-dim);
  flex-shrink: 0;
  min-width: 88px;
}

.fgc-list-meta {
  color: var(--text);
  font-size: 0.82rem;
}

.fgc-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
}

.fgc-row-actions .btn-secondary,
.fgc-row-actions .btn-danger {
  padding: 4px 10px;
  font-size: 0.78rem;
}

.fgc-combined-body .row-badges {
  display: flex;
  gap: 6px;
}

/* Events-Liste */
.fgc-events-list {
  display: flex;
  flex-direction: column;
}

.fgc-event-delete-btn {
  flex-shrink: 0;
  padding: 4px 10px;
  font-size: 0.78rem;
  border-radius: 6px;
  line-height: 1;
}
.event-list-empty,
.event-list-loading {
  font-size: 0.82rem;
  color: var(--text-dim);
  padding: 16px 20px;
  text-align: center;
  margin: 0;
}

/* ── Add Event button ── */
.fgc-add-event-btn {
  width: 100%;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s, background 0.18s, transform 0.15s;
  white-space: nowrap;
  text-align: center;
}

.fgc-add-event-btn:hover {
  border-color: var(--border);
  color: var(--text);
  background: rgba(255,255,255,0.03);
  transform: translateY(-1px);
}

.event-modal-card {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.event-modal-card .detail-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 16px;
  margin: 0;
}

/* ── Event modal form fixes ── */
.event-form-date {
  flex: 0 0 160px !important;
  min-width: 160px !important;
}

.event-form-date input[type="date"] {
  width: 100%;
  min-width: 150px;
  box-sizing: border-box;
}

.event-form-type {
  flex: 0 0 160px !important;
  min-width: 160px !important;
}

.event-form-type select {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  cursor: pointer;
}

.event-form-type select:focus {
  border-color: var(--accent);
}

/* ── Add button aligned to bottom of form row ── */
.event-form-row {
  display: flex;
  align-items: flex-end;   /* ← aligns button to bottom of inputs */
  gap: 12px;
  flex-wrap: wrap;
}

.event-add-btn {
  flex-shrink: 0;
  align-self: flex-end;    /* ← extra safety */
  margin-bottom: 0;
  white-space: nowrap;
}

/* Round info button — matches analysis page legend info */
.btn-class-info {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text-dim);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.72rem;
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  flex-shrink: 0;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.btn-class-info:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(74, 222, 128, 0.06);
}

.fgc-latest-label .btn-class-info {
  margin-left: 4px;
}

/* Alten CSS-Tooltip deaktivieren */
.som-info-tooltip { display: none !important; }
.fgc-latest-label { position: static; }

.fgc-latest-value--split {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fgc-split-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.fgc-split-label {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  min-width: 44px;
}