body {
  margin: 0;
  background: #0b0b0b;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
               Roboto, Helvetica, Arial, sans-serif;

  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ---- HERO ---- */

.hero {
  position: relative;
  padding: 22px 16px 10px;
  display: flex;
  flex-direction: column;
  background: none;   /* ❗ BELANGRIJK */
}

.hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 180px;

  background: radial-gradient(
    1200px 500px at 50% -60%,
    #2f89ff 0%,
    #0b0b0b 40%
  );

  z-index: 0;
}

.hero > * {
  position: relative;
  z-index: 1;
}



.vBlue { color: rgba(80,200,255,1); }

.heroTopRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1 {
  font-size: 2.1rem;
  margin: 0;
  letter-spacing: -0.5px;
}

.rangeLabel {
  font-size: 0.95rem;
  color: #cfd8e3;
  opacity: 0.95;
  margin-top: 6px;
}

.heroIllustration {
  margin: 12px 0 10px;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.heroIllustration * {
  pointer-events: none !important;
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
  padding-bottom: 10px;
}

.metric {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 10px 12px;
  backdrop-filter: blur(6px);
}

.metric span {
  display: block;
  font-size: 0.85rem;
  color: #cfd8e3;
  opacity: 0.9;
}

.metric strong {
  display: block;
  margin-top: 3px;
  font-size: 1.45rem;
  letter-spacing: -0.3px;
}

/* ---- CARDS ---- */

.cards {
  padding: 8px 12px 90px;
}

.card {
  background: #151515;
  border: 1px solid #1f1f1f;
  border-radius: 18px;
  padding: 12px;
  margin: 10px 4px 14px;
}

.card h2,
.card h3 {
  margin: 4px 4px 10px;
  font-size: 1.05rem;
  font-weight: 650;
  color: #eef2f7;
}

.cards canvas {
  width: 100% !important;
  height: 220px !important;
}


/* ===== EMS VARIANT ===== */
.ems-card {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 10px 12px;
  backdrop-filter: blur(6px);
  min-width: 0;
  overflow-wrap: break-word;
  /*overflow-wrap: anywhere;*/

}

.emsMetrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
  padding-bottom: 10px;
}

/* ===== EMS CARD LAYOUT ===== */

.emsCards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 10px 12px 90px;
}

.main-value {
  font-size:24px;
  font-weight: bold;
  margin-bottom: 6px;
  margin: 6px 0 10px;
}

.row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}



.pill {
  padding: 6px 10px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
}

/* ON / OFF (device state) */
.on {
  background: #123d2c;
  color: #32ff9c;
}

.off {
  background: #3d1b1b;
  color: #ff7b7b;
}

/* target */
.target {
  background: #1b2f55;
  color: #7bb7ff;
}

/* MODE basis */
.mode {}

/* ✅ specifiek per mode */

.mode-smart {
  background: #123d2c;
  color: #32ff9c;
}

/* uncontrolled */
.mode-uncontrolled {
  background: #3d2f1b;
  color: #ffd27b;
}


/* manual ON */
.mode-on {
  background: #123d2c;
  color: #32ff9c;
}

/* manual OFF */
.mode-off {
  background: #3d1b1b;
  color: #ff7b7b;
}

/* fallback */
.mode-default {
  background: #3d2f1b;
  color: #ffd27b;
}




.meta {
  font-size: 11px;
  margin-top: 8px;
}

.meta-row {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 8px;
  margin-top: 4px;
}

.meta-label {
  opacity: 0.6;
}

.meta-value {
  opacity: 0.9;
}




/* ---- TIMEBAR ---- */
.timebarWrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(8px + env(safe-area-inset-bottom));

  background: rgba(10,10,10,0.92);
  border-top: 1px solid rgba(255,255,255,0.10);
  backdrop-filter: blur(8px);

  padding: 10px 10px 12px;
  z-index: 1000;
}

.timebarRow {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 8px;
  align-items: center;
}

.navBtn {
  height: 40px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: #fff;
  font-size: 1.35rem;
  cursor: pointer;
}

