:root {
  --bg: #0a0e14;
  --bg-2: #0e141c;
  --panel: #121821;
  --line: #1e2836;
  --line-2: #2a3648;
  --text: #e7eef7;
  --muted: #8a97ab;
  --accent: #5eead4;
  --blue: #38bdf8;
  --warn: #fbbf24;
  --danger: #fb7185;
  --ok: #4ade80;
  --font: "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  --mono: "Cascadia Code", "SF Mono", ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  overflow: hidden;
}

code, .mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.error-text { color: var(--danger); min-height: 1.1em; margin: 0; }
.kicker {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, rgba(94, 234, 212, 0.28), rgba(56, 189, 248, 0.12));
  border: 1px solid rgba(94, 234, 212, 0.4);
  color: var(--accent);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.02em;
}
.brand-text h1 {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.brand-text p { margin: 0; font-size: 10px; color: var(--muted); }

.lookup {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.search {
  flex: 1;
  min-width: 0;
  height: 34px;
  border-radius: 8px;
  padding: 0 11px;
  border: 1px solid var(--line-2);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.12);
}
.interval select {
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  padding: 0 8px;
}

.nav { display: flex; align-items: center; gap: 6px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  border: 1px solid rgba(94, 234, 212, 0.4);
  background: var(--accent);
  color: #042f2e;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: 0.5; cursor: wait; }
.btn.ghost {
  background: transparent;
  border-color: var(--line-2);
  color: var(--text);
}
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn.tiny {
  height: 22px;
  padding: 0 8px;
  font-size: 11px;
  margin-left: auto;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge.idle { color: var(--muted); background: rgba(138, 151, 171, 0.12); }
.badge.live { color: var(--blue); background: rgba(56, 189, 248, 0.12); }
.badge.live::before { animation: pulse 1s ease-in-out infinite; }
.badge.ok { color: var(--ok); background: rgba(74, 222, 128, 0.12); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.banner {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-bottom: 1px solid rgba(251, 113, 133, 0.35);
  background: rgba(251, 113, 133, 0.1);
  color: #fecdd3;
}

.empty {
  flex: 1;
  display: grid;
  align-content: center;
  justify-items: start;
  padding: 48px 10vw;
  background:
    radial-gradient(ellipse 50% 40% at 12% 20%, rgba(94, 234, 212, 0.08), transparent 60%),
    var(--bg);
}
.empty h2 { margin: 6px 0 8px; font-size: 22px; letter-spacing: -0.03em; }
.empty p { margin: 0; max-width: 52ch; color: var(--muted); }
.empty .hint { margin-top: 14px; font-size: 12px; }
kbd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  color: var(--text);
}

.results {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex: 0 0 auto;
}
.stat-card {
  padding: 8px 10px;
  border-right: 1px solid var(--line);
  min-width: 0;
}
.stat-card:last-child { border-right: 0; }
.stat-card .label {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 650;
}
.stat-card .value {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-card .value.ok { color: var(--ok); }
.stat-card .value.warn { color: var(--warn); }
.stat-card .value.danger { color: var(--danger); }

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.85fr);
}

.col {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.col-main { border-right: 1px solid var(--line); }
.col-side { background: var(--bg-2); }

.panel {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--line);
}
.panel.grow {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
}
.panel-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  min-height: 22px;
}
.panel-head h2 {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.panel-head p { margin: 0; font-size: 11px; }
.panel-head #inflight { margin-left: auto; }

.table-wrap {
  overflow: auto;
  min-height: 0;
}
.panel.grow .table-wrap { flex: 1; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
table.data th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  color: var(--muted);
  font-weight: 650;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 8px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.col-main table.data th { background: var(--bg); }
table.data td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
table.data tbody tr:hover td { background: rgba(94, 234, 212, 0.04); }
table.data tr.ok td:nth-child(2) { color: var(--ok); font-weight: 700; }
table.data tr.fail td:nth-child(2) { color: var(--danger); font-weight: 700; }
table.data tr.noping td:nth-child(2) { color: var(--warn); font-weight: 700; }
table.data tr.testing td:nth-child(2) { color: var(--blue); font-weight: 700; }
table.data td.fail { color: var(--danger); }

.st {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.st::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.ns-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.ns-row:last-child { border-bottom: 0; }

.kv {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 3px 10px;
  font-size: 12px;
  margin: 0;
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.kv dd.ok { color: var(--ok); font-weight: 650; }
.kv dd.danger { color: var(--danger); font-weight: 650; }

.records { display: grid; gap: 2px; }
.record-card {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid var(--line);
  align-items: start;
}
.record-card:last-child { border-bottom: 0; }
.record-card h3 {
  margin: 0;
  padding-top: 1px;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.record-card ul { margin: 0; padding: 0; list-style: none; }
.record-card li { word-break: break-word; white-space: normal; line-height: 1.35; }
.record-card .empty-rec { color: var(--muted); margin: 0; }

.http-block { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.http-block .kv + .kv { margin-top: 8px; }

details.raw {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}
details.raw pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  max-height: 180px;
  overflow: auto;
  color: var(--text);
  font-size: 11px;
  margin: 6px 0 0;
}

.gate {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 50% 40% at 50% 0%, rgba(94, 234, 212, 0.1), transparent 60%),
    var(--bg);
}
.gate-card {
  width: min(380px, 100%);
  padding: 22px 20px;
  display: grid;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 12px;
}
.gate-card h1 { margin: 0; font-size: 20px; }
.gate-card input {
  width: 100%;
  height: 34px;
  border-radius: 8px;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.gate-card .btn { width: 100%; }

@media (max-width: 1100px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100%; }
  .topbar {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .stats-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .workspace { grid-template-columns: 1fr; }
  .col-main { border-right: 0; }
  .panel.grow { flex: none; }
  .panel.grow .table-wrap { max-height: 52vh; }
}

@media (max-width: 640px) {
  .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lookup { flex-wrap: wrap; }
  .search { min-width: 100%; }
}
