:root {
  color-scheme: dark;
  --bg: #090f15;
  --surface: #0e1720;
  --panel: #121d27;
  --panel-raised: #182630;
  --line: #273945;
  --line-strong: #3a5260;
  --text: #edf4f6;
  --muted: #9eb0b9;
  --subtle: #728791;
  --solar: #f3c45f;
  --grid: #68b7ff;
  --battery: #c0a2ff;
  --home: #58dcc0;
  --heat: #ff967a;
  --cars: #ee8fc6;
  --other: #a7d77c;
  --warning: #f0b86e;
  --danger: #ff837a;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 75% -12%, rgb(44 84 100 / 16%), transparent 38rem),
    var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
button, select, input { font: inherit; }
button, select, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible {
  outline: 2px solid #d5f7ef;
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.skip-link {
  position: fixed;
  z-index: 20;
  top: -60px;
  left: 14px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
}
.skip-link:focus { top: 12px; }

.login-view {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  padding: 32px;
}
.login-layout {
  display: grid;
  width: min(100%, 1030px);
  min-height: 590px;
  grid-template-columns: minmax(0, 1fr) minmax(360px, .82fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #0e1821;
  box-shadow: 0 28px 80px rgb(0 0 0 / 35%);
}
.login-intro {
  position: relative;
  display: flex;
  min-height: 100%;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: 34px 38px;
  background:
    radial-gradient(ellipse at 52% 56%, rgb(56 130 133 / 18%), transparent 44%),
    linear-gradient(150deg, #142630, #0d1821 74%);
}
.login-brand { display: flex; align-items: center; gap: 12px; font-size: 13px; font-weight: 720; letter-spacing: .14em; }
.login-brand img { border-radius: 15px; box-shadow: 0 8px 26px rgb(0 0 0 / 24%); }
.login-brand small, .brand small { display: block; margin-top: 3px; color: var(--subtle); font-size: 8px; font-weight: 550; letter-spacing: .15em; }
.login-art { position: relative; width: min(100%, 435px); height: 330px; align-self: center; }
.art-orbit { position: absolute; top: 50%; left: 50%; border: 1px solid rgb(116 167 167 / 20%); border-radius: 50%; transform: translate(-50%, -50%); }
.orbit-one { width: 280px; height: 280px; }
.orbit-two { width: 205px; height: 205px; border-style: dashed; opacity: .7; }
.art-sun { position: absolute; top: 44px; right: 72px; width: 34px; height: 34px; border-radius: 50%; background: var(--solar); box-shadow: 0 0 35px rgb(243 196 95 / 30%); }
.art-home {
  position: absolute;
  top: 110px;
  left: 50%;
  width: 170px;
  height: 132px;
  border: 2px solid #84aaa9;
  border-top: 0;
  border-radius: 5px 5px 15px 15px;
  background: linear-gradient(145deg, #16333d, #10232c);
  box-shadow: 0 22px 40px rgb(0 0 0 / 24%);
  transform: translateX(-50%);
}
.art-home::before {
  position: absolute;
  top: -58px;
  left: 17px;
  width: 130px;
  height: 130px;
  border-top: 2px solid #bad0cd;
  border-left: 2px solid #bad0cd;
  content: "";
  transform: rotate(45deg);
}
.art-home::after {
  position: absolute;
  bottom: 0;
  left: 68px;
  width: 33px;
  height: 72px;
  border: 1px solid #5b8589;
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  background: #0c1921;
  content: "";
}
.art-bolt {
  position: absolute;
  top: 146px;
  left: 50%;
  z-index: 2;
  width: 34px;
  height: 59px;
  background: linear-gradient(180deg, #ffe08c, #f3b348);
  clip-path: polygon(53% 0, 100% 0, 67% 39%, 100% 39%, 28% 100%, 44% 53%, 0 53%);
  filter: drop-shadow(0 0 14px rgb(243 196 95 / 36%));
  transform: translateX(-10%);
}
.art-flow { position: absolute; height: 2px; border-radius: 2px; }
.flow-one { top: 116px; left: 6%; width: 23%; background: linear-gradient(90deg, transparent, var(--grid)); }
.flow-two { right: 6%; bottom: 67px; width: 26%; background: linear-gradient(90deg, var(--home), transparent); }
.login-tagline { position: relative; z-index: 1; max-width: 340px; margin: 0; color: #c2d1d5; font-size: 18px; font-weight: 520; letter-spacing: -.025em; }
.login-card { align-self: center; padding: 48px clamp(28px, 4vw, 52px); }
.eyebrow { color: #84a1ad; font: 9px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; font-weight: 650; letter-spacing: .14em; }
.login-card h1 { margin: 9px 0 5px; font-size: 30px; font-weight: 630; letter-spacing: -.045em; }
.login-copy { margin: 0 0 27px; color: var(--muted); font-size: 12px; }
.login-card form { display: grid; gap: 8px; }
.login-card form > label:not(.remember-row) { margin-top: 9px; color: #c7d3d7; font-size: 10px; font-weight: 600; }
.login-card input[type="text"], .login-card input[type="password"] {
  width: 100%;
  min-height: 45px;
  padding: 10px 12px;
  border: 1px solid #324854;
  border-radius: 9px;
  background: #0a131a;
  color: var(--text);
}
.login-card input[type="text"]:focus, .login-card input[type="password"]:focus { border-color: #638991; }
.remember-row { display: flex; align-items: flex-start; gap: 10px; margin: 12px 0 7px; cursor: pointer; }
.remember-row input { width: 16px; height: 16px; flex: 0 0 auto; margin: 1px 0 0; accent-color: var(--home); }
.remember-row strong { display: block; color: #d3dddf; font-size: 10px; font-weight: 580; }
.remember-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.primary-button {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  margin-top: 7px;
  padding: 0 15px;
  border: 1px solid #56b9a7;
  border-radius: 9px;
  background: linear-gradient(100deg, #22665f, #1a514f);
  color: #effbf8;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  transition: filter .16s ease, transform .16s ease;
}
.primary-button:hover { filter: brightness(1.13); }
.primary-button:active { transform: translateY(1px); }
.primary-button:disabled { cursor: wait; opacity: .7; }
.primary-button span { font-size: 16px; }
.login-message { min-height: 18px; margin: 0; color: var(--danger); font-size: 10px; }
.login-security { display: flex; align-items: center; gap: 9px; margin-top: 12px; padding-top: 16px; border-top: 1px solid var(--line); color: #95a9b0; font-size: 9px; }
.security-mark { display: grid; width: 19px; height: 19px; place-items: center; border: 1px solid #36655a; border-radius: 50%; color: var(--other); font-size: 10px; }

.app-header {
  position: sticky;
  z-index: 5;
  top: 0;
  display: flex;
  min-height: 70px;
  align-items: center;
  gap: 28px;
  padding: 10px clamp(18px, 3vw, 44px);
  border-bottom: 1px solid var(--line);
  background: rgb(10 17 24 / 94%);
  backdrop-filter: blur(16px);
}
.brand { display: flex; flex: 0 0 auto; align-items: center; gap: 9px; color: var(--text); font-size: 12px; font-weight: 720; letter-spacing: .14em; text-decoration: none; }
.brand img { border-radius: 10px; }
.page-nav { display: flex; align-items: center; gap: 5px; }
.page-nav button, .quiet-button {
  min-height: 35px;
  padding: 7px 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}
.page-nav button:hover, .quiet-button:hover { background: #16242d; color: var(--text); }
.page-nav button[aria-current="page"] { border-color: #35525e; background: #172a35; color: var(--text); }
.header-actions { display: flex; flex: 1 1 auto; align-items: center; justify-content: flex-end; gap: 8px; }
.live-status { display: inline-flex; align-items: center; gap: 7px; margin-right: 5px; color: #a5b6bc; font-size: 9px; white-space: nowrap; }
.live-status i, .updated i { width: 6px; height: 6px; border-radius: 50%; background: var(--other); box-shadow: 0 0 10px rgb(167 215 124 / 35%); }
.clock { color: var(--muted); font: 9px ui-monospace, SFMono-Regular, Consolas, monospace; white-space: nowrap; }
.quiet-button { min-height: 32px; border-color: #2b3d48; font-size: 9px; }
.logout-button { color: #b7c5ca; }
.nibe-operation { margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
#nibe-compressor-status[data-state="active"] { color: var(--heat); }
#nibe-compressor-status[data-state="idle"] { color: var(--muted); }
#nibe-compressor-status[data-state="unknown"] { color: var(--warning); }
.install-help { width: min(420px, calc(100% - 32px)); padding: 24px; border: 1px solid var(--line); border-radius: 14px; background: #101a23; color: var(--text); }
.install-help::backdrop { background: rgb(0 0 0 / 65%); }
.install-help h2 { margin: 0 0 12px; font-size: 19px; }
.install-help p { color: var(--muted); }
.install-help form { margin-top: 18px; text-align: right; }
.app-content { width: min(100% - 48px, 1510px); margin: 0 auto; padding: 25px 0 22px; }
.message:not(:empty) { margin: 0 0 15px; padding: 11px 14px; border: 1px solid #725b38; border-radius: 8px; background: #241e15; color: #e8ca98; font-size: 11px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 17px; }
.page-heading h1 { margin: 6px 0 4px; font-size: clamp(26px, 3vw, 36px); font-weight: 630; letter-spacing: -.045em; line-height: 1.12; }
.page-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.updated { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: #aab9bf; font-size: 9px; white-space: nowrap; }
.card { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(145deg, #141f29, #101a23); box-shadow: 0 12px 34px rgb(0 0 0 / 14%); }
.flow-card { padding: 11px; }
.flow-diagram {
  position: relative;
  display: grid;
  min-height: 440px;
  grid-template: repeat(4, 1fr) / repeat(3, minmax(0, 1fr));
  align-items: center;
  justify-items: center;
  gap: 5px;
  overflow: hidden;
  border: 1px solid #223743;
  border-radius: 11px;
  background:
    linear-gradient(rgb(73 107 123 / 5%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(73 107 123 / 5%) 1px, transparent 1px),
    radial-gradient(ellipse at 50% 48%, rgb(52 112 121 / 13%), transparent 42%),
    #0c171f;
  background-size: 28px 28px, 28px 28px, auto, auto;
}
.flow-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.flow-track, .flow-line { fill: none; stroke-width: 3; vector-effect: non-scaling-stroke; }
.flow-track { stroke: #2d424d; }
.flow-line { opacity: 0; stroke-linecap: round; stroke-dasharray: 3 12; }
.flow-line[data-direction="forward"], .flow-line[data-direction="reverse"] { opacity: 1; animation: flow-pulse 1.4s linear infinite; }
.flow-line[data-direction="reverse"] { animation-direction: reverse; }
.solar-line { stroke: var(--solar); }
.grid-line { stroke: var(--grid); }
.battery-line { stroke: var(--battery); }
.home-line { stroke: var(--home); }
.heat-line { stroke: var(--heat); }
.cars-line { stroke: var(--cars); }
.other-line { stroke: var(--other); }
#flow-grid-line[data-direction="reverse"] { marker-start: url(#arrow-grid); marker-end: none; }
#flow-battery-line[data-direction="reverse"] { marker-start: url(#arrow-battery); marker-end: none; }
@keyframes flow-pulse { to { stroke-dashoffset: -30; } }
.flow-node, .flow-center {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(100%, 174px);
  min-height: 76px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 9px 7px;
  border: 1px solid #3b505b;
  border-radius: 10px;
  background: #101c25;
  box-shadow: 0 9px 24px rgb(0 0 0 / 23%);
  text-align: center;
}
.flow-node span, .flow-node small { color: #adbdc3; font-size: 9px; line-height: 1.35; }
.flow-node span { font-weight: 590; letter-spacing: .045em; }
.flow-node small { color: var(--muted); }
.flow-node strong { color: var(--tone, var(--text)); font-size: clamp(16px, 2vw, 22px); font-weight: 650; letter-spacing: -.04em; line-height: 1.2; }
.flow-node b { color: var(--battery); font-size: 9px; font-weight: 600; }
.flow-solar { grid-area: 1 / 2; --tone: var(--solar); border-color: rgb(243 196 95 / 44%); }
.flow-grid { grid-area: 2 / 1; --tone: var(--grid); border-color: rgb(104 183 255 / 44%); }
.flow-center { grid-area: 2 / 2; width: auto; min-width: 100px; min-height: 68px; border-color: #4a636e; background: #14252d; color: var(--home); font: 9px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .12em; }
.flow-center strong { color: var(--text); font-size: 18px; letter-spacing: .04em; }
.flow-battery { grid-area: 2 / 3; --tone: var(--battery); border-color: rgb(192 162 255 / 44%); }
.flow-home { grid-area: 3 / 2; --tone: var(--home); border-color: rgb(88 220 192 / 44%); }
.flow-heat { grid-area: 4 / 1; --tone: var(--heat); border-color: var(--heat); }
.flow-cars { grid-area: 4 / 2; --tone: var(--cars); border-color: var(--cars); }
.flow-other { grid-area: 4 / 3; --tone: var(--other); border-color: var(--other); }
.flow-heat strong, .flow-cars strong, .flow-other strong { font-size: clamp(13px, 1.5vw, 18px); overflow-wrap: anywhere; }
.flow-note-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 1px 7px 5px; }
.note { margin: 10px 0 0; color: #9fb0b7; font-size: 9px; line-height: 1.6; }
.flow-note-row .note { margin-top: 7px; }
.prices { margin-top: 15px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.section-heading h2, .card h2 { margin: 5px 0 7px; font-size: 16px; font-weight: 610; letter-spacing: -.02em; }
.price-current { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px 18px; }
.price-current strong { color: #d8e2e5; font-size: 10px; font-weight: 610; white-space: nowrap; }
.price-chart { width: 100%; max-width: 100%; }
.price-chart svg { display: block; width: 100%; height: 215px; }
.price-chart text { fill: #879ca6; font: 10px ui-monospace, SFMono-Regular, Consolas, monospace; }
.price-chart .price-line { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.price-chart .price-sale-line { fill: none; stroke: #a9bac4; stroke-width: 1.25; opacity: .78; }
.price-chart .price-hit { fill: transparent; cursor: crosshair; }
.price-chart .price-hit:focus-visible { outline: none; stroke: #f3f7f8; stroke-width: 1; }
.price-chart .price-grid { stroke: var(--line); stroke-width: 1; opacity: .75; }
.price-marker { pointer-events: none; }
.price-marker line { stroke: #eef4f5; stroke-width: 1; stroke-dasharray: 3 4; opacity: .8; }
.price-marker circle { fill: var(--panel); stroke: #eef4f5; stroke-width: 2; }
.price-marker .price-spot-dot { stroke: #a9bac4; stroke-width: 1.5; }
.price-marker text { fill: var(--text); }
#price-selected:empty { display: none; }
.disclaimer { margin: 7px 0 0; color: var(--muted); font-size: 9px; line-height: 1.55; }
.source-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-top: 15px; }
.source-grid .card { padding: 15px; }
.source-grid .card h2 { margin: 5px 0 9px; }
.readings { display: grid; gap: 0; }
.row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid #253640; font-size: 9px; }
.row:last-child { border-bottom: 0; }
.row span:first-child { color: var(--muted); }
.row strong { color: #e0e9eb; font-size: 9px; font-weight: 600; text-align: right; }
.stale { color: var(--warning) !important; }
.source-error { margin: 4px 0; color: #e5ba7b; font-size: 9px; line-height: 1.5; overflow-wrap: anywhere; }
.card-copy { margin: 7px 0 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.history-card { padding: 20px; }
.controls { display: flex; align-items: flex-end; gap: 10px; }
.controls label { display: grid; gap: 5px; color: var(--muted); font-size: 9px; }
.controls select {
  min-height: 35px;
  max-width: 230px;
  padding: 6px 29px 6px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #0e1921;
  color: #dce5e7;
  font-size: 10px;
}
.chart { position: relative; width: 100%; height: 340px; margin-top: 17px; overflow: hidden; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart text { fill: #91a5ad; font: 10px ui-monospace, SFMono-Regular, Consolas, monospace; }
.chart polyline { fill: none; stroke: var(--home); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart line { stroke: #2a3d48; }
.chart .empty { display: grid; height: 100%; place-items: center; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); font-size: 11px; }
.app-footer { display: flex; justify-content: space-between; gap: 15px; margin-top: 21px; padding-top: 12px; border-top: 1px solid #1e2d37; color: #758993; font: 8px/1.7 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .04em; }

@media (max-width: 1050px) {
  .source-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-header { gap: 18px; }
  .live-status { display: none; }
  .login-layout { min-height: 550px; }
  .login-intro { padding: 28px; }
}
@media (max-width: 760px) {
  .login-view { padding: 18px; }
  .login-layout { width: min(100%, 510px); min-height: 0; grid-template-columns: 1fr; border-radius: 19px; }
  .login-intro { min-height: 175px; padding: 20px 22px; }
  .login-art { position: absolute; top: -63px; right: -40px; width: 245px; height: 260px; opacity: .6; transform: scale(.78); transform-origin: center; }
  .login-tagline { max-width: 210px; margin-top: 38px; font-size: 14px; }
  .login-card { padding: 29px 23px 24px; }
  .app-header { min-height: 60px; flex-wrap: wrap; gap: 6px 14px; padding: 8px 14px; }
  .brand { margin-right: auto; }
  .page-nav { order: 3; flex: 1 0 100%; }
  .header-actions { flex: 0 0 auto; }
  .clock { display: none; }
  .app-content { width: min(100% - 28px, 1510px); padding-top: 17px; }
  .page-heading { align-items: flex-start; }
  .source-grid { grid-template-columns: 1fr 1fr; }
  .chart { height: 290px; }
}
@media (max-width: 520px) {
  .login-view { padding: 0; }
  .login-layout { min-height: 100vh; min-height: 100dvh; border: 0; border-radius: 0; }
  .login-intro { min-height: 150px; }
  .login-art { top: -96px; right: -78px; transform: scale(.66); }
  .login-card { align-self: start; padding: 25px 22px 30px; }
  .login-card h1 { font-size: 27px; }
  .app-header { gap: 5px 9px; padding: 8px 11px; }
  .brand img { width: 30px; height: 30px; }
  .brand { gap: 7px; font-size: 10px; }
  .brand small { font-size: 7px; }
  .page-nav { gap: 3px; }
  .page-nav button { min-height: 32px; padding: 6px 9px; font-size: 9px; }
  .header-actions { gap: 4px; }
  .quiet-button { min-height: 30px; padding: 5px 7px; font-size: 8px; }
  .app-content { width: calc(100% - 22px); padding-top: 14px; }
  .page-heading h1 { font-size: 27px; }
  .page-heading p { max-width: 265px; font-size: 10px; }
  .updated { padding: 7px; font-size: 8px; }
  .card { padding: 13px; border-radius: 11px; }
  .flow-card { padding: 7px; }
  .flow-diagram { min-height: 360px; gap: 3px; }
  .flow-node { width: min(100%, 112px); min-height: 63px; padding: 6px 4px; }
  .flow-node span, .flow-node small { font-size: 8px; }
  .flow-node strong { font-size: 15px; }
  .flow-center { min-width: 74px; min-height: 61px; font-size: 7px; }
  .flow-center strong { font-size: 15px; }
  .flow-note-row { grid-template-columns: 1fr; gap: 0; padding-inline: 5px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 9px; }
  .price-current { justify-content: flex-start; }
  .price-chart svg { height: 185px; }
  .source-grid { grid-template-columns: 1fr; gap: 9px; }
  .source-grid .card { padding: 13px; }
  .controls { width: 100%; }
  .controls label { flex: 1; }
  .controls select { width: 100%; max-width: none; }
  .history-card { padding: 14px; }
  .chart { height: 245px; margin-top: 12px; }
  .app-footer { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
