:root {
  --bg: #0f1419; --panel: #161c24; --panel-2: #1c242e; --border: #2a3441; --text: #e6edf3; --muted: #8b98a8;
  --accent: #4aa3ff; --warn: #f0b429; --bad: #ff6b6b; --ok: #3fb950;
  --pos: 255, 159, 67;        /* export / high: orange */
  --neg: 74, 163, 255;        /* import / low: blue */
  --negative: #ff6666;        /* negative numbers, as on the GB Fundies table */
  --actual: #ffffff;          /* measured values: plain white, no shading */
}
@media (prefers-color-scheme: light) {
  :root { --actual: #000000; --negative: #cf222e; --bg: #f6f8fa; --panel: #ffffff; --panel-2: #eef2f6; --border: #d0d7de; --text: #1f2328; --muted: #57606a; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 13px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }

.top { display: flex; flex-wrap: wrap; gap: 0.6rem 1.2rem; align-items: center; padding: 0.7rem 1rem; border-bottom: 1px solid var(--border); background: var(--panel); position: sticky; top: 0; z-index: 30; }
.top h1 { font-size: 1.05rem; margin: 0; letter-spacing: 0.01em; }
.switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.switch a, .switch button { padding: 0.35rem 0.8rem; background: transparent; color: var(--muted); border: 0; font: inherit; cursor: pointer; text-decoration: none; }
.switch a + a, .switch button + button { border-left: 1px solid var(--border); }
.switch a.on, .switch button.on { background: var(--accent); color: #fff; }
.date-nav { display: inline-flex; gap: 0.3rem; align-items: center; }
.date-nav button, .date-nav input { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 0.3rem 0.55rem; font: inherit; }
.date-nav button { cursor: pointer; }
.status { margin-left: auto; color: var(--muted); font-size: 12px; }

.help { margin: 0.6rem 1rem; color: var(--muted); max-width: 70rem; }
.chip { padding: 0 0.4rem; border-radius: 4px; color: #111; }
.chip.flow-pos { background: hsl(206, 70%, 46%); color: #fff; } .chip.flow-neg { background: hsl(4, 70%, 46%); color: #fff; }
.da-demo { font-style: italic; text-decoration: underline dotted; text-underline-offset: 3px; }
.error { margin: 0.5rem 1rem; padding: 0.5rem 0.8rem; background: rgba(255, 107, 107, 0.12); border: 1px solid var(--bad); border-radius: 6px; color: var(--bad); }

main { padding: 0 1rem 1rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.2rem; }
.area { min-width: 0; }
.area h2 { font-size: 0.95rem; margin: 0.4rem 0; }
.area h2 small { color: var(--muted); font-weight: normal; margin-left: 0.5rem; }
.scroller { overflow: auto; max-height: calc(100vh - 8.5rem); border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }

table.grid { border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.grid th, .grid td { padding: 2px 5px; border-bottom: 1px solid var(--border); border-right: 1px solid rgba(127, 127, 127, 0.12); text-align: right; white-space: nowrap; }
.grid thead th { position: sticky; background: var(--panel-2); z-index: 5; font-weight: 600; color: var(--muted); }
.grid thead tr.clock th { top: 0; }
.grid thead tr.num th { top: 22px; font-weight: normal; font-size: 11px; }
.grid th.label, .grid td.label { position: sticky; left: 0; z-index: 4; text-align: left; background: var(--panel-2); min-width: 17rem; max-width: 17rem; overflow: hidden; text-overflow: ellipsis; border-right: 1px solid var(--border); }
.grid thead th.label { z-index: 7; }
.grid td.label .unit { color: var(--muted); font-size: 11px; margin-left: 0.4rem; }
.grid tr.group td { background: var(--bg); color: var(--accent); font-weight: 600; text-align: left; letter-spacing: 0.04em; text-transform: uppercase; font-size: 11px; padding-top: 6px; }
.grid tr.group td.label { background: var(--bg); }
.grid tr.total td.label { font-weight: 600; }
.grid td.cell { min-width: 3.1rem; }
.hourly .grid td.cell { min-width: 4.2rem; }
.grid td.cell.blank { color: transparent; }
.grid td.cell.da { font-style: italic; text-decoration: underline dotted rgba(255, 255, 255, 0.45); text-underline-offset: 3px; }
.grid th.now, .grid td.now { box-shadow: inset 2px 0 0 var(--warn), inset -2px 0 0 var(--warn); }
.grid thead th.now { color: var(--warn); }
.grid td.dir { text-align: center; font-weight: 700; }
.grid td.dir.up { color: var(--bad); } .grid td.dir.down { color: var(--accent); }


.est-demo { font-style: italic; text-decoration: underline dashed; text-underline-offset: 3px; }
.grid td.cell.est { font-style: italic; text-decoration: underline dashed rgba(255, 255, 255, 0.45); text-underline-offset: 3px; }

/* Compact: the same table in roughly a third of the width. */
body.compact { font-size: 12px; }
body.compact .grid th, body.compact .grid td { padding: 1px 3px; }
body.compact .grid td.cell { min-width: 1.8rem; font-size: 11.5px; }
body.compact .hourly .grid td.cell { min-width: 2.6rem; }
body.compact .grid th.label, body.compact .grid td.label { min-width: 12.5rem; max-width: 12.5rem; font-size: 11.5px; }
body.compact .grid thead th { font-size: 11px; }
body.compact .grid thead tr.num th { top: 20px; font-size: 10px; }
body.compact .grid td.label .unit { margin-left: 0.25rem; font-size: 10px; }
body.compact .scroller { max-height: calc(100vh - 7.5rem); }

/* Interconnectors: a line above each link, so a link's scheduled row and the actual row beneath it read as a pair. */
.grid tr.link-start td { border-top: 2px solid var(--border); }
.grid tr.total td { border-top: 2px solid var(--border); }
