/* GridGuard customer panel (app.gridguardgroup.com).
   Style: the sidebar on a tinted frame tone with a hairline edge, the page beside it on the surface, edge to edge; the search heads the page column.
   Light: navy is the ink and the filled buttons; a darker cyan marks FIT data.
   Dark (follows the system setting): the brand navy ground of www, cyan for buttons and data.
   Started from tasteskill's app.css (design-taste-frontend skill). */

@font-face { font-family: "Space Grotesk"; src: url("fonts/space-grotesk-500-700.woff2") format("woff2"); font-weight: 500 700; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("fonts/barlow-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("fonts/barlow-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("fonts/barlow-600.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  --frame: #f3f5f9;           /* the L-frame: one blue-grey step off white, from the brand navy */
  --surface: #ffffff;         /* the sheet and panels */
  --raised: #f6f8fb;          /* wells, hovered rows */
  --active: #e6eaf2;          /* the active nav pill, selected segments */
  --border: #e3e7ee;          /* sheet and panel edges */
  --rule: #edf0f4;            /* row rules */
  --control: #c9d0dc;         /* inputs and outlined buttons */
  --text: #010c30;            /* brand dark navy as ink */
  --muted: #4b5470;           /* 7.5:1 on white */
  --faint: #5d6680;           /* 5.7:1 on white */
  --primary: #021851;         /* brand navy: the one filled button */
  --primary-hover: #0b2a78;
  --primary-ink: #ffffff;
  --data: #0899c9;            /* brand cyan darkened to 3.3:1 on white: FIT years left */
  --data-track: #dbe1ea;
  --brand-cyan: #5dd9fe;
  --negative: #b4232a;
  --pill-positive-bg: #dcfae5; --pill-positive-ink: #04250e;
  --pill-negative-bg: #ffedea; --pill-negative-ink: #831c1e;
  --pill-warning-bg: #fff6dd; --pill-warning-ink: #7a3d07;
  --pill-neutral-bg: #edf0f5; --pill-neutral-ink: #2c3550;
  --pill-change-bg: #e3f6fd; --pill-change-ink: #034a63;  /* equipment changed since install */
  --dot-good: #16a34a; --dot-warn: #d97706; --dot-bad: #dc2626;
  --control-hover: #b5bdcc;
  --input-bg: #ffffff;
  --selected: #dbe2ee;        /* highlighted option in a list */
  --negative-hover: #961b21;
  --negative-ink: #ffffff;    /* text on a filled delete button */
  --danger-border: #e6b7b9;
  --danger-hover-bg: #fff5f5;
  --focus-ring: rgb(8 153 201 / 0.18);
  --menu-shadow: 0 10px 28px rgb(1 12 48 / 0.14);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%234b5470' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  --font:"Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", "Barlow", system-ui, sans-serif;  /* titles and the FIT figure only */
  --fs-title: 24px; --fs-section: 16px; --fs-figure: 32px; --fs-body: 15px; --fs-small: 13px;

  --sidebar-width: 240px;
  --topbar: 48px;
  --inset: 8px;
  --pad: 24px;
  --gap: 16px;
  --card-pad: 20px;
  --radius-sheet: 16px;
  --radius-card: 10px;
  --radius-control: 8px;
  --control-height: 36px;
  --input-height: 40px;
  --row-height: 52px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --t-press: 120ms; --t-hover: 150ms; --t-ui: 200ms;
  color-scheme: light;
}

/* Dark: brand navy #010c30 frame, #021851 sheet. Every text tier holds 4.5:1 or more on the sheet. */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --frame: #010c30;
    --surface: #021851;
    --raised: #07215f;
    --active: #0f2c73;
    --border: #19326f;
    --rule: #122a66;
    --control: #3a5594;
    --control-hover: #5470b0;
    --input-bg: #011142;
    --selected: #1a3c8c;
    --text: #f2f5ff;
    --muted: #b2bedc;         /* 8:1 on the sheet */
    --faint: #94a2c6;         /* 6:1 on the sheet */
    --primary: #5dd9fe;       /* brand cyan, navy text: 11:1 */
    --primary-hover: #8ce6ff;
    --primary-ink: #010c30;
    --data: #5dd9fe;
    --data-track: #213a7c;
    --negative: #ff9aa0;
    --negative-hover: #ffb8bc;
    --negative-ink: #2a0508;
    --danger-border: #8a3448;
    --danger-hover-bg: #2b1238;
    --pill-positive-bg: #0d3a2a; --pill-positive-ink: #a3f2cb;
    --pill-negative-bg: #3f1226; --pill-negative-ink: #ffc0c4;
    --pill-warning-bg: #3a2d0c; --pill-warning-ink: #ffdc94;
    --pill-neutral-bg: #142c6c; --pill-neutral-ink: #d8e0f6;
    --pill-change-bg: #0a3757; --pill-change-ink: #a8e9ff;
    --dot-good: #4cc38a; --dot-warn: #f5b544; --dot-bad: #e5484d;
    --focus-ring: rgb(93 217 254 / 0.28);
    --menu-shadow: 0 12px 32px rgb(0 0 0 / 0.5);
    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%23b2bedc' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--frame); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* ---------- page changes: never a blank white window ---------- */
/* Full page loads (sign-in, sign-out) cross-fade; in-app links swap the sheet (app.js) and fade the same way. */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 140ms; }
/* Only shown when the next page takes more than 0.4 s */
html.is-loading { cursor: progress; }
html.is-loading body::before { content: ""; position: fixed; inset: 0 0 auto; z-index: 100; height: 2px; background: var(--data); transform-origin: left; animation: loading 1.1s var(--ease-out) infinite; }
@keyframes loading { from { transform: scaleX(0); } to { transform: scaleX(1); opacity: 0.3; } }
[tabindex="-1"]:focus { outline: none; }
body { margin: 0; background: var(--frame); color: var(--text); font: 400 var(--fs-body)/22px var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
strong, b { font-weight: 500; }
ul[class], ol[class] { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--data); outline-offset: 2px; border-radius: 4px; }
.num, table, .figure { font-variant-numeric: tabular-nums lining-nums; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.dash { color: var(--faint); }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 50; padding: 8px 12px; background: var(--primary); color: var(--primary-ink); border-radius: var(--radius-control); }
.skip-link:focus { top: 8px; }

/* ---------- shell: the sidebar on the frame tone, the page beside it on the surface, edge to edge ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); grid-template-rows: auto 1fr; min-height: 100svh; background: var(--surface); }
/* the sidebar's tone and edge run the whole height of the page, behind the sticky sidebar */
.app::before { content: ""; grid-column: 1; grid-row: 1 / -1; background: var(--frame); border-right: 1px solid var(--border); }
.sidebar { grid-column: 1; grid-row: 1 / -1; position: sticky; top: 0; height: 100svh; display: flex; flex-direction: column; padding: 16px 12px; overflow: auto; }
.brand { display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 8px; text-decoration: none; }
.brand .mark { width: 26px; height: 26px; }
.brand .wordmark { width: auto; height: 15px; }
.scope { margin: 4px 8px 24px 42px; font-size: var(--fs-small); color: var(--faint); }
.nav { display: grid; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; transition: background-color var(--t-hover) ease, color var(--t-hover) ease; }
.nav-item svg { width: 16px; height: 16px; flex: none; }
.nav-item:hover { background: var(--active); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--active); color: var(--text); }
.nav-item .count { margin-left: auto; font-size: var(--fs-small); color: var(--faint); font-variant-numeric: tabular-nums; }
.sidebar .bottom { margin-top: auto; display: grid; justify-items: start; gap: 12px; padding: 16px 12px 0; border-top: 1px solid var(--border); }
.who { display: grid; gap: 2px; min-width: 0; justify-self: stretch; }
.who strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span { font-size: var(--fs-small); color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* the search heads the page column, on the content's left edge */
.topbar { grid-column: 2; display: flex; align-items: center; gap: 12px; padding: 20px calc(var(--pad) + 8px) 0; min-width: 0; }
.topbar .menu-toggle, .topbar .topbar-brand { display: none; }
.search { position: relative; width: min(400px, 100%); }
.search svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search input { width: 100%; height: 36px; padding: 0 40px 0 36px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--input-bg); }
.search input::placeholder { color: var(--faint); }
.search input:focus { outline: none; border-color: var(--data); box-shadow: 0 0 0 3px var(--focus-ring); }
.search kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); min-width: 24px; height: 24px; padding: 0 8px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 5px; background: var(--raised); color: var(--faint); font: 500 12px/1 var(--font); }
.search input:focus + kbd, .search input:not(:placeholder-shown) + kbd { display: none; }

