:root {
  font-family: system-ui, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #242722;
  background: #f7f7f4;
  --paper: #fff;
  --line: #d6d9d2;
  --muted: #565c53;
  --accent: #285842;
  --error: #913031;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  font-size: 1.65rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

h2 {
  font-size: 1.25rem;
  line-height: 1.3;
}

h3 {
  font-size: 1rem;
  line-height: 1.4;
}

a {
  color: var(--accent);
}

button, select, input, .button {
  font: inherit;
  min-height: 42px;
  max-width: 100%;
  padding: 7px 11px;
  color: inherit;
  background: var(--paper);
  border: 1px solid #8a9185;
  border-radius: 4px;
}

button, select, .button {
  cursor: pointer;
}

button:hover:not(:disabled), .button:hover {
  background: #eceee9;
}

button:disabled {
  cursor: default;
  opacity: .65;
}

button.primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

button.primary:hover:not(:disabled) {
  background: #204936;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  white-space: nowrap;
}

:focus-visible {
  outline: 3px solid #8a580e;
  outline-offset: 3px;
}

.sr-only, .skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  white-space: nowrap;
  overflow: hidden;
}

.skip-link:focus {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  background: var(--paper);
  padding: 8px;
}

.muted {
  color: var(--muted);
}

.login {
  width: min(400px, calc(100% - 32px));
  margin: clamp(40px, 14vh, 124px) auto 32px;
  padding: 26px;
  background: var(--paper);
  border: 1px solid var(--line);
}

.login h1 {
  margin-bottom: 22px;
}

.login label, .field label {
  display: block;
  font-weight: 600;
  font-size: .875rem;
  margin-bottom: 4px;
}

.login input {
  display: block;
  width: 100%;
  margin-bottom: 14px;
}

.login button {
  margin-top: 6px;
  width: 100%;
}

.form-error {
  color: var(--error);
  margin-bottom: 9px;
}

.loading {
  padding: 28px;
  text-align: center;
}

.page-header {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.header-content, .workspace {
  max-width: 940px;
  padding-inline: 22px;
  margin: 0 auto;
}

.header-content, .section-header, .account, .device-line, .filters {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.header-content, .section-header {
  justify-content: space-between;
}

.header-content {
  min-height: 66px;
  padding-block: 10px;
}

.site-title {
  font-weight: 700;
}

.account, .account button {
  font-size: .875rem;
}

.account span {
  max-width: 15ch;
  overflow-wrap: anywhere;
}

.workspace {
  padding-block: 28px 42px;
}

.workspace section + section, .workspace > section, .workspace section + details {
  margin-top: 26px;
}

.section-header {
  margin-bottom: 10px;
}

.device-line {
  gap: 5px 14px;
  font-size: .875rem;
  color: var(--muted);
  margin-top: 6px;
}

.good {
  color: var(--accent);
}

.warn {
  color: #764b13;
}

.bad, .error {
  color: var(--error);
}

.notice {
  border-left: 3px solid #8a7747;
  background: #f0ede2;
  padding: 8px 12px;
  margin: 0 0 14px;
}

.notice.error {
  border-color: var(--error);
  background: #f8eded;
}

.measurements {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin-top: 9px;
  background: var(--paper);
}

.measurements th, .measurements td {
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  overflow-wrap: anywhere;
}

.measurements thead th {
  color: var(--muted);
  background: #eeefe9;
  font-weight: 600;
  font-size: .875rem;
}

.measurements th:first-child {
  width: 43%;
}

.measurements th:nth-child(2) {
  width: 21%;
}

.measurements tbody th {
  font-weight: 550;
}

.measurement-value {
  font-size: 1.125rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.measurement-value small {
  font-size: .78em;
  font-weight: 400;
  margin-left: 4px;
}

.measurement-quality {
  font-size: .875rem;
}

.measurement-detail, .measurement-last, .event-meta, .event-state {
  color: var(--muted);
  font-size: .875rem;
}

.measurement-detail, .measurement-last {
  margin-top: 2px;
}

.measurement-detail:empty {
  display: none;
}

.expandable {
  margin-top: 12px;
  border-block: 1px solid var(--line);
  padding-block: 10px;
}

summary {
  cursor: pointer;
  font-weight: 600;
}

.chart-content, #diagnostics {
  margin: 12px 0 4px;
}

.chart-content label {
  margin-right: 8px;
}

.chart-wrap {
  position: relative;
  height: 200px;
  margin-top: 12px;
}

.chart-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--paper);
  color: var(--muted);
}

.diagnostic-row {
  display: grid;
  grid-template-columns: minmax(135px, 1fr) 2fr;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
}

.diagnostic-row dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.filters {
  align-items: flex-end;
  margin-bottom: 12px;
}

.filters select {
  width: 100%;
}

#events-list {
  border-top: 1px solid var(--line);
}

.event {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 18px;
  align-items: start;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.event.unread h3 {
  color: #87332d;
}

.event-meta, .event-state {
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.event-simulation {
  font-size: .875rem;
  font-weight: 400;
  color: var(--muted);
  margin-left: 8px;
}

.events-empty {
  padding: 12px 0;
  color: var(--muted);
}

#push-status {
  margin: 6px 0 10px;
}

.toast {
  position: fixed;
  bottom: 14px;
  right: 14px;
  max-width: min(400px, calc(100% - 28px));
  padding: 12px 16px;
  color: #fff;
  background: #244432;
  border: 1px solid #183120;
}

.toast.error {
  background: var(--error);
  border-color: #731d1d;
}

@media (max-width: 520px) {
  .header-content, .workspace {
    padding-inline: 14px;
  }

  .workspace {
    padding-top: 20px;
  }

  .measurements th, .measurements td {
    padding: 7px 6px;
    font-size: .875rem;
  }

  .measurements th:first-child {
    width: 37%;
  }

  .measurements th:nth-child(2) {
    width: 23%;
  }

  .measurement-value {
    font-size: .94rem;
  }

  .measurement-value small {
    display: block;
    font-size: .72em;
    margin-left: 0;
  }

  .filters .field {
    flex: 1 1 140px;
    min-width: 0;
  }

  .event {
    grid-template-columns: minmax(0, 1fr);
  }

  #device-picker, #device-select {
    width: 100%;
  }
}
