@font-face {
  font-family: "Geist";
  src: url("/shared/fonts/geist-latin-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("/shared/fonts/geist-mono-latin-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --ground: #efe9e5;
  --white: #ffffff;
  --ink: #1e1512;
  --body: #4a3d38;
  --muted: #675953;
  --line: #e8dfda;
  --line-strong: #d6c9c2;
  --soft: #f6f1ee;
  --pale: #faf7f5;
  --brand: #8c3324;
  --on-brand: var(--white);
  --on-brand-muted: #e5d2ce;
  --highlight: #f3ddd5;
  --accent: #e9b04e;
  --ok-text: #1e6b45;
  --ok-bg: #e3f1e8;
  --warning-text: #7a5300;
  --warning-bg: #fbefd2;
  --danger-text: #a3161a;
  --danger-bg: #fbe0df;
  --stale-text: #5b5e66;
  --stale-bg: #ecedef;
  --info-text: #2a4f86;
  --info-bg: #e2eaf6;
  --focus: var(--brand);
}

* { box-sizing: border-box; }

html { background: var(--ground); }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--body);
  font-family: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { color: var(--ink); margin: 0; font-weight: 500; letter-spacing: -0.02em; }
h1 { font-size: 36px; letter-spacing: -0.03em; line-height: 1.15; }
h2 { font-size: 24px; line-height: 1.25; }
h3 { font-size: 15px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
p { margin: 0; }
a { color: var(--brand); }

:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 10;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--white);
  color: var(--ink);
}
.skip-link:focus { left: 16px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* App shell: a sidebar card on the left, cards in the main column. */
.app {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 16px;
  flex: 0 0 232px;
  width: 232px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 20px;
  background: var(--white);
  border-radius: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}
.brand small {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}
.brand-mark {
  position: relative;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--brand);
}
.brand-mark::after {
  content: "";
  position: absolute;
  right: 7px;
  top: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  color: var(--ink);
  text-decoration: none;
}
.side-nav a:hover { background: var(--pale); }
.side-nav a[aria-current="page"] {
  background: var(--soft);
  font-weight: 600;
}
.side-nav a[aria-current="page"]::after {
  content: "";
  margin-left: auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.hint { font-size: 13px; color: var(--muted); }

.content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  outline: none;
}

.page-heading { display: flex; flex-direction: column; gap: 8px; }
.page-heading h1 { font-size: 40px; }
.lead { color: var(--muted); }

.loading {
  padding: 24px;
  border-radius: 24px;
  background: var(--white);
  color: var(--muted);
}

.site-footer {
  padding: 8px 4px 16px;
  font-size: 13px;
  color: var(--muted);
}

/* Cards */
.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  background: var(--white);
  border-radius: 24px;
  min-width: 0;
}
.panel.inset, .inset { background: var(--pale); border-radius: 16px; }
.panel h2 { font-size: 24px; }
.context {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.muted { color: var(--muted); }
.note { font-size: 14px; color: var(--muted); }
.callout strong { display: block; margin-bottom: 4px; }

/* Status: always a text label, with the colour as a second cue. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  line-height: 1.2;
  color: var(--body);
  background: var(--soft);
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.pill.fresh { color: var(--ok-text); background: var(--ok-bg); }
.pill.warning { color: var(--warning-text); background: var(--warning-bg); }
.pill.aged { color: var(--stale-text); background: var(--stale-bg); }
.pill.info { color: var(--info-text); background: var(--info-bg); }
.pill.danger { color: var(--danger-text); background: var(--danger-bg); }

.callout,
.notice,
.empty-state,
.unsupported,
.error-card {
  padding: 16px 20px;
  border-radius: 16px;
  background: var(--info-bg);
  color: var(--info-text);
}
.callout.warning { background: var(--warning-bg); color: var(--warning-text); }
.notice:empty { display: none; }
.notice.error, .error-card { background: var(--danger-bg); color: var(--danger-text); }
.unsupported { background: var(--soft); color: var(--body); }
.empty-state { background: var(--white); color: var(--body); border-radius: 24px; padding: 32px; }
.empty-state h2 { margin-bottom: 8px; }

/* Buttons and fields: at least 44px, visible focus, real labels. */
button, .button {
  min-height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid var(--muted);
  background: var(--white);
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
}
button.secondary { background: var(--white); color: var(--ink); }
button:disabled {
  background: var(--soft);
  border-color: var(--line-strong);
  color: var(--muted);
  cursor: not-allowed;
}

input, select, textarea {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--muted);
  border-radius: 14px;
  background: var(--white);
  color: var(--ink);
  font: inherit;
}
input[type="range"] {
  min-height: 44px;
  padding: 0;
  accent-color: var(--brand);
  width: 100%;
}
select:disabled, input:disabled { background: var(--soft); color: var(--muted); }

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: var(--ink);
}