.sheet { min-width: 0; margin: 0 var(--inset) var(--inset) 0; padding: var(--pad) calc(var(--pad) + 8px) 40px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sheet); }
.app > .sheet { grid-column: 2; margin: 0; border: 0; border-radius: 0; background: none; }
.sheet-inner { max-width: 1240px; }

/* ---------- title row ---------- */
.crumbs { display: flex; align-items: center; gap: 4px; margin-bottom: 12px; font-size: var(--fs-small); color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.title-row h1 { font: 500 var(--fs-title)/1.2 var(--font-display); }
.title-row .sub { margin-top: 8px; color: var(--muted); }
.title-row .actions { display: flex; align-items: center; gap: 8px; flex: none; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--control-height); padding: 0 16px; border-radius: var(--radius-control); border: 1px solid var(--control); background: var(--surface); color: var(--text); font-weight: 500; text-decoration: none; white-space: nowrap; cursor: pointer; transition: background-color var(--t-hover) ease, border-color var(--t-hover) ease, transform var(--t-press) var(--ease-out); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:hover { background: var(--raised); border-color: var(--control-hover); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { background: var(--surface); color: var(--negative); border-color: var(--danger-border); }
.btn.danger:hover { background: var(--danger-hover-bg); border-color: var(--negative); }
.btn.danger-fill { background: var(--negative); color: var(--negative-ink); border-color: var(--negative); }
.btn.danger-fill:hover { background: var(--negative-hover); border-color: var(--negative-hover); }
.btn.small { height: 32px; padding: 0 12px; font-size: var(--fs-small); }
.btn.text { height: auto; padding: 0; border: 0; background: none; font-weight: 500; text-underline-offset: 3px; }
.btn.text:hover { background: none; text-decoration: underline; }
.btn.text.danger { color: var(--negative); }

/* ---------- flash messages ---------- */
.flash { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; padding: 12px 16px; border-radius: var(--radius-control); background: var(--pill-positive-bg); color: var(--pill-positive-ink); font-weight: 500; }
.flash svg { width: 16px; height: 16px; flex: none; }
.flash.info { background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); }
.flash.error { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }

/* ---------- pills ---------- */
.pill { display: inline-flex; flex: none; align-items: center; height: 24px; padding: 0 8px; border-radius: 6px; font-size: var(--fs-small); font-weight: 500; white-space: nowrap; background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); }
.pill.warn { background: var(--pill-warning-bg); color: var(--pill-warning-ink); }
.pill.change { background: var(--pill-change-bg); color: var(--pill-change-ink); }
.pill.admin { background: var(--pill-change-bg); color: var(--pill-change-ink); }

/* ---------- customer list ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 36px; margin-bottom: 8px; }
.toolbar .count { color: var(--muted); }
.toolbar .count strong { color: var(--text); font-weight: 500; }
.toolbar form { display: flex; align-items: center; gap: 8px; }
.toolbar label { color: var(--muted); font-size: var(--fs-small); }
.select { height: var(--control-height); padding: 0 32px 0 12px; border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--input-bg) var(--select-arrow) right 10px center / 12px no-repeat; color: var(--text); appearance: none; cursor: pointer; transition: border-color var(--t-hover) ease, box-shadow var(--t-hover) ease; }
.select:hover { border-color: var(--control-hover); }
.select:focus { outline: none; border-color: var(--data); box-shadow: 0 0 0 3px var(--focus-ring); }
.select.form-select { height: var(--input-height); min-width: 220px; }
.select option, .select optgroup { background: var(--surface); color: var(--text); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { height: 40px; padding: 0 16px; text-align: left; font-weight: 500; font-size: var(--fs-small); color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color var(--t-hover) ease; }
tbody tr:hover td { background: var(--raised); }
th.n, td.n { text-align: right; }
td .sub { display: block; margin-top: 2px; font-size: var(--fs-small); line-height: 18px; color: var(--muted); }
td.name a { font-weight: 500; text-decoration: none; }
td.name a::after { content: ""; position: absolute; inset: 0; }  /* the whole row opens the record */
tbody tr { position: relative; }
td.name a:hover { text-decoration: underline; text-underline-offset: 3px; }
/* every row two even lines (a value, then a quieter one), so rows share one height */
.customers { table-layout: fixed; }
.customers .col-name { width: 24%; } .customers .col-contact { width: 18%; } .customers .col-system { width: 20%; } .customers .col-fit { width: 15%; }
.customers td { height: 68px; }
.customers .line, .customers td .sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.customers .line.runway, .customers .line.status { display: flex; }
.customers td .sub { margin-top: 4px; }
.customers td.name a { font-size: 16px; line-height: 22px; }
.ellipsis { display: block; max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-line { display: none; }

/* the FIT runway: how much of the term is left, on one track length so the rows read as a column */
.runway { display: flex; align-items: center; gap: 12px; }
.runway .bar { flex: none; width: 64px; height: 4px; }
.runway .bar .track { fill: var(--data-track); }
.runway .bar .left { fill: var(--data); }
.runway strong { font-weight: 500; }

/* a status: a small dot in its tone, the words in ink (assessments, a FIT term to set) */
.status { display: flex; align-items: center; gap: 8px; min-width: 0; }
.status::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.status > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status.good::before { background: var(--dot-good); }
.status.warn::before { background: var(--dot-warn); }
.status.bad::before { background: var(--dot-bad); }

/* the summary figures lead the list; each one is a link that filters it (?filter=), the one shown is selected */
.list-stats { display: inline-grid; grid-auto-flow: column; grid-auto-columns: minmax(168px, auto); gap: 4px; max-width: 100%; margin: -4px 0 32px; padding: 4px; border: 1px solid var(--border); border-radius: 12px; }
.list-stats a { display: grid; align-content: start; gap: 4px; padding: 12px 16px; border-radius: 8px; color: var(--text); text-decoration: none; transition: background-color var(--t-hover) ease, box-shadow var(--t-hover) ease; }
.list-stats a:hover { background: var(--raised); }
.list-stats a:focus-visible { border-radius: 8px; }
.list-stats a[aria-current="page"] { background: var(--active); box-shadow: inset 0 0 0 1px var(--control); }
.list-stats .figure { order: 2; font: 500 28px/36px var(--font-display); }
.list-stats .label { order: 1; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: var(--fs-small); line-height: 20px; }
.list-stats a[aria-current="page"] .label { color: var(--text); }
.list-stats .is-warn .label::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--dot-warn); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 20px; color: var(--muted); }
.pager .links { display: flex; gap: 8px; }

