* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: #f2f4f7;
  color: #24292f;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: #1b2a41;
  color: #fff;
}

header h1 { font-size: 17px; margin: 0; font-weight: 600; }

.conn {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  white-space: nowrap;
}
.conn-on  { background: #1f7a35; }
.conn-off { background: #b3261e; }

main {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 12px;
  padding: 12px;
  max-width: 1700px;
  margin: 0 auto;
}

.empty {
  grid-column: 1 / -1;
  text-align: center;
  color: #667;
  padding: 40px 16px;
}

.card {
  background: #fff;
  border: 1px solid #d8dee4;
  border-radius: 10px;
  padding: 10px 12px 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #b3261e;
  flex: 0 0 auto;
}
.dot.ok { background: #1f9d43; }

.card-title { font-weight: 600; font-size: 15px; flex: 1 1 auto; min-width: 0; }
.card-sub   { font-size: 11px; color: #667; }

.card-head select {
  font-size: 12px;
  padding: 2px 4px;
  border: 1px solid #c6ccd4;
  border-radius: 5px;
  background: #fff;
}

.card-head .fs {
  font-size: 14px;
  line-height: 1;
  padding: 3px 8px;
  border: 1px solid #c6ccd4;
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
}
.card-head .fs:hover { background: #eef1f5; }

#overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  z-index: 50;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 14px;
}
#overlay[hidden] { display: none; }
#overlay .card { width: 100%; max-width: 1500px; }
#overlay .card canvas { height: calc(100vh - 165px); }

canvas { width: 100%; height: 230px; display: block; touch-action: pan-y; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.legend .chip {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 2px;
  margin-right: 5px;
}

@media (max-width: 480px) {
  header h1 { font-size: 15px; }
  main { padding: 8px; gap: 8px; }
  canvas { height: 200px; }
  #overlay { padding: 6px; }
  #overlay .card canvas { height: calc(100vh - 210px); }
}
