:root {
  --ink: #1c2b33;
  --muted: #5d717b;
  --line: #e4eaee;
  --bg: #eef3f4;
  --card: #fff;
  --green: #1f8a5b;
  --green-soft: #e5f6ee;
  --blue: #2f6f9a;
  --blue-soft: #e7f2f8;
  --peach: #f8efe4;
  --sand: #f4e6d4;
  --amber: #c56a32;
  --shadow: 0 10px 28px rgba(28, 43, 51, 0.06);
  --radius: 18px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "Avenir Next", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }
.eyebrow {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--green);
  font-weight: 700;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  max-width: 920px;
  margin: 0 auto;
  padding: 22px 18px 8px;
}
.stamp { margin: 2px 0 0; font-weight: 650; }
.stamp i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #b7c4cb;
  margin-right: 6px;
}
.stamp i.live { background: var(--green); box-shadow: 0 0 0 4px rgba(31, 138, 91, 0.15); }
.logout {
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.9rem;
}

.view {
  max-width: 920px;
  margin: 0 auto;
  padding: 8px 18px 108px;
}
.busy-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-weight: 650;
}
.busy-note i {
  width: 14px;
  height: 14px;
  border: 2px solid #d5dee3;
  border-top-color: var(--green);
  border-radius: 50%;
  flex: 0 0 auto;
  animation: spin 0.7s linear infinite;
}
.stale {
  opacity: 0.38;
  pointer-events: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .busy-note i { animation: none; }
}
.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
}
.tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 1px 6px;
  border-radius: 12px;
  font-size: clamp(0.72rem, 2.4vw, 0.95rem);
  white-space: nowrap;
}
.tabs button.active { color: var(--green); font-weight: 700; background: var(--green-soft); }

.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.card, .panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card { padding: 14px 14px 12px; }
.card .label { margin: 0; color: var(--muted); font-size: 0.86rem; }
.card strong { display: block; font-size: 1.55rem; margin-top: 4px; letter-spacing: -0.03em; }
.card em { font-style: normal; color: var(--muted); font-size: 0.82rem; }
.card.paid { background: var(--blue-soft); }
.card.without { background: var(--peach); }
.card.saved { background: var(--sand); }
.card.saved.good { background: var(--green-soft); }
.card.saved.good strong { color: var(--green); }
.card.saved.bad strong { color: var(--amber); }

.panel { margin-top: 12px; padding: 16px; }
.panel h2 { margin: 0 0 4px; font-size: 1.25rem; }
.lead { margin: 0 0 14px; color: var(--muted); }