.empty { display: grid; justify-items: start; gap: 12px; padding: 28px; border: 1px dashed var(--control); border-radius: var(--radius-card); color: var(--muted); }
.empty strong { color: var(--text); font-size: var(--fs-section); }

/* ---------- record page ---------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); }
.span-12 { grid-column: span 12; } .span-6 { grid-column: span 6; }
.panel { min-width: 0; padding: var(--card-pad); border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); }
.panel > header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel h2 { font: 500 var(--fs-section)/1.3 var(--font-display); }
.panel header a { font-size: var(--fs-small); font-weight: 500; text-underline-offset: 3px; }

/* key-value rows */
.kv { display: grid; }
.kv > div { display: grid; grid-template-columns: minmax(120px, 38%) minmax(0, 1fr); gap: 16px; padding: 12px 0; }
.kv > div + div { border-top: 1px solid var(--rule); }
.kv dt { color: var(--muted); }
.kv dd { min-width: 0; overflow-wrap: anywhere; }
.kv dd a { text-underline-offset: 3px; }
.kv .address { white-space: pre-line; }

/* the FIT runway: the record's main block */
.fit-panel { display: grid; grid-template-columns: minmax(240px, 0.8fr) minmax(0, 2fr); gap: 40px; align-items: center; padding: 24px var(--card-pad); }
.fit-figure .label { color: var(--muted); font-weight: 500; }
.fit-figure .figure { margin-top: 4px; font: 500 var(--fs-figure)/1.1 var(--font-display); }
.fit-figure .figure small { font-size: 0.56em; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.fit-figure .detail { margin-top: 8px; color: var(--muted); }
.fit-figure .detail strong { color: var(--text); font-weight: 500; }
.runway { min-width: 0; }
.runway-legend { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-bottom: 12px; font-weight: 500; }
.runway-legend span { display: inline-flex; align-items: center; gap: 8px; }
.runway-legend .key { width: 10px; height: 10px; border-radius: 2px; background: var(--data-track); }
.runway-legend .key.left { background: var(--data); }
.runway-bar { width: 100%; height: 12px; border-radius: 3px; overflow: hidden; }
.runway-bar .used { fill: var(--data-track); }
.runway-bar .left { fill: var(--data); }
.runway-scale { display: flex; justify-content: space-between; margin-top: 8px; font-size: var(--fs-small); color: var(--muted); }
.runway-scale strong { color: var(--text); font-weight: 500; }
.fit-note { display: flex; gap: 8px; align-items: flex-start; margin-top: 16px; padding: 12px 12px; border-radius: var(--radius-control); background: var(--pill-warning-bg); color: var(--pill-warning-ink); font-size: var(--fs-small); line-height: 19px; }
.fit-note.info { background: var(--raised); color: var(--muted); }
.fit-note svg { width: 15px; height: 15px; flex: none; margin-top: 2px; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 12px 0 12px; }
.section-head h2 { font: 500 var(--fs-section)/1.3 var(--font-display); }

/* equipment: one divided strip, label over state */
.equipment { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius-card); }
.equipment > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 12px var(--card-pad); min-width: 0; }
.equipment > div:not(:nth-child(3n + 1)) { border-left: 1px solid var(--border); }
.equipment > div:nth-child(n + 4) { border-top: 1px solid var(--border); }
.equipment dt { color: var(--muted); font-weight: 500; }
.equipment dd { display: flex; }
.equipment .state { font-weight: 500; }

.notes-text { white-space: pre-line; max-width: 75ch; }
.delete-summary { max-width: 640px; margin-bottom: 24px; }
.delete-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.record-meta { margin-top: 20px; font-size: var(--fs-small); color: var(--muted); }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border); }
.danger-zone h2 { font: 500 var(--fs-section)/1.3 var(--font-display); }
.danger-zone p { color: var(--muted); }

/* ---------- forms: section rows (label column beside a panel) ---------- */
.error-summary { margin-bottom: 24px; padding: 16px 16px; border-radius: var(--radius-control); background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.error-summary h2 { font: 500 var(--fs-body)/22px var(--font); }
.error-summary ul { margin: 8px 0 0; padding-left: 20px; }
.error-summary a { color: inherit; font-weight: 500; text-underline-offset: 3px; }
.form-section { display: grid; grid-template-columns: minmax(200px, 300px) minmax(0, 1fr); gap: 32px; padding: 28px 0; }
.form-section + .form-section { border-top: 1px solid var(--rule); }
.form-section:first-of-type { padding-top: 4px; }
.form-section > header h2 { font: 500 var(--fs-section)/1.3 var(--font-display); }
.form-section > header p, .form-section > header > div > p { margin-top: 8px; color: var(--muted); }
.fields { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px 16px; max-width: 760px; }
.field { display: grid; gap: 8px; grid-column: span 6; min-width: 0; align-content: start; }
.field.half { grid-column: span 3; } .field.third { grid-column: span 2; } .field.two-thirds { grid-column: span 4; }
.field > label, .field > legend, .field .label { font-weight: 500; }
.field .opt { font-weight: 400; color: var(--faint); }
.field .hint { color: var(--muted); font-size: var(--fs-small); line-height: 18px; }
.field .error { color: var(--negative); font-size: var(--fs-small); font-weight: 500; line-height: 18px; }
.input { width: 100%; height: var(--input-height); padding: 0 12px; border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--input-bg); transition: border-color var(--t-hover) ease, box-shadow var(--t-hover) ease; }
textarea.input { height: auto; min-height: 84px; padding: 8px 12px; line-height: 22px; resize: vertical; }
.input:hover { border-color: var(--control-hover); }
.input:focus { outline: none; border-color: var(--data); box-shadow: 0 0 0 3px var(--focus-ring); }
.input[aria-invalid="true"] { border-color: var(--negative); }
.input.year { max-width: 140px; }
.input-unit { display: flex; align-items: center; }
.input-unit .input { border-radius: var(--radius-control) 0 0 var(--radius-control); }
.input-unit span { display: grid; place-items: center; height: var(--input-height); padding: 0 12px; border: 1px solid var(--control); border-left: 0; border-radius: 0 var(--radius-control) var(--radius-control) 0; background: var(--raised); color: var(--muted); }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }

