:root {
  color-scheme: light dark;
  --background: 48 30% 96%;
  --foreground: 30 8% 10%;
  --card: 45 25% 93%;
  --secondary: 45 22% 90%;
  --muted-foreground: 40 6% 39%;
  --accent: 217 84% 46%;
  --destructive: 4 70% 47%;
  --border: 45 18% 85%;
  --success: 142 58% 32%;
  --warn: 32 92% 42%;
  --font-jb: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --font-space: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --background: 30 8% 8%;
    --foreground: 45 25% 90%;
    --card: 30 7% 11%;
    --secondary: 30 6% 15%;
    --muted-foreground: 40 8% 55%;
    --accent: 213 90% 64%;
    --destructive: 4 75% 60%;
    --border: 34 7% 20%;
    --success: 142 50% 52%;
    --warn: 38 92% 58%;
  }
}

*, *::before, *::after { box-sizing: border-box; border-radius: 0 !important; }
html, body { margin: 0; }
body {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: var(--font-jb);
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration-color: hsl(var(--border)); text-underline-offset: 3px; }
a:hover { text-decoration-color: hsl(var(--accent)); color: hsl(var(--accent)); }
:focus-visible { outline: 1px solid hsl(var(--accent)); outline-offset: 2px; }
.muted { color: hsl(var(--muted-foreground)); }
.small { font-size: 12.5px; }
kbd {
  font-family: var(--font-jb);
  font-size: 11px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--secondary));
  padding: 0 4px;
  margin-left: 2px;
  color: hsl(var(--muted-foreground));
}

.top, main, .foot { max-width: 980px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }
.top { display: flex; justify-content: space-between; align-items: center; padding-top: 18px; padding-bottom: 18px; border-bottom: 1px solid hsl(var(--border)); font-size: 13.5px; }
.brand { text-decoration: none; font-weight: 600; }
.mark { color: hsl(var(--accent)); font-weight: 400; }

.hero { padding: 48px 0 24px; }
.page-title {
  font-size: clamp(2rem, 4.6vw, 3.25rem);
  line-height: 1.04;
  letter-spacing: -0.045em;
  font-weight: 600;
  margin: 0 0 12px;
}
.cursor-blink::after { content: "▋"; color: hsl(var(--accent)); animation: sx-blink 1s step-end infinite; margin-left: 4px; font-weight: 400; }
@keyframes sx-blink { 50% { opacity: 0; } }
.lede { margin: 0; color: hsl(var(--muted-foreground)); max-width: 56ch; }

.banner {
  display: flex; align-items: center; gap: 16px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  padding: 18px 20px;
  transition: border-color .3s, background-color .3s;
}
.banner-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.banner-text strong { font-family: var(--font-space); font-size: clamp(1.15rem, 2vw, 1.4rem); font-weight: 700; letter-spacing: -0.01em; }
.banner-text span { font-size: 13.5px; }
.banner[data-state="ok"] { --state: var(--success); }
.banner[data-state="degraded"] { --state: var(--warn); }
.banner[data-state="down"], .banner[data-state="error"] { --state: var(--destructive); }
.banner[data-state="loading"] { --state: var(--accent); }
.banner { border-left: 3px solid hsl(var(--state, var(--border))); }

.dot-wrap { position: relative; display: inline-flex; width: 10px; height: 10px; flex: none; }
.dot { width: 10px; height: 10px; background: hsl(var(--state, var(--muted-foreground))); position: relative; }
.banner .dot::before {
  content: ""; position: absolute; inset: 0; background: hsl(var(--state)); opacity: .55;
  animation: live-pulse 1.6s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}
@keyframes live-pulse { 0% { transform: scale(1); opacity: .55; } 70%, 100% { transform: scale(2.4); opacity: 0; } }

.btn, .chip, .link {
  font-family: var(--font-jb); font-size: 13px; color: hsl(var(--foreground));
  background: hsl(var(--background)); border: 1px solid hsl(var(--border));
  padding: 6px 10px; cursor: pointer; transition: border-color .2s, color .2s;
}
.btn:hover, .chip:hover { border-color: hsl(var(--accent)); color: hsl(var(--accent)); }
.btn[disabled] { opacity: .6; cursor: progress; }
.chip { font-size: 12.5px; padding: 3px 8px; }
.chip[aria-pressed="true"] { border-color: hsl(var(--foreground)); }
.chip[aria-pressed="true"]::before { content: "▸ "; color: hsl(var(--accent)); }
.link { border: 0; padding: 0; background: none; text-decoration: underline; text-decoration-color: hsl(var(--border)); text-underline-offset: 3px; font-size: inherit; color: inherit; }
.link:hover { color: hsl(var(--accent)); }

