@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url(fonts/barlow-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url(fonts/barlow-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap; src: url(fonts/barlow-condensed-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-display: swap; src: url(fonts/barlow-condensed-latin-700-normal.woff2) format("woff2"); }

:root {
  --concrete: #e6e7e2;
  --panel: #f4f4f0;
  --line: #c6c9c1;
  --asphalt: #1e2227;
  --asphalt-2: #2a3036;
  --text: #1e2227;
  --muted: #59605c;
  --kerb: #f2b705;
  --alert: #bf3a22;
  --ok: #2b8a4b;
  --solar: #d9930d;
  --battery: #0e8a8c;
  --grid: #4a6fa5;
  --genset: #b5481f;
  --bay1: #6b5ca5;
  --bay2: #9a86d4;
  --load: #7b867f;
  --sink-charge: #5fbfc0;
  --export: #86a3cf;
  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Barlow", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --concrete: #16191d;
    --panel: #1e2328;
    --line: #353b42;
    --text: #e6e7e2;
    --muted: #9aa19c;
    --asphalt: #0f1215;
    --asphalt-2: #1b2025;
    --solar: #eab13a;
    --battery: #35b2b4;
    --grid: #7b9ccc;
    --genset: #dd7142;
    --bay1: #9585d1;
    --bay2: #bba9ee;
    --load: #98a39c;
    --sink-charge: #7fd3d4;
    --export: #a9c1e4;
    --alert: #e8664d;
    --ok: #52b873;
  }
}

* { box-sizing: border-box; }
a { color: inherit; }
a:visited { color: inherit; }
html, body { margin: 0; background: var(--concrete); color: var(--text); font: 400 15px/1.5 var(--body); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--kerb); outline-offset: 2px; }
h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 600; letter-spacing: 0.01em; }
h2 { font-size: 22px; line-height: 1.1; }
.num, .mono { font-variant-numeric: tabular-nums; }

