:root {
  color-scheme: light;
  font: 14px/1.45 Roboto, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: #212121;
  background: #f4f4f4;
  --muted: #616161;
  --line: #e8e8e8;
  --primary: #ff8a00;
  --speed: #c45500;
  --rate: #00796b;
  font-variant-numeric: tabular-nums;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .38; cursor: default; }
button:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid #a04600;
  outline-offset: -2px;
}
h1, h2, p { margin: 0; }
.appbar {
  height: 56px;
  padding-inline: clamp(16px, 3vw, 44px);
  display: flex;
  align-items: center;
  gap: 16px;
  color: #211608;
  background: var(--primary);
  box-shadow: 0 2px 4px #0003;
  position: relative;
  z-index: 1;
}
.appbar h1 { font-size: 20px; font-weight: 500; letter-spacing: .01em; }
.mark { display: flex; align-items: end; gap: 3px; height: 23px; padding-block: 2px; }
.mark i { width: 5px; background: currentColor; border-radius: 1px; height: 42%; }
.mark i:nth-child(2) { height: 68%; }
.mark i:nth-child(3) { height: 100%; }
.link-state {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #fff7;
  border-radius: 16px;
  padding: 5px 11px;
  margin-inline-start: auto;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.link-state i { width: 8px; height: 8px; border-radius: 50%; background: #654e36; }
.link-state[data-state="live"] i { background: #147640; }
.link-state[data-state$="error"] i, .link-state[data-state="unauthorized"] i { background: #b71c1c; }

.dashboard {
  width: min(100%, 1640px);
  margin: auto;
  padding: 20px clamp(20px, 3vw, 44px);
  display: grid;
  gap: 16px;
  height: calc(100vh - 56px);
  height: calc(100dvh - 56px);
  grid-template-rows: auto minmax(144px, 1fr) minmax(232px, .88fr);
}
.card {
  background: white;
  border-radius: 4px;
  box-shadow: 0 1px 2px #0002, 0 2px 4px #0001;
  min-width: 0;
  min-height: 0;
}
.metrics, .lower { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; min-height: 0; }
.lower { grid-template-columns: minmax(0, 1.10fr) minmax(0, 1fr); }
.speed { --accent: var(--speed); --tint: #ffebd7; --track: #ed872e; }
.rate { --accent: var(--rate); --tint: #d9efea; --track: #36a99a; }
.metric { padding: 14px 20px 15px; border-top: 3px solid var(--track); }
.metric-top { display: flex; align-items: center; justify-content: space-between; font-size: 15px; font-weight: 500; }
.meta { font-size: 12px; font-weight: 400; color: var(--muted); }
.reading { display: flex; gap: 8px; align-items: baseline; margin-block: 2px 8px; color: var(--accent); }
.reading strong { font-size: clamp(42px, 4.4vw, 58px); font-weight: 400; line-height: 1.05; letter-spacing: -.035em; white-space: nowrap; }
.reading span { font-size: 15px; font-weight: 500; }
.range { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; color: var(--muted); font-size: 12px; }
.rail { height: 7px; background: var(--tint); border-radius: 6px; position: relative; margin-inline: 4px; }
.range-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--tint), var(--track)); width: 100%; }
.range[data-available="false"] .range-fill { opacity: .2; }
.rail i {
  position: absolute; left: var(--position, 50%); top: 50%; transform: translate(-50%, -50%);
  display: none; height: 13px; width: 13px; border: 3px solid white; background: var(--accent);
  border-radius: 50%; box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent), transparent 35%);
}
.range[data-marker="true"] .rail i { display: block; }

.graph-panel { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: minmax(0, 1fr); padding: 14px 0 10px; }
.graph { position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr); padding: 0 16px; min-width: 0; min-height: 0; }
.graph + .graph { border-left: 1px solid var(--line); }
.graph-label { display: flex; gap: 7px; align-items: center; font-weight: 500; padding: 0 4px 5px; }
.graph-label i { width: 13px; height: 2px; background: var(--accent); }
.graph-label span { color: var(--muted); font-size: 11px; font-weight: 400; }
canvas { display: block; width: 100%; height: 100%; min-height: 0; contain: size; }
.tooltip {
  position: absolute; top: 24px; right: 22px; z-index: 1;
  background: #292929; color: white; padding: 4px 8px; border-radius: 4px;
  font-size: 11px; pointer-events: none;
}

