:root {
  --bg-dark: #0f172a;
  --bg-panel: rgba(15, 23, 42, 0.92);
  --border-subtle: rgba(148, 163, 184, 0.22);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #ef4444;
  --accent-hover: #dc2626;
  --accent-blue: #38bdf8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.65rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  z-index: 1000;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.badge-live {
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.brand h1 {
  font-size: 1.05rem;
  font-weight: 600;
}

.brand h1 small {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.85rem;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.control-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.control-item select {
  background: #1e293b;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
}

.checkbox-item {
  cursor: pointer;
  color: var(--text-main);
  user-select: none;
}

.btn-live-mode {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  color: #fff;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 10px rgba(239, 68, 68, 0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-live-mode:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.65);
}

.map-wrapper {
  position: relative;
  flex: 1;
  width: 100%;
}

#map {
  width: 100%;
  height: 100%;
  background: #0b1120;
}

.scene-info-card {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 310px;
  background: var(--bg-panel);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  z-index: 900;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
}

.status-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-blue);
  margin-bottom: 0.4rem;
}

.scene-info-card h2 {
  font-size: 0.98rem;
  margin-bottom: 0.6rem;
  color: #fff;
}

.meta-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
}

.meta-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.meta-list li span {
  color: var(--text-muted);
}

.meta-list li code {
  font-size: 0.72rem;
  color: #cbd5e1;
  max-width: 175px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-box {
  margin-top: 0.7rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.76rem;
  line-height: 1.35;
}

.legend-box strong {
  color: var(--accent-blue);
  display: block;
  margin-bottom: 0.2rem;
}

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

.hover-inspector-card {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  width: 340px;
  background: var(--bg-panel);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  z-index: 900;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
}

.inspector-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  margin-bottom: 0.5rem;
  color: #fff;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
}

.inspector-body {
  font-size: 0.78rem;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.inspector-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

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

.inspector-hint {
  color: var(--text-muted);
  font-style: italic;
}

.timeseries-card {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  width: 480px;
  max-width: calc(100vw - 380px);
  background: var(--bg-panel);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  z-index: 950;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
}

.timeseries-card.egms-webgl-canvas {
  mix-blend-mode: multiply;
}

.hidden {
  display: none;
}

.timeseries-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.timeseries-header strong {
  display: block;
  font-size: 0.88rem;
  color: #fff;
}

.timeseries-header small {
  font-size: 0.74rem;
  color: var(--text-muted);
}

#btnCloseChart {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 0.15rem 0.45rem;
  cursor: pointer;
}

#btnCloseChart:hover {
  color: #fff;
  border-color: #fff;
}

.chart-container {
  position: relative;
  height: 195px;
  width: 100%;
}

.timeseries-large {
  top: 4.2rem;
  left: 3.5vw;
  right: 3.5vw;
  bottom: 4.5rem;
  width: auto;
  max-width: none;
  z-index: 1500;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.45);
}

.chart-container-large {
  flex: 1;
  height: auto;
  min-height: 360px;
}

/* EGMS NL & Omstreken GPU + ML Stijlen */
.btn-secondary {
  background: #1e293b;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
}

.btn-secondary:hover {
  background: #334155;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.search-box input {
  background: #1e293b;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.34rem 0.6rem;
  font-size: 0.8rem;
  width: 235px;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  width: 310px;
  max-height: 240px;
  overflow-y: auto;
  list-style: none;
  background: #0f172a;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  margin-top: 0.3rem;
  z-index: 2000;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.65);
}

.search-results li {
  padding: 0.45rem 0.65rem;
  font-size: 0.78rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.search-results li:hover {
  background: #1e293b;
}

.search-results li small {
  color: var(--accent-blue);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.btn-collapse {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-blue);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 5px;
  padding: 0.16rem 0.45rem;
  font-size: 0.72rem;
  cursor: pointer;
}

.btn-collapse:hover {
  background: rgba(56, 189, 248, 0.28);
}

.egms-panel {
  position: absolute;
  top: 1rem;
  background: var(--bg-panel);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  z-index: 900;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.48);
}

.egms-ml-card {
  left: 1rem;
  width: 330px;
  max-height: calc(100vh - 165px);
  display: flex;
  flex-direction: column;
}

.egms-ml-card h2,
.egms-extremes-card h2 {
  font-size: 0.95rem;
  margin-bottom: 0.45rem;
  color: #fff;
}

.ml-summary {
  font-size: 0.78rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.6rem;
}

