/* heizung.vrah.de – Optik von hm.vrah.de (M7), Farben als Tokens, dazu Dunkel-Modus. */
:root {
  color-scheme: light dark;
  --bg: #F3F4F1; --card: #FFFFFF; --ink: #15181B; --muted: #5B6168; --line: #E2E4E0; --soft: #ECEEEA;
  --border: #D5D8D3; --input: #FFFFFF; --label: #3F454B; --on-ink: #FFFFFF;
  --heat: #C2410C; --heat-soft: #FFF1E8; --heat-ink: #9A3412; --cool: #1D4ED8; --cool-soft: #EAF0FD; --cool-ink: #1E40AF;
  --ok: #15803D; --warn: #B45309; --warn-soft: #FEF3C7;
  --grey-soft: #EEF0EC; --grey-ink: #3F454B; --toggle-off: #C9CDD1; --bar: #9AA1A8;
  --dark: #15181B; --dark-ink: #FFFFFF; --dark-muted: #C9CDD1; --tile: #22272C;
  --vz-grid: #EEF0EC; --vz-gridT: #F3F4F1; --vz-band: #F3F4F1; --vz-fenster: rgba(21,24,27,.10); --shadow: rgba(0,0,0,.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1214; --card: #181C20; --ink: #E8EAEC; --muted: #9AA2AA; --line: #2A3036; --soft: #232930;
    --border: #39414A; --input: #111417; --label: #C3C8CD; --on-ink: #15181B;
    --heat: #F07A3E; --heat-soft: #3A2116; --heat-ink: #FDBA8C; --cool: #7AA2FF; --cool-soft: #18233D; --cool-ink: #B4C8FF;
    --ok: #3DD07A; --warn: #E6A23C; --warn-soft: #3A2D10;
    --grey-soft: #2A3036; --grey-ink: #C3C8CD; --toggle-off: #4A525A; --bar: #6B737B;
    --dark: #21262B; --dark-ink: #F2F3F4; --dark-muted: #A9B0B7; --tile: #2C3238;
    --vz-grid: #262C32; --vz-gridT: #1E2328; --vz-band: #232930; --vz-fenster: rgba(232,234,236,.12); --shadow: rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: -apple-system, "Segoe UI", Inter, Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 16px 16px 8px; max-width: 1200px; margin: 0 auto; }
.top h1 { font-size: 26px; font-weight: 700; }
.top .sub { color: var(--muted); font-size: 13px; }
.top .sub a { color: var(--muted); text-decoration: none; font-weight: 600; }
.title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.conn { font-size: 12px; padding: 6px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.conn.on::before { content: "● "; color: var(--ok); }
.conn.off::before { content: "● "; color: var(--heat); }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 16px 10px; max-width: 1200px; margin: 0 auto; scrollbar-width: none; }
.tabs a { flex: 0 0 auto; padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); background: var(--card); border: 1px solid var(--line); font-size: 14px; font-weight: 600; }
.tabs a.act { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

main { max-width: 1200px; margin: 0 auto; padding: 0 16px 24px; display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; min-width: 0; }
.card h2 { font-size: 15px; font-weight: 700; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.card h2 small { font-weight: 500; color: var(--muted); font-size: 12px; }
.dark { background: var(--dark); color: var(--dark-ink); border-color: var(--dark); }
.dark .muted { color: var(--dark-muted); }
.muted { color: var(--muted); font-size: 13px; }
.big { font-size: 40px; font-weight: 700; line-height: 1.05; }
.mid { font-size: 24px; font-weight: 700; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { background: var(--tile); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.statusline { font-size: 14px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.strip { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 13px; color: var(--muted); }
.strip b { color: var(--ink); }

.chip { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.chip.komfort { background: var(--heat-soft); color: var(--heat-ink); }
.chip.absenk { background: var(--cool-soft); color: var(--cool-ink); }
.chip.wart { background: var(--warn-soft); color: var(--warn); }
.chip.grey { background: var(--grey-soft); color: var(--grey-ink); }
.chip.ok { background: var(--grey-soft); color: var(--ok); }

a.kreis { display: block; text-decoration: none; color: inherit; }
.kreis .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.kreis .head h3 { font-size: 17px; }
.temps { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.bar { flex: 1; height: 8px; border-radius: 4px; background: var(--soft); overflow: hidden; }
.bar > i { display: block; height: 8px; border-radius: 4px; background: var(--bar); }
.barrow { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 13px; font-weight: 600; }
.dir-open { color: var(--heat); } .dir-close { color: var(--cool); } .dir-hold { color: var(--grey-ink); } .dir-warn { color: var(--warn); }
.kl { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px 10px; font-size: 14px; align-items: baseline; }
.kl a { text-decoration: none; font-weight: 600; }
.kl .chip { white-space: normal; display: inline-block; }

.curve { width: 100%; height: auto; display: block; }
.curve .g { stroke: var(--vz-grid); } .curve text { fill: var(--muted); font-size: 11px; }
.curve .base { stroke: var(--toggle-off); } .curve .live { stroke: var(--heat); } .curve .dot { fill: var(--card); stroke: var(--heat); }
.stepper { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn { min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); font-weight: 600; cursor: pointer; }
.btn.sq { width: 44px; padding: 0; font-size: 22px; }
.btn.primary { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.btn.heat { color: var(--heat); } .btn.cool { color: var(--cool); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.seg { display: flex; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; min-width: 0; }
.seg button { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 0 6px; border: 0; background: var(--card); font-weight: 600; cursor: pointer; border-right: 1px solid var(--border); overflow-wrap: anywhere; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: var(--on-ink); }

.form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 12px; align-items: center; font-size: 14px; }
.form label { color: var(--label); }
.form input, .form select { min-height: 40px; border: 1px solid var(--border); border-radius: 10px; padding: 0 10px; background: var(--input); width: 120px; text-align: right; }
.form input:disabled { opacity: .5; }
.form .wide { grid-column: 1 / -1; }
.toggle { position: relative; width: 52px; height: 30px; border-radius: 999px; border: 0; background: var(--toggle-off); cursor: pointer; flex: 0 0 auto; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .15s; }
.toggle.on { background: var(--heat); } .toggle.on::after { left: 25px; }
.toggle.warn.on { background: var(--warn); }
.toggle.cool.on { background: var(--cool); }
.toggle:disabled { opacity: .45; cursor: not-allowed; }
details summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 4px 0; }
.note { font-size: 12px; color: var(--muted); }
.line { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; }
.sep { border-top: 1px solid var(--line); margin: 12px 0 4px; padding-top: 8px; }

.login { max-width: 380px; width: 100%; margin: 40px auto; display: flex; flex-direction: column; gap: 12px; }
.login input { min-height: 48px; border-radius: 12px; border: 1px solid var(--border); background: var(--input); padding: 0 14px; font-size: 20px; text-align: center; letter-spacing: .2em; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--on-ink); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 10; max-width: 90vw; }
.foot { text-align: center; color: var(--muted); font-size: 11px; padding: 8px 0 20px; }

@media (min-width: 900px) {
  .top h1 { font-size: 30px; }
  .split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 14px; align-items: start; }
  .split > .card + .card { margin-top: 0; }
}
@media (max-width: 899px) { .split { display: flex; flex-direction: column; gap: 14px; } }

.vt { width: 100%; border-collapse: collapse; font-size: 14px; }
.vt th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 4px 6px 6px 0; }
.vt td { padding: 8px 6px 8px 0; border-top: 1px solid var(--line); vertical-align: top; }
.warnbox { display: block; background: var(--warn-soft); border: 1px solid var(--warn); color: inherit; text-decoration: none; }

/* Startseite (Hub) */
.hub { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); }
a.site { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: inherit; min-height: 132px; transition: border-color .15s; }
a.site:hover { border-color: var(--ink); }
.site h3 { font-size: 19px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.site .ziel { font-size: 12px; color: var(--muted); margin-top: auto; }
.site .kurz { font-size: 14px; font-weight: 600; }
.site.off { opacity: .55; filter: grayscale(1); cursor: default; pointer-events: none; }
.badge { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--grey-soft); color: var(--grey-ink); white-space: nowrap; }
.badge.live { color: var(--ok); }
.hubhead { margin: 4px 0 2px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* Verlauf */
.hsel { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.hsel .seg { flex: 1 1 320px; }
.verlauf { margin-top: 6px; }
.vz { position: relative; touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.vz canvas { display: block; width: 100%; }
.vz .tip { position: absolute; top: 8px; pointer-events: none; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 14px var(--shadow); min-width: 150px; }
.vz .tip div { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.vz .tip b { font-size: 13px; color: var(--ink); }
.vz .tip span { color: var(--muted); }
.vz .tip i { display: inline-block; width: 14px; height: 0; border-top: 2px solid; }
.vz .tip i.dash { border-top-style: dashed; }
.ov { position: relative; margin-top: 6px; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.ov[hidden], .vz .tip[hidden] { display: none; }
.ov canvas { display: block; width: 100%; height: 38px; border-radius: 6px; }
.zbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--muted); min-height: 30px; flex-wrap: wrap; }
.zbar .pill { background: var(--soft); border-radius: 999px; padding: 4px 10px; font-weight: 600; color: var(--ink); }
.zbar button { min-height: 30px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); padding: 0 12px; font-weight: 600; font-size: 12px; cursor: pointer; color: var(--ink); }
.zbar button[hidden] { display: none; }
.hleg { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.hleg span { display: inline-flex; align-items: center; gap: 6px; }
.hevs { max-height: 380px; overflow-y: auto; }
.hev { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 8px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px; }
.card.busy { opacity: .55; }

/* v0.2: unbestätigte Werte (M5), getrennt = Eingaben gesperrt (G5) */
[data-pend] { outline: 2px dashed var(--warn); outline-offset: 2px; }
.stale input, .stale select, .stale .toggle, .stale .seg button[data-seg], .stale [data-pulse], .stale [data-step], .stale [data-act="bkrestore"] { pointer-events: none; opacity: .45; }