.control-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}
.control-form label { width: 100%; }
.control-form select { min-width: 220px; flex: 1 1 220px; }
/* The recirculation form stacks its fields, so a flex basis would turn the 220 px into a height. */
.control-form.recirc-mode select { flex: 0 0 auto; width: 100%; min-width: 0; }
.button-row { display: flex; flex-wrap: wrap; gap: 12px; }

/* Identity line: which home, which heater, and how old the data is. */
.identity {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
}
.identity-status { display: flex; flex-wrap: wrap; gap: 8px; }
.identity h2 { font-size: 22px; }

/* Readings: the heating status is the one hero card; the rest are plain cards. */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.metric {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px;
  background: var(--white);
  border-radius: 22px;
  min-width: 0;
}
.metric-value {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.metric-source {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}
.metric.is-hero {
  grid-column: 1 / -1;
  padding: 32px;
  background-color: var(--brand);
  background-image: radial-gradient(rgba(255, 255, 255, 0.13) 1px, transparent 1px);
  background-size: 18px 18px;
  color: var(--on-brand);
}
.metric.is-hero h3 { color: var(--on-brand); }
.metric.is-hero .metric-value {
  font-size: clamp(56px, 9vw, 96px);
  font-weight: 600;
  letter-spacing: -0.05em;
  color: var(--on-brand);
}
.metric.is-hero .metric-source {
  color: var(--on-brand-muted);
  border-top-color: rgba(255, 255, 255, 0.25);
}

/* Change in progress: three steps, each with what is done, now, or not yet. */
.journey {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.journey-step { display: flex; gap: 12px; align-items: flex-start; }
.step-dot {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--muted);
  background: var(--white);
  color: var(--ink);
  font-size: 13px;
}
.is-done .step-dot { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.is-now .step-dot { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.step-text { display: flex; flex-direction: column; gap: 2px; }
.step-state { font-weight: 600; color: var(--ink); }

/* Homeowner controls: a 64rem column of task sections; temperature and Home / Away are peer groups. */
.home-controls {
  display: grid;
  gap: 16px;
  align-items: start;
  max-width: 64rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
}

/* Recirculation: one column, then a fixed side column from 720px. */
.recirc-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 720px) {
  .recirc-layout { grid-template-columns: minmax(16rem, 22rem) minmax(0, 1fr); }
}

/* Recirculation spans the whole controls column so its two-column layout has room. */
.home-controls > .recirculation-section { grid-column: 1 / -1; }

/* Plumber directory: a 72rem structured table until a home is selected. */
.portfolio-layout:not(.has-selection) {
  grid-template-columns: minmax(0, 1fr);
  max-width: 72rem;
}
.portfolio-layout:not(.has-selection) .home-table {
  display: table;
}
.home-open:hover:not(:disabled) { transform: none; }
.table-wrap:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* Two-column arrangement that stacks on narrow screens. */
.home-support,
.content-grid,
.portfolio-layout,
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 16px;
  align-items: start;
}
.setting-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 26rem));
  gap: 20px;
}
.setting-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.setting-group:last-child { border-bottom: 0; padding-bottom: 0; }
.recirc-readout { font-family: "Geist Mono", ui-monospace, monospace; font-size: 13px; color: var(--muted); }
.recirc-status { font-weight: 500; color: var(--ink); }