/* postcode search: a combobox over postcodes.io, then the area and any customers already at that postcode */
.combo { position: relative; width: min(240px, 100%); }
.input.postcode { text-transform: uppercase; font-variant-numeric: tabular-nums; }
.combo-list { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 100%; max-height: 330px; overflow-y: auto; margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-control); box-shadow: var(--menu-shadow); }
.combo-list li { padding: 8px 12px; border-radius: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; cursor: pointer; }
.combo-list li:hover { background: var(--raised); }
.combo-list li[aria-selected="true"] { background: var(--selected); font-weight: 500; }
.postcode-result { display: grid; gap: 8px; max-width: 560px; }
.postcode-result:empty { display: none; }
.postcode-result .area { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.postcode-result .area svg { width: 15px; height: 15px; flex: none; color: var(--data); }
.postcode-result .area small { color: var(--faint); font-weight: 400; font-size: var(--fs-small); }
.postcode-result .note { color: var(--muted); font-size: var(--fs-small); line-height: 19px; }
.postcode-matches { padding: 12px 12px; border-radius: var(--radius-control); background: var(--pill-warning-bg); color: var(--pill-warning-ink); font-size: var(--fs-small); line-height: 19px; }
.postcode-matches ul { margin: 4px 0 0; padding-left: 20px; }
.postcode-matches a { color: inherit; font-weight: 500; text-underline-offset: 3px; }

/* segmented radio group: every option in full ink; the chosen one is a solid fill (navy on light, cyan on dark);
   "Not recorded" when chosen is a quiet grey fill, so each row visibly has an answer */
.segmented { display: inline-flex; flex-wrap: wrap; width: max-content; max-width: 100%; padding: 4px; gap: 4px; border-radius: 10px; background: var(--raised); border: 1px solid var(--border); }
.segmented label { position: relative; display: block; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: block; height: 32px; padding: 0 16px; line-height: 32px; border-radius: 7px; color: var(--text); font-weight: 500; white-space: nowrap; transition: background-color var(--t-hover) ease, color var(--t-hover) ease; }
.segmented label:hover span { background: var(--active); }
.segmented input:checked + span { background: var(--primary); color: var(--primary-ink); font-weight: 500; }
.segmented input:checked + span.unset { background: var(--active); color: var(--muted); font-weight: 500; }
.segmented input:focus-visible + span { outline: 2px solid var(--data); outline-offset: 2px; }

/* equipment rows in the form */
.equip-rows { display: grid; max-width: 760px; }
.equip-row { display: grid; grid-template-columns: minmax(150px, 210px) minmax(0, 1fr); justify-items: start; align-items: center; gap: 8px 16px; padding: 12px 0; }
.equip-row + .equip-row { border-top: 1px solid var(--rule); }
.equip-row legend { float: left; padding: 0; font-weight: 500; }
.equip-row .error { grid-column: 1 / -1; }

/* live FIT preview beside the install year */
.fit-preview { display: grid; gap: 4px; margin-top: 20px; padding: 16px 16px; border-radius: var(--radius-card); background: var(--raised); }
.fit-preview .figure { font: 500 20px/1.2 var(--font-display); }
.fit-preview .detail { color: var(--muted); font-size: var(--fs-small); line-height: 19px; }

.form-actions { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin: 8px calc(-1 * (var(--pad) + 8px)) -40px; padding: 16px calc(var(--pad) + 8px); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-sheet) var(--radius-sheet); background: var(--surface); }
.app .form-actions { border-radius: 0; }
.form-actions .note { margin-right: auto; color: var(--muted); font-size: var(--fs-small); }

/* settings-style rows (staff, account) */
.settings-row { display: grid; grid-template-columns: minmax(200px, 300px) minmax(0, 1fr); gap: 32px; padding: 28px 0; }
.settings-row + .settings-row { border-top: 1px solid var(--rule); }
.settings-row:first-of-type { padding-top: 4px; }
.settings-row > header h2 { font: 500 var(--fs-section)/1.3 var(--font-display); }
.settings-row > header p { margin-top: 8px; color: var(--muted); }
.staff-table td { vertical-align: middle; }
.staff-actions { display: flex; justify-content: flex-end; align-items: center; gap: 16px; }
details.reset summary { cursor: pointer; font-weight: 500; list-style: none; white-space: nowrap; }
details.reset summary::-webkit-details-marker { display: none; }
details.reset[open] summary { margin-bottom: 8px; }
details.reset form { display: flex; gap: 8px; }
details.reset .input { height: 32px; width: 220px; }
.checkbox { display: flex; align-items: flex-start; gap: 8px; font-weight: 500; }
.checkbox input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--primary); }
.checkbox span small { display: block; color: var(--muted); font-weight: 400; font-size: var(--fs-small); }

/* ---------- sign-in, setup and error pages ---------- */
.plain { min-height: 100svh; display: grid; place-items: center; padding: 24px 16px; }
.plain-card { width: min(420px, 100%); padding: 32px; border: 1px solid var(--border); border-radius: var(--radius-sheet); background: var(--surface); }
.plain-card .brand { padding: 0; margin-bottom: 28px; }
.plain-card h1 { font: 500 22px/1.25 var(--font-display); }
.plain-card .lead { margin-top: 8px; color: var(--muted); }
.plain-card form { display: grid; gap: 16px; margin-top: 24px; }
.plain-card .btn { height: var(--input-height); }
.plain-card .flash { margin: 20px 0 0; }
.plain-foot { margin-top: 20px; font-size: var(--fs-small); color: var(--muted); text-align: center; }

