:root {
  color-scheme: light;
  --bg: #f3f6f1;
  --bg-2: #ffffff;
  --bg-3: #eef3ec;
  --line: #d5e0d4;
  --line-strong: #8eaa92;
  --text: #1a261c;
  --muted: #5c6d60;
  --faint: #7d8e82;
  --lime: #c6e14a;
  --lime-ink: #1a2608;
  --water: #0f8f86;
  --run: #1c7a45;
  --wait: #9a6810;
  --fault: #c44536;
  --park: #2f629e;
  --shadow: 0 18px 40px rgba(26, 38, 28, 0.08);
  --font: "Avenir Next", "Segoe UI", sans-serif;
  --display: "Avenir Next Condensed", "Avenir Next", "Arial Narrow", sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: calc(164px + env(safe-area-inset-bottom, 0px));
  background:
    radial-gradient(1000px 420px at 0% -10%, rgba(198, 225, 74, 0.28), transparent 55%),
    radial-gradient(800px 420px at 100% 0%, rgba(15, 143, 134, 0.1), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: contain;
}
.pull-refresh {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 25;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 12px 12px;
  text-align: center;
  font-weight: 650;
  color: var(--muted);
  background: rgba(243, 246, 241, 0.96);
  pointer-events: none;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button, a, input, select { touch-action: manipulation; }
:focus { outline: none; }
:focus-visible { outline: 2px solid #3d7310; outline-offset: 2px; }
::placeholder { color: var(--faint); }

h1, h2, h3 { overflow-wrap: anywhere; }
h1 {
  margin: 0;
  font-size: clamp(32px, 4vw, 46px);
  line-height: 0.95;
  letter-spacing: -0.035em;
  font-weight: 650;
}
h2 { margin: 0 0 12px; font-size: 16px; font-weight: 650; }

.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: rgba(243, 246, 241, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.dock-status {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
}
.running-pumps {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 42px;
  overflow-x: auto;
  scrollbar-width: none;
}
.running-pumps::-webkit-scrollbar { display: none; }
.running-pump {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  min-height: 42px;
  padding: 0 14px 0 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: inherit;
  text-decoration: none;
  font-size: 15px;
  line-height: 1.2;
  white-space: nowrap;
}
.running-pump b { font-weight: 650; }
.running-pump span { color: var(--muted); }
.running-empty { margin: 0; color: var(--muted); font-size: 15px; white-space: nowrap; }
.nav {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
  padding: 8px 8px 10px;
}
.nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 84px;
  padding: 8px 4px;
  border-radius: 16px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.1;
  text-align: center;
}
.nav-icon { width: 30px; height: 30px; display: block; }
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--lime-ink); background: var(--lime); }
.nav a[aria-current="page"]:hover { color: var(--lime-ink); }
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
}
.dot.running { background: var(--run); box-shadow: 0 0 0 3px rgba(61, 190, 122, 0.18); }
.dot.building, .dot.waiting, .dot.held { background: var(--wait); box-shadow: 0 0 0 3px rgba(224, 168, 74, 0.16); }
.dot.parked { background: var(--park); }
.dot.stopped { background: #8a9a8e; }

.sim { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
#clock { flex: none; font-family: var(--mono); color: var(--muted); font-size: 14px; white-space: nowrap; }

.offline, .noscript {
  margin: 0;
  padding: 10px 16px;
  background: #fde8e4;
  color: #8d2e24;
  text-align: center;
}

.page {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 24px;
}
.page-overview { padding-top: 12px; }
.page-overview .section-head { margin-top: 8px; }
.page-overview .fill-section { margin-top: 14px; }
.fill-list .pivot-metrics { margin: 2px 0 0; gap: 2px 8px; }
.fill-list .pivot-metrics b { font-size: 16px; }
.fill-list .pivot-metrics span,
.fill-list .muted { font-size: 12px; line-height: 1.25; }
.fill-list .pivot-card-body .muted { margin-top: 2px; }
.page-overview .fill-section .section-head { margin-top: 0; }
.gauge.compact .gauge-track,
.gauge.compact .gauge-low { stroke-width: 16; }
.gauge.compact .gauge-needle { stroke-width: 7; }
.page-overview h1 { font-size: 28px; }

.kicker {
  margin: 0 0 6px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.lede { color: var(--muted); max-width: 68ch; margin: 8px 0 0; }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.dial-facts {
  width: 100%;
  margin-top: 12px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 20px;
  line-height: 1.3;
}
.dial-facts th,
.dial-facts td { padding: 2px 4px; text-align: center; }
.dial-facts th {
  font-weight: 650;
  color: var(--muted);
  font-size: 15px;
}
.dial-facts td { font-weight: 650; padding-top: 4px; }
.dial-facts .fact-status { vertical-align: middle; }
.dial-facts .pill {
  justify-content: center;
  width: 9ch;
  font-size: 18px;
  padding: 5px 0;
}
.dial-updated {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}
.page-head { margin: 8px 0 18px; }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.back {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}
.back:hover { color: var(--text); }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin: 26px 0 12px;
}
.summary { margin: 0; color: var(--muted); }

.card, .banner, .pivot-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.card { padding: 16px; }
.banner {
  display: grid;
  grid-template-columns: minmax(190px, 250px) 1fr;
  gap: 18px;
  align-items: center;
  padding: 18px;
  color: inherit;
  text-decoration: none;
}
.banner:hover, .pivot-card:hover { border-color: var(--line-strong); }
.banner h2 { margin: 0 0 4px; font-size: 28px; letter-spacing: -0.03em; }

.statline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}
.statline div, .mini-stats div {
  background: var(--bg-3);
  border-radius: 12px;
  padding: 10px 12px;
}
.statline dt, .mini-stats dt { color: var(--muted); font-size: 12px; }
.statline dd, .mini-stats dd {
  margin: 4px 0 0;
  font-family: var(--display);
  font-size: 28px;
  letter-spacing: -0.03em;
  line-height: 1;
}
.statline small, .mini-stats small {
  margin-left: 4px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0;
}
.stats-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 14px; }

