:root {
  color-scheme: dark;
  --bg: #0f1419;
  --panel: #1a2028;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #3b82f6;
  --ok: #22c55e;
  --bad: #ef4444;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, "SF Pro Text", system-ui, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}

main {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

#picker {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  gap: 16px;
}

#picker h1 { margin: 0 0 4px; font-size: 28px; font-weight: 600; letter-spacing: -0.01em; }
#picker .lede { color: var(--muted); margin: 0 0 24px; max-width: 340px; line-height: 1.4; }

button {
  font: inherit;
  font-size: 17px;
  padding: 14px 28px;
  min-height: 48px;
  border: 1px solid transparent;
  background: var(--accent);
  color: white;
  border-radius: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.status {
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
  min-height: 1.4em;
}
.status.err { color: var(--bad); }

#hmi { background: var(--bg); }
#hmi header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid #2a323c;
  font-size: 14px;
  min-height: 44px;
}
#device-name { font-weight: 600; }
#connection-indicator { font-size: 10px; transition: color 200ms; }
#connection-indicator.live { color: var(--ok); }
#connection-indicator.disc { color: var(--bad); }

#canvas {
  flex: 1;
  width: 100%;
  display: block;
  background: #0f1419;
}

#hmi-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: var(--panel);
  border-top: 1px solid #2a323c;
  font-size: 13px;
  color: var(--muted);
}
#hmi-footer button {
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  font-size: 14px;
  border: 1px solid #2a323c;
}

/* When disconnected, dim the canvas — the spec's "walk away → HMI greys out". */
#canvas.stale {
  opacity: 0.35;
  filter: grayscale(0.6);
  transition: opacity 200ms, filter 200ms;
}

/* Widget base styles (SVG). Actual colors come from render code. */
.widget-label {
  font: 12px -apple-system, system-ui, sans-serif;
  fill: var(--muted);
  dominant-baseline: hanging;
}
.widget-numeric-value {
  font: 28px -apple-system, system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  fill: var(--text);
  text-anchor: middle;
  dominant-baseline: middle;
}
.widget-numeric-unit {
  font: 12px -apple-system, system-ui, sans-serif;
  fill: var(--muted);
  text-anchor: middle;
}
.tank-shell { fill: none; stroke: #4b5563; stroke-width: 2; }
.tank-fill  { fill: #3b82f6; }
.pump-body  { fill: #1a2028; stroke: #4b5563; stroke-width: 2; }
.pump-impeller-on  { fill: var(--ok); }
.pump-impeller-off { fill: #4b5563; }
.valve-body-open   { fill: var(--ok); stroke: #2f855a; stroke-width: 2; }
.valve-body-closed { fill: #4b5563; stroke: #374151; stroke-width: 2; }
.pipe { fill: none; stroke: #6b7280; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