.flow {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  gap: 8px;
  align-items: stretch;
}
.node {
  border-radius: 16px;
  padding: 12px;
  background: #f7fafb;
  min-height: 92px;
}
.node b { display: block; font-size: 1.2rem; margin-top: 4px; }
.node span { color: var(--muted); font-size: 0.82rem; }
.node.solar { background: var(--green-soft); grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
.node.home { background: #f3f7f4; }
.node.ev { background: #f4f1fa; }
.node.grid.in { background: var(--blue-soft); }
.node.grid.out { background: #e7f6f2; }

.mix { margin-top: 14px; }
.mixbar {
  height: 10px;
  border-radius: 999px;
  background: #c5d7e4;
  overflow: hidden;
}
.mixbar i {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: inherit;
}
.mix p { margin: 6px 0 0; color: var(--muted); font-size: 0.9rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.stat {
  background: #f7fafb;
  border-radius: 14px;
  padding: 10px;
}
.stat b { display: block; font-size: 1.02rem; }
.stat b .muted { display: block; font-weight: 500; font-size: 0.75rem; margin-top: 2px; }
.stat span { color: var(--muted); font-size: 0.78rem; }
.pending { opacity: 0.45; }
.scroll { overflow-x: auto; margin-top: 14px; }
.sim-table { min-width: 640px; }
.sim-table .was { display: block; color: var(--muted); font-weight: 500; font-size: 0.75rem; }
tr.total td { font-weight: 700; }

.hours {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 3px;
  height: 168px;
  align-items: end;
}
.pricebars { height: 46px; align-items: stretch; }
.pricebars i { display: block; height: 100%; border-radius: 4px; }
.hour {
  position: relative;
  height: 100%;
  border: 0;
  border-radius: 6px 6px 3px 3px;
  padding: 0;
  background: #d7dee3;
}
.hour .level {
  position: absolute;
  left: 2px; right: 2px; bottom: 16px;
  border-radius: 3px 3px 0 0;
  background: rgba(20, 32, 38, 0.78);
}
.hour .sun {
  position: absolute;
  left: 2px; right: 2px; bottom: 16px;
  border-radius: 3px 3px 0 0;
  background: rgba(31, 138, 91, 0.95);
}
.hour small {
  position: absolute;
  left: 0; right: 0; bottom: 2px;
  text-align: center;
  font-size: 9px;
  color: #243038;
}
.hour.now { outline: 2px solid var(--ink); outline-offset: 1px; }
.hour.on { box-shadow: inset 0 0 0 2px var(--ink); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 0.82rem; margin: 8px 0 0; }
.swatch { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.swatch.full { background: var(--green); }
.swatch.short { background: var(--amber); }
.swatch.none { background: #c5d0d6; }
.swatch.open { background: var(--blue); }
.fill-chart { display: grid; gap: 7px; margin-top: 14px; }
.fill-row { display: grid; grid-template-columns: 46px 1fr; gap: 8px; align-items: end; }
.fill-label { color: var(--muted); font-size: 0.75rem; line-height: 1.15; }
.fill-label b { display: block; color: var(--ink); font-weight: 650; }
.fill-days {
  display: grid;
  grid-template-columns: repeat(31, minmax(0, 1fr));
  gap: 2px;
  height: 52px;
  align-items: end;
}
.fill-days i { position: relative; height: 100%; }
.fill-days b {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  border-radius: 2px;
  background: var(--amber);
}
.fill-days i.full b { background: var(--green); }
.fill-days i.none b { background: #c5d0d6; }
.fill-days i.open b { background: var(--blue); }
.fill-days i.open { box-shadow: inset 0 0 0 1px var(--blue); border-radius: 2px; }
.panel > .legend + .muted { margin: 10px 0 0; }
.detail {
  display: grid;
  grid-template-columns: 1.2fr repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.detail div { background: #f7fafb; border-radius: 12px; padding: 8px 10px; }
.detail b { display: block; }

.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.note {
  background: #f7fafb;
  border-radius: 14px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.92rem;
}
.warn { color: var(--amber); }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 0.78rem; }
th, td { padding: 8px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; }

label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
input, select {
  width: 100%;
  border: 1px solid #d5dee3;
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
}
.toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: end; margin-bottom: 8px; }
.toolbar input, .toolbar select { width: auto; }
button.primary, .login-card button, form button[type="submit"] {
  border: 0;
  background: var(--green);
  color: white;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
}
.inv { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--green-soft);
  font-size: 0.78rem;
}
.pill.bad { background: #fde8df; color: #8a3d12; }

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card { width: min(420px, 100%); background: var(--card); border-radius: 24px; padding: 28px; box-shadow: var(--shadow); }
.login-card h1 { margin: 4px 0; }
.login-card form { display: grid; gap: 8px; margin-top: 16px; }
.error { color: #9a3412; background: #fde8df; border-radius: 10px; padding: 8px 10px; }

.banner {
  margin-top: 12px;
}

@media (max-width: 720px) {
  .cards, .stats { grid-template-columns: 1fr 1fr; }
  .cards .card:first-child { grid-column: 1 / -1; }
  .flow { grid-template-columns: 1fr 1fr; }
  .node.home { grid-column: 1 / -1; }
  .detail, .split { grid-template-columns: 1fr 1fr; }
  .hours { height: 140px; }
}