/* ---------- tablet and phone ---------- */
@media (max-width: 1100px) {
  .customers .col-contact, .customers td.contact { display: none; }
  .customers .col-name { width: 30%; } .customers .col-system { width: 24%; } .customers .col-fit { width: 20%; }
  .runway .bar { width: 40px; }
}
@media (max-width: 1000px) {
  .equipment { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .equipment > div:nth-child(n) { border-left: 0; border-top: 0; }
  .equipment > div:nth-child(2n) { border-left: 1px solid var(--border); }
  .equipment > div:nth-child(n + 3) { border-top: 1px solid var(--border); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { position: fixed; inset: 0; z-index: 30; width: 100%; height: 100%; background: var(--frame); transform: translateX(-100%); visibility: hidden; transition: transform var(--t-ui) var(--ease-out), visibility 0s linear var(--t-ui); }
  .sidebar.open { transform: none; visibility: visible; transition: transform var(--t-ui) var(--ease-out); }
  .sidebar .close { display: inline-flex; }
  .app::before { display: none; }
  .topbar { grid-column: 1; flex-wrap: wrap; justify-content: space-between; gap: 8px 12px; padding: 8px 16px 12px; background: var(--frame); border-bottom: 1px solid var(--border); }
  .topbar .menu-toggle { display: inline-flex; }
  .topbar .topbar-brand { display: flex; align-items: center; gap: 8px; margin-right: auto; }
  .topbar .topbar-brand img { height: 22px; width: auto; }
  .topbar .topbar-brand .wordmark { height: 13px; }
  .search { order: 3; width: 100%; }
  .search kbd { display: none; }
  .sheet { margin: 0; border-width: 1px 0 0; border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; padding: 20px 16px 32px; }
  .app > .sheet { grid-column: 1; }
  .form-section, .settings-row { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  /* the FIT preview follows the fields it is worked out from */
  .form-section.with-preview > header { display: contents; }
  .form-section.with-preview .fields { order: 1; }
  .form-section.with-preview .fit-preview { order: 2; margin-top: 0; }
  .fit-panel { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .span-6 { grid-column: span 12; }
  .form-actions { margin: 8px -16px -32px; padding: 12px 16px; border-radius: 0; }
}
@media (min-width: 901px) {
  .sidebar .close { display: none; }
}
@media (max-width: 640px) {
  .title-row { flex-wrap: wrap; align-items: flex-start; margin-bottom: 16px; }
  .title-row h1 { font-size: 22px; }
  .toolbar { flex-wrap: wrap; }
  .customers thead { display: none; }
  .customers tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
  .customers tbody tr:last-child { border-bottom: 0; }
  .customers td { height: auto; padding: 0; border: 0; }
  .customers td.contact, .customers td.system { display: none; }
  .customers td.name .sub { display: none; }
  .customers td.name { grid-column: 1; grid-row: 1; }
  .customers td.fit { grid-column: 2; grid-row: 1 / span 2; text-align: right; }
  .customers td.fit .runway { justify-content: flex-end; gap: 8px; }
  .customers td.fit .runway .bar { width: 48px; }
  .customers td.fit .status { justify-content: flex-end; }
  .customers .mobile-line { display: block; grid-column: 1; grid-row: 2; margin-top: 4px; font-size: var(--fs-small); line-height: 20px; color: var(--muted); }
  .customers .mobile-line span { white-space: nowrap; }
  .customers td.assessed { grid-column: 1 / -1; grid-row: 3; display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: var(--fs-small); }
  .customers td.assessed.is-none { display: none; }
  .customers td.assessed .sub { margin: 0; }
  .customers td.assessed .sub::before { content: "· "; }
  .list-stats { display: grid; grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; margin-bottom: 24px; }
  .list-stats a { min-height: 76px; padding: 12px; }
  .list-stats .figure { font-size: 24px; line-height: 32px; }
  tbody tr:hover td { background: none; }
  .equipment { grid-template-columns: minmax(0, 1fr); }
  .equipment > div:nth-child(n) { border-left: 0; }
  .equipment > div:nth-child(n + 2) { border-top: 1px solid var(--border); }
  .kv > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dt { font-size: var(--fs-small); }
  .section-head { flex-wrap: wrap; gap: 2px 12px; }
  .segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .segmented label:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .segmented span { text-align: center; }
  .field.half, .field.third, .field.two-thirds { grid-column: span 6; }
  .fit-figure .figure { font-size: 28px; }
  .equip-row { grid-template-columns: minmax(0, 1fr); }
  .danger-zone { flex-direction: column; align-items: flex-start; }
  .staff-table thead { display: none; }
  .staff-table tr { display: grid; gap: 4px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
  .staff-table td { padding: 0; border: 0; }
  .staff-actions { justify-content: flex-start; flex-wrap: wrap; }
  details.reset form { flex-direction: column; }
  details.reset .input { width: 100%; }
  .plain-card { padding: 24px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation: none !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* ---------- staff access ticks and the activity log ---------- */
.ticks { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.checkbox.tick { align-items: center; gap: 4px; font-size: var(--fs-small); white-space: nowrap; cursor: pointer; }
.checkbox.tick input { margin: 0; }
.field.access { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; }
.field.access legend { margin-bottom: 8px; font-weight: 500; }
.toolbar .filters { flex-wrap: wrap; }
.activity-table td { vertical-align: top; }
.activity-table .when { white-space: nowrap; color: var(--muted); }
.activity-table td a { color: var(--text); text-underline-offset: 3px; }
.activity-table tr.flagged td:first-child { box-shadow: inset 3px 0 0 var(--negative); padding-left: 12px; }
.activity-table tr.flagged strong { color: var(--negative); }
@media (max-width: 760px) {
  .activity-table thead { display: none; }
  .activity-table tr { display: grid; gap: 4px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
  .activity-table td { padding: 0; border: 0; }
}

/* ---------- assessments from quote ---------- */
.pill.good { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.pill.bad { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.assessment-list { display: grid; gap: 12px; }
.assessment-list li { display: grid; gap: 8px; padding: 16px 16px; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--raised); }
.assessment-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.assessment-head a { text-underline-offset: 3px; }
.assessment-list .btn { justify-self: start; }
.kv.compact > div { padding: 8px 0; }

/* ---------- energy dashboard (/customers/{id}/energy, and the customer's own /home) ---------- */
/* The stage stays brand navy in both themes: it is the showcase, shown to customers on site.
   Chart colours checked with the dataviz validator: cyan = solar and income, orange = home use and the bill. */
:root {
  --stage: #011142; --stage-raised: #0a2266; --stage-line: rgb(242 245 255 / 0.1);
  --stage-ink: #f2f5ff; --stage-muted: #aab7da; --stage-accent: #5dd9fe;
  --stage-solar: #1aa3d1; --stage-use: #cc7a30;
  --chart-income: #0899c9; --chart-bill: #c2702a;
}
@media (prefers-color-scheme: dark) {
  :root { --chart-income: #1aa3d1; --chart-bill: #cc7a30; --stage: #010c30; }
}

.en-source { display: grid; gap: 8px; margin: -8px 0 16px; }
.en-source p { display: flex; align-items: flex-start; gap: 8px; color: var(--muted); font-size: var(--fs-small); }
.en-source p svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.en-source p.warn { padding: 8px 12px; border-radius: var(--radius-control); background: var(--pill-warning-bg); color: var(--pill-warning-ink); }
.en-source a { color: inherit; text-underline-offset: 3px; }

.en-stage { position: relative; padding: 24px; border-radius: var(--radius-card); border: 1px solid var(--stage-line); background: var(--stage); color: var(--stage-ink); }
.en-stage-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.en-stage h2 { font: 500 20px/1.25 var(--font-display); }
.en-when { font: 400 var(--fs-body)/1.3 var(--font); color: var(--stage-muted); letter-spacing: 0; }
.en-status { margin-top: 4px; color: var(--stage-accent); font-weight: 500; }
.en-badge { flex: none; display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border: 1px solid var(--stage-line); border-radius: 6px; color: var(--stage-muted); font-size: var(--fs-small); font-weight: 500; }

.en-scene { display: grid; grid-template-columns: minmax(128px, 176px) minmax(0, 680px) minmax(128px, 176px); grid-template-rows: 1fr 1fr; grid-template-areas: "solar house home" "battery house grid"; justify-content: center; column-gap: 16px; margin-top: 16px; }
.en-house { grid-area: house; min-width: 0; }
.en-house svg { display: block; width: 100%; height: auto; }
.readout { display: grid; align-content: start; gap: 4px; align-self: end; }
.readout.is-solar { grid-area: solar; } .readout.is-home { grid-area: home; } .readout.is-battery { grid-area: battery; } .readout.is-grid { grid-area: grid; }
/* left of the house they read towards it; the top pair sits level with the roof, the bottom pair with the battery and pylon */
.readout.is-solar, .readout.is-battery { justify-items: end; text-align: right; }
.readout.is-battery, .readout.is-grid { padding-bottom: 16px; }
.readout .label { display: inline-flex; align-items: center; gap: 8px; color: var(--stage-muted); font-size: var(--fs-small); }
.readout .label svg { width: 16px; height: 16px; }
.readout .value { font: 500 32px/40px var(--font-display); white-space: nowrap; }
.readout .value .soc { font-size: 20px; color: var(--stage-muted); }
.readout .sub { color: var(--stage-muted); font-size: var(--fs-small); line-height: 20px; }
/* A narrower stage (tablet, or the staff page beside the sidebar): the house on top, the four readouts in a row under it;
   on a phone, two by two */
.en-stage { container-type: inline-size; }
@container (max-width: 880px) {
  .en-scene { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: auto; grid-template-areas: "house house house house" "solar home battery grid"; column-gap: 16px; margin-top: 8px; }
  .en-house { justify-self: center; width: 100%; max-width: 640px; margin-bottom: 8px; }
  .readout, .readout.is-battery, .readout.is-grid { align-self: start; padding: 12px 0 0; border-top: 1px solid var(--stage-line); }
  .readout.is-solar, .readout.is-battery { justify-items: start; text-align: left; }
  .readout .value { font-size: 28px; line-height: 36px; }
}
@container (max-width: 560px) {
  .en-scene { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "house house" "solar home" "battery grid"; }
  .en-house { margin: 0 -8px 8px; width: calc(100% + 16px); max-width: none; }
  .readout.is-battery, .readout.is-grid { margin-top: 12px; }
  .readout.is-home, .readout.is-grid { justify-items: end; text-align: right; }
  .readout .value { font-size: 24px; line-height: 32px; }
  .readout .value .soc { font-size: 16px; }
}

/* the house picture */
.house .stars circle { fill: #c9d4f2; opacity: 0; transition: opacity 400ms ease; }
.house.night .stars circle { opacity: 0.7; }
.house .moon { fill: #c9d4f2; opacity: 0; transition: opacity 400ms ease; }
.house.night .moon { opacity: 0.85; }

.house .sun .disc { fill: #ffd56a; }
.house .shadow { fill: #000; opacity: 0.28; }
.house .ground { stroke: var(--stage-line); stroke-width: 2; }
.house .pylon path { fill: none; stroke: #7387bd; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.house .chimney { fill: #132f78; }
.house .side { fill: #0f2a6c; }
.house .gable { fill: #14337e; }
.house .verge { stroke: #2a4ea8; stroke-width: 6; stroke-linecap: round; }
.house .ridge { stroke: #4a72d4; stroke-width: 3; stroke-linecap: round; }
.house .wall { fill: #1a3d8f; }
.house .roof { fill: #0c2563; }
.house .panels polygon { fill: #061a4c; stroke: #2b5bb0; stroke-width: 1; transition: fill 400ms ease, stroke 400ms ease; }
.house.sunny .panels polygon { fill: #0b3a8a; stroke: #5dd9fe; }
.house .eaves { fill: rgb(1 12 48 / 0.35); }
.house .windows .pane { fill: #0c2766; stroke: #dfe7fb; stroke-width: 2; transition: fill 400ms ease; }
.house.night .windows .pane { fill: #0a1b4a; }
.house.night .windows.use1 .pane { fill: #7a6440; }
.house.night .windows.use2 .pane { fill: #d6ad64; }
.house.night .windows.use3 .pane { fill: #ffd98c; }
.house .glints { transition: opacity 400ms ease; }
.house .glints path { fill: rgb(255 255 255 / 0.12); }
.house.night .glints { opacity: 0; }
.house .frames path { fill: none; stroke: #dfe7fb; stroke-width: 2; }
.house .frames rect { fill: #dfe7fb; }
.house .door { fill: #0b1f55; }
.house .door-glass { fill: #0c2766; stroke: #dfe7fb; stroke-width: 1.5; }
.house .knob { fill: #dfe7fb; }
.house .hub { fill: #e7edfd; }
.house .battery-unit { fill: #dfe7fb; }
.house .battery-level { fill: var(--stage-solar); }
.house .cable { fill: none; stroke: rgb(255 255 255 / 0.14); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.house .flow { fill: none; stroke: var(--stage-accent); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 2 10; animation: en-flow 1.1s linear infinite; transition: opacity 300ms ease; }
.house .flow.f1 { animation-duration: 1.8s; opacity: 0.75; }
.house .flow.f3 { animation-duration: 0.6s; }
.house .flow.reverse { animation-direction: reverse; }
.house .flow.off { opacity: 0; }
@keyframes en-flow { to { stroke-dashoffset: -12; } }

/* time and month */
.en-controls { display: grid; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--stage-line); }
.en-time { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; align-items: center; gap: 4px 16px; }
.en-time label { grid-column: 2; color: var(--stage-muted); font-size: var(--fs-small); }
.en-time output { margin-left: 8px; color: var(--stage-ink); font-weight: 500; }
.en-time input[type="range"] { grid-column: 2; width: 100%; margin: 0; accent-color: var(--stage-accent); cursor: pointer; }
.en-play { grid-row: 1 / 3; display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 16px 0 12px; border: 0; border-radius: 8px; background: var(--stage-accent); color: var(--stage); font-weight: 500; white-space: nowrap; cursor: pointer; transition: background-color var(--t-hover) ease, transform var(--t-press) var(--ease-out); }
.en-play:hover { background: #8ce6ff; }
.en-play:active { transform: translateY(1px); }
.en-play svg { width: 14px; height: 14px; fill: currentColor; }
.en-play:focus-visible, .en-months input:focus-visible + span { outline: 2px solid var(--stage-accent); outline-offset: 2px; }
.en-months { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0; padding: 0; border: 0; }
.en-months legend { float: left; padding: 0; margin-right: 12px; color: var(--stage-muted); font-size: var(--fs-small); line-height: 32px; }
.en-months label { position: relative; }
.en-months input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.en-months span { display: grid; place-items: center; min-width: 40px; height: 32px; padding: 0 8px; border-radius: 6px; color: var(--stage-muted); font-size: var(--fs-small); font-weight: 500; cursor: pointer; transition: background-color var(--t-hover) ease, color var(--t-hover) ease; }
.en-months span:hover { background: var(--stage-raised); color: var(--stage-ink); }
.en-months input:checked + span { background: var(--stage-ink); color: var(--stage); }

/* the day chart */
.en-day { margin: 20px 0 0; }
.en-day figcaption { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-bottom: 8px; color: var(--stage-ink); font-size: var(--fs-small); font-weight: 500; }
.en-day figcaption .key { width: 10px; height: 10px; border-radius: 2px; }
.en-day figcaption .key.solar { background: var(--stage-solar); }
.en-day figcaption .key.use { height: 2px; margin-left: 12px; border-radius: 1px; background: var(--stage-use); }
.en-day-note { margin-left: auto; color: var(--stage-muted); font-weight: 400; }
.en-day svg { display: block; width: 100%; height: 110px; }
.en-day .axis { stroke: var(--stage-line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.en-day .solar-area { fill: rgb(26 163 209 / 0.32); stroke: var(--stage-solar); stroke-width: 2; vector-effect: non-scaling-stroke; }
.en-day .use-line { fill: none; stroke: var(--stage-use); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.en-day .cursor { stroke: var(--stage-ink); stroke-width: 1.5; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.en-day-axis { display: flex; justify-content: space-between; margin-top: 8px; color: var(--stage-muted); font-size: 12px; }
.en-day-totals { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--stage-line); }
.en-day-totals dt { color: var(--stage-muted); font-size: 12px; }
.en-day-totals dd { margin-top: 2px; font: 500 18px/1.3 var(--font-display); }

/* the year, the next ten years, trial runs: open sections on the sheet, ruled apart, each led by its main figure */
.en-section { margin-top: 40px; padding-top: 32px; border-top: 1px solid var(--rule); container-type: inline-size; }
.en-stage + .en-section { margin-top: 48px; padding-top: 0; border-top: 0; }
.en-section-head { display: grid; gap: 4px; margin-bottom: 24px; }
.en-section-head h2 { font: 500 22px/28px var(--font-display); }
.en-section-head p { color: var(--muted); }
.en-figure { font: 500 40px/48px var(--font-display); }

.en-year-body { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 32px 64px; align-items: start; }
.en-money { display: grid; grid-template-columns: repeat(2, max-content); gap: 24px 64px; }
.en-money dt { color: var(--muted); }
.en-money .en-figure { margin-top: 4px; }
.en-money .sub { margin-top: 4px; color: var(--muted); font-size: var(--fs-small); line-height: 20px; }
.en-energy { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
.en-energy > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-content: start; align-items: baseline; column-gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.en-energy > div:nth-child(-n + 2) { border-top: 1px solid var(--rule); }
.en-energy dt { color: var(--muted); }
.en-energy dd.num { font: 500 18px/24px var(--font-display); text-align: right; }
.en-energy dd.sub { grid-column: 1 / -1; color: var(--muted); font-size: var(--fs-small); line-height: 20px; }

.en-forecast-lead { display: grid; grid-template-columns: max-content minmax(0, 60ch); align-items: end; gap: 16px 64px; }
.en-worth { display: grid; gap: 4px; }
.en-worth .en-figure { font-size: 48px; line-height: 56px; color: var(--data); }
.en-worth span { color: var(--muted); }
.en-forecast-text { color: var(--muted); }
.en-forecast-text strong { color: var(--text); font-weight: 500; }

/* the 10-year chart: bars in an SVG stretched to the plot, the £ scale and years as text around it */
.en-chart { margin: 40px 0 0; }
.en-chart .legend { display: flex; flex-wrap: wrap; gap: 4px 24px; margin-bottom: 16px; color: var(--muted); font-size: var(--fs-small); }
.en-chart .legend span { display: inline-flex; align-items: center; gap: 8px; }
.en-chart .legend .key { width: 10px; height: 10px; border-radius: 2px; }
.en-chart .legend .key.income { background: var(--chart-income); }
.en-chart .legend .key.bill { background: var(--chart-bill); }
.en-chart .legend .key.fit-end { width: 0; height: 16px; border-radius: 0; border-left: 1.5px dashed var(--faint); }
.en-plot { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 280px auto; column-gap: 12px; }
.en-plot-scale { grid-row: 1; display: flex; flex-direction: column; justify-content: space-between; margin: -8px 0; color: var(--muted); font-size: 12px; line-height: 16px; text-align: right; font-variant-numeric: tabular-nums; }
.en-plot-bars { grid-row: 1; grid-column: 2; width: 100%; height: 100%; overflow: visible; }
.en-plot-years { grid-row: 2; grid-column: 2; display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 16px; text-align: center; }
.en-plot .gridlines line { stroke: var(--rule); stroke-width: 1; }
.en-plot .gridlines line.base { stroke: var(--control); }
.en-plot .income { fill: var(--chart-income); }
.en-plot .bill { fill: var(--chart-bill); }
.en-plot .year .hit { fill: transparent; transition: fill var(--t-hover) ease; }
.en-plot .year:hover .hit { fill: var(--raised); }
.en-plot .fit-end { stroke: var(--faint); stroke-width: 1.5; stroke-dasharray: 4 4; }
.en-table { margin-top: 24px; }
.en-table summary { width: max-content; font-weight: 500; cursor: pointer; }
.en-table table { margin-top: 8px; }
.en-table td, .en-table tfoot th { padding-top: 8px; padding-bottom: 8px; }
.en-table tbody th { height: auto; padding: 8px 16px 8px 0; color: var(--text); font-size: var(--fs-body); font-weight: 400; border-bottom: 1px solid var(--rule); }
.en-table tfoot th, .en-table tfoot td { border-top: 1px solid var(--border); border-bottom: 0; color: var(--text); font-size: var(--fs-body); font-weight: 500; }
.en-assumptions { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--rule); }
.en-assumptions h3 { font-size: var(--fs-body); font-weight: 500; color: var(--text); }
.en-assumptions ul { display: grid; gap: 4px; margin: 8px 0 0; padding-left: 20px; color: var(--muted); }
.en-assumptions strong { color: var(--text); font-weight: 500; }

.en-trial-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px 16px; max-width: 860px; }
.en-trial-form label { display: grid; gap: 8px; font-weight: 500; }
.en-trial-form .select { width: 100%; height: var(--input-height); }
.money-input { position: relative; display: block; }
.money-input > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 400; }
.money-input .input { padding-left: 28px; font-weight: 400; }
.en-trial-result { margin-top: 20px; transition: opacity var(--t-ui) ease; }
.en-trial-result.is-busy { opacity: 0.55; }
.en-trial-empty { color: var(--muted); }
.en-trial-headline { font-size: 18px; line-height: 28px; }
.en-trial-headline strong { font-weight: 500; }
.en-compare { max-width: 640px; margin-top: 12px; }
.en-compare tbody th { height: auto; padding: 12px 16px 12px 0; color: var(--text); font-size: var(--fs-body); font-weight: 400; border-bottom: 1px solid var(--rule); }
.en-compare td { padding: 12px 16px; }
.en-compare tr.total th, .en-compare tr.total td { border-top: 1px solid var(--border); font-weight: 500; }
.en-trial-note { margin-top: 12px; max-width: 78ch; color: var(--muted); font-size: var(--fs-small); }
.en-disclaimer { max-width: 92ch; margin-top: 48px; color: var(--muted); font-size: var(--fs-small); line-height: 20px; }
.en-disclaimer strong { color: var(--text); font-weight: 500; }

@container (max-width: 900px) {
  .en-year-body { grid-template-columns: minmax(0, 1fr); }
}
@container (max-width: 760px) {
  .en-forecast-lead { grid-template-columns: minmax(0, 1fr); }
}
@container (max-width: 560px) {
  .en-money { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .en-money .en-figure { font-size: 32px; line-height: 40px; }
  .en-energy { grid-template-columns: minmax(0, 1fr); }
  .en-energy > div:nth-child(2) { border-top: 0; }
  .en-worth .en-figure { font-size: 40px; line-height: 48px; }
  .en-plot { grid-template-rows: 220px auto; column-gap: 8px; }
  .en-plot-years { font-size: 11px; }
}

/* staff panels under the dashboard */
.en-staff { margin-top: 48px; }
.en-link { display: grid; gap: 8px; margin-bottom: 16px; padding: 16px 16px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--raised); }
.en-link-row { display: flex; gap: 8px; }
.en-link-row .input { min-width: 0; }
.en-access { display: grid; gap: 8px; margin-top: 16px; }
.en-access label { font-weight: 500; }
.en-access-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.field-error { margin: 0; color: var(--negative); font-size: var(--fs-small); font-weight: 500; }
.en-figures { display: grid; gap: 20px; }
.en-figures fieldset { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; margin: 0; padding: 0; border: 0; }
.en-figures legend { margin-bottom: 12px; font-weight: 500; }
.en-figures .field { grid-column: auto; }
.en-figures .field > label { font-weight: 500; }
.en-figures-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* the customer's own pages */
body.customer { min-height: 100svh; display: flex; flex-direction: column; }
.customer-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; padding: 0 calc(var(--inset) + 16px); }
.customer-brand { display: inline-flex; align-items: center; gap: 8px; }
.customer-brand .wordmark { width: auto; height: 14px; }
.customer-sheet { flex: 1; margin: 0 var(--inset) var(--inset); }
.customer-sheet .sheet-inner { margin: 0 auto; }
.customer-title { margin-bottom: 24px; }
.customer-title h1 { font-size: 32px; line-height: 40px; }
.customer-foot { display: flex; justify-content: center; gap: 12px; padding: 4px 16px 16px; color: var(--faint); font-size: var(--fs-small); }
.customer-foot a { color: inherit; }
.plain-note { margin-top: 20px; color: var(--muted); font-size: var(--fs-small); }

@media (max-width: 760px) {
  .en-stage { padding: 20px 16px 16px; margin: 0 -8px; }
  .en-months { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 2px; }
  .en-months legend { float: none; margin: 0 0 4px; line-height: 20px; }
  .en-months span { min-width: 0; padding: 0; font-size: 12px; }
  .customer-title h1 { font-size: 28px; line-height: 36px; }
  .en-section-head h2 { font-size: 20px; }
  .en-day-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .en-day-note { margin-left: 0; width: 100%; }
  .en-link-row { flex-direction: column; }
  .customer-sheet { margin: 0; border-radius: 0; border-left: 0; border-right: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .house .flow { animation: none; stroke-dasharray: 2 6; }
}

/* ---------- live readings on the dashboard ---------- */
/* The stage shows either the live reading or the modelled average day; each part says which it belongs to. */
.en-stage[data-mode="live"] [data-model-only], .en-stage[data-mode="model"] [data-live-only] { display: none !important; }
.en-stage-tags { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 8px; }
.en-views { display: inline-flex; padding: 2px; border: 1px solid var(--stage-line); border-radius: 8px; }
.en-views[hidden] { display: none; }
.en-views a { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 6px; color: var(--stage-muted); font-size: var(--fs-small); font-weight: 500; text-decoration: none; transition: background-color var(--t-hover) ease, color var(--t-hover) ease; }
.en-views a:hover { color: var(--stage-ink); }
.en-views a[aria-current="true"] { background: var(--stage-ink); color: var(--stage); }
.en-views a:focus-visible { outline: 2px solid var(--stage-accent); outline-offset: 2px; }
.en-badge.is-live { gap: 8px; color: var(--stage-ink); }
.en-badge.is-live i { width: 8px; height: 8px; border-radius: 50%; background: #4cc38a; }
.en-source p.muted-note { color: var(--muted); }
.status-detail { display: block; margin-top: 4px; color: var(--negative); font-size: var(--fs-small); line-height: 18px; }
.en-test { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 16px; font-size: var(--fs-small); }

/* ---------- the inverter form (staff) ---------- */
.inverter-form { display: flex; flex-direction: column; gap: 24px; max-width: 760px; }
.inverter-modes { gap: 8px; margin: 0; padding: 0; border: 0; }
.inverter-modes legend { margin-bottom: 8px; font-weight: 500; }
.inverter-creds { margin: 0; padding: 20px 20px 20px; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--raised); }
.inverter-creds[hidden] { display: none; }
.inverter-creds legend { padding: 0 8px; font-weight: 500; }
.inverter-note { max-width: 70ch; color: var(--muted); font-size: var(--fs-small); }
.inverter-actions { display: flex; gap: 8px; }
.en-test form { display: inline; }

/* ---------- sign-in: Client / Engineer ---------- */
.sign-in-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 24px; padding: 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--raised); }
.sign-in-switch a { display: grid; place-items: center; height: 32px; border-radius: 6px; color: var(--muted); font-weight: 500; text-decoration: none; transition: background-color var(--t-hover) ease, color var(--t-hover) ease; }
.sign-in-switch a:hover { color: var(--text); }
.sign-in-switch a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border); }
.sign-in-switch a:focus-visible { outline: 2px solid var(--data); outline-offset: 2px; }
.plain-note a { color: var(--text); text-underline-offset: 3px; white-space: nowrap; }