.rangeBtns {
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.rangeBtns button {
  flex: 1;
  height: 40px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
}

.rangeBtns button.active {
  background: #2f89ff;
  border-color: rgba(47,137,255,0.65);
}

/* ---------- OVERLAY ---------- */
/* ===== OVERLAYS (algemeen) ===== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  overscroll-behavior: contain;

  /* 100% dicht: niks erachter zichtbaar */
  background: #0b0b0b;
  backdrop-filter: none;

  /* iOS: voorkom “rubber band” die achtergrond laat zien */
  overscroll-behavior: contain;
}

.overlay.show { display: flex; }

/* Binnencontainer */
.overlayInner {
  width: 100%;
  height: 100%;
  min-height: 0;

  display: flex;
  flex-direction: column;

  /* safe areas */
  padding-top: max(16px, env(safe-area-inset-top));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));

  /* belangrijk: geen background bleed */
  background: #0b0b0b;
  overflow: hidden;
}

/* Specifiek: chart overlay full height */
#chartOverlay { height: 100dvh; width: 100vw; }
#settingsOverlay { height: 100dvh; width: 100vw; }

/* Chart wrapper vult resterende hoogte */
.overlayCanvasWrap {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Canvas vult wrapper */
#overlayCanvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Readout / title */
.overlayReadout { margin: 10px 0 10px; min-height: 1.2em; }
#overlayTitle { margin: 0 0 6px; }

/* Close button */
.overlayClose {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));

  width: 36px;
  height: 36px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 10px;

  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);

  border: 1px solid rgba(255, 255, 255, 0.12);

  color: rgba(255, 255, 255, 0.9);
  font-size: 18px;
  line-height: 1;

  cursor: pointer;
  z-index: 10;

  transition: all 0.2s ease;
}
















/* BELPEX */




.belpex-current {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.85;

  display: flex;
  align-items: center;
  gap: 4px;
}

 .card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.device-name {
  font-size: 14px;
  font-weight: 700;
}

.priority {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 14px;
  background: #223a55;
}


  


.belpex-current.positive {
  color: #a855f7;
}

.belpex-current.negative {
  color: #22c55e;
}

.belpex-current.hidden {
  display: none;
}

.belpex-unit {
  font-size: 11px;
  margin-left: 4px;
  opacity: 0.9;
}

/* METRIC */
.metric span {
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: normal;
}

.metric .metric-ts {
  font-size: 0.75em;
  opacity: 0.7;
  font-weight: 400;
}

