:root {
  color-scheme: dark;
  --bg: #0a0c11;
  --bg-soft: #10141c;
  --card: #12161f;
  --card-hover: #161b26;
  --border: #1f2430;
  --border-strong: #2a3142;
  --text: #e8ecf4;
  --text-dim: #99a3b5;
  --text-faint: #6b7488;
  --accent: #6b8cff;
  --accent-soft: rgba(107, 140, 255, 0.12);
  --ok: #3fb950;
  --warn: #d29922;
  --danger: #e0554d;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

a { color: var(--accent); text-decoration: none; }

/* ------------------------------------------------------------ 布局 */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(10, 12, 17, 0.88);
  backdrop-filter: blur(12px);
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(140deg, var(--accent), #9a6bff);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.topbar-spacer { flex: 1; }

.who {
  font-size: 13px;
  color: var(--text-dim);
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

main {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* ------------------------------------------------------------ 认证 */

.auth-wrap {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px 20px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 30px 26px;
}

.auth-card h1 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.auth-sub {
  margin: 0 0 24px;
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.6;
}

/* ------------------------------------------------------------ 表单 */

label {
  display: block;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 7px;
  font-weight: 500;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field { margin-bottom: 16px; }

button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  border-radius: 9px;
  border: 1px solid transparent;
  padding: 11px 16px;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, opacity 120ms;
}

button:disabled { opacity: 0.55; cursor: default; }

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) { background: #7d9bff; }

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-dim);
  padding: 8px 13px;
  font-size: 13px;
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text);
}

.btn-danger { color: var(--danger); }
.btn-danger:hover:not(:disabled) { border-color: var(--danger); }

.switch-line {
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
}

.switch-line a { cursor: pointer; }

/* ------------------------------------------------------------ 提示 */

.notice {
  font-size: 13px;
  line-height: 1.55;
  border-radius: 9px;
  padding: 10px 13px;
  margin-bottom: 16px;
  display: none;
}

.notice.show { display: block; }

.notice.error {
  background: rgba(224, 85, 77, 0.1);
  border: 1px solid rgba(224, 85, 77, 0.3);
  color: #ffb3ae;
}

.notice.ok {
  background: rgba(63, 185, 80, 0.1);
  border: 1px solid rgba(63, 185, 80, 0.28);
  color: #8fe39a;
}

/* ------------------------------------------------------------ Agent 列表 */

.section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.section-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.section-head .count {
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--mono);
}

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

.agent {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
  transition: border-color 140ms, background 140ms;
}

.agent:hover { border-color: var(--border-strong); background: var(--card-hover); }

.agent-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  flex: none;
}

.status-dot.online {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(63, 185, 80, 0.15);
}

.status-dot.offline { background: #3a4152; }

.agent-name {
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-state {
  font-size: 12px;
  color: var(--text-faint);
  margin-left: auto;
  flex: none;
  font-family: var(--mono);
}

.agent-url {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 12px;
  display: block;
}

.agent-url:hover { color: var(--accent); }

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

.chip {
  font-size: 11.5px;
  font-family: var(--mono);
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  background: var(--bg-soft);
}

.chip.hot {
  border-color: rgba(210, 153, 34, 0.4);
  color: var(--warn);
  background: rgba(210, 153, 34, 0.08);
}

.chip.live {
  border-color: rgba(63, 185, 80, 0.35);
  color: var(--ok);
  background: rgba(63, 185, 80, 0.08);
}

.agent-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.agent-actions .btn-open {
  background: var(--accent-soft);
  border: 1px solid rgba(107, 140, 255, 0.32);
  color: #a9bdff;
  padding: 8px 15px;
  font-size: 13px;
  text-decoration: none;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.agent-actions .btn-open:hover { background: rgba(107, 140, 255, 0.2); }

.empty {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 40px 22px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.7;
}

.empty strong { color: var(--text); display: block; margin-bottom: 6px; font-size: 14.5px; }

/* ------------------------------------------------------------ 弹窗 */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-backdrop.show { display: flex; }

.modal {
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 26px 24px;
  width: 100%;
  max-width: 440px;
}

.modal h3 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.modal p {
  margin: 0 0 16px;
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.65;
}

.token-box {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 12px 13px;
  color: #b9c4d6;
  word-break: break-all;
  line-height: 1.6;
  margin-bottom: 14px;
  user-select: all;
}

.modal-actions { display: flex; gap: 9px; justify-content: flex-end; margin-top: 6px; }

.warn-line {
  font-size: 12.5px;
  color: var(--warn);
  background: rgba(210, 153, 34, 0.08);
  border: 1px solid rgba(210, 153, 34, 0.25);
  border-radius: 8px;
  padding: 9px 12px;
  line-height: 1.55;
  margin-bottom: 16px;
}

.foot {
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
  padding: 20px;
  border-top: 1px solid var(--border);
}

.hidden { display: none !important; }

@media (max-width: 480px) {
  main { padding: 20px 14px 50px; }
  .topbar { padding: 13px 14px; }
  .agent { padding: 13px 14px; }
}