.ml-clusters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.3rem;
}

.cluster-chip {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #cbd5e1;
  font-size: 0.7rem;
  padding: 0.12rem 0.38rem;
  border-radius: 4px;
}

.anomaly-list-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--border-subtle);
}

.anomaly-list-header small {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.anomaly-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-right: 0.2rem;
}

.anomaly-item {
  background: rgba(30, 41, 59, 0.72);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.42rem 0.55rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.anomaly-item:hover {
  background: rgba(51, 65, 85, 0.95);
  border-color: var(--accent-blue);
}

.anom-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.77rem;
}

.anom-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.12rem;
}

.egms-extremes-card {
  right: 1rem;
  width: 345px;
}

.ext-subtitle {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.ext-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.ext-btn,
.ext-stat {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 0.48rem 0.55rem;
  text-align: left;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.ext-btn {
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s;
}

.ext-btn:hover {
  transform: translateY(-1px);
  border-color: #facc15;
}

.ext-btn span,
.ext-stat span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.ext-btn strong,
.ext-stat strong {
  font-size: 0.92rem;
}

.ext-btn small {
  font-size: 0.66rem;
  color: var(--accent-blue);
}

.ext-rise strong { color: #f87171; }
.ext-drop strong { color: #818cf8; }
.ext-anom strong { color: #facc15; }

.ext-nearest {
  margin-top: 0.55rem;
  font-size: 0.74rem;
  color: #cbd5e1;
}

.egms-colorbar-card {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  width: 440px;
  max-width: 90vw;
  background: var(--bg-panel);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  z-index: 900;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

.colorbar-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.74rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.cb-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--text-main);
}

.cb-input-wrap input {
  width: 56px;
  background: #1e293b;
  color: #fff;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 0.12rem 0.28rem;
  font-size: 0.74rem;
  font-weight: 600;
  text-align: right;
}

.cb-input-wrap input:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.ew-panel {
  overflow-y: auto;
  max-height: 280px;
  font-size: 0.74rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.ew-metrics {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(250, 204, 21, 0.3);
  border-radius: 6px;
  padding: 0.45rem 0.55rem;
  line-height: 1.4;
}

.ew-cluster-item {
  background: rgba(30, 41, 59, 0.78);
  border: 1px solid rgba(249, 115, 22, 0.35);
  border-radius: 6px;
  padding: 0.38rem 0.5rem;
  cursor: pointer;
}

.ew-cluster-item:hover {
  border-color: #facc15;
  background: rgba(51, 65, 85, 0.95);
}

.colorbar-gradient {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(
    to right,
    #8c00f2 0%,
    #0a5cff 17%,
    #00c7d6 34%,
    #f5f7f2 50%,
    #ff9e1c 67%,
    #eb1a1a 84%,
    #73001a 100%
  );
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.colorbar-caption {
  margin-top: 0.25rem;
  text-align: center;
  font-size: 0.69rem;
  color: var(--text-muted);
}

.egms-webgl-canvas {
  mix-blend-mode: multiply;
}

.hidden {
  display: none !important;
}

.vp-extreme-wrapper {
  background: transparent;
  border: none;
}

.vp-extreme-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.16rem 0.42rem;
  border-radius: 999px;
  white-space: nowrap;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
  border: 1.5px solid #ffffff;
  cursor: pointer;
}

.vp-extreme-badge.vp-drop {
  background: #5b21b6;
  color: #ffffff;
}

.vp-extreme-badge.vp-rise {
  background: #b91c1c;
  color: #ffffff;
}

.timeline-bar {
  background: var(--bg-panel);
  border-top: 1px solid var(--border-subtle);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  z-index: 1000;
}

.playback-buttons {
  display: flex;
  gap: 0.4rem;
}

.playback-buttons button {
  background: #1e293b;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.playback-buttons button:hover:not(:disabled) {
  background: #334155;
}

.playback-buttons button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.slider-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
}

#labelCounter {
  color: var(--text-main);
  font-weight: 600;
}

input[type="range"] {
  accent-color: var(--accent);
  cursor: pointer;
}

.layers-popup-menu {
  position: absolute;
  top: 0.6rem;
  right: 0.75rem;
  z-index: 1200;
  min-width: 245px;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.layers-popup-menu .layers-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 700;
  color: #e2e8f0;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  margin-bottom: 0.15rem;
}

.layers-popup-menu .checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: #e2e8f0;
  cursor: pointer;
  padding: 0.12rem 0;
}