/* COLORS */
.vPurple { color: #b366ff; }
.vGreen  { color: #4cff4c; }
.vGray   { color: #aaa; }

/* INPUT FIX */
input, textarea, select {
  -webkit-user-select: auto;
  user-select: auto;
  -webkit-touch-callout: default;
}

.settingsBtn {
  position: absolute;
  top: 16px;
  right: 16px;

  width: 28px;
  height: 28px;

  display: flex;
  align-items: center;
  justify-content: center;

  background: none;
  border: none;
  padding: 0;

  cursor: pointer;

  opacity: 0.85;
  transition: all 0.15s ease;
  /*z-index: 99999;*/
}

.settingsIcon {
  width: 20px;
  height: 20px;

  stroke: rgba(255,255,255,0.8);
  stroke-width: 1.6;
  fill: none;
  display: block;
  pointer-events: none;
}



.settingsBtn:active {
  transform: scale(0.9);
}


.settingsBtn:hover .settingsIcon {
  opacity: 1;
}


.metricsWrap {
  position: relative;
}

/* BELPEX zwevend boven de rechter tile */
.belpexFloating {
  position: absolute;
  top: -14px;     /* 👈 bepaalt hoe hoog boven de box */
  right: 6px;     /* 👈 aligned met rechter metric */

  font-size: 13px;
  font-weight: 600;

  display: flex;
  align-items: center;
  gap: 4px;

  z-index: 5;
}

.settingsSection {
  margin-top: 18px;
}

.settingsSection h3 {
  margin: 12px 0 8px;
  font-size: 0.95rem;
  color: #cfd8e3;
}

.settingsSection label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.settingsSection input {
  width: 100%;
  margin-top: 4px;
  padding: 8px;
  border-radius: 8px;
  border: none;
  background: #222;
  color: #fff;
}




.settingRow {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.settingKey {
  font-size: 0.9rem;
  color: #cfd8e3;
  word-break: break-all;
}

.settingInput {
  padding: 8px;
  border-radius: 8px;
  border: none;
  background: #222;
  color: #fff;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;

}

textarea.settingInput {
  resize: vertical;
  min-height: 60px;
  font-family: monospace;   /* 👈 ideaal voor JSON */

  /* ✅ breekt lange JSON lijnen */
  white-space: pre-wrap;
  word-break: break-word;

}


@media (max-width: 768px) {
  .settingRow {
    grid-template-columns: 1fr;
  }
}

.settingRow > * {
  min-width: 0;
}

#saveSettings {
  flex-shrink: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 100%;
  margin-top: 10px;
  padding: 14px;

  background: #2f89ff;
  border-radius: 12px;
  border: none;

  color: #fff;
  font-size: 1rem;

  margin-bottom: calc(28px + env(safe-area-inset-bottom));
}



#settingsContainer {
  flex: 1;
  overflow-y: auto;

  padding-bottom: calc(60px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}

.saveToast {
  position: fixed;
  left: 50%;
  bottom: 100px;
  transform: translateX(-50%) translateY(20px);

  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;

  font-size: 0.9rem;

  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

.saveToast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}


::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
}






#chartOverlay.show {
  display: flex;
}

/* Panel binnenin (kolom layout) */
#chartOverlay .overlayPanel {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;

  /* cruciaal: laat flex children correct schalen */
  min-height: 0;
}



#overlayReadout {
  margin: 0 0 10px 0;
}

/* Chart wrapper moet de resterende ruimte krijgen */
#overlayChartWrap {
  position: relative;     /* Chart.js verwacht dit vaak */
  flex: 1 1 auto;
  min-height: 0;          /* SUPER belangrijk in flex kolom */
}



/* Close knop blijft klikbaar */
#overlayClose {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 2;
}





/* ===== OVERLAY FULLSCREEN ===== */


#chartOverlay.show {
  display: flex;
}


html.overlay-open,
body.overlay-open {
  overflow: hidden;
}


/* --click on tiles ems-- */
.history-panel {
  position: fixed;
  right: 0;
  top: 0;
  width: 360px;
  height: 100%;
  background: #111;
  color: white;
  padding: 15px;
  overflow-y: auto;
  border-left: 1px solid #333;
  z-index: 999;
}

.hidden {
  display: none;
}

.history-item {
  border-bottom: 1px solid #333;
  padding: 10px 0;
}

.history-reason {
  font-size: 12px;
  color: #aaa;
}
.history-action {
  font-size: 12px;
  color: #aaa;
}
.history-time {
  font-size: 12px;
  color: #aaa;
}

.history-bucket {
  font-size: 12px;
  color: #aaa;
}

.history-final {
  font-size: 16px;
  color: #4caf50;
  text-transform: capitalize;
}
/* --Json Presentatie in index.html settings-- */
.jsonList {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.jsonRow {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: nowrap;
}


.jsonRow .settingInput {
  flex: 1;
  min-width: 0;  
}



.jsonRemove {
  background: #5a1a1a;
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}



.jsonAdd {
  margin-top: 10px;
  align-self: flex-start;
  background: #222;
  border: 1px solid #444;
  color: white;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 6px;
}


.jsonArrow {
  display: flex;
  align-items: center;
  opacity: 0.6;
}


.settingsGroupHeader {
  font-weight: 600;
  padding: 10px;
  margin-top: 10px;
  border-radius: 8px;
  background: #1a1a1a;
  cursor: pointer;
  user-select: none;
}

.settingsGroupHeader:hover {
  background: #2a2a2a;
}

.settingsGroupContent {
  margin-top: 5px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}



