/* Thuis — rustig grijsgroen canvas, witte kaarten, één diepgroene accentkaart per rij */
:root {
  color-scheme: light;
  --bg: #EEF0EC;
  --surface: #FFFFFF;
  --surface-2: #F5F6F3;
  --ink: #121A15;
  --ink-soft: #6A736D;
  --line: #E3E6E0;
  --g900: #0E3B27;
  --g700: #17633F;
  --g500: #2E8B57;
  --g300: #9ED6B4;
  --g100: #E4F2E9;
  --hatch: #A3ABA5;
  --track: #EEF0EC;
  --heat: #D9692A;
  --heat-soft: #FBE8DA;
  --cool: #2479B5;
  --cool-soft: #E1EEF8;
  --danger: #C0432F;
  --focus: #2E8B57;
  --on-dark: #F2F7F3;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0C110E; --surface: #151C18; --surface-2: #1C2520; --ink: #E7EDE9; --ink-soft: #93A098;
    --line: #26302A; --g700: #2F8A5B; --g500: #3FA36E; --g300: #2D6447; --g100: #1B3326;
    --hatch: #56625B; --track: #1C2520; --heat: #F0904C; --heat-soft: #3A2617; --cool: #5AB0E6;
    --cool-soft: #16293A; --danger: #E8735F; --focus: #3FA36E;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0C110E; --surface: #151C18; --surface-2: #1C2520; --ink: #E7EDE9; --ink-soft: #93A098;
  --line: #26302A; --g700: #2F8A5B; --g500: #3FA36E; --g300: #2D6447; --g100: #1B3326;
  --hatch: #56625B; --track: #1C2520; --heat: #F0904C; --heat-soft: #3A2617; --cool: #5AB0E6;
  --cool-soft: #16293A; --danger: #E8735F; --focus: #3FA36E;
}

:root {
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: inherit; }
html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0; min-height: 100%; background: var(--bg); color: var(--ink);
  font: 15px/1.5 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { touch-action: manipulation; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.3rem); font-weight: 600; line-height: 1.1; }
h2 { font-size: 1.02rem; font-weight: 600; }
.muted { color: var(--ink-soft); margin: 0; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Opbouw ---------- */
.shell { display: grid; grid-template-columns: 1fr; min-height: 100%; padding: 14px 14px 96px; gap: 14px; }
.side { display: none; }
.main { min-width: 0; }
@media (min-width: 980px) {
  .shell { grid-template-columns: 236px minmax(0, 1fr); padding: 18px; gap: 18px; }
  .side {
    display: flex; flex-direction: column; gap: 22px; position: sticky; top: 18px;
    height: calc(100vh - 36px); background: var(--surface); border-radius: 26px; padding: 24px 16px;
  }
  .tabbar { display: none !important; }
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.2rem; padding: 0 8px; }
.logo { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--g700); color: #fff; }
.menu { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.menu a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px;
  color: var(--ink-soft); text-decoration: none; font-weight: 500; position: relative;
}
.menu a:hover { background: var(--surface-2); color: var(--ink); }
.menu a[aria-current="page"] { color: var(--ink); font-weight: 600; background: var(--g100); }
.menu a[aria-current="page"]::before {
  content: ""; position: absolute; left: -16px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--g700);
}
.weather-card {
  margin-top: auto; border-radius: 20px; padding: 18px; color: var(--on-dark);
  display: flex; flex-direction: column; gap: 2px;
  background:
    repeating-radial-gradient(circle at 110% -10%, rgba(255,255,255,.07) 0 1px, transparent 1px 14px),
    linear-gradient(150deg, var(--g700), var(--g900));
}
.weather-card .w-temp { font-size: 2.2rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.muted-on-dark { opacity: .75; font-size: .9rem; }
.logout { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: none; background: none; color: var(--ink-soft); border-radius: 14px; }
.logout:hover { background: var(--surface-2); color: var(--ink); }

/* Tabbalk op telefoon */
.tabbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border-radius: 22px;
  padding: 6px; box-shadow: 0 8px 30px rgba(10, 30, 20, .14);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 16px;
  color: var(--ink-soft); text-decoration: none; font-size: .74rem; font-weight: 500;
}
.tabbar a[aria-current="page"] { background: var(--g100); color: var(--g700); font-weight: 600; }

