@font-face {
  font-family: 'Manrope';
  src: url('vendor/manrope.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --bg: #060709;
  --card: #131519;
  --inset: #1d2026;
  --line: #23262d;
  --text: #f4f5f7;
  --muted: #9097a3;
  --soft: #c6cad2;
  --solar: #f2c94c;
  --micro: #e5a04b;
  --battery: #45c486;
  --load: #5b9df5;
  --grid: #b79cf2;
  --ev: #f27fb2;
  --warn: #f2994a;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

.app { max-width: 560px; min-height: 100vh; min-height: 100dvh; margin: 0 auto; display: flex; flex-direction: column; }
.screen { flex: 1; padding: 0 16px 20px; display: flex; flex-direction: column; min-width: 0; }
.page { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.page > * { min-width: 0; }
.wide-only { display: none; }

.num { font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.muted { color: var(--muted); }

/* Header */
.head { padding: 18px 0 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.head h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.head .sub { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--battery); display: inline-block; animation: soft 2s ease-in-out infinite; }
.dot.off { background: var(--warn); animation: none; }
.chip { font-size: 12px; font-weight: 700; background: var(--card); border-radius: 999px; padding: 8px 12px; white-space: nowrap; }
.back { min-height: 28px; display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; color: var(--load); padding-top: 14px; }
.head.sub-page { padding-top: 0; }

.banner { margin: 0 0 12px; padding: 10px 14px; border-radius: 14px; background: #2a1d12; color: #f6c9a0; font-size: 12px; font-weight: 600; }

/* Cards */
.card { background: var(--card); border-radius: 22px; padding: 14px; display: flex; flex-direction: column; justify-content: space-between; gap: 10px; color: var(--text); min-width: 0; }
a.card { transition: background 0.15s; }
a.card:hover, a.card:focus-visible { background: #181b20; }
.card.row { flex-direction: row; align-items: center; gap: 12px; justify-content: flex-start; }
.card .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card .title { font-size: 13px; font-weight: 700; }
.card .title.dim { color: var(--muted); }
.card .note { font-size: 11px; font-weight: 600; color: var(--muted); }
.big { font-size: 28px; font-weight: 800; line-height: 30px; }
.big .unit, .mid .unit { font-size: 12px; font-weight: 600; color: var(--muted); }
.mid { font-size: 20px; font-weight: 800; line-height: 22px; }
.stale .big, .stale .mid { opacity: 0.45; }
.pill { align-self: flex-start; font-size: 11px; font-weight: 700; background: var(--inset); border-radius: 999px; padding: 4px 9px; }
.kv { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; font-weight: 600; color: var(--muted); }
.kv b { font-weight: 800; color: var(--text); }
.kv .c-load { color: var(--load); font-weight: 700; }
.kv .c-micro { color: var(--micro); font-weight: 700; }
.rule { border-top: 1px solid var(--inset); padding-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.cols3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.cols3 span { display: block; font-size: 10px; font-weight: 600; color: var(--muted); }
.cols3 b { font-size: 12px; font-weight: 700; }

.bar { height: 6px; border-radius: 3px; background: var(--inset); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; transform-origin: left; transition: width 0.8s cubic-bezier(0.2, 0.8, 0.2, 1); }

/* Summary layout: two columns, with flow lines in the rows between cards */
.flow {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  column-gap: 20px;
  grid-template-areas:
    'solar micro'
    't1 tlong'
    'battery tlong'
    't2 tlong'
    'inv loads'
    't3 t4'
    'grid ev';
}
.a-solar { grid-area: solar; } .a-micro { grid-area: micro; } .a-battery { grid-area: battery; }
.a-inv { grid-area: inv; position: relative; } .a-loads { grid-area: loads; } .a-grid { grid-area: grid; } .a-ev { grid-area: ev; }
.a-t1 { grid-area: t1; } .a-t2 { grid-area: t2; } .a-t3 { grid-area: t3; } .a-t4 { grid-area: t4; } .a-tlong { grid-area: tlong; }
.link { display: flex; justify-content: center; min-height: 28px; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
/* Full-width strip under the flow diagram */
.card.strip { margin-top: 12px; }
.card.strip .pill { align-self: center; }
.card.strip .cols3 b { font-size: 15px; font-weight: 800; }

/* Status cards at the top of a screen: they sit apart, with no lines to what is below */
.pair.status { margin-bottom: 2px; }
.pair.links { height: 28px; margin: -12px 0; }
.pair.status .card { padding: 12px 14px; border-radius: 18px; }

/* Flow lines: a faint track with a streak of light moving the way power flows */
.trk { position: relative; width: 2px; height: 100%; min-height: 28px; overflow: hidden; color: var(--muted); }
.trk::before { content: ''; position: absolute; inset: 0; background: currentColor; opacity: 0.22; }
.trk i { display: none; position: absolute; left: 0; width: 2px; height: 18px; top: -18px; background: linear-gradient(180deg, transparent, currentColor, transparent); animation: travel 2.6s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite; }
.trk.on i { display: block; }
.trk.up i { animation-direction: reverse; }
.trk.long i { animation-duration: 3.8s; }
.htrk { position: absolute; right: -20px; top: 50%; width: 20px; height: 2px; overflow: hidden; color: var(--load); }
.htrk::before { content: ''; position: absolute; inset: 0; background: currentColor; opacity: 0.22; }
.htrk i { display: none; position: absolute; top: 0; left: -14px; width: 14px; height: 2px; background: linear-gradient(90deg, transparent, currentColor, transparent); animation: travelx 1.8s linear infinite; }
.htrk.on i { display: block; }
.c-solar { color: var(--solar); } .c-micro { color: var(--micro); } .c-battery { color: var(--battery); }
.c-load { color: var(--load); } .c-grid { color: var(--grid); } .c-ev { color: var(--ev); } .c-warn { color: var(--warn); }

@keyframes travel { from { top: -18px; } to { top: 100%; } }
@keyframes travelx { from { left: -14px; } to { left: 100%; } }
@keyframes soft { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Screens made of stacked cards */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tiles .card { gap: 4px; padding: 12px 14px; border-radius: 18px; }

/* Range buttons */
.tabs { display: flex; gap: 6px; overflow-x: auto; }
.a-graph { display: flex; flex-direction: column; gap: 12px; }
.tabs button { flex: 1 0 auto; min-height: 36px; padding: 0 12px; border: 0; border-radius: 999px; background: var(--card); color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.tabs button[aria-pressed='true'] { background: var(--inset); color: var(--text); }
.tabs button:focus-visible, .legend .key:focus-visible { outline: 2px solid var(--load); outline-offset: 2px; }

/* "Right now" split bars */
.split { display: flex; flex-direction: column; gap: 6px; }
.split .kv { font-size: 12px; }
.split-bar { display: flex; gap: 2px; height: 10px; min-width: 8px; transition: width 0.8s cubic-bezier(0.2, 0.8, 0.2, 1); }
.split-bar i { display: block; min-width: 3px; border-radius: 4px; }
.split-keys { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; font-weight: 600; color: var(--muted); }
.split-keys span { display: inline-flex; align-items: center; gap: 5px; }
.split-keys span.idle { opacity: 0.5; }
.split-keys i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.split-keys b { color: var(--text); font-weight: 700; }

/* Chart */
.legend { display: flex; flex-wrap: wrap; gap: 6px; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 10px; border: 0; border-radius: 999px; background: var(--inset); color: var(--text); font-size: 11px; font-weight: 700; cursor: pointer; }
.legend .key.off { opacity: 0.45; }
.legend .key:disabled { opacity: 0.3; cursor: default; }
.legend .key i, .tip-row i { display: inline-block; width: 14px; height: 0; border-top: 2px solid currentColor; }
.legend .key i.dash, .tip-row i.dash { border-top-style: dashed; }
.legend .key i.dot, .tip-row i.dot { border-top-style: dotted; }
.chart { position: relative; transition: opacity 0.2s; touch-action: pan-y; }
.chart svg { display: block; }
.chart .gridline { stroke: var(--line); stroke-width: 1; }
.chart .zero { stroke: #3a3e47; stroke-width: 1; }
.chart .nowline { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 4; opacity: 0.6; }
.chart .brush { fill: var(--text); opacity: 0.1; stroke: var(--soft); stroke-width: 1; }
.chart svg { cursor: crosshair; user-select: none; -webkit-user-select: none; }
.zoombar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 28px; }
.zoombar .reset { min-height: 28px; padding: 0 12px; border: 0; border-radius: 999px; background: var(--load); color: #04101f; font-size: 11px; font-weight: 800; cursor: pointer; }
.chart .cross { stroke: var(--soft); stroke-width: 1; opacity: 0.6; }
.chart .tick { fill: var(--muted); font-size: 10px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tip { position: absolute; top: 22px; width: 164px; padding: 8px 10px; border-radius: 12px; background: #23272f; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45); pointer-events: none; font-size: 11px; }
.tip-time { color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 6px; line-height: 17px; }
.tip-row b { font-weight: 800; white-space: nowrap; }
.tip-row span { color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.table-view summary { font-size: 11px; font-weight: 700; color: var(--muted); cursor: pointer; padding: 4px 0; }
.table-scroll { overflow-x: auto; max-height: 260px; margin-top: 6px; }
.table-view table { border-collapse: collapse; width: 100%; font-size: 11px; }
.table-view th, .table-view td { text-align: right; padding: 4px 6px; border-bottom: 1px solid var(--inset); white-space: nowrap; }
.table-view th { color: var(--muted); font-weight: 700; position: sticky; top: 0; background: var(--card); }
.table-view th:first-child, .table-view td:first-child { text-align: left; }

/* Stats for geeks */
.dates { display: grid; grid-template-columns: 38px minmax(0, 1fr) minmax(0, 1fr) 38px; align-items: end; gap: 8px; }
.dates label { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: 11px; font-weight: 700; color: var(--muted); }
.dates input { min-height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--inset); color: var(--text); font: inherit; font-size: 13px; font-weight: 700; color-scheme: dark; min-width: 0; width: 100%; }
.dates .step { min-width: 38px; min-height: 38px; border: 0; border-radius: 12px; background: var(--inset); color: var(--text); font-size: 18px; font-weight: 800; cursor: pointer; }
.dates .step:disabled, .ghost:disabled, .tabs button:disabled { opacity: 0.35; cursor: default; }
.zoombar .actions { display: flex; gap: 6px; flex: none; }
.ghost { min-height: 28px; padding: 0 12px; border: 0; border-radius: 999px; background: var(--inset); color: var(--text); font-size: 11px; font-weight: 800; cursor: pointer; }
.picker summary { font-size: 13px; font-weight: 700; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.picker .pick-group { display: flex; flex-direction: column; gap: 6px; }
.hint { padding: 0 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.tip-range { color: var(--muted); font-weight: 600; font-size: 10px; margin: -2px 0 3px 20px; }
a.more { display: inline-flex; align-items: center; min-height: 28px; font-size: 12px; font-weight: 700; color: var(--load); }
.dates input:focus-visible, .dates .step:focus-visible, .ghost:focus-visible, a.more:focus-visible { outline: 2px solid var(--load); outline-offset: 2px; }

/* Energy */
.stepper { flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; }
.stepper .when { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; min-width: 0; }
.stepper .step { min-width: 40px; min-height: 40px; border: 0; border-radius: 12px; background: var(--inset); color: var(--text); font-size: 20px; font-weight: 800; cursor: pointer; }
.stepper .step:disabled { opacity: 0.3; cursor: default; }
.stepper .step:focus-visible { outline: 2px solid var(--load); outline-offset: 2px; }
.e-tiles .card:first-child { grid-column: 1 / -1; }
.e-charts { display: flex; flex-direction: column; gap: 12px; transition: opacity 0.2s; }
.bars svg { display: block; touch-action: pan-y; cursor: pointer; }
.bars .gridline { stroke: var(--line); stroke-width: 1; }
.bars .zero { stroke: #3a3e47; stroke-width: 1; }
.bars .tick { fill: var(--muted); font-size: 10px; font-weight: 600; font-variant-numeric: tabular-nums; }
.bars .column { fill: var(--text); opacity: 0.06; }
.barinfo { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 30px; font-size: 12px; font-weight: 600; color: var(--soft); }
.barinfo b { color: var(--text); font-weight: 800; }
.barinfo i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin: 0 4px 0 6px; }
.barinfo .muted i:first-child { margin-left: 0; }

/* Human check */
.human { max-width: 420px; gap: 12px; }
.human .widget { min-height: 65px; }
.human .ghost { align-self: flex-start; }
.overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(6, 7, 9, 0.78); }
.overlay .human { width: 100%; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); }

/* Bottom navigation */
.nav { position: sticky; bottom: 0; height: 64px; background: #0d0f12; border-top: 1px solid var(--inset); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); font-size: 12px; font-weight: 700; padding-bottom: env(safe-area-inset-bottom); }
.nav a { display: flex; align-items: center; justify-content: center; color: var(--muted); }
.nav a[aria-current='page'] { color: var(--text); }
.nav .brand { display: none; }

/* Very small phones */
@media (max-width: 359px) {
  .screen { padding: 0 10px 16px; }
  .flow { column-gap: 12px; }
  .htrk { right: -12px; width: 12px; }
  .card { padding: 12px; border-radius: 18px; }
  .big { font-size: 24px; line-height: 26px; }
  .mid { font-size: 18px; }
}

/* Tablets and small windows: one roomy column */
@media (min-width: 700px) {
  .app { max-width: 720px; }
  .screen { padding: 0 24px 28px; }
  .head h1 { font-size: 26px; }
  .card { padding: 18px; }
  .big { font-size: 34px; line-height: 36px; }
  .mid { font-size: 22px; line-height: 24px; }
  .card .title { font-size: 14px; }
  .card .note, .kv { font-size: 12px; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Wide screens: menu on the left, content in columns */
@media (min-width: 1000px) {
  .app { max-width: 1440px; flex-direction: row-reverse; align-items: flex-start; }
  .screen { padding: 8px 32px 32px; }
  .nav { position: sticky; top: 0; bottom: auto; width: 200px; flex: none; height: 100vh; display: flex; flex-direction: column; gap: 4px; padding: 26px 14px; border-top: 0; border-right: 1px solid var(--inset); background: transparent; font-size: 14px; }
  .nav .brand { display: block; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; padding: 0 12px 18px; }
  .nav a { justify-content: flex-start; min-height: 42px; padding: 0 12px; border-radius: 12px; }
  .nav a:hover { background: var(--card); }
  .nav a[aria-current='page'] { background: var(--card); }
  .wide-only { display: block; }

  .summary-page { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
  .power-page { display: grid; grid-template-columns: 360px minmax(0, 1fr); grid-template-areas: 'now graph' 'tiles graph' 'plan graph'; grid-template-rows: auto auto 1fr; gap: 16px; align-items: start; }
  .a-now { grid-area: now; } .a-graph { grid-area: graph; } .a-tiles { grid-area: tiles; } .a-plan { grid-area: plan; }
  .power-page .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .screen > .page:not(.summary-page):not(.power-page):not(.stats-page):not(.energy-page):not(.devices-page):not(.device-page), .screen > .empty { max-width: 760px; }
  .e-tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .e-tiles .card:first-child { grid-column: auto; }
  .e-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .energy-page > .tabs, .energy-page > .stepper { max-width: 520px; }
}

/* Link to the system write-up */
.about { margin-top: 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--inset); border-radius: 18px; color: var(--text); text-decoration: none; font-size: 13px; }
.about b { display: block; font-weight: 700; }
.about .note { font-size: 11px; font-weight: 600; color: var(--muted); }
.about .chev { color: var(--load); font-weight: 700; }
.nav .nav-out { display: none; }
@media (min-width: 1000px) {
  .about { display: none; }
  .nav .nav-out { display: flex; margin-top: auto; color: var(--muted); font-size: 13px; }
}

/* Devices */
.dev-group { display: flex; flex-direction: column; gap: 8px; }
.dev-group h2 { margin: 6px 2px 0; font-size: 12px; font-weight: 700; color: var(--muted); }
.dev-list { display: grid; gap: 8px; }
a.dev { text-decoration: none; }
a.dev:focus-visible { outline: 2px solid var(--load); outline-offset: 2px; }
.dev { padding: 12px 14px; border-radius: 18px; }
.dev-icon { width: 36px; flex: none; display: flex; justify-content: center; }
.dev-name { flex: 1; min-width: 0; }
.dev .mid { white-space: nowrap; }
.dev .chev { color: var(--muted); font-size: 18px; font-weight: 700; }
.dev.idle .mid, .dev.idle .title { color: var(--muted); }
.dev-head { padding: 12px 14px; border-radius: 18px; }
.dev-tiles.stale .mid { opacity: 0.45; }
.dev-charts { display: flex; flex-direction: column; gap: 12px; }
.device-page > a.more { align-self: flex-start; }
@media (min-width: 700px) {
  .dev-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1000px) {
  .dev-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .screen > .page.devices-page, .screen > .page.device-page { max-width: 1100px; }
  .dev-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .dev-charts > .card:only-child { grid-column: 1 / -1; }
}

.empty { margin-top: 24px; text-align: center; padding: 28px 18px; }
.empty p { margin: 0; font-size: 13px; color: var(--muted); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