.pivot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
}
.pivot-card {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 8px 12px;
  align-items: center;
  padding: 12px 14px 12px 8px;
  color: inherit;
  text-decoration: none;
}
.pivot-card-main { display: contents; }
.pivot-sight {
  position: relative;
  width: 112px;
  height: 112px;
  isolation: isolate;
  z-index: 0;
}
.pivot-sight.has-satellite {
  border-radius: 16px;
  overflow: hidden;
}
.pivot-card-dial { position: relative; z-index: 1; width: 112px; max-width: 112px; }
.pivot-card-dial svg { width: 112px; height: auto; }
.pivot-sight.has-satellite .dial .field { fill: transparent; }
.pivot-card .pivot-mini-map {
  position: absolute;
  inset: 0;
  width: auto !important;
  height: auto !important;
  min-height: 0;
  margin: 0;
  border-radius: 16px;
  overflow: hidden;
  background: #d7e0d6;
  pointer-events: none;
  z-index: 0;
  isolation: isolate;
}
.pivot-card .pivot-mini-map.is-empty { display: none; }
.leaflet-container { z-index: 0; }
.map-card, .satellite-map { position: relative; z-index: 0; isolation: isolate; }
.pivot-card.status-running { box-shadow: inset 3px 0 0 var(--run); }
.pivot-card.status-waiting, .pivot-card.status-held, .pivot-card.status-building { box-shadow: inset 3px 0 0 var(--wait); }
.pivot-card.status-parked { box-shadow: inset 3px 0 0 var(--park); }
.pivot-card h2 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.pivot-card-name { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.pivot-no { color: var(--muted); font-size: 15px; font-weight: 650; letter-spacing: 0.01em; }
.pivot-card-top, .row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.pivot-card-body { min-width: 0; }
.pivot-metrics {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin: 6px 0 2px;
}
.pivot-metrics b,
.pivot-metrics span { white-space: nowrap; }
.pivot-metrics b {
  font-family: var(--display);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
}
.pivot-metrics span, .muted { color: var(--muted); }
.pivot-card p { margin: 0; }
.pivot-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin: 10px 0 0;
}
.pivot-facts div { min-width: 0; }
.pivot-facts dt {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.pivot-facts dd {
  margin: 1px 0 0;
  font-size: 16px;
  font-weight: 650;
  line-height: 1.2;
}
.pivot-facts .is-online { color: #146b3a; }
.pivot-facts .is-offline { color: #b42318; }
.pivot-updated {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}
.pivot-list { gap: 8px; }
.pivot-list .pivot-card {
  grid-template-columns: 72px 1fr;
  gap: 6px 10px;
  padding: 8px 12px 8px 6px;
}
.pivot-list .pivot-card:has(.pivot-sight) {
  grid-template-columns: auto 1fr;
  align-items: stretch;
  column-gap: 10px;
  padding: 0 12px 0 0;
}
.pivot-list .pivot-card:has(.pivot-sight) .pivot-card-body {
  padding: 8px 0;
  align-self: center;
}
.pivot-list .pivot-card-dial,
.pivot-list .pivot-card-dial svg {
  width: 72px;
  max-width: 72px;
  height: 72px;
}
.pivot-list .pivot-sight {
  height: 100%;
  width: auto;
  max-width: none;
  aspect-ratio: 1;
  min-height: 0;
  overflow: hidden;
  border-radius: calc(var(--radius) - 1px) 0 0 calc(var(--radius) - 1px);
}
.pivot-list .pivot-sight .pivot-card-dial {
  position: absolute;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
}
.pivot-list .pivot-sight .pivot-card-dial svg {
  display: block;
  width: 100%;
  max-width: none;
  height: 100%;
}
.pivot-list .pivot-sight.has-satellite,
.pivot-list .pivot-sight .pivot-mini-map {
  border-radius: calc(var(--radius) - 1px) 0 0 calc(var(--radius) - 1px);
}
.pivot-list h2 { font-size: 18px; }
.pivot-list .pivot-no { font-size: 14px; }
.pivot-list .pill { font-size: 16px; padding: 5px 12px; }
.pivot-brief {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 12px;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.25;
}
.pivot-brief li { min-width: 0; }
.pivot-list .pivot-facts {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 10px;
  margin: 4px 0 0;
}
.pivot-list .pivot-facts dt { font-size: 12px; }
.pivot-list .pivot-facts dd { font-size: 15px; margin: 0; }
.pivot-list .pivot-updated { margin-top: 4px; font-size: 12px; }

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  background: #e7eee8;
  color: #4d5e52;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}
.pill-running, .pill-online { background: #e5f6ea; color: var(--run); }
.pill-waiting, .pill-building, .pill-held { background: #f8ecd4; color: #8a5d0a; }
.pill-parked { background: #e3eef9; color: #2d5f99; }
.pill-offline { background: #fde8e4; color: #b42318; }
.pill-stopped { background: #e7eee8; color: #4d5e52; }

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 460px) minmax(280px, 1fr);
  gap: 14px;
  align-items: start;
}
.stack { display: flex; flex-direction: column; gap: 14px; }
.mt { margin-top: 12px; }
.pivot-hero {
  position: relative;
  isolation: isolate;
  z-index: 0;
}
.pivot-hero .pivot-mini-map { display: none; }
.pivot-hero.has-satellite {
  border-radius: 16px;
  overflow: hidden;
}
.pivot-hero.has-satellite .pivot-mini-map {
  display: block;
  position: absolute;
  inset: 0;
  width: auto !important;
  height: auto !important;
  min-height: 0;
  margin: 0;
  border-radius: 16px;
  overflow: hidden;
  background: #d7e0d6;
  pointer-events: none;
  z-index: 0;
}
.pivot-hero.has-satellite .dial .field { fill: transparent; }
.pivot-hero #dial { position: relative; z-index: 1; }
#satellite-map[hidden] { display: none; }
#satellite-map { height: min(420px, 62vw); min-height: 240px; }

.btn {
  min-height: 48px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 650;
}
.btn-primary { background: var(--lime); color: var(--lime-ink); }
.btn-primary:hover { filter: brightness(0.97); }
.btn-stop { background: #fff; border-color: #e7b2ab; color: #a33b2e; }
.btn-stop:hover { background: #fde8e4; }
.btn-quiet { background: #fff; border-color: var(--line); color: var(--muted); }
.btn-choice { background: #fff; border-color: var(--line); color: var(--faint); }
.btn-choice[aria-pressed="true"] {
  background: var(--lime);
  border-color: #6d8f10;
  color: var(--lime-ink);
  box-shadow: inset 0 0 0 2px #243808;
}
#btn-stop[aria-pressed="true"] {
  background: #c44536;
  border-color: #8d2e24;
  color: #fff;
  box-shadow: inset 0 0 0 2px #6e241c;
}
#btn-wet[aria-pressed="true"] {
  background: #0f8f86;
  border-color: #0b6b64;
  color: #fff;
  box-shadow: inset 0 0 0 2px #084843;
}
#btn-run-dry[aria-pressed="true"] {
  background: #9a6810;
  border-color: #6e4a0b;
  color: #fff;
  box-shadow: inset 0 0 0 2px #4d3308;
}
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choices-3 { grid-template-columns: 1fr 1fr 1fr; }
.choices-3 .btn { padding: 0 8px; }
button:disabled, input:disabled { opacity: 0.45; cursor: not-allowed; }

.readout {
  font-family: var(--display);
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
}
.row-between h2 { margin: 0; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 32px;
  margin: 8px 0 0;
  background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  background: #d7e2d8;
  border-radius: 99px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--lime);
  border: 2px solid var(--lime-ink);
}
input[type="range"]::-moz-range-track {
  height: 8px;
  background: #d7e2d8;
  border-radius: 99px;
  border: 0;
}
input[type="range"]::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--lime);
  border: 2px solid var(--lime-ink);
}
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }
#speed-presets { display: contents; }
.presets button {
  min-height: 36px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
}
.presets button[aria-pressed="true"] {
  background: var(--lime);
  border-color: var(--lime);
  color: var(--lime-ink);
}
.mini-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0 0;
}
.mini-stats dd { font-size: 26px; }
.safety-name { margin: 0; font-weight: 650; }
#centre-card { margin-top: 18px; padding-top: 4px; border-top: 1px solid var(--line); }

.legend, .log, .signals { list-style: none; padding: 0; margin: 12px 0 0; }
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  color: var(--muted);
  font-size: 13px;
}
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch.angle { background: #5f8f12; }
.swatch.pressure { background: #0f8f86; }
.history-chart, .spark { width: 100%; touch-action: none; cursor: crosshair; }
.history-chart { height: auto; display: block; margin-top: 8px; }
.history-chart .scrub-line, .spark .scrub-line { stroke: #1a261c; stroke-width: 1.5; stroke-dasharray: 3 3; }
.spark .scrub-dot { fill: var(--water); }
.chart-readout { margin: 6px 0 0; font-weight: 650; min-height: 1.2em; }
.history-chart .grid { stroke: #d5e0d4; stroke-width: 1; }
.history-chart .angle-line { fill: none; stroke: #5f8f12; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.history-chart .pressure-line { fill: none; stroke: #0f8f86; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.history-chart .tick { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.history-chart .dot-angle { fill: #5f8f12; }
.history-chart .dot-pressure { fill: #0f8f86; }
.swatch.water { background: rgba(15, 143, 134, 0.55); }
.swatch.sector { background: rgba(15, 143, 134, 0.16); box-shadow: inset 0 0 0 1px rgba(15, 143, 134, 0.7); }
.swatch.stop { background: var(--fault); }

.stop-slot {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  margin-top: 10px;
}
.stop-slot .btn { min-width: 118px; }
.sis-readout { margin: 0; font-weight: 650; }
.dial.detail { touch-action: none; }
.dial .sis.off { stroke-opacity: 0.35; }
.leaflet-div-icon.sis-handle {
  background: #e10600;
  border: 2px solid #fff;
  border-radius: 50%;
  box-sizing: border-box;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.span-2 { grid-column: 1 / -1; }
.inline-find { display: flex; gap: 8px; align-items: center; }
.inline-find input { flex: 1; min-width: 0; }
.satellite-map {
  height: min(480px, 72vw);
  min-height: 300px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #d7e0d6;
}
.satellite-map .leaflet-container { width: 100%; height: 100%; font-family: var(--font); background: #d7e0d6; }
.pivot-centre-pin {
  width: 18px;
  height: 18px;
  background: #fff;
  border: 3px solid #1a261c;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.45);
}
.field { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.field input, .sim select, .field select {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.form-error { color: #b42318; margin: 8px 0 0; }
.form-error:empty { display: none; }
details.card summary { cursor: pointer; font-weight: 650; }
details.card summary + * { margin-top: 12px; }
.signals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}
.signals li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-3);
  border-radius: 10px;
  padding: 10px 12px;
}
.signals span { color: var(--muted); }
.signals b { font-weight: 650; }
.signals .on b { color: #146b3a; }
.signals .fault b { color: #b42318; }
.signals .off b, .signals .idle b { color: var(--muted); }

.warn {
  margin: 12px 0 0;
  padding: 12px 14px;
  color: #7a5410;
  background: #fff6e4;
  border: 1px solid #e6cf9a;
  border-radius: 12px;
}
.warn[hidden] { display: none; }

.log li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.log time {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
}
.empty { color: var(--muted); margin: 0; }
.foot { color: var(--faint); font-size: 13px; margin: 22px 0 0; }
.block { margin-top: 14px; }

.demand-row {
  display: grid;
  grid-template-columns: minmax(90px, 1.1fr) minmax(90px, 1fr) minmax(80px, 1.3fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}
.demand-row:hover { color: var(--water); }
.meter { height: 8px; background: #d7e2d8; border-radius: 99px; overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--water); }
.spark { width: 100%; height: 56px; display: block; }
.spark path { fill: none; stroke: var(--water); stroke-width: 2; }

.dial, .gauge { width: 100%; height: auto; display: block; }
.dial .field { fill: #e7f2ea; }
.dial .pressure-ring { fill: none; stroke: #1a6bb5; stroke-opacity: 0.45; }
.dial .pressure-ring.dry { stroke: var(--run); }
.dial .track { fill: none; stroke: #c5d5c8; stroke-width: 16; }
.dial .track.wet { stroke: #0c3d73; }
.dial .track.dry { stroke: var(--run); }
.dial .sector { fill: rgba(15, 143, 134, 0.16); }
.dial .water { fill: rgba(15, 143, 134, 0.38); }
.dial .walked { fill: rgba(26, 38, 28, 0.08); }
.dial .arm { stroke: #fff; stroke-width: 8; stroke-linecap: round; }
.dial .sis { stroke: #e10600; stroke-width: 8; stroke-linecap: round; }
.dial .tower { fill: #5f8f12; }
.dial .tick { stroke: #9aafa0; stroke-width: 1; }
.dial .tick.major { stroke: #6d8474; stroke-width: 1.5; }
.dial .label { fill: #5c6d60; font-size: 12px; font-family: var(--mono); }
.dial .barrier { stroke: var(--fault); stroke-width: 3; stroke-linecap: round; }
.dial .endgun { fill: rgba(15, 143, 134, 0.22); stroke: var(--water); stroke-width: 1.5; }
.dial .endgun-dot { fill: var(--water); }
.dial .dir { fill: #fff; }
.dial .hub { fill: #f7fbf7; }
.dial .angle-text {
  fill: var(--text);
  font-family: var(--display);
  font-size: 42px;
  font-weight: 600;
}
.dial .angle-sub { fill: var(--muted); font-family: var(--font); font-size: 14px; }
.dial.compact .track { stroke-width: 8; }
.dial.compact .arm,
.dial.compact .sis { stroke-width: 4; }
.dial.offline .field,
.pivot-sight.has-satellite .dial.offline .field,
.pivot-hero.has-satellite .dial.offline .field { fill: #e10600; }
.dial.offline .sector,
.dial.offline .water,
.dial.offline .walked,
.dial.offline .hub,
.dial.offline .endgun,
.dial.offline .endgun-dot,
.dial.offline .dir { fill: #8f1208; }
.dial.offline .pressure-ring,
.dial.offline .track,
.dial.offline .track.wet,
.dial.offline .track.dry,
.dial.offline .arm,
.dial.offline .sis,
.dial.offline .tick,
.dial.offline .tick.major,
.dial.offline .barrier,
.dial.offline .endgun {
  stroke: #8f1208;
  stroke-opacity: 1;
}
.dial.offline .label,
.dial.offline .angle-text,
.dial.offline .angle-sub { fill: #fff; }

.gauge-track { fill: none; stroke: #d5e0d4; stroke-width: 14; stroke-linecap: round; }
.gauge-low { fill: none; stroke: var(--fault); stroke-width: 14; stroke-linecap: butt; }
.gauge-set { stroke: var(--text); stroke-width: 3; }
.gauge-needle { stroke-width: 5; stroke-linecap: round; }
.gauge-needle.ok { stroke: #5f8f12; }
.gauge-needle.warn { stroke: var(--wait); }
.gauge-needle.bad { stroke: var(--fault); }
.gauge-needle.idle { stroke: var(--muted); }
.gauge-value {
  fill: var(--text);
  font-family: var(--display);
  font-size: 52px;
  font-weight: 600;
}
.gauge-unit, .gauge-label { fill: var(--muted); font-family: var(--font); font-size: 13px; }

@media (max-width: 860px) {
  .layout, .banner, .stats-4 { grid-template-columns: 1fr; }
  .stats-4 { grid-template-columns: 1fr 1fr; }
  body.pivot-page .page-head { margin: 0 0 8px; }
  body.pivot-page h1 { font-size: 24px; }
  body.pivot-page .lede { display: none; }
  #satellite-map { height: 240px; min-height: 0; }
  body.pivot-page #centre-card .readout { font-size: 16px; line-height: 1.15; }
  body.pivot-page #dial { display: flex; justify-content: center; }
  body.pivot-page #dial svg { width: min(100%, 280px); height: auto; }
}
@media (max-width: 720px) {
  .dock-status { min-height: 52px; padding: 6px 10px; gap: 8px; }
  .running-pump { min-height: 40px; font-size: 14px; }
  .nav { padding: 6px 6px 8px; gap: 2px; }
  .nav a { min-height: 78px; font-size: 11px; gap: 4px; border-radius: 14px; }
  .nav-icon { width: 28px; height: 28px; }
  .page { width: min(1120px, calc(100% - 20px)); }
  .form-grid, .banner .statline { grid-template-columns: 1fr 1fr; }
  .demand-row { grid-template-columns: 1fr auto; }
  .demand-row .meter { grid-column: 1 / -1; }
  #satellite-map { height: 220px; border-radius: 16px; }
  body.pivot-page .legend { display: none; }
}
@media (min-width: 960px) {
  body {
    padding: 56px 0 32px 232px;
  }
  .dock {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: auto;
    width: 232px;
    flex-direction: column;
    align-items: stretch;
    border-top: none;
    border-right: 1px solid var(--line);
    background: #fff;
    backdrop-filter: none;
    padding: 0 12px 16px;
  }
  .dock::before {
    content: "PivotControl";
    display: flex;
    align-items: center;
    height: 56px;
    margin: 0 -12px 8px;
    padding: 0 24px;
    border-bottom: 1px solid var(--line);
    font-size: 18px;
    font-weight: 650;
    letter-spacing: -0.03em;
  }
  .nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 0 0;
  }
  .nav a {
    flex-direction: row;
    justify-content: flex-start;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 10px;
    font-size: 15px;
    gap: 12px;
    text-align: left;
  }
  .nav-icon { width: 22px; height: 22px; flex: none; }
  .dock-status {
    position: fixed;
    top: 0;
    left: 232px;
    right: 0;
    bottom: auto;
    z-index: 31;
    height: 56px;
    min-height: 56px;
    padding: 0 28px;
    border-bottom: 1px solid var(--line);
    background: #fff;
  }
  .page {
    width: min(1480px, calc(100% - 56px));
    padding-top: 28px;
  }
  h1 { font-size: 34px; }
  .command-wait { top: 68px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

.pump-stack { display: grid; gap: 12px; }
.pump-group { display: grid; gap: 10px; }
.pump-group + .pump-group { margin-top: 14px; }
.pump-group-head h2 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.valve-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.valve-actions { margin-top: 12px; }
.valve-actions .btn { display: inline-flex; align-items: center; text-decoration: none; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.check-list { display: grid; gap: 8px; }
.safety-log { max-height: 520px; overflow: auto; }
.apply-wheel { display: grid; justify-items: center; margin-top: 12px; }
.apply-stage { position: relative; width: min(100%, 440px); }
.apply-stage svg { position: relative; z-index: 1; width: 100%; height: auto; display: block; }
.apply-sat-clip {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 16px;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
  background: #d7e0d6;
}
.apply-sat-clip[hidden] { display: none; }
.apply-sat, .apply-sat .leaflet-container { width: 100%; height: 100%; background: #d7e0d6; }
.apply-wheel path { cursor: pointer; }
.apply-wheel path.is-picked { stroke: #1a261c; stroke-width: 3; }
.apply-scale { height: 14px; width: min(100%, 440px); margin: 8px auto 0; border-radius: 999px; border: 1px solid var(--line); }
.apply-scale-labels { display: flex; justify-content: space-between; width: min(100%, 440px); margin: 4px auto 0; color: var(--muted); font-size: 12px; }
.check { display: flex; align-items: center; gap: 8px; }
.safety-pivot { min-height: 40px; }
.safety-pivot-name { flex: 1; font-weight: 650; }
.safety-move { display: flex; flex-direction: column; align-items: flex-end; min-width: 52px; color: var(--muted); font-size: 11px; line-height: 1.1; }
.safety-move strong { color: var(--text); font-size: 16px; font-weight: 650; }
.setup-choices { display: grid; gap: 10px; }
.choice-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  cursor: pointer;
}
.choice-card strong { font-size: 16px; }
.choice-card span { color: var(--muted); font-size: 14px; line-height: 1.4; }
.choice-card[aria-pressed="true"] { border-color: var(--run); box-shadow: inset 0 0 0 1px var(--run); }
#pump-picker a { text-decoration: none; }
#supply-box { margin-bottom: 10px; }
@media (min-width: 860px) {
  .setup-choices { grid-template-columns: repeat(3, 1fr); }
}
.settings-tabs { margin: 16px 0; }
.icon-btn {
  width: 36px;
  height: 36px;
  margin-left: auto;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}
.icon-btn svg { width: 18px; height: 18px; }
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px 16px;
  margin: 12px 0 0;
}
.facts dt { color: var(--muted); font-size: 12px; }
.facts dd { margin: 2px 0 0; font-weight: 650; }
.toolbar { margin: 0 0 12px; }
.modal {
  width: min(640px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  background: #fff;
  color: var(--text);
}
.modal::backdrop { background: rgba(26, 38, 28, 0.4); }
.modal h2 { margin: 0; }
#connection-lost { z-index: 40; }
#connection-lost p, #speed-confirm p, #rate-manual .field { margin: 10px 0 16px; color: var(--muted); line-height: 1.4; }
.command-wait {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 50%;
  z-index: 35;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 24px);
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--shadow);
}
.command-wait p { margin: 0; font-weight: 650; }
.wait-ring {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 3px solid #d5e0d4;
  border-top-color: var(--run);
  border-radius: 50%;
  animation: wait-spin 0.8s linear infinite;
}
@keyframes wait-spin { to { transform: rotate(360deg); } }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
[hidden] { display: none !important; }
.machine-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.machine-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
}
.machine-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.machine-actions a { color: var(--muted); font-weight: 650; }
svg.layout { width: 100%; height: auto; display: block; margin-top: 12px; background: #f7faf6; border: 1px solid var(--line); border-radius: 12px; }
.layout-pump { fill: #e7f6f4; stroke: #0f8f86; }
.layout-valve { fill: #fff; stroke: #5f8f12; }
.layout-valve.closed { stroke: #8aa08a; }
.layout-dest { fill: #fff; stroke: #c5d4c4; }
.layout-pipe { stroke: #c5d4c4; stroke-width: 3; }
.layout-pipe.open { stroke: #0f8f86; }
.layout text { font-size: 13px; fill: #1a261c; font-family: var(--font); }
.layout .sub { font-size: 11px; fill: var(--muted); }
.reservoir-pumps { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.reservoir-pumps li { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.reservoir-pumps label { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; }
.valve-run-list { display: grid; gap: 14px; }
.valve-run { display: grid; gap: 8px; }
.valve-run .btn-choice[data-mode="open"][aria-pressed="true"] {
  background: #0f8f86;
  border-color: #0b6b64;
  color: #fff;
  box-shadow: inset 0 0 0 2px #084843;
}
.valve-run .btn-choice[data-mode="closed"][aria-pressed="true"] {
  background: #c44536;
  border-color: #8d2e24;
  color: #fff;
  box-shadow: inset 0 0 0 2px #6e241c;
}
.valve-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.valve-row strong { margin-right: 6px; }

