:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);

  --production: #008300;
  --consumption: #eb6834;
  --battery: #2a78d6;
  --grid-import: #e34948;
  --grid-export: #4a3aa7;

  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-critical: #d03b3b;
  --paper: #fffdf6;
}


* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

.flow-diagram {
  background:
    repeating-linear-gradient(var(--paper, #fffdf6) 0 27px, rgba(120, 150, 210, 0.12) 27px 28px),
    var(--paper, #fffdf6);
  border: 2px solid var(--text-primary);
  border-radius: 3px 14px 4px 16px / 12px 4px 16px 4px;
  padding: 10px;
  margin-bottom: 10px;
  position: relative;
  box-shadow: 3px 4px 0 rgba(11, 11, 11, 0.06);
}
.flow-diagram::before {
  content: "";
  position: absolute;
  left: 34px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(211, 90, 90, 0.35);
  pointer-events: none;
}
.flow-diagram svg { width: 100%; height: auto; display: block; }

.flow-diagram .ink { fill: none; stroke: var(--text-primary); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.flow-diagram .ink-fill { fill: var(--surface); stroke: var(--text-primary); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.flow-diagram .muted-fill { fill: var(--gridline); stroke: var(--text-primary); stroke-width: 2; }
.flow-diagram .icon-label {
  fill: var(--text-secondary);
  font-size: 15px;
  text-anchor: middle;
  font-family: "Patrick Hand", "Comic Sans MS", cursive, sans-serif;
}
.flow-diagram .icon-value {
  font-size: 17px;
  font-weight: 400;
  text-anchor: middle;
  font-variant-numeric: normal;
  font-family: "Patrick Hand", "Comic Sans MS", cursive, sans-serif;
}

.flow-diagram .battery-fill {
  fill: var(--battery);
  transition: height 0.8s ease, y 0.8s ease;
}
.flow-diagram .icon-value { transition: fill 0.4s ease; }

.flow-diagram .flow-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 7 7;
  animation: flow-dash 0.9s linear infinite;
  transition: stroke 0.5s ease, opacity 0.5s ease;
}
.flow-diagram .flow-reverse { animation-direction: reverse; }
.flow-diagram .flow-idle {
  stroke: var(--gridline);
  stroke-dasharray: none;
  animation: none;
  opacity: 0.6;
}
.flow-diagram .flow-production { stroke: var(--production); }
.flow-diagram .flow-consumption { stroke: var(--consumption); }
.flow-diagram .flow-battery { stroke: var(--battery); }
.flow-diagram .flow-grid-import { stroke: var(--grid-import); }
.flow-diagram .flow-grid-export { stroke: var(--grid-export); }

@keyframes flow-dash {
  to { stroke-dashoffset: -28; }
}

/* Heat pump fan spins only while the device is actually running */
#hpFan { transition: opacity 0.4s ease; }
#hpFan.spin { animation: hp-spin 2.4s linear infinite; }
@keyframes hp-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .flow-diagram .flow-line,
  #hpFan.spin {
    animation: none;
  }
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: var(--page);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  max-width: 90vw;
}
.toast.error { background: var(--status-critical); color: #fff; }
