:root {
  --bg: #0d1117;
  --text: #c9d1d9;
  --text-muted: #8b949e;
  --heading: #f0f6fc;
  --border: #21262d;
  --border-light: #30363d;

  --good: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --blue: #58a6ff;
  --purple: #bc8cff;
  --text-faint: #545b64;

  --mono: "SF Mono", ui-monospace, Consolas, monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  background-image: radial-gradient(circle, #272727 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--text);
  line-height: 1.6;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 80px 24px;
}

header {
  margin-bottom: 48px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 2px;
}

h1 {
  font-size: 2.2rem;
  line-height: 1.15;
  color: var(--heading);
}

.header-links {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.github-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 9px 16px;
  flex-shrink: 0;
}

.github-link:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.github-link svg {
  opacity: 0.9;
}

.about-link {
  background: none;
  border: none;
  margin: 0;
  padding: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-decoration: underline;
  text-decoration-color: var(--border-light);
  text-underline-offset: 3px;
  cursor: pointer;
  font-family: inherit;
}

.about-link:hover {
  color: var(--text);
  text-decoration-color: var(--text-muted);
}

dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  max-width: 460px;
  width: calc(100% - 48px);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 28px;
  font-family: inherit;
  line-height: 1.6;
}

dialog::backdrop {
  background: rgba(1, 4, 9, 0.7);
}

dialog h2 {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 14px;
}

dialog p {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 14px;
}

.dialog-close {
  background: none;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  color: var(--text);
  padding: 7px 16px;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  margin-top: 4px;
}

.dialog-close:hover {
  border-color: var(--text-muted);
}

h2 {
  font-size: 1.1rem;
  color: var(--heading);
  margin-bottom: 14px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

section {
  margin-bottom: 48px;
}

.status-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.device-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  line-height: 1.4;
  font-size: 0.8rem;
  color: var(--text-faint);
  flex-shrink: 0;
}

.vital {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.dot {
  position: relative;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.dot.good { background: var(--good); }
.dot.bad { background: var(--bad); }

.dot.good::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: var(--good);
  opacity: 0.3;
  animation: pulse 2.4s ease-out infinite;
}

@keyframes pulse {
  0% { transform: scale(0.6); opacity: 0.3; }
  70% { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1.5); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .dot.good::before {
    animation: none;
    opacity: 0.45;
  }
}

.vital-label {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--heading);
}

.vital-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 24px 23px;
}

.readouts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.readout {
  text-align: center;
  border-left: 1px solid var(--border);
}

.readout:first-child { border-left: none; }

.readout-value {
  font-family: var(--mono);
  font-size: 1.3rem;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
}

.readout-value .unit {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: 1px;
}

.readout-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.uptime-row {
  display: flex;
  gap: 3px;
  height: 34px;
  align-items: stretch;
}

.uptime-bar {
  flex: 1;
  border-radius: 2px;
  min-width: 2px;
  height: 100%;
  background: var(--border-light);
}

.uptime-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 12px;
}

.bar-tooltip {
  display: none;
  position: fixed;
  z-index: 50;
  background: var(--border);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: nowrap;
  pointer-events: none;
}

.bar-tooltip strong {
  display: block;
  color: var(--heading);
  font-weight: 600;
}

.bar-tooltip span {
  color: var(--text-muted);
}

.chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.chart-block {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 8px;
  padding: 18px;
}

.chart-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.empty, .error {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 16px 0;
}

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

@media (max-width: 480px) {
  main { padding: 40px 16px; }
  h1 { font-size: 1.8rem; }

  .status-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .device-info {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    text-align: left;
    margin-top: 2px;
    margin-bottom: 20px;
  }

  .device-info span:not(:last-child)::after {
    content: "\00b7";
    margin: 0 8px;
    color: var(--border-light);
  }

  .readouts {
    grid-template-columns: repeat(2, 1fr);
    row-gap: 20px;
  }

  .readout {
    border-left: none;
  }
}