:root {
  --brand: #160966;
  --hover: #24147d;
  --soft: #f0edfa;
  --bg: #f6f7fb;
  --surface: #fff;
  --text: #172033;
  --muted: #526079;
  --border: #d9dfea;
  --good: #18794e;
  --warn: #8a5700;
  --danger: #b42318;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    15px/1.5 system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  font-variant-numeric: tabular-nums;
}
header {
  height: 112px;
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: white;
  border-bottom: 1px solid var(--border);
  gap: 24px;
}
header img {
  width: 200px;
  height: auto;
  display: block;
}
.header-state {
  display: flex;
  gap: 4px 20px;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  max-width: 800px;
  font-size: 13px;
}
.header-state strong {
  font-size: 16px;
}
.hint-btn {
  background: var(--soft);
  color: var(--brand);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
}
.hint-btn:hover {
  background: var(--brand);
  color: white;
}
.shell {
  display: grid;
  grid-template-columns: 204px minmax(0, 1fr);
  min-height: calc(100vh - 112px);
}
nav {
  background: white;
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
nav button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  margin-bottom: 4px;
  font-weight: 500;
}
nav button[aria-current='page'] {
  background: var(--soft);
  color: var(--brand);
  font-weight: 700;
}
nav small {
  margin-top: auto;
  padding: 12px;
  color: var(--muted);
}
#menu-toggle {
  display: none;
}
main {
  min-width: 0;
  padding: 20px 28px 90px;
  max-width: 1640px;
  width: 100%;
  margin: 0 auto;
}
.page-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 16px;
}
h1 {
  font-size: 26px;
  margin: 0;
}
h2 {
  font-size: 19px;
  margin: 0 0 14px;
}
h3 {
  font-size: 16px;
  margin: 0 0 10px;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 1.3px;
  color: var(--muted);
  margin: 0 0 3px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  min-width: 0;
}
.full {
  grid-column: 1/-1;
}
p {
  margin: 8px 0;
  color: var(--muted);
}
.metric {
  font-size: 28px;
  font-weight: 650;
  color: var(--text);
}
.metric small {
  font-size: 14px;
  color: var(--muted);
}
.measurements {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.measurement {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
}
.good {
  color: var(--good);
}
.warn {
  color: var(--warn);
}
.bad {
  color: var(--danger);
}
.muted,
small {
  color: var(--muted);
}
.badge {
  display: inline-block;
  background: var(--soft);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
}
.leds {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.led {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #929bac;
  border: 1px solid #748096;
  margin-right: 6px;
}
.red.on {
  background: #b42318;
}
.green.on {
  background: #18794e;
}
.yellow.on {
  background: #b77800;
}
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 10px 0 4px;
}
input,
select,
textarea,
button {
  font: inherit;
  max-width: 100%;
}
input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid #9aa6ba;
  border-radius: 6px;
  padding: 8px 10px;
  background: white;
  color: var(--text);
}
input[type='checkbox'] {
  width: 20px;
  min-height: 20px;
  vertical-align: middle;
  margin: 0 10px 0 0;
}
label.check {
  display: flex;
  align-items: center;
  min-height: 36px;
}
button {
  min-height: 40px;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  background: white;
  color: var(--text);
}
button:hover {
  background: var(--soft);
}
button.primary {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}
button.primary:hover {
  background: var(--hover);
}
button:disabled {
  opacity: 0.55;
  cursor: wait;
}
button.busy:before {
  content: '◌ ';
  display: inline-block;
}
button.danger {
  color: var(--danger);
}
.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 16px;
}
.inline {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.inline label {
  margin: 0;
}
.inline select {
  width: auto;
  min-width: 130px;
}
.buttons {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}
footer {
  position: fixed;
  bottom: 0;
  left: 204px;
  right: 0;
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 28px;
  gap: 12px;
  z-index: 6;
}
footer span {
  margin-right: auto;
  font-size: 13px;
}
#notice {
  background: #fff5e0;
  border: 1px solid #d5b15c;
  color: #634000;
  padding: 12px 16px;
  border-radius: 8px;
  margin: 12px 0;
  white-space: pre-line;
}
#notice.error {
  background: #fef0ee;
  border-color: #dc9c95;
  color: var(--danger);
}
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--bg);
  padding: 12px;
  border-radius: 6px;
  font:
    13px/1.5 ui-monospace,
    Consolas,
    monospace;
  max-height: 240px;
  overflow: auto;
}
dialog {
  width: min(580px, calc(100% - 32px));
  max-height: 90vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}
