/* The web SCADA's look (ADR-068 §6). Phones first; dark when the device is dark. */
:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1b2430;
  --soft: #5d6b7c;
  --line: #dde3ea;
  --accent: #1f6feb;
  --on: #1a9a4a;
  --off: #9aa5b1;
  --bad: #c62828;
  --warn: #b26a00;
  --label: #3a4553;
  --on-soft: #e3f5e8;
  --bad-soft: #fde4e4;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141414;
    --card: #1c1c1c;
    --text: #f2f2f2;
    --soft: #9c9c9c;
    --line: #3a3a3a;
    --accent: #3d8ee6;
    --on: #14a314;
    --off: #555555;
    --bad: #d94343;
    --warn: #f0a742;
    --label: #d4d4d4;
    --on-soft: #183418;
    --bad-soft: #451b1b;
  }
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font:
    15px/1.5 system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  background: var(--bg);
  color: var(--text);
}
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}
a {
  color: var(--accent);
}
h1 {
  font-size: 22px;
  margin: 0 0 12px;
}
h2 {
  font-size: 17px;
  margin: 0 0 4px;
}
code {
  font-size: 13px;
}
button,
input {
  font: inherit;
}
.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  margin-right: auto;
}
.brand span {
  color: var(--accent);
}
.who {
  color: var(--soft);
  font-size: 14px;
}
.bar form {
  margin: 0;
}
button.link {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  padding: 4px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}
.narrow {
  max-width: 420px;
  margin: 40px auto;
}
.stack {
  display: grid;
  gap: 12px;
}
.stack label {
  display: grid;
  gap: 4px;
  font-weight: 600;
  font-size: 14px;
}
input[type="email"],
input[type="password"],
input[type="search"],
input[type="text"],
input[type="number"],
textarea {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  width: 100%;
}
button {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.hint {
  color: var(--soft);
  font-size: 13px;
  margin: 4px 0;
}
.error {
  color: var(--bad);
  font-weight: 600;
}
.ok {
  color: var(--on);
  font-weight: 600;
}
.head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
}
.filter {
  max-width: 260px;
}
.sites {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.site {
  color: var(--text);
  text-decoration: none;
  display: block;
}
.site:hover {
  border-color: var(--accent);
}
.state {
  margin: 8px 0 0;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--off);
  display: inline-block;
}
.state.online .dot {
  background: var(--on);
}
.state.some .dot {
  background: var(--warn);
}
.state.offline .dot {
  background: var(--bad);
}
.empty {
  text-align: center;
}
.crumbs {
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--soft);
}
.widget {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 22px;
  display: grid;
  gap: 10px;
  align-content: start;
}
.widget .name {
  font-size: 16px;
  font-weight: 500;
  color: var(--label);
  overflow-wrap: anywhere;
}
.widget .value {
  font-size: clamp(22px, 17cqi, 40px);
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
/* A variable's tile: its name (and alarm badge) on top, what it shows under it, the message at the bottom. */
.page-grid > .widget.tile {
  display: flex;
  flex-direction: column;
}
.widget.tile > .msg {
  margin-top: auto;
}
.badge {
  font-size: 15px;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--bad-soft);
  color: var(--bad);
  white-space: nowrap;
}
.badge[hidden] {
  display: none;
}
.icon {
  width: 1.1em;
  height: 1.1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.widget.tile > .msg:empty {
  min-height: 0;
}
.spark {
  width: 100%;
  height: 26px;
}
.spark polyline {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linejoin: round;
}
.tank-row {
  display: flex;
  align-items: center;
  gap: 22px;
}
.tank {
  width: 44px;
  height: 108px;
  border: 2px solid var(--line);
  border-radius: 8px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  flex: none;
}
.tank span {
  display: block;
  width: 100%;
  height: 0;
  background: var(--accent);
  transition: height 0.3s;
}
.now {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.now .dot {
  width: 8px;
  height: 8px;
}
.now .dot.on {
  background: var(--on);
}
.now .dot[hidden] {
  display: none;
}
.widget .unit {
  font-size: 0.6em;
  font-weight: 400;
  color: var(--label);
  margin-left: 6px;
}
.lamp {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  font-weight: 700;
  font-size: clamp(22px, 17cqi, 40px);
  line-height: 1.2;
}
.lamp::before {
  content: "";
  flex: none;
  width: 0.95em;
  height: 0.95em;
  border-radius: 50%;
  background: var(--off);
}
.lamp.on::before {
  background: var(--on);
}
.lamp + .hint {
  font-size: 17px;
  margin: 0;
}
.bar-track {
  height: 10px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.bar-track span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
}
.range {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--soft);
}
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px;
  border: 0;
  background: none;
  font-weight: 700;
}
.switch .track {
  width: 46px;
  height: 26px;
  border-radius: 13px;
  background: var(--off);
  position: relative;
  transition: background 0.15s;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.15s;
}
.switch[aria-checked="true"] .track {
  background: var(--on);
}
.switch[aria-checked="true"] .track::after {
  left: 23px;
}
.entry {
  display: flex;
  gap: 6px;
}
.entry[hidden],
.change[hidden] {
  display: none;
}
button.change {
  width: 100%;
  padding: 12px 14px;
  font-size: 18px;
  border-radius: 12px;
  background: none;
}
.entry input {
  min-width: 0;
}
.msg {
  font-size: 13px;
  min-height: 1em;
  margin: 0;
}
.msg.wait {
  color: var(--warn);
}
.msg.bad {
  color: var(--bad);
}
.msg.done {
  color: var(--on);
}
.pill {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--line);
}
.pill.online {
  background: var(--on-soft);
  color: var(--on);
}
.pill.offline {
  background: var(--bad-soft);
  color: var(--bad);
}
.pill.some {
  background: var(--warn);
  color: #fff;
}
.pill.alarm-count {
  background: var(--bad-soft);
  color: var(--bad);
}
.pill[hidden] {
  display: none;
}
/* The site's name, how fresh its values are, its state and its alarms, in one bar. */
.site-head {
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  padding: 20px 28px;
  margin-bottom: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.site-icon {
  display: inline-flex;
  font-size: 26px;
  color: var(--label);
}
.site-title {
  flex: 1;
  min-width: 160px;
}
.site-head h1 {
  margin: 0;
  font-size: 24px;
}
.site-head .live {
  margin: 0;
  font-size: 17px;
  color: var(--label);
}
.site-head .live.error {
  color: var(--bad);
}
.site-head .pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 17px;
  font-weight: 500;
  padding: 4px 16px;
  border-radius: 999px;
}
.site-head .pill[hidden] {
  display: none;
}
.site-head .edit-page {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 6px;
  padding: 12px 20px;
  font-size: 18px;
  border-radius: 12px;
  background: none;
}
.page-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-rows: minmax(56px, auto);
}
/* A tile's big text follows its width, so a narrow tile still shows it whole. */
.page-grid > .widget {
  min-width: 0;
  container-type: inline-size;
}
.widget.offline {
  opacity: 0.55;
}
.widget.device-row {
  background: none;
  border: 0;
  padding: 0;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  align-self: end;
}
.widget.device-row h2 {
  margin: 0;
  font-size: 16px;
}
/* A controller's row and a title are section heads: a line under them groups the tiles below. */
.widget.device-row {
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 4px 0 6px;
}
/* A title is a section head over the tiles below it. */
.widget.text h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  padding-left: 2px;
}
.widget.text h2 .icon {
  font-size: 16px;
  color: var(--label);
}
.widget-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}
.widget-tools {
  display: flex;
  gap: 12px;
  align-items: center;
  flex: 1;
  justify-content: flex-end;
}
.widget-head select {
  width: auto;
  flex: 0 1 330px;
  min-width: 0;
  font-size: 15px;
  padding: 10px 14px;
  border-radius: 10px;
}
.gone {
  font-style: italic;
}
/* A gauge: its value inside the arc. */
.dial-wrap {
  position: relative;
  width: 100%;
  max-width: 220px;
  margin: 0 auto;
}
.dial {
  display: block;
  width: 100%;
}
.dial path {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
}
.widget .dial-value {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  text-align: center;
  font-size: clamp(20px, 17cqi, 34px);
}
.dial-back {
  stroke: var(--line);
}
.dial-fill {
  stroke: var(--accent);
}
.lamp.on.red::before {
  background: var(--bad);
  box-shadow: 0 0 8px var(--bad);
}
.lamp.on.amber::before {
  background: #f59f00;
  box-shadow: 0 0 8px #f59f00;
}
.lamp.on.blue::before {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
button.press {
  padding: 14px 8px;
  width: 100%;
  font-size: clamp(15px, 9cqi, 20px);
  border-radius: 10px;
}
/* A Start and Stop pair: two buttons side by side, and what they do under them. */
.press-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.widget.pair > .ask {
  font-size: 17px;
  margin: 2px 0 0;
}
.widget.pair:has(> .msg:not(:empty)) > .ask {
  display: none;
}
button.press.go {
  background: var(--on);
  border-color: var(--on);
  color: #fff;
}
button.press.halt {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}
button.press:not(:disabled):hover {
  filter: brightness(1.08);
}
.widget.kind-trend {
  grid-template-rows: auto 1fr auto;
  align-content: stretch;
}
.trend-chart {
  display: grid;
  height: 100%;
  min-height: 120px;
  padding-top: 8px;
}
.trend {
  display: grid;
  grid-template-rows: 1fr auto auto;
  min-height: 0;
}
.trend-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 11px;
  color: var(--soft);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.trend-plot {
  width: 100%;
  height: 100%;
  overflow: visible;
}
.limit-line {
  stroke: var(--bad);
  stroke-width: 2;
  stroke-dasharray: 8 7;
  vector-effect: non-scaling-stroke;
}
.trend-line {
  fill: none;
  stroke-width: 3;
  stroke-linejoin: round;
}
.trend-times {
  display: flex;
  justify-content: space-between;
  font-size: 17px;
  color: var(--soft);
  padding-top: 14px;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 13px;
}
.legend .key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend i {
  width: 12px;
  height: 3px;
  border-radius: 2px;
}
.table-wrap {
  overflow: auto;
  max-height: 360px;
}
td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
a.csv {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: 17px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
a.csv:hover {
  border-color: var(--accent);
}
.widget.text {
  background: none;
  border: 0;
  padding: 4px 0;
  align-content: end;
}
.widget.text h2,
.widget.text p {
  margin: 0;
  overflow-wrap: anywhere;
}
.widget.note p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.widget.note.yellow {
  background: #fff6c7;
  color: #3d3200;
}
.widget.note.blue {
  background: #dcebff;
  color: #0b2a55;
}
.widget.note.green {
  background: #dcf5e3;
  color: #0d3a1c;
}
.widget.note.red {
  background: #ffe0e0;
  color: #5a1010;
}
.widget.note.grey {
  background: var(--line);
}
/* A picture fills its box, whole and in proportion. */
.widget.picture {
  position: relative;
  padding: 0;
  overflow: hidden;
}
.widget.picture img {
  position: absolute;
  inset: 6px;
  width: calc(100% - 12px);
  height: calc(100% - 12px);
  object-fit: contain;
}
/* A trend or table without values in its time: one short line in the middle. */
.widget.is-empty {
  grid-template-rows: auto 1fr auto;
  align-content: stretch;
}
.widget.is-empty > .trend,
.widget.is-empty > .table-wrap {
  display: none;
}
.widget.is-empty > .hint {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 17px;
  color: var(--label);
}
@media (max-width: 700px) {
  .page-grid > .widget {
    grid-column: 1 / -1 !important;
    grid-row: auto !important;
  }
  .page-grid > .kind-trend {
    min-height: 260px;
  }
  .page-grid > .picture {
    min-height: 200px;
  }
}
.edit-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.edit-bar .msg {
  flex: 1;
  min-width: 160px;
}
.editor {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.editor aside {
  position: sticky;
  top: 70px;
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 90px);
  overflow: auto;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.editor aside h3 {
  margin: 0;
}
.palette {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.palette button {
  font-size: 13px;
  padding: 6px;
}
.props {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.field {
  display: grid;
  gap: 2px;
  font-size: 13px;
}
.field > span {
  color: var(--soft);
}
.field textarea {
  font: inherit;
  resize: vertical;
}
.field-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.field-row input {
  width: 100%;
  min-width: 0;
}
.checks {
  max-height: 200px;
  overflow: auto;
}
.canvas .page-grid {
  min-height: 300px;
  padding: 6px;
  border: 1px dashed var(--line);
  border-radius: 10px;
}
.canvas .widget {
  position: relative;
}
.canvas .widget.text,
.canvas .widget.device-row {
  outline: 1px dashed var(--line);
}
.edit-cover {
  position: absolute;
  inset: 0;
  cursor: move;
  border-radius: 10px;
  touch-action: none;
}
.edit-cover:focus {
  outline: none;
}
.widget.selected > .edit-cover,
.edit-cover:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.edit-grip {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  border-right: 3px solid var(--accent);
  border-bottom: 3px solid var(--accent);
  border-radius: 0 0 6px 0;
}
.edit-page[hidden] {
  display: none !important;
}
@media (max-width: 700px) {
  .editor {
    grid-template-columns: 1fr;
  }
  .editor aside {
    position: static;
    max-height: none;
  }
  .edit-grip {
    display: none;
  }
}
.safety {
  margin-top: 24px;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  max-width: 360px;
  width: calc(100% - 32px);
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}
dialog .question {
  font-weight: 700;
  font-size: 17px;
}
dialog .buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
/* The panels (S3c): the bar's links, tables, add forms, choices and the shown-once box. */
.nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.nav a {
  padding: 4px 8px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 14px;
}
.nav a:hover {
  background: var(--bg);
}
section.card,
details.card {
  margin-bottom: 14px;
}
h3 {
  font-size: 15px;
  margin: 0;
}
.table {
  overflow-x: auto;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}
th,
td {
  text-align: left;
  padding: 8px 10px 8px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  color: var(--soft);
  font-weight: 600;
  font-size: 13px;
}
td .state {
  margin: 0;
}
details.add {
  margin-top: 12px;
}
details.add > summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}
details.add > form {
  margin-top: 12px;
  max-width: 480px;
}
fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 0;
  display: grid;
  gap: 6px;
}
legend {
  font-weight: 600;
  font-size: 14px;
  padding: 0 4px;
}
.stack label.choice,
label.choice {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-weight: 400;
}
.ticks {
  display: grid;
  gap: 4px;
  padding-left: 24px;
}
.ticks[aria-disabled="true"] {
  opacity: 0.5;
}
select {
  font: inherit;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
form.inline {
  display: inline;
  margin: 0;
}
.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.block {
  border-top: 1px solid var(--line);
  padding: 10px 0;
}
.block .head {
  align-items: center;
}
.line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding: 6px 0 6px 12px;
}
button.danger {
  color: var(--bad);
  border-color: var(--bad);
}
button.link.danger {
  border: 0;
}
.secret {
  display: flex;
  gap: 8px;
}
.secret input {
  font-family: ui-monospace, monospace;
  font-size: 13px;
}
.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 0 0 12px;
}
.facts dt {
  color: var(--soft);
}
.facts dd {
  margin: 0;
}
.pager {
  display: flex;
  gap: 16px;
}
