:root {
  color-scheme: dark;
  --bg: #0a0b0f;
  --bg-elevated: #121319;
  --card: #15161d;
  --card-hover: #1a1c25;
  --border: #22242e;
  --text: #e7e8ec;
  --text-dim: #8b8d9a;
  --text-faint: #5b5d6b;
  --green: #2fd97f;
  --green-dim: rgba(47, 217, 127, 0.14);
  --yellow: #f5c042;
  --yellow-dim: rgba(245, 192, 66, 0.14);
  --red: #f0514f;
  --red-dim: rgba(240, 81, 79, 0.14);
  --gray: #30323c;
  --accent: #6e7dff;
  --radius: 14px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

.bg-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    radial-gradient(circle at 20% -10%, rgba(110, 125, 255, 0.12), transparent 40%),
    radial-gradient(circle at 90% 10%, rgba(47, 217, 127, 0.08), transparent 35%),
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: auto, auto, 48px 48px, 48px 48px;
  opacity: 0.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  max-width: 920px;
  margin: 0 auto;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #4a56c9);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.brand-name { color: var(--text); }
.brand-sub { color: var(--text-dim); font-weight: 500; margin-left: 4px; }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.last-updated { font-size: 13px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-dim);
  cursor: pointer;
  transition: transform 0.4s ease, color 0.2s ease, background 0.2s ease;
}
.icon-btn:hover { color: var(--text); background: var(--card-hover); }
.icon-btn.spin svg { animation: spin 0.6s ease; }
@keyframes spin { to { transform: rotate(360deg); } }

.wrap { max-width: 920px; margin: 0 auto; padding: 8px 32px 64px; }

.banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  margin-bottom: 24px;
}
.banner.operational { background: linear-gradient(135deg, var(--green-dim), var(--card) 60%); border-color: rgba(47, 217, 127, 0.25); }
.banner.degraded { background: linear-gradient(135deg, var(--yellow-dim), var(--card) 60%); border-color: rgba(245, 192, 66, 0.25); }
.banner.outage { background: linear-gradient(135deg, var(--red-dim), var(--card) 60%); border-color: rgba(240, 81, 79, 0.25); }

.banner-icon { width: 38px; height: 38px; border-radius: 50%; flex: none; position: relative; }
.banner-icon::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
}
.banner.operational .banner-icon::after { background: var(--green); box-shadow: 0 0 0 6px var(--green-dim); }
.banner.degraded .banner-icon::after { background: var(--yellow); box-shadow: 0 0 0 6px var(--yellow-dim); }
.banner.outage .banner-icon::after { background: var(--red); box-shadow: 0 0 0 6px var(--red-dim); }

.banner-text h1 { margin: 0 0 2px; font-size: 18px; font-weight: 650; }
.banner-text p { margin: 0; font-size: 13px; color: var(--text-dim); }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
#search {
  flex: 1;
  min-width: 180px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 13px;
  outline: none;
}
#search:focus { border-color: var(--accent); }
#search::placeholder { color: var(--text-faint); }

.toolbar-right { display: flex; align-items: center; gap: 18px; }

.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-dim); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }

.text-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.text-btn:hover { color: var(--accent); }

.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gray);
  flex: none;
}
.dot.operational { background: var(--green); box-shadow: 0 0 0 3px var(--green-dim); }
.dot.degraded { background: var(--yellow); box-shadow: 0 0 0 3px var(--yellow-dim); }
.dot.down { background: var(--red); box-shadow: 0 0 0 3px var(--red-dim); }
.dot.unknown { background: var(--gray); }

.service-list { display: flex; flex-direction: column; gap: 10px; }

.group {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: 14px;
  overflow: hidden;
}

.group-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  transition: background 0.15s ease;
}
.group-summary::-webkit-details-marker { display: none; }
.group-summary:hover { background: var(--card-hover); }

.chevron { color: var(--text-faint); transition: transform 0.2s ease; flex: none; }
.group[open] > .group-summary .chevron { transform: rotate(90deg); }

.group-name { flex: 1; }
.group-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.group-dot { width: 9px; height: 9px; }

.group-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 10px 10px;
}

.service {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 12px;
  padding: 14px 18px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.service:hover { background: var(--card-hover); border-color: #2a2c38; }

.service-main { display: flex; align-items: center; gap: 12px; }
.service-name { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.service-name .name { font-size: 14px; font-weight: 550; }
.service-name .host { font-size: 12px; color: var(--text-faint); }

.service-meta { display: flex; align-items: center; gap: 18px; font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.service-meta .uptime { min-width: 52px; text-align: right; }

.bars {
  display: grid;
  grid-template-columns: repeat(90, 1fr);
  gap: 2px;
  margin-top: 10px;
  height: 28px;
}
.bar {
  border-radius: 2px;
  background: var(--gray);
  height: 100%;
}
.bar.operational { background: var(--green); opacity: 0.85; }
.bar.degraded { background: var(--yellow); opacity: 0.9; }
.bar.outage { background: var(--red); opacity: 0.95; }
.bar.nodata { background: var(--gray); opacity: 0.35; }
.bar:hover { opacity: 1; }

.page-footer {
  margin-top: 28px;
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
}

@media (max-width: 640px) {
  .topbar, .wrap { padding-left: 16px; padding-right: 16px; }
  .service-meta .latency { display: none; }
}