.block { margin-top: 40px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-heading { font-family: var(--font-space); font-size: clamp(1.35rem, 2.2vw, 1.7rem); letter-spacing: -0.01em; font-weight: 700; margin: 0; }
.section-heading::before { content: "■ "; color: hsl(var(--accent)); font-weight: 400; }
.filters { display: flex; gap: 6px; }

.table { border: 1px solid hsl(var(--border)); }
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px 64px 72px 44px;
  gap: 16px; align-items: center;
  padding: 12px 16px;
  border-top: 1px solid hsl(var(--border));
  transition: background-color .2s;
}
#rows .row:first-child, #launching-rows .row:first-child { border-top: 1px solid hsl(var(--border)); }
#launching-rows .row:first-child { border-top: 0; }
.row.head { border-top: 0; font-size: 11px; color: hsl(var(--muted-foreground)); padding-top: 8px; padding-bottom: 8px; background: hsl(var(--card)); }
.row:not(.head):hover, .row.sel { background: hsl(var(--card)); }
.row.sel { outline: 1px solid hsl(var(--accent)); outline-offset: -1px; }
.p-main { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.p-main .dot-wrap { margin-top: 7px; }
.p-text { min-width: 0; }
.p-name { font-weight: 600; text-decoration: none; }
.p-name::after { content: " ↗"; color: hsl(var(--muted-foreground)); font-weight: 400; font-size: 12px; }
.p-action { display: block; font-size: 12.5px; color: hsl(var(--muted-foreground)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-host { font-size: 11px; color: hsl(var(--muted-foreground)); }
.row[data-s="ok"] { --state: var(--success); }
.row[data-s="slow"] { --state: var(--warn); }
.row[data-s="down"] { --state: var(--destructive); }
.row[data-s="pending"] { --state: var(--muted-foreground); }
.c-up, .c-ms, .c-code { font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.c-ms.slow { color: hsl(var(--warn)); }
.c-code.bad { color: hsl(var(--destructive)); }

.spark { display: flex; gap: 2px; height: 22px; align-items: flex-end; justify-content: flex-end; }
.spark i { display: block; width: 2px; flex: none; background: hsl(var(--success)); }
.spark i.down { background: hsl(var(--destructive)); height: 100% !important; }
.spark i.empty { background: hsl(var(--border)); height: 3px !important; }
.spark i.slow { background: hsl(var(--warn)); }

.empty { padding: 16px 0; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid hsl(var(--border)); }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-left: 1px solid hsl(var(--border)); }
.stat:first-child { border-left: 0; }
.stat strong { font-weight: 600; font-variant-numeric: tabular-nums; }

.foot { margin-top: 56px; padding-top: 18px; padding-bottom: 40px; border-top: 1px solid hsl(var(--border)); }
.foot p { margin: 4px 0; }
.keys kbd { margin-right: 2px; }

@media (max-width: 720px) {
  .row { grid-template-columns: minmax(0, 1fr) 64px 56px; gap: 10px; padding: 12px; }
  .row .c-hist { grid-column: 1 / -1; order: 5; }
  .row.head .c-hist, .row .c-code { display: none; }
  .spark { justify-content: flex-start; }
  .banner { flex-wrap: wrap; padding: 16px; }
  .banner-text { flex: 1 1 calc(100% - 26px); }
  .banner-actions { flex-basis: 100%; }
  .btn kbd, .chip kbd { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid hsl(var(--border)); }
  .keys { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }
#alerts[aria-pressed="true"] { border-color: hsl(var(--foreground)); }
#alerts[aria-pressed="true"]::before { content: "▸ "; color: hsl(var(--accent)); }

.incidents { list-style: none; margin: 0; padding: 0; border: 1px solid hsl(var(--border)); }
.incidents li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 16px; border-top: 1px solid hsl(var(--border)); font-size: 13.5px; }
.incidents li:first-child { border-top: 0; }
.incidents li .dot { width: 8px; height: 8px; }
.incidents li[data-s="ongoing"] { --state: var(--destructive); }
.incidents li[data-s="resolved"] { --state: var(--success); }
.incidents li.none { display: block; color: hsl(var(--muted-foreground)); }
.incidents .when { font-size: 12.5px; color: hsl(var(--muted-foreground)); font-variant-numeric: tabular-nums; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  margin: 0; padding: 8px 14px; font-size: 12.5px;
  background: hsl(var(--foreground)); color: hsl(var(--background));
  border: 1px solid hsl(var(--foreground));
}
