:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --panel: #ffffff;
  --panel-border: #dde1e4;
  --text: #262627;
  --muted: #78787b;
  --inside: #de8f34;
  --outside: #5da8ff;
  --power: #3f9c62;
  --error: #b93434;
  --rule: #ececeb;
}

* {
  box-sizing: border-box;
}

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

.app-shell {
  width: min(1120px, calc(100% - 24px));
  margin: 0 auto;
  padding: 20px 0 40px;
}

.hero {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: end;
  flex-wrap: wrap;
  margin-top: 8px;
}

.title-lockup {
  display: flex;
  gap: 14px;
  align-items: center;
}

.hero-mark {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  background: linear-gradient(180deg, #cf8a2b 0%, #c87613 100%);
  position: relative;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.08);
}

.hero-mark::before,
.hero-mark::after {
  content: "";
  position: absolute;
  top: 4px;
  width: 4px;
  height: 4px;
  border-radius: 1px;
  background: #fff4d8;
}

.hero-mark::before {
  left: 6px;
}

.hero-mark::after {
  right: 6px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 2.6rem);
  line-height: 1.05;
}

.subhead {
  margin-top: 8px;
  color: var(--muted);
  max-width: 48rem;
}

.controls {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

button {
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  padding: 10px 14px;
  font: inherit;
}

button {
  cursor: pointer;
}

.range-toggle {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: #fbfbf8;
}

.range-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 10px;
}

.range-button.is-active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(32, 37, 43, 0.08);
}

.state-toggle-group {
  display: inline-flex;
  gap: 8px;
}

.state-toggle {
  border-radius: 999px;
  padding: 9px 14px;
  color: var(--muted);
}

.state-toggle.is-active {
  border-color: rgba(93, 168, 255, 0.28);
  background: rgba(93, 168, 255, 0.12);
  color: #22537d;
}

.state-toggle.is-saving {
  opacity: 0.65;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.summary-item {
  padding: 12px 0 14px;
  border-top: 1px solid var(--rule);
}

.summary-item strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(1.3rem, 2.4vw, 1.7rem);
}

.summary-label {
  color: var(--muted);
  font-size: 0.92rem;
}

.summary-item-wide {
  text-align: right;
}

.muted {
  color: var(--muted);
}

.chart-board {
  margin-top: 18px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  overflow: hidden;
}

.tab-row {
  display: flex;
  gap: 6px;
  align-items: end;
  padding: 0 20px;
  border-bottom: 1px solid var(--rule);
  overflow-x: auto;
}

.tab-button {
  appearance: none;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 14px 6px 12px;
  white-space: nowrap;
}

.tab-button.is-active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.chart-panel {
  display: none;
  padding: 18px 20px 16px;
}

.chart-panel.is-active {
  display: block;
}

.chart-header {
  margin-bottom: 14px;
}

.chart-header h2 {
  font-size: 1.08rem;
  margin-bottom: 4px;
}

.chart-frame {
  position: relative;
  height: clamp(260px, 48vh, 430px);
}

canvas {
  width: 100%;
  height: 100% !important;
}

.error-banner {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(185, 52, 52, 0.2);
  background: rgba(185, 52, 52, 0.08);
  color: var(--error);
}

.hidden {
  display: none;
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 16px, 1120px);
    padding-top: 16px;
  }

  .summary-strip {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .summary-item-wide {
    text-align: left;
  }

  .chart-board {
    border-radius: 16px;
  }

  .tab-row {
    padding: 0 14px;
  }

  .chart-panel {
    padding: 16px 14px 14px;
  }

  .chart-frame {
    height: 300px;
  }
}