/* Monospaced data: timestamps, IDs and units. */
code, .fault-code, .recirc-readout, .metric-source, .home-identity, [data-freshness] {
  font-family: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

/* Tables: dense data scrolls inside its own box. */
.table-wrap, .home-table-wrap {
  overflow-x: auto;
  border-radius: 16px;
}
table { width: 100%; border-collapse: collapse; }
th {
  padding: 12px;
  text-align: left;
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  white-space: nowrap;
}
td {
  min-height: 56px;
  padding: 14px 12px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  vertical-align: middle;
}
tr.selected td, tr[aria-selected="true"] td { background: var(--highlight); }
.home-name, .home-heater, .home-heating, .home-target { color: var(--ink); }
.home-heater > * { display: block; }
.home-heater > small { font-family: "Geist Mono", ui-monospace, monospace; font-size: 13px; color: var(--muted); }

.directory-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}
.toolbar-search { flex: 1 1 260px; max-width: 32rem; }
.toolbar-profile, .toolbar-status { flex: 0 1 15rem; }
.toolbar-field { display: flex; flex-direction: column; }

/* Digital twin: one demand row per home, then the four heater types side by side. */
.demand-list { display: flex; flex-direction: column; gap: 8px; }
.demand-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(160px, 3fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--pale);
}
.demand-row.is-selected { background: var(--highlight); }
.demand-home > * { display: block; }
.demand-home > small { font-size: 13px; color: var(--muted); }
.demand-value { font-weight: 600; color: var(--ink); text-align: right; }
.demand-links a, .note a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}
.heater-response {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 12px;
}
/* Three response cards share one row, so their metric tiles wrap instead of squeezing into 69 px columns. */
.heater-response .metric-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); }
.heater-response .metric-value { font-size: 1.15rem; line-height: 1.25; overflow-wrap: break-word; word-break: normal; }

.fault-card, .fault-resolve { display: flex; flex-direction: column; gap: 8px; }

.login-card {
  max-width: 520px;
  margin: 40px auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 32px;
  background: var(--white);
  border-radius: 24px;
}
.login-card form { display: flex; flex-direction: column; gap: 12px; }

.profile-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  padding: 16px 20px;
  background: var(--white);
  border-radius: 24px;
}
.profile-switch > div { display: flex; flex-direction: column; gap: 2px; flex: 1 1 200px; }
.profile-switch form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
/* At 320 px the profile list must fit the card, not push the page wider. */
.profile-switch > div, .profile-switch form, .profile-switch select { min-width: 0; max-width: 100%; }
@media (max-width: 620px) { .profile-switch form select { flex: 1 1 100%; width: 100%; } }

/* Narrow screens: the sidebar moves above the content and its links wrap. */
@media (max-width: 860px) {
  .app { flex-direction: column; padding: 12px; gap: 12px; }
  .sidebar {
    position: static;
    width: 100%;
    flex: none;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
    padding: 16px 20px;
  }
  .side-nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .side-nav a { padding: 0 14px; }
  .sidebar-footer {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
    width: 100%;
  }
  .page-heading h1 { font-size: 32px; }
  .demand-row { grid-template-columns: 1fr auto; }
  .demand-row > :nth-child(2) { grid-column: 1 / -1; order: 3; }
}

@media (max-width: 620px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-value { font-size: 26px; }
  .metric.is-hero .metric-value { font-size: 64px; }
  .panel { padding: 20px; }
}