.history, .detail { display: flex; flex-direction: column; }
.toolbar {
  min-height: 46px; display: flex; gap: 8px; justify-content: space-between; align-items: center;
  padding: 0 12px 0 16px; border-bottom: 1px solid var(--line);
}
.toolbar h2, .dialog-head h2 { font-size: 16px; font-weight: 500; white-space: nowrap; }
.toolbar h2 span { font-size: 11px; color: var(--muted); margin-left: 4px; }
.actions { display: flex; gap: 2px; align-items: center; }
select { border: 0; background: transparent; min-height: 36px; font-size: 12px; padding-inline: 4px; }
.icon-button, .text-button {
  display: inline-grid; place-items: center; background: transparent; border: 0;
  border-radius: 4px; min-width: 36px; min-height: 36px;
}
.icon-button { font-size: 22px; line-height: 1; }
.text-button { padding-inline: 8px; color: #a04500; font-size: 12px; font-weight: 600; }
:is(.icon-button,.text-button):hover:enabled { background: #0000000c; }
.table-viewport, .detail-viewport { flex: 1; overflow: auto; min-height: 0; scrollbar-width: thin; }
table { width: 100%; border-spacing: 0; text-align: left; white-space: nowrap; font-size: 12px; }
th { position: sticky; top: 0; z-index: 1; background: #fafafa; color: #424242; font-weight: 500; }
th, td { padding: 6px 10px; border-bottom: 1px solid #efefef; }
th:first-child, td:first-child { padding-left: 16px; }
th span, td:last-child { color: var(--muted); }
td:nth-child(3) { color: var(--speed); }
td:nth-child(4) { color: var(--rate); }
td:first-child, th:first-child { width: 1%; }
tr:hover td { background: #fff8ef; }
td.empty { text-align: center; color: var(--muted); padding-block: 20px; }
dl { margin: 0; padding: 7px 16px 9px; display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; }
.field { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; min-width: 0; padding: 4px 0; border-bottom: 1px solid #f1f1f1; font-size: 12px; }
.field.wide { grid-column: 1 / -1; }
dt { flex-shrink: 0; color: var(--muted); }
dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
dialog { width: min(520px, calc(100% - 32px)); padding: 0; border: 0; border-radius: 4px; box-shadow: 0 12px 32px #0006; }
dialog::backdrop { background: #0006; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px 8px 18px; border-bottom: 1px solid var(--line); }
pre { font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; padding: 0 18px; line-height: 1.65; }
.sr-only { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }

@media (min-width: 1250px) {
  dl { grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 12px; padding-block: 5px; }
  .field { padding-block: 2px; line-height: 15px; }
  .field:nth-last-child(2) { grid-column: span 2; }
}
@media (min-width: 801px) and (max-height: 730px) {
  .dashboard { padding-block: 12px; gap: 12px; }
  .metric { padding-block: 10px; }
  .reading strong { font-size: 44px; }
}
@media (max-width: 800px) {
  .appbar { padding-inline: 16px; }
  .dashboard { height: auto; padding: 12px; gap: 12px; grid-template-rows: auto auto auto; }
  .metrics { gap: 12px; }
  .lower, .graph-panel { grid-template-columns: 1fr; gap: 12px; }
  .graph-panel { padding: 12px 0; grid-template-rows: auto auto; }
  .graph { height: 174px; padding-inline: 12px; }
  .graph + .graph { border-left: 0; border-top: 1px solid var(--line); padding-top: 9px; }
  .graph + .graph .tooltip { top: 32px; }
  .table-viewport { max-height: 310px; }
  .icon-button, .text-button, select { min-height: 44px; }
}
@media (max-width: 460px) {
  .metric { padding: 10px 9px 12px; }
  .metric-top { font-size: 14px; }
  .meta { font-size: 10px; }
  .reading { gap: 5px; margin-block: 5px 10px; }
  .reading strong { font-size: 39px; }
  .reading span { font-size: 12px; }
  .range { gap: 6px; font-size: 11px; }
  .field { font-size: 11px; }
  dl { padding-inline: 12px; column-gap: 12px; }
  th, td { padding-inline: 5px; }
  th:first-child, td:first-child { padding-left: 10px; }
}
@media (max-width: 340px) {
  .metrics { grid-template-columns: 1fr; }
}

.backup-open { margin-inline-start: -8px; }
.backup-open span {
  width: 17px; height: 13px; margin-top: 4px; border: 2px solid currentColor;
  border-radius: 2px; position: relative;
}
.backup-open span::before {
  content: ""; position: absolute; height: 5px; border: 2px solid currentColor;
  border-radius: 2px; inset: -6px -3px auto;
}
.backup-open span::after {
  content: ""; position: absolute; width: 6px; height: 2px; background: currentColor;
  inset: 3px 0 auto; margin-inline: auto;
}
#backup-dialog { width: min(440px, calc(100% - 32px)); }
#backup-form { display: flex; gap: 8px; padding: 12px 16px 4px; }
#backup-form[hidden] { display: none; }
#backup-key {
  flex: 1; min-width: 0; font: inherit; padding: 8px 10px; border: 1px solid #999;
  border-radius: 4px;
}
#backup-key:focus-visible { outline: 2px solid #a04600; outline-offset: -2px; }
#backup-message { padding-inline: 16px; color: var(--muted); }
#backup-message:not(:empty) { margin-block: 5px 12px; }
#backup-list { list-style: none; margin: 6px 16px 12px; padding: 0; max-height: 42vh; overflow: auto; }
#backup-list:empty { margin: 0; }
#backup-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-block: 5px; border-bottom: 1px solid var(--line); }
#backup-list small { display: block; color: var(--muted); }
@media (max-width: 380px) {
  .appbar { gap: 8px; }
  .appbar h1 { font-size: 17px; }
  .backup-open { margin-inline-start: -4px; }
}

.bluetooth-open {
  color: #2e1d0b;
  background: #fff7;
  white-space: nowrap;
  padding-inline: 10px;
}
.bluetooth-open:hover:enabled { background: #fffd; }
.bluetooth-open[data-connected="true"] { background: #fff9; color: #11634b; }
#bluetooth-dialog { width: min(410px, calc(100% - 32px)); }
#bluetooth-message:not(:empty) { padding: 12px 16px 0; color: var(--muted); }
.bluetooth-actions { padding: 8px 12px 12px; }
.bluetooth-actions button[hidden] { display: none; }
@media (max-width: 430px) {
  .appbar { gap: 7px; padding-inline: 10px; }
  .appbar h1 span { display: none; }
  .bluetooth-open { padding-inline: 8px; }
  .link-state { padding-inline: 6px; }
  .backup-open { margin-inline-start: 0; }
}
