:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #657083;
  --line: #d7dde7;
  --panel: #ffffff;
  --bg: #eef3f8;
  --teal: #0f6d7a;
  --blue: #335c9a;
  --amber: #b8731b;
  --green: #20724d;
  --red: #aa3b3b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 24px auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1, h2, p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

p, span, dt {
  color: var(--muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e6ebf2;
}

.segmented button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.segmented button.active {
  background: var(--panel);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(24, 33, 47, 0.12);
}

.badge,
.profile-control {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  text-align: center;
  background: var(--panel);
  font-size: 12px;
}

.profile-control {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px 5px 10px;
}

.profile-control span {
  color: var(--muted);
  font-weight: 700;
}

.profile-control select {
  min-width: 150px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  outline: none;
}

.badge {
  min-width: 82px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.badge.online {
  color: #0b7a3b;
  border-color: #a7cfbb;
  font-weight: 900;
}

.calc-link {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  background: var(--panel);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.calc-link:hover {
  border-color: #9fb0c4;
}

.modebar,
.rangeslider,
.range-slider,
.zoom-controls,
.chart-controls,
button[aria-label="Zoom in"],
button[aria-label="Zoom out"] {
  display: none !important;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.metrics > article, .panel, .alert-strip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metrics > article {
  padding: 14px;
  min-height: 116px;
  position: relative;
  overflow: hidden;
}

.metrics > article::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 4px;
  background: var(--line);
}

.metrics > article.primary::after {
  background: var(--teal);
}

.metrics > article span {
  display: block;
  font-size: 13px;
  margin-bottom: 12px;
}

.metrics > article strong {
  display: block;
  font-size: 26px;
  line-height: 1.1;
}

.metrics > article small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.alert-strip {
  display: grid;
  grid-template-columns: 160px 1fr 220px;
  align-items: center;
  gap: 16px;
  padding: 14px;
  margin-bottom: 12px;
}

.alert-strip strong {
  display: block;
  margin-top: 4px;
}

.bar {
  height: 12px;
  border-radius: 999px;
  background: #e6ebf2;
  overflow: hidden;
}

.bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 240ms ease, background 240ms ease;
}

.health-strip {
  display: grid;
  grid-template-columns: 170px 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.health-strip-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.health-strip-head h2 {
  font-size: 16px;
}

.health-strip-head span {
  font-size: 12px;
}

.layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-areas:
    "kw kw"
    "kwh kwh"
    "usage billing"
    "summary summary";
  gap: 12px;
}

.kw-panel {
  grid-area: kw;
}

.usage-panel {
  grid-area: usage;
}

.billing-panel {
  grid-area: billing;
}

.kwh-panel {
  grid-area: kwh;
  min-height: 300px;
}

.panel {
  padding: 16px;
  min-width: 0;
}

.wide {
  min-height: 420px;
}

.kwh-panel.wide {
  min-height: 300px;
}

.summary-panel {
  grid-area: summary;
  grid-column: 1 / -1;
  min-height: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

h2 {
  font-size: 18px;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 360px;
  cursor: grab;
  touch-action: none;
}

.kwh-panel canvas {
  max-height: 240px;
}

canvas:active {
  cursor: grabbing;
}

.usage-panel canvas {
  width: min(260px, 58%);
  max-height: none;
  margin: 8px auto 10px;
  cursor: default;
  touch-action: auto;
}

.usage-panel canvas:active {
  cursor: default;
}

.usage-period-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.usage-period-controls label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f9fc;
}

.usage-period-controls span {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.usage-period-controls input,
.usage-period-controls select {
  min-width: 0;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  outline: none;
}

.split-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
  padding: 3px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e6ebf2;
}

.split-toggle button {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  padding: 0 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.split-toggle button.active {
  background: var(--panel);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(24, 33, 47, 0.12);
}

.split-legend {
  display: grid;
  gap: 8px;
}

.split-legend div {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.split-legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.split-legend span,
.split-summary {
  color: var(--muted);
}

.split-legend strong {
  font-size: 12px;
  white-space: nowrap;
}

.split-summary {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.35;
}

dl {
  margin: 0;
}

dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

dl div:last-child {
  border-bottom: 0;
}

dd {
  margin: 0;
  font-weight: 700;
}

.warning {
  color: var(--red);
  font-weight: 700;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.health-grid div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  min-height: 76px;
}

.health-grid span {
  display: block;
  font-size: 12px;
}

.health-grid strong {
  display: block;
  margin-top: 10px;
  font-size: 20px;
}

.health-lines {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.health-lines div {
  display: grid;
  grid-template-columns: 72px repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.health-lines > div > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.health-lines strong {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 6px;
  background: #f7f9fc;
  color: var(--ink);
  font-size: 12px;
}

.health-lines strong span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.health-lines b {
  color: var(--ink);
  font-size: 14px;
  white-space: nowrap;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-weight: 700;
}

td {
  font-weight: 600;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.calculation-page {
  background: #f7f9fc;
}

.calc-shell {
  width: min(980px, calc(100vw - 32px));
  margin: 24px auto 48px;
}

.calc-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.calc-hero p {
  margin-top: 8px;
  max-width: 680px;
  line-height: 1.5;
}

.calc-card {
  padding: 18px;
  margin-bottom: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.calc-card h2 {
  margin-bottom: 10px;
}

.calc-card p,
.calc-card li {
  line-height: 1.55;
}

.calc-card ul {
  margin: 10px 0 0;
  padding-left: 20px;
}

.formula {
  display: block;
  margin-top: 10px;
  padding: 12px;
  border-radius: 6px;
  background: #eef3f8;
  color: var(--ink);
  font-family: Consolas, "Courier New", monospace;
  overflow-x: auto;
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .segmented {
    width: 100%;
  }

  .profile-control {
    width: 100%;
  }

  .profile-control select {
    flex: 1;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .layout,
  .alert-strip,
  .health-strip {
    grid-template-columns: 1fr;
  }

  .layout {
    grid-template-areas:
      "kw"
      "usage"
      "kwh"
      "billing"
      "summary";
  }

  .calc-hero {
    flex-direction: column;
  }

  .health-lines div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .health-lines {
    grid-template-columns: 1fr;
  }

  .health-lines strong {
    justify-content: flex-start;
  }
}