.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.rail { background: var(--asphalt); color: #e6e7e2; padding: 22px 18px; display: flex; flex-direction: column; gap: 28px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 12px; align-items: center; }
.brand .mark { width: 14px; height: 44px; background: repeating-linear-gradient(180deg, var(--kerb) 0 9px, transparent 9px 16px); border-radius: 1px; flex: none; }
.brand b { display: block; font: 700 22px/1 var(--display); }
.brand small { color: #9aa19c; font-size: 13px; }
#nav { display: flex; flex-direction: column; gap: 4px; }
#nav a { display: block; text-decoration: none; text-align: left; background: none; border: 0; border-left: 4px solid transparent; padding: 9px 12px; color: #c4c8c3; font: 600 17px/1.2 var(--display); letter-spacing: 0.02em; cursor: pointer; }
#nav a:hover, #nav a:visited:hover { color: #fff; }
#nav a:visited { color: #c4c8c3; }
#nav a[aria-current="page"], #nav a[aria-current="page"]:visited { color: #fff; border-left-color: var(--kerb); background: var(--asphalt-2); }
.railfoot { margin-top: auto; font-size: 13px; color: #9aa19c; }
.railfoot .clock { font: 600 20px/1.2 var(--display); color: #e6e7e2; }

main { padding: 0 28px 40px; min-width: 0; }
.top { display: flex; align-items: center; gap: 18px; padding: 14px 0; border-bottom: 1px solid var(--line); margin-bottom: 22px; flex-wrap: wrap; }
.simbadge { display: inline-flex; align-items: stretch; font: 600 15px/1 var(--display); background: var(--kerb); color: #1e2227; border-radius: 1px; overflow: hidden; }
.simbadge::before { content: ""; width: 24px; background: repeating-linear-gradient(135deg, #1e2227 0 6px, var(--kerb) 6px 12px); }
.simbadge span { padding: 9px 12px; }
.top .spacer { flex: 1; }
.conn { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.conn i { width: 9px; height: 9px; border-radius: 50%; background: var(--alert); display: inline-block; }
.conn.live i { background: var(--ok); }
.speedpick { display: flex; gap: 0; }
.speedpick button { border: 1px solid var(--line); background: var(--panel); padding: 4px 11px; cursor: pointer; font-size: 13px; }
.speedpick button + button { border-left: 0; }
.speedpick button[aria-pressed="true"] { background: var(--asphalt); color: #fff; border-color: var(--asphalt); }

.view { display: none; }
.view.active { display: block; }

/* Pylon: the price-board readout */
.pylon { background: var(--asphalt); color: #f1efe6; border: 6px solid #3a4148; outline: 2px solid #11151a; display: grid; grid-template-columns: repeat(4, 1fr); border-radius: 3px; }
.pylon .cell { padding: 16px 20px 16px; border-left: 2px solid var(--kerb); position: relative; }
.pylon .cell:first-child { border-left: 0; }
.pylon .lbl { font-size: 15px; color: #c9cbc2; }
.pylon .num { font: 700 64px/1 var(--display); letter-spacing: 0.01em; margin-top: 4px; color: #fbf6e2; text-shadow: 0 0 14px rgba(255, 244, 200, 0.25); }
.pylon .unit { font-size: 14px; color: var(--kerb); margin-top: 2px; }
.pylon .bar { height: 5px; background: #3a4148; margin-top: 10px; position: relative; }
.pylon .bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--kerb); width: 0; transition: width 0.6s linear; }
.pylon .bar b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: #fff; }
.statusline { display: flex; gap: 22px; flex-wrap: wrap; align-items: center; padding: 12px 2px 0; color: var(--muted); font-size: 14px; }
.statusline strong { color: var(--text); font-weight: 600; }
.pill { display: inline-block; padding: 2px 10px; border: 1px solid var(--line); border-radius: 2px; background: var(--panel); font-weight: 600; font-size: 13px; color: var(--text); }
.pill.warn { border-color: var(--kerb); background: color-mix(in srgb, var(--kerb) 22%, var(--panel)); }
.pill.bad { border-color: var(--alert); color: var(--alert); }
.pill.ok { border-color: var(--ok); color: var(--ok); }

.grid2 { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 22px; margin-top: 22px; }
.panel { background: var(--panel); border: 1px solid var(--line); padding: 16px 18px 14px; margin: 0; min-width: 0; }
.panel h2 { margin-bottom: 10px; }
.panel .hint { color: var(--muted); font-size: 13px; margin: 0 0 8px; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; display: inline-block; }
.legend b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* single-line diagram */
#sld { width: 100%; height: auto; display: block; }
#sld text { font-family: var(--body); fill: var(--text); }
#sld .nodebox { fill: var(--concrete); stroke: var(--line); stroke-width: 1.5; }
#sld .nodename { font-size: 15px; fill: var(--muted); }
#sld .nodeval { font: 700 29px var(--display); }
#sld .nodesub { font-size: 14px; fill: var(--muted); }
#sld .bus { stroke: var(--text); stroke-width: 5; stroke-linecap: square; }
#sld .busname { font-size: 14px; fill: var(--muted); }
#sld .flow { fill: none; stroke-linecap: butt; stroke-dasharray: 9 7; animation: flow 0.9s linear infinite; }
#sld .flow.rev { animation-direction: reverse; }
#sld .flow.off { animation: none; stroke-dasharray: 2 6; opacity: 0.35; }
@keyframes flow { to { stroke-dashoffset: -16; } }
@media (prefers-reduced-motion: reduce) { #sld .flow { animation: none; } .pylon .bar i { transition: none; } }

.today { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 12px 0 0; border-top: 1px solid var(--line); }
.today div { padding: 12px 14px 10px 0; border-bottom: 1px solid var(--line); }
.today dt { color: var(--muted); font-size: 13px; }
.today dd { margin: 0; font: 600 30px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.today dd small { font: 400 13px var(--body); color: var(--muted); margin-left: 4px; }

/* bays */
.lane { background: var(--panel); border: 1px solid var(--line); margin-bottom: 18px; padding: 8px 14px 6px; }
.lane svg { width: 100%; height: auto; display: block; }
.lane .tname { font: 700 24px var(--display); fill: var(--text); }
.lane .tsub { font-size: 14px; fill: var(--text); }
.lane .bigkw { font: 700 40px var(--display); fill: var(--text); }
.lane .sub { font-size: 13px; fill: var(--muted); }
.capbar { margin: 4px 0 20px; display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; align-items: center; }
.capbar .track { height: 18px; background: var(--panel); border: 1px solid var(--line); position: relative; }
.capbar .track i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--bay1); }
.capbar .track i + i { background: var(--bay2); }

table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); border-bottom: 2px solid var(--text); padding: 6px 10px 6px 0; font-size: 13px; }
td { padding: 7px 10px 7px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; vertical-align: top; }
td.r, th.r { text-align: right; }

.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.charts .wide { grid-column: 1 / -1; }

.controls { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.controls button { text-align: left; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); cursor: pointer; border-left: 4px solid var(--kerb); }
.controls button:hover { background: var(--concrete); }
.controls button b { display: block; font: 600 17px/1.2 var(--display); }
.controls button span { font-size: 13px; color: var(--muted); }
.toast { min-height: 22px; color: var(--muted); font-size: 14px; margin-top: 10px; }

#events { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow: auto; }
#events li { display: grid; grid-template-columns: 74px 8px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
#events time { color: var(--muted); font-variant-numeric: tabular-nums; }
#events .sev { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; background: var(--muted); }
#events .sev.warning { background: var(--kerb); }
#events .sev.critical { background: var(--alert); }

.u-legend { display: none; }
.uplot { font-family: var(--body); }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px 22px; padding: 12px 16px; }
  .railfoot { display: none; }
  #nav { flex-direction: row; flex-wrap: wrap; }
  #nav a { border-left: 0; border-bottom: 4px solid transparent; padding: 6px 10px; }
  #nav a[aria-current="page"] { border-bottom-color: var(--kerb); }
  main { padding: 0 14px 30px; }
  .pylon { grid-template-columns: repeat(2, 1fr); }
  .pylon .cell:nth-child(3) { border-left: 0; }
  .pylon .cell:nth-child(n+3) { border-top: 2px solid var(--kerb); }
  .pylon .num { font-size: 52px; }
  .grid2, .charts { grid-template-columns: 1fr; }
}

/* navigation groups */
.navhead { margin: 14px 0 2px 16px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: #8b938e; }
.muted { color: var(--muted); }
h2.sect { margin: 30px 0 12px; font-size: 24px; }
.crumb { margin: 0 0 6px; color: var(--muted); font-size: 14px; }
.crumb a, .crumb a:visited { color: var(--muted); }

/* mode pills, as in the product spec */
.modepick { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.modepick button { border: 2px solid var(--grid); background: var(--panel); color: var(--grid); border-radius: 999px; padding: 8px 22px; font: 600 16px var(--body); cursor: pointer; }
.modepick button[aria-pressed="true"] { background: var(--grid); color: #fff; }

/* decision pipeline */
.pipeline { display: grid; grid-template-columns: minmax(0, 1.1fr) 28px minmax(0, 1.2fr) 28px minmax(0, 0.95fr); gap: 0; align-items: stretch; }
.pipeline .stage { background: var(--panel); border: 1px solid var(--line); padding: 14px 16px; min-width: 0; }
.pipeline .stage h3 { font-size: 19px; margin-bottom: 8px; }
.pipeline .stage.envelope { border: 2px solid var(--kerb); }
.pipeline .arrow { position: relative; }
.pipeline .arrow::after { content: ""; position: absolute; left: 4px; right: 4px; top: 50%; border-top: 3px solid var(--kerb); }
.pipeline .arrow::before { content: ""; position: absolute; right: 2px; top: calc(50% - 7px); border-left: 9px solid var(--kerb); border-top: 7px solid transparent; border-bottom: 7px solid transparent; }
.inputs { list-style: none; margin: 0; padding: 0; }
.inputs li { display: grid; gap: 0; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.inputs li span { color: var(--muted); font-size: 12px; }
.inputs li b { font-weight: 600; }
.inputs li.on b { color: var(--text); }
.inputs li.off b { color: var(--muted); font-weight: 400; }
.rules { margin: 0; padding-left: 20px; font-size: 14px; }
.rules li { padding: 4px 0; }
.envnum { display: flex; align-items: center; gap: 10px; }
.envnum #env-seq { font: 700 34px/1 var(--display); }
dl.env { margin: 8px 0 10px; display: grid; gap: 0; }
dl.env div { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--line); padding: 6px 0; }
dl.env dt { color: var(--muted); font-size: 14px; }
dl.env dd { margin: 0; font: 700 26px var(--display); font-variant-numeric: tabular-nums; }
dl.env dd small { font: 400 13px var(--body); color: var(--muted); margin-left: 4px; }
.countdown { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.countdown .track { flex: 1; height: 8px; background: var(--concrete); border: 1px solid var(--line); position: relative; min-width: 60px; }
.countdown .track i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--kerb); }

/* device tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.tile:visited { color: var(--text); }
.tile { display: grid; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-top: 6px solid var(--tc); padding: 12px 14px 10px; text-decoration: none; color: var(--text); }
.tile:hover { background: var(--concrete); }
.tile .tname { font: 600 19px var(--display); }
.tile .tkw { font: 700 40px/1.05 var(--display); }
.tile .tkw small { font: 400 14px var(--body); color: var(--muted); }
.tile .tstate { font-weight: 600; font-size: 14px; }
.tile .tstate.warn { color: var(--solar); }
.tile .tstate.bad { color: var(--alert); }
.tile .tsub { font-size: 13px; color: var(--muted); }
.tile .tage { font-size: 12px; color: var(--muted); margin-top: 6px; }
.tile .tage.warn { color: var(--solar); }
.tile .tage.bad { color: var(--alert); }
.tile .tgo { font-size: 13px; color: var(--muted); text-align: right; }
.tile .tgo::after { content: " \25B8"; }
#sld .nodelink { cursor: pointer; }
#sld .nodelink:hover .nodebox, #sld .nodelink:focus-visible .nodebox { fill: var(--panel); }
.balance { margin: 6px 0 0; font-size: 13px; color: var(--muted); }

/* device pages */
.devhead { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.devhead h1 { font-size: 36px; }
.devhead .age { font-size: 13px; color: var(--muted); }
.devhead .age.warn { color: var(--solar); }
.devhead .age.bad { color: var(--alert); }
.kpis { margin-top: 10px; }
.tablewrap { overflow-x: auto; }
#dev-regs td, #dev-regs th { white-space: nowrap; }
#dev-regs td:first-child { white-space: normal; }
.evlist { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: auto; }
.evlist li { display: grid; grid-template-columns: 74px 8px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.evlist time { color: var(--muted); font-variant-numeric: tabular-nums; }
.evlist .sev { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; background: var(--muted); }
.evlist .sev.warning { background: var(--kerb); }
.evlist .sev.critical { background: var(--alert); }
.chargers { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-top: 18px; }
.charger { background: var(--panel); border: 1px solid var(--line); padding: 12px 14px; }
.charger .chead { display: flex; justify-content: space-between; align-items: center; }
.charger .chead b { font: 600 19px var(--display); }
.charger .ckw { font: 700 38px/1.1 var(--display); margin-top: 4px; }
.charger .ckw small { font: 400 14px var(--body); color: var(--muted); }
.charger .cbar { height: 8px; background: var(--concrete); border: 1px solid var(--line); position: relative; margin: 6px 0; }
.charger .cbar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--bay1); }
.charger .cbar b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); }
.charger .csub { font-size: 13px; color: var(--muted); min-height: 38px; }

@media (max-width: 980px) {
  .navhead { display: none; }
  .pipeline { grid-template-columns: 1fr; gap: 10px; }
  .pipeline .arrow { height: 22px; }
  .pipeline .arrow::after { left: 50%; right: auto; top: 2px; bottom: 6px; border-top: 0; border-left: 3px solid var(--kerb); }
  .pipeline .arrow::before { right: auto; left: calc(50% - 6px); top: auto; bottom: 0; border-top: 9px solid var(--kerb); border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 0; }
}
