:root {
  --bg: #07090d;
  --surface: #0c1017;
  --surface-2: #11161f;
  --line: #1c2330;
  --line-strong: #2a3342;
  --text: #e8ecf3;
  --muted: #8891a5;
  --dim: #626b7d;
  --accent: #2b9df4;
  --accent-soft: rgba(43, 157, 244, 0.12);
  --ok: #35c07d;
  --warn: #e2a53c;
  --bad: #e2606b;
  --radius: 12px;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 18% -12%, rgba(43, 157, 244, 0.14), transparent 70%),
    radial-gradient(700px 360px at 88% -18%, rgba(53, 192, 125, 0.08), transparent 72%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

.shell {
  width: min(1180px, 100% - 40px);
  margin: 0 auto;
  padding: 32px 0 56px;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- header ---------- */

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; gap: 14px; align-items: center; }

.mark {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  flex: 0 0 auto;
  border-radius: 12px;
  border: 1px solid rgba(43, 157, 244, 0.35);
  background: linear-gradient(160deg, rgba(43, 157, 244, 0.22), rgba(43, 157, 244, 0.04));
  color: #7cc6ff;
}
.mark svg { width: 24px; height: 24px; }

.brand-text h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: 0.01em;
}
.brand-text p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}

.head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.head-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.dot-idle {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(53, 192, 125, 0.16);
}
.head-status.is-running .dot-idle {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(43, 157, 244, 0.18);
  animation: pulse 1.1s ease-in-out infinite;
}
.head-status.is-error .dot-idle {
  background: var(--bad);
  box-shadow: 0 0 0 3px rgba(226, 96, 107, 0.18);
}
@keyframes pulse {
  50% { opacity: 0.35; }
}

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  padding: 8px 15px;
  border-radius: 9px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:hover { border-color: #3a4557; background: #161d28; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn.small { padding: 5px 11px; font-size: 12.5px; }
.btn.ghost { background: transparent; }

select, input[type="search"], input[type="text"], input:not([type]) {
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 8px 11px;
  min-width: 0;
}
select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.period {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--dim);
  font-size: 12.5px;
  white-space: nowrap;
}

/* ---------- stats ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0 20px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent), var(--surface);
}
.stat-label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.stat-value {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}
.stat-value.ok { color: var(--ok); }
.stat-value.warn { color: var(--warn); }
.stat-value.bad { color: var(--bad); }
.stat-note { font-size: 11.5px; color: var(--dim); }

/* ---------- toolbar ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.chip b {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 12px;
  color: var(--dim);
  margin-left: 4px;
}
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip.is-active {
  color: #bfe3ff;
  border-color: rgba(43, 157, 244, 0.5);
  background: var(--accent-soft);
}
.chip.is-active b { color: #8ccbff; }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.toolbar-right { display: flex; gap: 8px; flex-wrap: wrap; }
.field { display: inline-flex; }
.field.grow { flex: 1 1 auto; }
.field.search input { width: min(260px, 46vw); }

/* ---------- progress / alert ---------- */

.progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.progress-track {
  flex: 1 1 auto;
  height: 3px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.progress-track i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #1c86dd, #6cc7ff);
  transition: width 0.25s ease;
}

.alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  padding: 10px 14px;
  border: 1px solid rgba(226, 96, 107, 0.4);
  background: rgba(226, 96, 107, 0.08);
  border-radius: 10px;
  color: #ffc9ce;
  font-size: 13px;
}

/* ---------- table ---------- */

.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  text-align: left;
  font-weight: 500;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 11px 14px;
  background: #0a0e14;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid rgba(28, 35, 48, 0.75); }
tbody tr:last-child { border-bottom: 0; }
tbody tr:hover { background: rgba(255, 255, 255, 0.014); }
tbody tr.is-pending { opacity: 0.62; }

tbody td {
  padding: 11px 14px;
  vertical-align: middle;
}

