* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0f1220; color: #e8eaf2;
  display: flex; flex-direction: column;
  overscroll-behavior: none; touch-action: manipulation;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

/* ---------- login ---------- */
#login { flex: 1; display: flex; align-items: center; justify-content: center; }
.login-box { text-align: center; width: min(320px, 85vw); }
.login-logo { font-size: 56px; }
.login-box h1 { margin: 8px 0 24px; font-weight: 600; letter-spacing: 1px; }
.login-box input {
  width: 100%; padding: 14px 16px; border-radius: 14px; border: 1px solid #2a2f4a;
  background: #181c30; color: #fff; font-size: 17px; margin-bottom: 12px; outline: none;
}
.login-box input:focus { border-color: #5b8cff; }
.login-box button {
  width: 100%; padding: 14px; border-radius: 14px; border: 0;
  background: #5b8cff; color: #fff; font-size: 17px; font-weight: 600; cursor: pointer;
}
#loginMsg { margin-top: 12px; color: #ff7b7b; min-height: 1.2em; }

/* ---------- header ---------- */
#topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: #141830; border-bottom: 1px solid #232847;
}
#title { font-weight: 700; font-size: 17px; }
#totaal { margin-left: auto; color: #8fd18f; font-variant-numeric: tabular-nums; font-size: 14px; }
#topbar button {
  border: 0; background: #232847; color: #fff; border-radius: 10px;
  width: 38px; height: 38px; font-size: 17px; cursor: pointer;
}
#topbar button.actief { background: #5b8cff; }

/* ---------- edit-werkbalk ---------- */
#editTools {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px;
  background: #1a1f38; border-bottom: 1px solid #232847; font-size: 14px;
}
#editTools button {
  border: 0; border-radius: 10px; padding: 8px 12px; font-size: 14px;
  background: #232847; color: #fff; cursor: pointer;
}
#editTools #saveBtn { background: #2f9e5f; margin-left: auto; font-weight: 600; }
#editTools #delBtn { background: #a33; }
#editTools button.actief { background: #5b8cff; }
#editHint { color: #8b91b3; font-size: 12px; }

/* ---------- view-schakelaar (eigen balk onder de kop) ---------- */
#viewSwitch {
  display: flex; gap: 6px; padding: 8px 14px;
  background: #141830; border-bottom: 1px solid #232847;
}
#viewSwitch button {
  flex: 1; border: 0; background: #232847; color: #aab0d0; border-radius: 10px;
  padding: 10px 0; font-size: 15px; font-weight: 600; cursor: pointer;
}
#viewSwitch button.actief { background: #5b8cff; color: #fff; }