/* Kop van de pagina */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px 20px; flex-wrap: wrap; margin: 10px 4px 22px; }
.page-head .muted { margin-top: 6px; }
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.status { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: .9rem; background: var(--surface); border-radius: 999px; padding: 8px 14px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-soft); }
.dot.ok { background: var(--g500); }
.dot.bad { background: var(--danger); }

/* Knoppen */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 999px; padding: 10px 18px; font-weight: 600; border: 1.5px solid transparent; }
.btn.primary { background: linear-gradient(150deg, var(--g700), var(--g900)); color: #fff; }
.btn.outline { background: none; border-color: var(--g700); color: var(--g700); }
.btn.small { padding: 5px 12px; font-size: .85rem; }
.btn.wide { width: 100%; }
.round { width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); display: grid; place-items: center; flex: none; }
.chip { border: 1.5px solid var(--line); background: none; border-radius: 999px; padding: 4px 12px; font-size: .85rem; }
.chip[aria-pressed="true"] { background: var(--g700); border-color: var(--g700); color: #fff; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.segmented button { border: none; background: none; border-radius: 999px; padding: 5px 13px; font-size: .85rem; color: var(--ink-soft); font-weight: 500; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.pill-soft { background: var(--g100); color: var(--g700); border-radius: 999px; padding: 3px 10px; font-size: .85rem; font-weight: 600; white-space: nowrap; }

/* ---------- Kaarten ---------- */
.card { background: var(--surface); border-radius: 24px; padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; height: 100%; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

.stat { gap: 6px; }
.stat-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.stat-value { font-size: 2.9rem; font-weight: 600; line-height: 1.05; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; margin-top: 6px; }
.stat-sub { color: var(--ink-soft); font-size: .85rem; }
.stat.featured {
  color: var(--on-dark);
  background:
    radial-gradient(120% 90% at 100% 100%, rgba(255,255,255,.10), transparent 60%),
    linear-gradient(150deg, var(--g700), var(--g900));
}
.stat.featured .stat-sub { color: var(--on-dark); opacity: .8; }
.stat.featured .round { background: #fff; color: var(--g900); border-color: #fff; }

/* Pil-staafjes */
.bars { display: grid; gap: 10px; height: 128px; align-items: stretch; }
.bars.tall { height: 176px; }
.bars.dense { gap: 3px; }
.bar { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.bar .track { position: relative; flex: 1; width: 100%; max-width: 46px; display: flex; align-items: flex-end; }
.bar .fill { width: 100%; border-radius: 999px; background: var(--g500); min-height: 8px; }
.bar.alt .fill { background: var(--g300); }
.bar.current .fill { background: var(--g900); }
.bar.future .fill {
  background: repeating-linear-gradient(135deg, var(--hatch) 0 2px, transparent 2px 7px);
  box-shadow: inset 0 0 0 1.5px var(--hatch); opacity: .7;
}
.bars.dense .fill { border-radius: 6px; }
.bubble {
  position: absolute; left: 50%; transform: translateX(-50%); top: -2px; translate: 0 -100%;
  background: var(--surface); border: 1.5px solid var(--g500); color: var(--g700);
  border-radius: 8px; padding: 1px 6px; font-size: .72rem; font-weight: 600; white-space: nowrap; z-index: 1;
}
.bar .lbl { font-size: .75rem; color: var(--ink-soft); line-height: 1; min-height: 1em; white-space: nowrap; }
.bar.current .lbl { color: var(--ink); font-weight: 600; }
.usage-line { display: flex; align-items: baseline; gap: 6px 10px; flex-wrap: wrap; }
.big { font-size: 2.3rem; font-weight: 600; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.usage-overview .bars { margin-top: 16px; }

/* Schema */
.schedule .next-title { font-size: 1.35rem; font-weight: 600; color: var(--g700); line-height: 1.25; }
.schedule .later { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.schedule .later li { display: flex; justify-content: space-between; gap: 8px; }
.schedule .btn { margin-top: auto; }

/* Slim stoken */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cmp { border-radius: 16px; padding: 10px 12px; background: var(--surface-2); display: flex; flex-direction: column; }
.cmp.win { background: var(--g100); box-shadow: inset 0 0 0 1.5px var(--g500); }
.cmp-label { font-size: .82rem; color: var(--ink-soft); font-weight: 500; }
.cmp-value { font-size: 1.7rem; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.cmp.win .cmp-value { color: var(--g700); }
.cmp-value small { font-size: .9rem; font-weight: 500; }
.slim .row-sub { margin: -4px 0 0; }
.slim-status { font-weight: 500; }
.last-log { margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.slim .btn { align-self: flex-start; margin-top: auto; }
.slim-detail { display: grid; gap: 14px; grid-template-columns: 1fr; margin-bottom: 28px; align-items: start; }
@media (min-width: 900px) { .slim-detail { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); } }
.tariffs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: end; }
.tariffs label { min-width: 0; display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--ink-soft); font-weight: 500; }
.tariffs input { width: 100%; min-width: 0; padding: 9px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface-2); color: var(--ink); font-size: 1rem; font-variant-numeric: tabular-nums; }
.tariffs .btn { grid-column: 1 / -1; }
.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; max-height: 420px; overflow-y: auto; }
.log li { display: grid; grid-template-columns: 7.5em 1fr; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: .9rem; }
.log li:first-child { border-top: none; }
.log .when { color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* Voordeur */
.door-shot { position: relative; border-radius: 16px; overflow: hidden; background: var(--surface-2); aspect-ratio: 16 / 10; }
.door-shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.door-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center; color: var(--ink-soft); font-size: .88rem;
  background: repeating-linear-gradient(135deg, transparent 0 8px, color-mix(in srgb, var(--hatch) 25%, transparent) 8px 10px); }
.door-alert { position: absolute; left: 10px; bottom: 10px; max-width: calc(100% - 20px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--heat); color: #fff; border-radius: 999px; padding: 4px 12px; font-size: .82rem; font-weight: 600; }
.door.alert { box-shadow: inset 0 0 0 2px var(--heat); }

/* Lijsten */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.list li { display: flex; align-items: center; gap: 12px; padding: 8px 4px; border-radius: 14px; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--ink-soft); font-size: .82rem; }
.lamp-dot { width: 30px; height: 30px; border-radius: 50%; flex: none; border: 1.5px solid var(--line); background: var(--surface-2); transition: background .2s, box-shadow .2s; }
li.on .lamp-dot { background: #F3C24C; border-color: #F3C24C; box-shadow: 0 0 14px rgba(243,194,76,.6); }
.switch { position: relative; width: 46px; height: 26px; border-radius: 999px; border: none; background: var(--line); flex: none; padding: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch[aria-checked="true"] { background: var(--g500); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
input[type=range] { width: 100%; accent-color: var(--g500); margin: 4px 0 0; }
.temp-badge {
  width: 46px; height: 46px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--g100); color: var(--g700); font-weight: 700; font-size: .88rem; font-variant-numeric: tabular-nums;
}
.tag { border-radius: 8px; padding: 2px 8px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.tag.ok { background: var(--g100); color: var(--g700); }
.tag.heat { background: var(--heat-soft); color: var(--heat); }
.tag.off { background: var(--surface-2); color: var(--ink-soft); }

/* Comfortmeter */
.gauge-wrap { position: relative; max-width: 260px; width: 100%; margin: 4px auto 0; }
.gauge-wrap svg { width: 100%; display: block; }
.gauge-center { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; }
.legend { list-style: none; margin: auto 0 0; padding: 0; display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--ink-soft); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.key { width: 12px; height: 12px; border-radius: 50%; }
.key.ok { background: var(--g700); }
.key.heat { background: var(--heat); }
.key.off { background: repeating-linear-gradient(135deg, var(--hatch) 0 2px, transparent 2px 4px); box-shadow: inset 0 0 0 1.5px var(--hatch); }

/* Airco-kaart */
.airco-card {
  color: var(--on-dark);
  background:
    repeating-radial-gradient(ellipse at 20% 120%, rgba(255,255,255,.06) 0 1px, transparent 1px 12px),
    linear-gradient(150deg, var(--g700), var(--g900));
}
.airco-temp { font-size: 3.4rem; font-weight: 600; line-height: 1; letter-spacing: -0.03em; text-align: center; font-variant-numeric: tabular-nums; margin-top: 4px; }
.airco-temp small { font-size: 1.4rem; vertical-align: 1.5rem; }
.airco-mode { text-align: center; opacity: .8; font-size: .9rem; }
.airco-actions { display: flex; justify-content: center; gap: 12px; margin-top: auto; }
.ctl {
  width: 46px; height: 46px; border-radius: 50%; border: none; background: rgba(255,255,255,.95); color: var(--g900);
  font-size: 1.4rem; line-height: 1; display: grid; place-items: center;
}
.ctl.power { background: rgba(255,255,255,.18); color: #fff; }
.ctl.power.on { background: #fff; color: var(--g700); }
.ctl.light { background: var(--surface-2); color: var(--ink); border: 1.5px solid var(--line); }
.dots { display: flex; gap: 6px; }
.dots button { width: 9px; height: 9px; border-radius: 50%; border: none; padding: 0; background: rgba(255,255,255,.35); }
.dots button[aria-pressed="true"] { background: #fff; }

/* Klimaattegels */
.climate .temp-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.climate .temp { font-size: 3.2rem; font-weight: 600; line-height: 1; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; }
.climate .temp small { font-size: 1.3rem; vertical-align: 1.4rem; }
.climate .steppers { display: flex; gap: 8px; }
.climate.heating { background: radial-gradient(120% 100% at 0% 0%, var(--heat-soft) 0%, var(--surface) 70%); }
.climate.heating .temp { color: var(--heat); }
.climate.cooling { background: radial-gradient(120% 100% at 0% 0%, var(--cool-soft) 0%, var(--surface) 70%); }
.climate.cooling .temp { color: var(--cool); }
.climate.off .temp { color: var(--ink-soft); }

/* ---------- Rasters ---------- */
.bento { display: grid; gap: 14px; grid-template-columns: 1fr; }
.stats { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stats .stat-value { font-size: 2.3rem; }
.b-airco:empty { display: none; }
@media (min-width: 760px) {
  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "s s" "u u" "r l" "z g" "d a"; }
}
@media (min-width: 1240px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stats .stat-value { font-size: 2.9rem; }
  .bento { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-areas: "s s s s" "u u r l" "z z g l" "z z d a"; }
}
@media (min-width: 760px) {
  .stats { grid-area: s; } .b-usage { grid-area: u; } .b-schedule { grid-area: r; } .b-lights { grid-area: l; }
  .b-zones { grid-area: z; } .b-gauge { grid-area: g; } .b-airco { grid-area: a; } .b-door { grid-area: d; }
}
@media (min-width: 760px) and (max-width: 1239px) {
  .bento { grid-template-areas: "s s" "u u" "r g" "z l" "d a"; }
}
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); align-items: start; }
.grid.rooms { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
h2.group { margin: 6px 4px 12px; font-size: 1.15rem; }
.grid + h2.group { margin-top: 28px; }
.view-tools { display: flex; justify-content: flex-end; margin: -6px 0 14px; }

.notice { background: var(--surface); border-radius: 18px; padding: 14px 16px; margin-bottom: 16px; }
.notice.bad { box-shadow: inset 0 0 0 1.5px var(--danger); }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--surface); border-radius: 14px; padding: 10px 16px; max-width: calc(100% - 32px); z-index: 20;
}
@media (min-width: 980px) { .toast { bottom: 24px; } }

/* ---------- Inloggen ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 18px; }
.login form { width: 100%; max-width: 360px; background: var(--surface); border-radius: 26px; padding: 28px; }
.login h1 { margin-bottom: 8px; }
.login .sub { color: var(--ink-soft); margin: 0; }
.login label { display: block; font-weight: 600; margin: 24px 0 6px; }
.login input { width: 100%; padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface-2); font-size: 1.05rem; }
.login-btn { margin-top: 16px; width: 100%; background: linear-gradient(150deg, var(--g700), var(--g900)); color: #fff; border: none; border-radius: 999px; padding: 12px 18px; font-weight: 600; cursor: pointer; }
.error { color: var(--danger); margin-top: 12px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