dialog::backdrop {
  background: #17203380;
}
dialog form p {
  font-size: 13px;
}
#login-error {
  color: var(--danger);
}
:focus-visible {
  outline: 3px solid #8069dc;
  outline-offset: 3px;
}
[hidden] {
  display: none !important;
}
.scroll {
  overflow: auto;
  max-height: 330px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th,
td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 8px;
  vertical-align: top;
}
canvas {
  display: block;
  width: 100%;
  height: 220px;
  margin-top: 12px;
}
.hint {
  font-size: 13px;
}
.file {
  padding: 10px 0;
}
progress {
  width: 100%;
  accent-color: var(--brand);
}
details {
  margin: 14px 0;
}
summary {
  cursor: pointer;
  font-weight: 600;
}
.field-error {
  border-color: var(--danger);
  outline: 1px solid var(--danger);
}
@media (min-width: 1100px) {
  .form-scroll {
    max-height: calc(100vh - 365px);
    overflow: auto;
    padding-right: 6px;
  }
}
@media (max-width: 850px) {
  header {
    height: auto;
    min-height: 100px;
    padding: 12px 16px;
    gap: 12px;
  }
  header img {
    width: 160px;
  }
  .header-state {
    font-size: 11px;
    gap: 2px 10px;
    max-width: 380px;
  }
  .header-state strong {
    font-size: 13px;
  }
  .shell {
    grid-template-columns: 1fr;
  }
  nav {
    padding: 8px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  nav small {
    display: none;
  }
  #menu-toggle {
    display: block;
    width: auto;
    margin: 0;
  }
  #navigation {
    display: none;
  }
  #navigation.open {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  main {
    padding: 16px 16px 100px;
  }
  footer {
    left: 0;
    padding: 12px 16px;
  }
  .grid.three {
    grid-template-columns: 1fr;
  }
  .grid {
    gap: 12px;
  }
  .page-title {
    align-items: flex-start;
  }
  h1 {
    font-size: 23px;
  }
}
@media (max-width: 520px) {
  header img {
    width: 142px;
  }
  .header-state {
    max-width: 180px;
  }
  .header-state span:nth-last-child(-n + 2) {
    display: none;
  }
  .grid,
  .fields {
    grid-template-columns: 1fr;
  }
  .page-title {
    gap: 8px;
  }
  #stream-state {
    font-size: 12px;
  }
  button,
  input,
  select {
    min-height: 44px;
  }
  footer {
    flex-wrap: wrap;
    gap: 8px;
  }
  footer span {
    width: 100%;
  }
  .card {
    padding: 14px;
  }
  .measurements {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .metric {
    font-size: 25px;
  }
  .eyebrow {
    font-size: 10px;
  }
  canvas {
    height: 190px;
  }
}

/* Keep every screen inside the available workspace. */
html,
body {
  height: 100%;
  overflow: hidden;
}
body {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  font-size: 13px;
  line-height: 1.35;
}
header {
  height: 72px;
  flex: 0 0 72px;
  padding: 8px 20px;
}
header img {
  width: 156px;
  max-height: 56px;
  object-fit: contain;
}
.header-state {
  font-size: 11px;
  gap: 4px 12px;
}
.header-state strong {
  font-size: 14px;
}
.shell {
  flex: 1;
  min-height: 0;
  grid-template-columns: 174px minmax(0, 1fr);
}
nav {
  min-height: 0;
  padding: 10px;
  gap: 8px;
}
nav button {
  padding: 8px;
  min-height: 34px;
}
nav small {
  padding: 8px;
}
main {
  min-height: 0;
  max-width: none;
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
}
.page-title {
  flex: none;
  margin-bottom: 8px;
}
h1 {
  font-size: 23px;
}
h2 {
  font-size: 16px;
  margin-bottom: 8px;
}
h3 {
  font-size: 14px;
  margin-bottom: 6px;
}
p {
  margin: 6px 0;
}
#notice {
  flex: none;
  padding: 6px 10px;
  margin: 0 0 8px;
}
#page-viewport {
  flex: 1;
  min-height: 0;
}
#page {
  height: 100%;
}
.grid {
  gap: 12px;
  align-items: start;
}
.card {
  padding: 12px;
}
.fields {
  gap: 0 10px;
}
label {
  font-size: 12px;
  margin: 6px 0 3px;
}
input,
select,
button,
textarea {
  min-height: 32px;
  padding: 5px 8px;
}
label.check {
  min-height: 26px;
}
.inline {
  gap: 8px;
}
.inline select {
  min-width: 100px;
  max-width: 100%;
}
.buttons {
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.form-scroll,
.scroll,
pre {
  max-height: none;
  overflow: visible;
}
pre {
  padding: 8px;
  margin: 6px 0;
  font-size: 11px;
  line-height: 1.35;
}
.hint {
  font-size: 11px;
}
footer {
  position: static;
  flex: none;
  padding: 8px 0 0;
}
#page[data-screen='1'] > .grid {
  grid-template-columns: 0.8fr 1fr 1.5fr;
}
#page[data-screen='2'] .fields {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
#page[data-screen='0'] {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#page[data-screen='0'] > .card {
  flex: 1;
  min-height: 0;
}
#page[data-screen='0'] .full {
  padding: 8px 12px;
}
.measurements {
  margin: 0;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}