/* ---------- kamerweergave ---------- */
#rooms-wrap { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; -webkit-overflow-scrolling: touch; }
.room-card { margin-bottom: 18px; }
.room-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.room-head h2 { font-size: 17px; font-weight: 700; }
.room-head .room-meta { color: #8b91b3; font-size: 13px; }
.room-head .room-actions { margin-left: auto; display: flex; gap: 6px; }
.room-head .room-actions button {
  border: 0; border-radius: 9px; padding: 7px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
  background: #232847; color: #cfd4ee;
}
.room-head .room-actions button.aan { background: #ffd957; color: #1a1a06; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.tile {
  background: #181c30; border: 1px solid #2a2f4a; border-radius: 16px;
  padding: 14px 10px 12px; text-align: center; cursor: pointer; position: relative;
  transition: background .12s, border-color .12s; user-select: none;
}
.tile.aan { background: #2a2710; border-color: #ffd957; }
.tile.offline { opacity: .45; }
.tile .ic { font-size: 30px; line-height: 1; }
.tile .nm { font-size: 12px; color: #d4d8f0; margin-top: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .st { font-size: 11px; margin-top: 3px; min-height: 14px; }
.tile.aan .st { color: #ffd957; }
.tile .st.watt { color: #8fd18f; }
.tile.uit-kleur .st { color: #8b91b3; }
.room-empty { color: #8b91b3; font-size: 13px; padding: 4px 0 8px; }

/* ---------- plattegrond ---------- */
#plan-wrap { flex: 1; min-height: 0; display: flex; }
#plan { flex: 1; width: 100%; height: 100%; touch-action: none; }
.kamer { fill: #1b2140; stroke: #39406b; stroke-width: 2; rx: 12; }
.kamer.geselecteerd { stroke: #5b8cff; stroke-width: 3; }
.kamernaam { fill: #707699; font-size: 20px; font-weight: 600; pointer-events: none; user-select: none; }
.dev-hit { fill: transparent; cursor: pointer; }
.dev-icoon { font-size: 30px; pointer-events: none; user-select: none; }
.dev-naam { fill: #aab0d0; font-size: 12px; text-anchor: middle; pointer-events: none; user-select: none; }
.dev-watt { fill: #8fd18f; font-size: 11px; text-anchor: middle; pointer-events: none; }
.dev-ring { fill: #181c30; stroke: #2a2f4a; stroke-width: 2; }
.dev-ring.aan { fill: #3a3413; stroke: #ffd957; }
.dev-ring.geselecteerd { stroke: #5b8cff; stroke-width: 3; }
.dev-ring.offline { opacity: .4; }
.resize-handle { fill: #5b8cff; cursor: nwse-resize; }

/* ---------- lade ---------- */
#tray { background: #141830; border-top: 1px solid #232847; padding: 8px 12px; max-height: 130px; }
#trayTitle { font-size: 12px; color: #8b91b3; margin-bottom: 6px; }
#trayItems { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.tray-item {
  flex: 0 0 auto; width: 72px; text-align: center; background: #1b2140;
  border: 1px solid #2a2f4a; border-radius: 12px; padding: 8px 4px; cursor: pointer; font-size: 24px;
}
.tray-item.actief { border-color: #5b8cff; background: #232c55; }
.tray-item small { display: block; font-size: 10px; color: #aab0d0; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- bottom sheet ---------- */
#overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 8; }
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9;
  background: #1a1f38; border-radius: 22px 22px 0 0; padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(0,0,0,.5);
}
#sheetHandle { width: 44px; height: 5px; border-radius: 3px; background: #39406b; margin: 4px auto 14px; }
#sheetTitle { font-size: 18px; font-weight: 700; margin-bottom: 14px; }
#sheetBody .rij { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
#sheetBody .rij label { width: 90px; color: #8b91b3; font-size: 14px; }
#sheetBody input[type=range] { flex: 1; accent-color: #ffd957; height: 30px; }
.knop {
  border: 0; border-radius: 12px; padding: 12px 18px; font-size: 15px; font-weight: 600;
  background: #232847; color: #fff; cursor: pointer;
}
.knop.aan { background: #ffd957; color: #1a1a06; }
.kleur-rij { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 38px; height: 38px; border-radius: 50%; border: 2px solid #2a2f4a; cursor: pointer; }
.watt-groot { font-size: 26px; color: #8fd18f; font-variant-numeric: tabular-nums; }
/* ---------- aankomst-paneel ---------- */
#geoPanel {
  position: fixed; inset: 0; z-index: 20; background: #0f1220;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.geo-head {
  display: flex; align-items: center; padding: 14px 16px; font-size: 17px; font-weight: 700;
  background: #141830; border-bottom: 1px solid #232847;
}
.geo-head button { margin-left: auto; background: #232847; color: #fff; border: 0; border-radius: 10px; width: 36px; height: 36px; font-size: 16px; cursor: pointer; }
.geo-body { flex: 1; overflow-y: auto; padding: 18px 16px 40px; -webkit-overflow-scrolling: touch; }
.geo-toggle { display: flex; align-items: center; gap: 12px; font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.geo-toggle input { width: 22px; height: 22px; accent-color: #5b8cff; }
.geo-uitleg { color: #8b91b3; font-size: 13px; line-height: 1.4; margin-bottom: 18px; }
.geo-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-top: 1px solid #232847; }
.geo-val { color: #aab0d0; font-size: 14px; }
.geo-slider { margin: 16px 0; }
.geo-slider label { display: flex; justify-content: space-between; font-size: 14px; color: #cfd4ee; margin-bottom: 8px; }
.geo-slider b { color: #5b8cff; }
.geo-slider input { width: 100%; accent-color: #5b8cff; height: 28px; }
.geo-sub { margin: 20px 0 10px; font-size: 13px; color: #8b91b3; text-transform: uppercase; letter-spacing: 1px; }
.geo-devs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.geo-devs label {
  display: flex; align-items: center; gap: 8px; background: #181c30; border: 1px solid #2a2f4a;
  border-radius: 12px; padding: 10px 12px; font-size: 14px; cursor: pointer;
}
.geo-devs label.aan { border-color: #5b8cff; background: #1d2547; }
.geo-devs input { width: 18px; height: 18px; accent-color: #5b8cff; flex: 0 0 auto; }
.geo-devs .gn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.geo-knop { width: 100%; border: 0; border-radius: 12px; padding: 13px; font-size: 15px; font-weight: 600; background: #232847; color: #fff; cursor: pointer; margin-top: 12px; }
.geo-knop.primair { background: #2f9e5f; }
.geo-status { margin: 18px 0 4px; color: #8b91b3; font-size: 13px; line-height: 1.5; white-space: pre-line; }

.hidden { display: none !important; }
