:root {
  color-scheme: dark;
  --bg: #101318;
  --panel: #1b212a;
  --panel-soft: #242b36;
  --text: #f7f9fc;
  --muted: #aeb8c6;
  --line: #343d4a;
  --accent: #36d6b5;
  --good: #41d17d;
  --warn: #f6c85f;
  --bad: #ff6b6b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  width: 100vw;
  height: 100vh;
  margin: 0;
  overflow: hidden;
  background: #0e1117;
  color: var(--text);
}

.viewport {
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

.shell {
  position: absolute;
  left: 0;
  top: 0;
  width: 1780px;
  min-height: auto;
  margin: 0;
  padding: 26px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 18px;
  transform-origin: top left;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 48px);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

button:hover {
  background: var(--panel-soft);
}

svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.message {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px 16px;
  color: var(--muted);
  line-height: 1.5;
}

.systems {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-content: stretch;
}

.system {
  min-width: 0;
  min-height: 500px;
  display: grid;
  gap: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: clamp(18px, 3vw, 28px);
}

.system-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h2 {
  font-size: clamp(26px, 3vw, 40px);
}

.state {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgb(54 214 181 / 35%);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--accent);
  background: rgb(54 214 181 / 10%);
  font-weight: 800;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-content: start;
}

.metric {
  min-height: 124px;
  display: grid;
  align-content: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 18px;
}

.metric span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.metric strong {
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1;
}

.text-metric strong {
  font-size: clamp(28px, 3vw, 42px);
}

.produced,
.energy-stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #202731;
  overflow: hidden;
}

.produced {
  position: relative;
  padding: 22px 24px 24px;
}

.produced::after {
  content: none;
}

.produced header,
.energy-stat header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: relative;
  z-index: 1;
}

h3 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.produced-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 26px;
}

.produced-grid div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.produced-grid strong {
  font-size: clamp(25px, 3vw, 34px);
  line-height: 1;
}

.produced-grid small {
  margin-left: 4px;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
}

.produced-grid p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.produced-grid em {
  color: var(--accent);
  font-size: 16px;
  font-style: normal;
}

.energy-stat {
  padding: 22px 24px 24px;
}

.energy-stat header span {
  min-width: 120px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1b2029;
  color: var(--text);
  font-weight: 800;
}

.flow {
  position: relative;
  min-height: 330px;
  margin-top: 20px;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) 112px;
  border-radius: 8px;
  overflow: hidden;
  background: #151a20;
}

.flow-left,
.flow-right {
  position: relative;
  z-index: 2;
  display: grid;
  align-content: stretch;
}

.flow-left {
  background: rgb(255 240 67 / 78%);
}

.flow-right {
  background: rgb(139 76 232 / 72%);
}

.flow-art {
  width: 100%;
  height: 100%;
  min-height: 330px;
  display: block;
  background: #20252e;
}

.band-solar {
  fill: url("#solarFlow");
}

.band-battery {
  fill: url("#batteryFlow");
}

.band-grid {
  fill: url("#gridFlow");
}

.split-line {
  fill: none;
  stroke: rgb(14 17 23 / 80%);
  stroke-width: 3;
}

.flow-tag {
  display: grid;
  align-content: start;
  gap: 4px;
  min-height: 108px;
  padding: 10px 9px;
  color: #0f1c2d;
}

.flow-tag span {
  width: max-content;
  max-width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  background: rgb(255 255 255 / 72%);
  box-shadow: 0 8px 18px rgb(0 0 0 / 18%);
  color: #18243a;
  font-size: 13px;
  font-weight: 800;
}

.flow-tag strong {
  font-size: 24px;
  line-height: 1;
}

.flow-tag small,
.flow-tag em {
  font-size: 15px;
  font-style: normal;
}

.flow-tag.battery span {
  background: #69e6ee;
}

.flow-tag.load span {
  background: #c49afa;
}

.flow-tag.grid span {
  background: #bac5ff;
}

.metric small {
  color: var(--accent);
  font-size: 16px;
  font-weight: 800;
}

details {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  color: var(--muted);
}

summary {
  cursor: pointer;
  font-weight: 700;
}

pre {
  max-height: 260px;
  overflow: auto;
  margin: 12px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
}

@media (max-width: 900px) {
  .systems {
    grid-template-columns: 1fr;
  }

  .system {
    min-height: 0;
  }

  .produced-grid {
    grid-template-columns: 1fr;
  }

  .flow {
    grid-template-columns: 92px minmax(0, 1fr) 92px;
  }
}
