:root {
  --bg: #060a13;
  --bg-soft: #0a1120;
  --panel: rgba(13, 21, 38, 0.86);
  --panel-solid: #0d1526;
  --panel-2: #111d33;
  --line: rgba(148, 163, 184, 0.14);
  --line-strong: rgba(148, 163, 184, 0.24);
  --text: #e8eefb;
  --muted: #8d9cb8;
  --faint: #64748b;
  --accent: #22d3ee;
  --accent-2: #818cf8;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --leas: #a78bfa;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --mono: "Cascadia Code", "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

[hidden] { display: none !important; }

code, pre, .mono { font-family: var(--mono); }

a { color: var(--accent); }

.bg-grid {
  position: fixed;
  inset: 0;
  z-index: -3;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.045) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 90% 65% at 50% 0%, #000 25%, transparent 78%);
}

.bg-glow {
  position: fixed;
  z-index: -2;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.5;
  pointer-events: none;
}

.glow-a {
  width: 560px;
  height: 560px;
  top: -260px;
  left: -120px;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.35), transparent 65%);
}

.glow-b {
  width: 620px;
  height: 620px;
  top: -300px;
  right: -180px;
  background: radial-gradient(circle, rgba(129, 140, 248, 0.32), transparent 65%);
}

/* ------------------------------------------------------------------ login */

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  padding: 34px 32px 28px;
  background: linear-gradient(180deg, rgba(17, 29, 51, 0.96), rgba(10, 17, 32, 0.96));
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  text-align: center;
}

.brand-mark {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04101c;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -1px;
  box-shadow: 0 10px 30px rgba(34, 211, 238, 0.25);
}

.brand-mark.small {
  width: 38px;
  height: 38px;
  margin: 0;
  font-size: 15px;
  border-radius: 11px;
  box-shadow: none;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 26px;
  letter-spacing: -0.5px;
}

.login-sub {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 13px;
}

.field-label {
  display: block;
  text-align: left;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.login-card input {
  width: 100%;
  height: 44px;
  margin-bottom: 14px;
  font-family: var(--mono);
}

.btn-block { width: 100%; height: 44px; }

.login-hint {
  margin: 18px 0 0;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.7;
}

.login-hint code {
  color: var(--muted);
  background: rgba(148, 163, 184, 0.1);
  padding: 1px 5px;
  border-radius: 5px;
}

.form-error {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.28);
  color: #fca5a5;
  font-size: 12px;
  text-align: left;
}

/* ------------------------------------------------------------------ shell */

.shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 28px 40px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  background: linear-gradient(180deg, rgba(6, 10, 19, 0.92) 70%, rgba(6, 10, 19, 0));
  backdrop-filter: blur(10px);
}

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

.brand-title { font-size: 17px; font-weight: 700; letter-spacing: -0.2px; }

.brand-sub { color: var(--muted); font-size: 12px; }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.health {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--good);
  font-size: 12px;
  padding: 6px 11px;
  border: 1px solid rgba(52, 211, 153, 0.22);
  background: rgba(52, 211, 153, 0.07);
  border-radius: 999px;
}

.health i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.12);
}

.layout { display: grid; gap: 18px; min-width: 0; }
.layout > * { min-width: 0; }

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

.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}

.stat {
  position: relative;
  padding: 15px 16px 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.stat::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 2px;
  background: var(--tone, var(--accent));
  opacity: 0.8;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-value {
  margin-top: 5px;
  font-size: 27px;
  font-weight: 750;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  color: var(--tone, var(--text));
}

.stat-sub { color: var(--faint); font-size: 11.5px; margin-top: 1px; }

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  min-width: 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 18px;
  min-width: 0;
}

.grid-2 > * { min-width: 0; }

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-head h2 { margin: 0 0 3px; font-size: 15.5px; letter-spacing: -0.2px; }

.panel-head p { margin: 0; color: var(--muted); font-size: 12.5px; }

.badge {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}

.badge.link { text-decoration: none; color: var(--accent); border-color: rgba(34, 211, 238, 0.25); }

.badge.link:hover { background: rgba(34, 211, 238, 0.08); }

/* ------------------------------------------------------------------ forms */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