@media (max-width: 360px) {
  .metric-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Shared header (Step 3): product name, the three views, one household switcher and one sample-data line. */
.app { display: flex; flex-direction: column; align-items: stretch; gap: 16px; padding: 16px; min-height: 100vh; }
.content { width: 100%; max-width: 1200px; margin: 0 auto; }
.site-header { background: var(--white); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 1px 2px rgba(30, 21, 18, 0.06); padding: 16px 24px; }
.site-header-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
.site-header .brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 18px; }
.site-header .brand-name { white-space: nowrap; }
.view-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.view-tabs a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border-radius: 10px; color: var(--body); text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; }
.view-tabs a:hover { background: var(--pale); }
.view-tabs a[aria-current="page"] { background: var(--highlight); color: var(--brand); font-weight: 600; border-bottom-color: var(--brand); }
.household-switch { display: flex; flex-direction: column; gap: 4px; min-width: 240px; }
.household-switch .field-label { font-size: 13px; color: var(--muted); }
.household-switch select { min-height: 44px; padding: 0 12px; border: 1px solid var(--muted); border-radius: 10px; background: var(--white); color: var(--ink); font: inherit; }
.sample-line { margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.sample-line strong { color: var(--ink); font-weight: 600; }
@media (max-width: 620px) {
  .site-header-top { display: grid; grid-template-columns: 1fr; gap: 12px; }
  .view-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .view-tabs a { padding: 0 6px; text-align: center; }
  .household-switch { min-width: 0; width: 100%; }
}
.site-header .brand { min-height: 44px; }
.view-tabs { margin-left: 32px; margin-right: auto; }
@media (max-width: 620px) { .view-tabs { margin: 0; } }

/* Shared components (Step 4). Prefix c-. Colours come from the tokens above. */
.c-card { background: var(--white); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 1px 2px rgba(30, 21, 18, 0.06); padding: 16px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.c-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.c-label { margin: 0; font-size: 14px; font-weight: 500; color: var(--muted); }
.c-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.c-chip--ok { color: var(--ok-text); background: var(--ok-bg); }
.c-chip--warning { color: var(--warning-text); background: var(--warning-bg); }
.c-chip--danger { color: var(--danger-text); background: var(--danger-bg); }
.c-chip--info { color: var(--info-text); background: var(--info-bg); }
.c-chip--stale { color: var(--stale-text); background: var(--stale-bg); }
.c-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.c-value { margin: 0; font-family: "Geist Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; font-size: 28px; font-weight: 500; color: var(--ink); display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.c-value small { font-size: 14px; color: var(--muted); }
.c-value--muted { color: var(--muted); }
.c-note { margin: 0; font-size: 14px; color: var(--body); }
.c-age, .c-facts dd { font-family: "Geist Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); }
.c-age { margin: 0; padding-top: 8px; border-top: 1px solid var(--line); }
.c-placeholder { display: block; height: 28px; width: 70%; border-radius: 8px; background: var(--soft); }
.c-facts { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.c-facts div { display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.c-facts dt { font-size: 14px; color: var(--muted); }
.c-facts dd { margin: 0; }
.c-fault-code { margin: 0; font-size: 16px; color: var(--ink); }
.c-fault-code code { font-family: "Geist Mono", ui-monospace, monospace; font-size: 13px; color: var(--muted); }
.c-fault--active { border-color: var(--accent); }
.c-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 44px; }
.c-row-label { font-size: 14px; color: var(--body); }
.c-muted-text { font-family: "Geist Mono", ui-monospace, monospace; font-size: 13px; color: var(--muted); }
.c-btn { min-width: 44px; min-height: 44px; border-radius: 12px; border: 1px solid var(--muted); background: var(--white); color: var(--ink); font: inherit; font-size: 18px; cursor: pointer; }
.c-btn:disabled { background: var(--soft); color: var(--muted); border-color: var(--line-strong); cursor: not-allowed; }
.c-stepper { display: flex; align-items: center; gap: 8px; }
.c-stepper-value { min-width: 72px; text-align: center; font-family: "Geist Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; font-size: 18px; color: var(--ink); }
.c-stepper-value small { font-size: 12px; color: var(--muted); margin-left: 2px; }
.c-range { width: 100%; min-height: 44px; accent-color: var(--brand); margin: 0; }
.c-range:disabled { accent-color: var(--muted); }
.c-range-scale { display: flex; justify-content: space-between; font-family: "Geist Mono", ui-monospace, monospace; font-size: 12px; color: var(--muted); }
.c-flow.is-disabled .c-row-label { color: var(--muted); }
.c-switch { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; font-size: 14px; color: var(--ink); }
.c-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.c-switch-track { position: relative; width: 44px; height: 24px; border-radius: 999px; background: var(--muted); transition: background 0.2s; }
.c-switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--white); transition: transform 0.2s; }
.c-switch input:checked + .c-switch-track { background: var(--brand); }
.c-switch input:checked + .c-switch-track::after { transform: translateX(20px); }
.c-switch input:focus-visible + .c-switch-track { outline: 2px solid currentColor; outline-offset: 3px; }
.c-switch input:disabled + .c-switch-track { background: var(--line-strong); }
.c-seg-wrap { display: flex; flex-direction: column; gap: 8px; }
.c-seg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.c-seg-btn { min-height: 44px; border-radius: 12px; border: 1px solid var(--muted); background: var(--white); color: var(--ink); font: inherit; font-family: "Geist Mono", ui-monospace, monospace; font-size: 14px; cursor: pointer; }
.c-seg-btn[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 600; }
.c-seg-btn:disabled { background: var(--soft); color: var(--muted); border-color: var(--line-strong); cursor: not-allowed; }
.c-seg-wrap.is-disabled .c-row-label { color: var(--muted); }
.c-remaining { display: flex; flex-direction: column; gap: 4px; }
.c-remaining-time { font-family: "Geist Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; font-size: 22px; color: var(--ink); }
.c-bar { height: 8px; border-radius: 999px; background: var(--soft); overflow: hidden; }
.c-bar-fill { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.c-bar-fill.is-held { background: var(--stale-text); }
.c-estimate--na .c-note { color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .c-switch-track, .c-switch-track::after { transition: none; } }
.c-seg-btn { white-space: nowrap; padding: 0 6px; }

/* My Home board (Step 5). */
.home-board { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.home-main, .home-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.home-readings { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.c-status .c-value--text { font-size: 22px; font-family: inherit; }
.c-energy .c-note { margin-bottom: 8px; }
.c-energy-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: start; padding: 12px 0; border-top: 1px solid var(--line); }
.c-energy-label { margin: 0; font-size: 16px; font-weight: 500; color: var(--ink); }
.c-energy-value { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }
.c-value--row { font-size: 20px; }
.c-settings-form { display: flex; flex-direction: column; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.c-settings-form .c-row { min-height: 44px; }
.c-not-sent { margin: 0; }
.c-recirc .button-row, .c-recirc .control-form { display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 900px) {
  .home-board { grid-template-columns: minmax(0, 1fr); }
  .home-readings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 360px) {
  .home-readings { grid-template-columns: minmax(0, 1fr); }
}

/* Recirculation block inside the My Home side column (Step 5). */
.c-recirc .recirculation-section { padding: 0; margin: 0; border: 0; background: none; box-shadow: none; }
.c-recirc .recirculation-section > .context { display: none; }
.c-recirc .recirc-layout { grid-template-columns: minmax(0, 1fr) !important; gap: 12px; }
.c-recirc .recirc-readout { display: block; }

/* Service Team (Step 7). */
.c-table-wrap { overflow-x: auto; }
.c-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.c-table th { text-align: left; font-family: "Geist Mono", ui-monospace, monospace; font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.c-table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--ink); }
.c-table tr.is-selected td { background: var(--highlight); }
.c-table tr.is-blocked td { color: var(--muted); }
.c-table .c-age { white-space: nowrap; }
.c-table .secondary { min-height: 44px; }
/* Below 620 px each home is a card: the column name is shown above each value. */
@media (max-width: 620px) {
  .c-table-wrap { overflow: visible; }
  .c-table thead { display: none; }
  .c-table, .c-table tbody, .c-table tr, .c-table td { display: block; width: 100%; }
  .c-table tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .c-table tr.is-selected { background: var(--highlight); }
  .c-table tr.is-selected td { background: none; }
  .c-table td { border: 0; padding: 4px 12px; }
  .c-table td::before { display: block; font-family: "Geist Mono", ui-monospace, monospace; font-size: 12px; color: var(--muted); text-transform: uppercase; }
  .c-table td:nth-child(1)::before { content: 'Household'; }
  .c-table td:nth-child(2)::before { content: 'Heater type'; }
  .c-table td:nth-child(3)::before { content: 'Fault'; }
  .c-table td:nth-child(4)::before { content: 'Reading age'; }
  .c-table td:nth-child(5)::before { content: none; }
  .c-table td:nth-child(5) { padding-top: 8px; }
  .c-table .c-age { white-space: normal; }
}
.c-detail { display: flex; flex-direction: column; gap: 16px; }
.c-detail-title { margin: 0; font-size: 26px; font-weight: 500; letter-spacing: -0.01em; color: var(--ink, #1a1a1a); }
.c-readonly .c-facts dd { font-family: "Geist Mono", ui-monospace, monospace; font-size: 13px; }
.c-review .button-row, .c-review button { min-height: 44px; }
.c-noaccess { gap: 12px; }

/* Digital twin (Step 8). Desktop: shower, faucet and combined flow on top; household water and sample clock below.
   Phones: combined flow, shower, faucet, sample clock, household water (the DOM order). */
.twin-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 0.9fr); grid-template-areas: "shower faucet combined" "water water clock"; align-items: start; }
.twin-combined { grid-area: combined; }
.twin-shower { grid-area: shower; }
.twin-faucet { grid-area: faucet; }
.twin-clock { grid-area: clock; }
.twin-water { grid-area: water; }
.twin-item { min-width: 0; }
.twin-combined { background: var(--brand); color: var(--on-brand); border-radius: 24px; padding: 20px; min-height: 100%; box-sizing: border-box; }
.c-combined-label { margin: 0; font-size: 14px; color: var(--on-brand-muted); }
.c-combined-value { margin: 12px 0 4px; font-family: "Geist Mono", ui-monospace, monospace; font-size: 56px; font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums; }
.c-combined-value small { font-family: "Geist", system-ui, sans-serif; font-size: 18px; margin-left: 6px; }
.c-combined-breakdown { margin: 8px 0 0; font-family: "Geist Mono", ui-monospace, monospace; font-size: 14px; }
.c-combined-note { margin: 10px 0 0; font-size: 14px; color: var(--on-brand-muted); }
.twin-combined .c-chip { margin-top: 10px; }
.twin-clock .c-value--text { font-family: "Geist Mono", ui-monospace, monospace; font-size: 36px; }
.twin-clock .c-value--text small { font-family: "Geist", system-ui, sans-serif; font-size: 15px; margin-left: 8px; color: var(--muted); }
.c-paused-note { margin: 12px 0; padding: 12px 14px; border-radius: 14px; background: var(--info-bg, #e4ecf8); color: var(--info-text, #1d3b66); font-size: 14px; }
.twin-clock button, .twin-water button { width: 100%; min-height: 44px; margin-top: 12px; }
.danger-outline { min-height: 44px; width: 100%; background: var(--white); color: var(--brand); border: 1px solid var(--brand); border-radius: 999px; font: inherit; font-weight: 500; cursor: pointer; }
.danger-outline:hover { background: var(--danger-bg); }
.c-fixture .c-fixture-name { font-size: 22px; color: var(--ink); }
.c-fixture .c-remaining-time { font-family: "Geist Mono", ui-monospace, monospace; font-size: 22px; font-variant-numeric: tabular-nums; }
.all-homes-demand { margin-top: 16px; }
@media (max-width: 900px) {
  .twin-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "combined combined" "shower faucet" "clock clock" "water water"; }
}
@media (max-width: 620px) {
  .twin-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "combined" "shower" "faucet" "clock" "water"; }
  .c-combined-value { font-size: 44px; }
}