.measurement {
  padding: 6px 10px;
  border-left: 3px solid var(--signal, #0891b2);
  background: linear-gradient(120deg, #ffffff, #f0f7ff);
  box-shadow: 0 3px 10px #203b6010;
}
#chart {
  border-radius: 10px;
  border: 1px solid #e2eaf4;
}
.metric {
  font-size: 22px;
}
canvas {
  height: clamp(90px, 19vh, 220px);
  margin-top: 6px;
}
th,
td {
  padding: 4px 6px;
  font-size: 11px;
}
details {
  margin: 8px 0;
}
dialog {
  padding: 18px;
  max-height: calc(100dvh - 20px);
}
@media (max-width: 850px) {
  body {
    font-size: 11px;
  }
  header {
    min-height: 0;
    height: 52px;
    flex-basis: 52px;
    padding: 4px 10px;
  }
  header img {
    width: 112px;
    max-height: 44px;
  }
  .header-state {
    font-size: 10px;
  }
  .header-state strong {
    font-size: 11px;
  }
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }
  nav {
    position: relative;
    padding: 4px 8px;
  }
  #navigation.open {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 10;
    background: white;
    padding: 8px;
    border-bottom: 1px solid var(--border);
  }
  main {
    padding: 6px 8px;
  }
  h1 {
    font-size: 18px;
  }
  h2 {
    font-size: 13px;
  }
  h3 {
    font-size: 12px;
  }
  .eyebrow {
    display: none;
  }
  .grid,
  .fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 8px;
  }
  .grid {
    gap: 8px;
  }
  .card {
    padding: 8px;
  }
  label,
  .hint,
  #stream-state {
    font-size: 10px;
  }
  input,
  select,
  button,
  textarea {
    min-height: 28px;
    padding: 4px;
    font-size: 11px;
  }
  label.check {
    min-height: 24px;
  }
  #page[data-screen='1'] > .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .point-card {
    grid-column: 1 / -1;
  }
  .point-card .fields,
  #page[data-screen='2'] .fields {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .point-card .inline {
    flex-wrap: nowrap;
  }
  .point-card .inline select {
    width: 200px;
  }
  .inline {
    gap: 4px;
  }
  .inline select {
    min-width: 70px;
  }
  #page[data-screen='4'] > .grid,
  #page[data-screen='7'] > .grid {
    grid-template-columns: 1fr;
  }
  #page[data-screen='7'] table {
    font-size: 10px;
  }
  th,
  td {
    padding: 2px 4px;
    font-size: 10px;
  }
  .metric {
    font-size: 18px;
  }
  .measurements {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }
  .measurement {
    padding: 4px;
    overflow-wrap: anywhere;
  }
  .metric small {
    font-size: 10px;
  }
  footer {
    flex-wrap: nowrap;
    gap: 6px;
    padding-top: 6px;
  }
  footer span {
    width: auto;
    font-size: 10px;
  }
  pre {
    font-size: 9px;
    padding: 4px;
  }
  #notice {
    font-size: 10px;
    padding: 4px 6px;
    margin-bottom: 4px;
  }
}
#page[data-screen='0'] > .card {
  display: flex;
  flex-direction: column;
}
#page[data-screen='0'] canvas {
  flex: 1;
  min-height: 0;
  height: 0;
}
@media (max-width: 850px) {
  #page[data-screen='4'] .fields {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  #page[data-screen='4'] input,
  #page[data-screen='4'] select,
  #page[data-screen='4'] button {
    min-height: 24px;
    padding: 2px 4px;
  }
  #page[data-screen='4'] .card {
    padding: 6px;
  }
  #cloud-state {
    font-size: 10px;
  }
  #page[data-screen='4'] p {
    font-size: 10px;
    margin: 4px 0;
  }
  #page[data-screen='7'] p {
    font-size: 10px;
    margin: 4px 0;
  }
}
@media (max-width: 850px) {
  .measurement .hint {
    display: none;
  }
  .measurement p {
    margin: 2px 0;
  }
  .measurement > small {
    display: block;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }
}
#confirm-diff {
  overflow: visible;
  max-height: none;
  font-size: 11px;
}
#page[data-screen='4'] details .fields {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.inline h2,
.inline h3 {
  margin-bottom: 0;
}
@media (max-width: 850px) {
  #page[data-screen='4'] .card {
    padding-top: 6px;
    padding-bottom: 6px;
  }
  #page[data-screen='4'] input:not([type='checkbox']),
  #page[data-screen='4'] select {
    min-height: 26px;
    height: 26px;
    padding-top: 2px;
    padding-bottom: 2px;
  }
  #page[data-screen='4'] details p {
    margin-bottom: 0;
  }
}
@media (max-width: 850px) {
  #page[data-screen='4'] details .fields {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