input:not([type="checkbox"]),
select,
textarea {
  width: 100%;
  margin-top: 6px;
  background: #0a1322;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea { resize: vertical; min-height: 96px; font-family: var(--mono); line-height: 1.65; }

input:focus, select:focus, textarea:focus {
  border-color: rgba(34, 211, 238, 0.65);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.1);
}

input::placeholder, textarea::placeholder { color: #4c5b73; }

select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 18px, calc(100% - 11px) 18px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }

.field { margin-bottom: 12px; }

.provider-hint {
  margin: 2px 0 14px;
  min-height: 18px;
  color: var(--faint);
  font-size: 12px;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

.check input { accent-color: var(--accent); width: 15px; height: 15px; }

.result-box {
  margin-top: 14px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(52, 211, 153, 0.22);
  background: rgba(52, 211, 153, 0.06);
  color: #a7f3d0;
  font-size: 12.5px;
}

.result-box.warn {
  border-color: rgba(251, 191, 36, 0.25);
  background: rgba(251, 191, 36, 0.06);
  color: #fde68a;
}

/* ----------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, opacity 0.15s;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04101c;
  border: none;
  box-shadow: 0 8px 22px rgba(34, 211, 238, 0.16);
}

.btn-primary:hover { filter: brightness(1.06); }

.btn-ghost {
  border-color: var(--line-strong);
  background: rgba(148, 163, 184, 0.05);
  color: var(--muted);
}

.btn-ghost:hover { background: rgba(148, 163, 184, 0.11); color: var(--text); }

.btn-ghost.danger:hover {
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.1);
  color: #fca5a5;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:hover { background: rgba(148, 163, 184, 0.1); color: var(--text); }

/* --------------------------------------------------------------- endpoints */

.endpoint-list { display: grid; gap: 8px; }

.endpoint {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(7, 13, 24, 0.6);
}

.method {
  flex: none;
  padding: 2px 6px;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.method.get { color: #67e8f9; background: rgba(34, 211, 238, 0.1); }
.method.post { color: #c4b5fd; background: rgba(167, 139, 250, 0.12); }

.endpoint code {
  flex: 1;
  min-width: 0;
  color: #b9c7de;
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy {
  flex: none;
  border: none;
  background: transparent;
  color: var(--faint);
  font-size: 11px;
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 5px;
}

.copy:hover { color: var(--accent); background: rgba(34, 211, 238, 0.08); }

.code-sample {
  margin: 12px 0;
  padding: 12px 14px;
  background: #070d18;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: #9fb3d1;
  font-size: 11.5px;
  line-height: 1.6;
  overflow: auto;
  max-height: 190px;
  white-space: pre;
}

.api-meta { display: grid; gap: 6px; }

.api-meta > div {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--faint);
  font-size: 11.5px;
}

.api-meta code { color: var(--muted); font-size: 11px; }

.tag {
  flex: none;
  width: 34px;
  text-align: center;
  padding: 4px 0;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
}

.tag.ok { color: #6ee7b7; background: rgba(52, 211, 153, 0.1); }
.tag.miss { color: #fca5a5; background: rgba(248, 113, 113, 0.1); }
.tag.warn { color: #fcd34d; background: rgba(251, 191, 36, 0.1); }

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

.table-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.toolbar input { flex: 1 1 220px; margin-top: 0; height: 36px; max-width: 320px; }
.toolbar select { width: auto; min-width: 132px; margin-top: 0; height: 36px; padding-top: 0; padding-bottom: 0; }
.toolbar-spacer { flex: 1; }

.updated { color: var(--faint); font-size: 11.5px; }

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

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  min-width: 0;
  max-width: 100%;
}

table { width: 100%; border-collapse: collapse; min-width: 900px; }

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 12px;
  background: #0b1424;
  border-bottom: 1px solid var(--line-strong);
  color: var(--faint);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.3px;
  text-align: left;
  white-space: nowrap;
}

tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.07);
  font-size: 12.5px;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background: rgba(148, 163, 184, 0.035); }

td.id { color: var(--faint); font-family: var(--mono); font-size: 11.5px; }

.cell-provider { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cell-provider strong { font-size: 12.5px; font-weight: 600; }
.cell-provider small { color: var(--faint); font-family: var(--mono); font-size: 10.5px; max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.key-hint { color: #aebdd6; font-family: var(--mono); font-size: 11.5px; white-space: nowrap; }

.err-text {
  margin-top: 2px;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #f87171;
  font-size: 10.5px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
  cursor: default;
}

.status::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.status.active { color: #6ee7b7; background: rgba(52, 211, 153, 0.09); border-color: rgba(52, 211, 153, 0.22); }
.status.invalid { color: #fca5a5; background: rgba(248, 113, 113, 0.09); border-color: rgba(248, 113, 113, 0.2); }
.status.exhausted { color: #fdba74; background: rgba(251, 146, 60, 0.09); border-color: rgba(251, 146, 60, 0.2); }
.status.rate_limited { color: #fcd34d; background: rgba(251, 191, 36, 0.08); border-color: rgba(251, 191, 36, 0.2); }
.status.error { color: #fca5a5; background: rgba(248, 113, 113, 0.08); border-color: rgba(248, 113, 113, 0.18); }
.status.unknown { color: #94a3b8; background: rgba(148, 163, 184, 0.08); border-color: rgba(148, 163, 184, 0.18); }
.status.disabled { color: #7c8ba4; background: rgba(100, 116, 139, 0.1); border-color: rgba(100, 116, 139, 0.2); }
.status.leased { color: #c4b5fd; background: rgba(167, 139, 250, 0.1); border-color: rgba(167, 139, 250, 0.22); }

.status-stack { display: flex; flex-wrap: wrap; gap: 4px; }

.latency { color: var(--muted); font-family: var(--mono); font-size: 11.5px; }
.latency.good { color: #6ee7b7; }
.latency.slow { color: #fcd34d; }

.time { color: var(--muted); font-size: 11.5px; white-space: nowrap; }

td.actions-col, th.actions-col { text-align: right; }

.row-actions { display: flex; justify-content: flex-end; gap: 4px; flex-wrap: wrap; }

.row-actions button {
  height: 27px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.row-actions button:hover { background: rgba(148, 163, 184, 0.1); color: var(--text); }
.row-actions button.danger:hover { border-color: rgba(248, 113, 113, 0.4); color: #fca5a5; background: rgba(248, 113, 113, 0.08); }

.empty { padding: 46px 20px; text-align: center; color: var(--faint); }
.empty strong { display: block; color: var(--muted); font-size: 14px; margin-bottom: 4px; }
.empty p { margin: 0; font-size: 12.5px; }

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

/* ------------------------------------------------------------------ events */

.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 330px; overflow: auto; }

.events li {
  display: grid;
  grid-template-columns: 132px 112px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 7px 2px;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.1);
  font-size: 12px;
}

.events li:last-child { border-bottom: none; }

.events .ev-time { color: var(--faint); font-family: var(--mono); font-size: 10.5px; white-space: nowrap; }

.events .ev-kind {
  color: var(--muted);
  font-size: 10.5px;
  white-space: nowrap;
}

.events .ev-kind::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--accent-2);
}

.events .ev-message { color: #b6c4db; }

/* ------------------------------------------------------------------- modal */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 6, 14, 0.72);
  backdrop-filter: blur(4px);
}

.modal-card {
  width: min(520px, 100%);
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-sub { margin: 0 0 14px; color: var(--muted); font-size: 12px; }

.secret-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #070d18;
}

.secret-row code {
  flex: 1;
  min-width: 0;
  color: #a5f3fc;
  font-size: 12px;
  word-break: break-all;
}

.modal-note { margin: 12px 0 0; color: var(--faint); font-size: 11.5px; }

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 80;
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: 10px;
  background: #0f1b30;
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 12.5px;
  box-shadow: var(--shadow);
  animation: toast-in 0.18s ease-out;
}

.toast.ok { border-color: rgba(52, 211, 153, 0.35); }
.toast.err { border-color: rgba(248, 113, 113, 0.4); color: #fecaca; }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

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

/* ------------------------------------------------------------------ mobile */

@media (max-width: 1120px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .shell { padding: 0 14px 30px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { flex-wrap: wrap; }
  .topbar-right { width: 100%; justify-content: flex-end; }
  .health { margin-right: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .panel { padding: 16px; }
  .panel-head { flex-direction: column; gap: 10px; }
  .table-actions { justify-content: flex-start; }
  .events li { grid-template-columns: 1fr; gap: 1px; }
  .row-between { align-items: flex-end; }
  .secret-row { flex-direction: column; align-items: stretch; }
  .secret-row .btn { width: 100%; }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .brand-sub { display: none; }
}