.cell-status { width: 84px; }
.cell-latency { width: 116px; }
.cell-auth { width: 84px; }
.cell-age { width: 104px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
}
.badge i {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--dim);
}
.badge.ok { color: #6fdfa9; }
.badge.ok i { background: var(--ok); box-shadow: 0 0 0 3px rgba(53, 192, 125, 0.14); }
.badge.limited { color: #efc279; }
.badge.limited i { background: var(--warn); box-shadow: 0 0 0 3px rgba(226, 165, 60, 0.14); }
.badge.down { color: #f09aa1; }
.badge.down i { background: var(--bad); box-shadow: 0 0 0 3px rgba(226, 96, 107, 0.14); }
.badge.idle { color: var(--dim); }

.host-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.host-line code {
  font-family: var(--mono);
  font-size: 13px;
  color: #d7e3f4;
  overflow-wrap: anywhere;
}
.meta {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--dim);
}

.icon-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--dim);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 11px;
  cursor: pointer;
  line-height: 1.4;
  flex: 0 0 auto;
}
.icon-btn:hover { color: #bfe3ff; border-color: var(--line-strong); background: var(--surface-2); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.lat-line { display: flex; align-items: center; gap: 9px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.lat-line .num { font-size: 12.5px; color: #cfdaea; min-width: 52px; }
.meter {
  display: block;
  width: 46px; height: 3px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.meter i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.meter.is-warn i { background: var(--warn); }
.meter.is-bad i { background: var(--bad); }

.pull { font-size: 12.5px; }
.pull.ok { color: #9fe8c4; }
.pull.warn { color: #efc279; }
.pull.bad { color: #f09aa1; }
.pull.idle { color: var(--dim); }
.pull code { font-family: var(--mono); font-size: 11.5px; }

.auth-tag {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  white-space: nowrap;
}

.ago { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

.empty {
  margin: 0;
  padding: 34px 18px;
  text-align: center;
  color: var(--dim);
  font-size: 13.5px;
}

/* ---------- add form ---------- */

.add {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 14px 0 26px;
}
.add .field.grow { flex: 1 1 320px; }
.add input { width: 100%; }
.hint {
  flex: 1 1 100%;
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--dim);
}
.hint code {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
}
.hint.is-error { color: #f09aa1; }

/* ---------- panels ---------- */

.panel {
  margin-bottom: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}
.panel h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.panel-sub { margin: 3px 0 0; font-size: 12.5px; color: var(--dim); }

.code {
  margin: 0 0 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #080b10;
  color: #cfe2f7;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre;
}

.method ol { margin: 0 0 10px; padding-left: 20px; color: #c3cbd9; font-size: 13.5px; }
.method li { margin-bottom: 5px; }
.method li::marker { color: var(--dim); font-family: var(--mono); font-size: 12px; }
.method strong { color: var(--text); font-weight: 600; }
.method code, .panel-sub code {
  font-family: var(--mono);
  font-size: 12px;
  color: #a8c8e8;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
}

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 12px;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 12px);
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: #141b25;
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.18s, transform 0.18s;
  pointer-events: none;
  z-index: 20;
}
.toast.is-open { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .head-actions { width: 100%; }
  .head-status { flex: 1 1 auto; }
}

@media (max-width: 760px) {
  .shell { width: min(1180px, 100% - 24px); padding: 20px 0 40px; }
  .brand-text h1 { font-size: 18px; }
  .brand-text p { font-size: 12.5px; }

  .table-wrap { background: transparent; border: 0; border-radius: 0; overflow: visible; }
  table, tbody { display: block; }
  thead { display: none; }

  tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px 12px;
    margin-bottom: 10px;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
  }
  tbody tr:last-child { margin-bottom: 0; }
  tbody tr:hover { background: var(--surface); }

  tbody td {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 0;
    width: auto;
  }
  tbody td::before {
    content: attr(data-label);
    font-size: 10.5px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--dim);
  }
  .cell-host { grid-column: 1 / -1; }
  .cell-host::before { display: none; }
  .host-line code { font-size: 13.5px; }
  .cell-status { flex-direction: row; align-items: center; gap: 8px; }
  .cell-status::before { content: none; }
  .cell-status .badge { font-size: 13px; }
  .lat-line .num { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
