/* GridGuard customer panel (app.gridguardgroup.com).
   Style: a tinted L-frame (sidebar + 48px top bar) holding a work sheet, inset 8px, 1px edge, no shadow.
   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: 600; 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 */
  --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: 228px;
  --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;
    --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; }
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: one tinted L (sidebar + top bar), the white sheet inset 8px ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); grid-template-rows: var(--topbar) 1fr; min-height: 100svh; }
.sidebar { grid-row: 1 / -1; position: sticky; top: 0; height: 100svh; display: flex; flex-direction: column; padding: 14px 12px 16px; overflow: auto; }
.brand { display: flex; align-items: center; gap: 10px; height: 28px; padding: 0 8px; text-decoration: none; }
.brand .mark { width: 26px; height: 26px; }
.brand .wordmark { width: auto; height: 15px; }
.scope { margin: 6px 8px 22px 44px; font-size: var(--fs-small); color: var(--faint); }
.nav { display: grid; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; 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; gap: 10px; padding: 12px 10px 0; }
.who { display: grid; gap: 1px; min-width: 0; }
.who strong { font-weight: 600; 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; }

.topbar { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 0 calc(var(--inset) + 16px) 0 16px; min-width: 0; }
.topbar .menu-toggle, .topbar .topbar-brand { display: none; }
.search { position: relative; width: min(548px, 100%); }
.search svg { position: absolute; left: 12px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search input { width: 100%; height: 34px; 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: 22px; height: 22px; padding: 0 6px; 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); }
.sheet-inner { max-width: 1240px; }

/* ---------- title row ---------- */
.crumbs { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; 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: 600 var(--fs-title)/1.2 var(--font-display); letter-spacing: -0.015em; }
.title-row .sub { margin-top: 6px; 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 14px; border-radius: var(--radius-control); border: 1px solid var(--control); background: var(--surface); color: var(--text); font-weight: 600; 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: 30px; padding: 0 10px; font-size: var(--fs-small); }
.btn.text { height: auto; padding: 0; border: 0; background: none; font-weight: 600; 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: 10px; margin-bottom: 20px; padding: 10px 14px; 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 9px; border-radius: 999px; font-size: var(--fs-small); font-weight: 600; 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: 600; }
.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 14px; 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: 13px 14px; 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: 600; 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; }
.col-name { width: 26%; }
.ellipsis { display: block; max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.phone, td.system, td.meter, td.installed, td.fit { white-space: nowrap; }
td.fit { padding-right: 0; }
.mobile-line { display: none; }

/* FIT left in the list: years over a thin track showing how much of the term is left */
.fit-cell { display: inline-grid; justify-items: end; gap: 5px; }
.fit-cell strong { font-weight: 600; }
.fit-cell .bar { width: 72px; height: 3px; }
.fit-cell .bar .track { fill: var(--data-track); }
.fit-cell .bar .left { fill: var(--data); }

.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: 600 var(--fs-section)/1.3 var(--font-display); letter-spacing: -0.01em; }
.panel header a { font-size: var(--fs-small); font-weight: 600; 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: 11px 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: 600 var(--fs-figure)/1.1 var(--font-display); letter-spacing: -0.02em; }
.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: 600; }
.runway { min-width: 0; }
.runway-legend { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-bottom: 10px; 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: 600; }
.fit-note { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; padding: 10px 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: 600 var(--fs-section)/1.3 var(--font-display); letter-spacing: -0.01em; }

/* 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: 600; }

.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: 600 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: 14px 16px; border-radius: var(--radius-control); background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.error-summary h2 { font: 600 var(--fs-body)/22px var(--font); }
.error-summary ul { margin: 6px 0 0; padding-left: 18px; }
.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: 600 var(--fs-section)/1.3 var(--font-display); letter-spacing: -0.01em; }
.form-section > header p, .form-section > header > div > p { margin-top: 6px; color: var(--muted); }
.fields { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 18px 16px; max-width: 760px; }
.field { display: grid; gap: 7px; 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: 600; }
.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: 600; 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: 9px 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: 7px 10px; 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: 600; }
.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: 600; }
.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: 10px 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: 18px; }
.postcode-matches a { color: inherit; font-weight: 600; 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: 3px; gap: 3px; 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 14px; 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: 600; }
.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: 10px 0; }
.equip-row + .equip-row { border-top: 1px solid var(--rule); }
.equip-row legend { float: left; padding: 0; font-weight: 600; }
.equip-row .error { grid-column: 1 / -1; }

/* live FIT preview beside the install year */
.fit-preview { display: grid; gap: 4px; margin-top: 18px; padding: 14px 16px; border-radius: var(--radius-card); background: var(--raised); }
.fit-preview .figure { font: 600 20px/1.2 var(--font-display); letter-spacing: -0.01em; }
.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: 14px calc(var(--pad) + 8px); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-sheet) var(--radius-sheet); background: var(--surface); }
.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: 600 var(--fs-section)/1.3 var(--font-display); }
.settings-row > header p { margin-top: 6px; 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: 600; 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: 10px; 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: 600 22px/1.25 var(--font-display); letter-spacing: -0.015em; }
.plain-card .lead { margin-top: 6px; color: var(--muted); }
.plain-card form { display: grid; gap: 18px; 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) {
  th.meter, td.meter { display: none; }
}
@media (max-width: 1000px) {
  th.installed, td.installed { display: none; }
  .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; }
  .topbar { flex-wrap: wrap; justify-content: space-between; gap: 8px 12px; padding: 8px 16px 10px; }
  .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; }
  .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: 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
  .customers tbody tr:last-child { border-bottom: 0; }
  .customers td { padding: 0; border: 0; }
  .customers td.address, .customers td.phone, .customers td.system, .customers td.installed, .customers td.meter { display: none; }
  .customers td.name .sub { display: none; }
  .customers td.fit { grid-column: 2; grid-row: 1 / span 2; }
  .customers .mobile-line { display: block; grid-column: 1; margin-top: 2px; font-size: var(--fs-small); color: var(--muted); }
  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: 6px; 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: 6px 14px; }
.checkbox.tick { align-items: center; gap: 6px; font-size: var(--fs-small); white-space: nowrap; cursor: pointer; }
.checkbox.tick input { margin: 0; }
.field.access { display: grid; gap: 10px; margin: 0; padding: 0; border: 0; }
.field.access legend { margin-bottom: 8px; font-weight: 600; }
.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: 14px 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: 6px 0; }
.customers td.assessed { white-space: nowrap; }
.customers td.assessed .sub { display: block; margin-top: 4px; }
@media (max-width: 760px) {
  .customers td.assessed { display: none; }
}
