:root {
  --bg: #0b1120;
  --bg-grad: radial-gradient(1200px 600px at 15% -10%, #16324f 0%, transparent 60%),
             radial-gradient(900px 500px at 100% 0%, #1e2a4a 0%, transparent 55%);
  --surface: #121a2b;
  --surface-2: #172033;
  --border: #253049;
  --text: #e6ecf7;
  --text-dim: #93a1bd;
  --accent: #38bdf8;
  --accent-2: #22d3ee;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --shadow: 0 18px 50px -22px rgba(0, 0, 0, .9);
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg-grad), var(--bg);
  color: var(--text);
  font: 14px/1.6 "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.mono { font-family: ui-monospace, "JetBrains Mono", Consolas, monospace; font-size: 12.5px; }

/* ---------------- 登录 ---------------- */
.view { min-height: 100vh; }

#view-login {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 28px 24px;
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand h1 { font-size: 18px; margin: 0; letter-spacing: .5px; }
.brand.small h1 { font-size: 16px; }
.brand-sub { margin: 2px 0 0; color: var(--text-dim); font-size: 12px; }

.brand-mark {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
  color: #04121f;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 22px -10px rgba(56, 189, 248, .9);
}

/* ---------------- 表单元素 ---------------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 6px; color: var(--text-dim); font-size: 12.5px; }
.field > span em { font-style: normal; opacity: .75; }

input[type="text"], input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: #5b6a86; }
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, .16);
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  cursor: pointer;
  transition: transform .12s, background .15s, border-color .15s, opacity .15s;
}
.btn:hover { border-color: #35456a; background: #1d2a42; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04121f;
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.05); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; margin-top: 4px; padding: 11px; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-danger { border-color: #4a2330; color: var(--danger); }
.btn-danger:hover { background: #2a1720; border-color: #6b3040; }

.error { color: var(--danger); font-size: 12.5px; margin: 0 0 12px; }
.hint { color: var(--text-dim); font-size: 12.5px; margin: 14px 0 0; }

/* ---------------- 主界面 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--border);
  background: rgba(11, 17, 32, .72);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar .brand { margin: 0; }
.topbar-actions { display: flex; gap: 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  background: rgba(148, 163, 184, .12);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.chip.ok { color: var(--ok); background: rgba(52, 211, 153, .1); border-color: rgba(52, 211, 153, .3); }
.chip.bad { color: var(--danger); background: rgba(248, 113, 113, .1); border-color: rgba(248, 113, 113, .32); }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 18px;
  padding: 22px clamp(16px, 4vw, 40px) 48px;
  max-width: 1180px;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-head h2 { font-size: 14.5px; margin: 0; letter-spacing: .3px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 11px 10px;
  border-bottom: 1px solid rgba(37, 48, 73, .7);
  white-space: nowrap;
}
th {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(56, 189, 248, .04); }
td.username { font-family: ui-monospace, Consolas, monospace; }
.col-actions, td.actions { text-align: right; }
td.actions { display: flex; gap: 6px; justify-content: flex-end; }

.dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-dim);
}
.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim); }
.dot.active { color: var(--ok); }
.dot.active::before { background: var(--ok); box-shadow: 0 0 8px rgba(52, 211, 153, .8); }
.dot.locked { color: var(--warn); }
.dot.locked::before { background: var(--warn); }

.empty { color: var(--text-dim); text-align: center; padding: 26px 10px; font-size: 13px; }

.stack { display: flex; flex-direction: column; }
.divider { height: 1px; background: var(--border); margin: 18px 0 4px; }

.credential {
  margin-top: 14px;
  border: 1px dashed rgba(52, 211, 153, .45);
  background: rgba(52, 211, 153, .07);
  border-radius: 12px;
  padding: 13px 14px;
}
.credential-title { margin: 0 0 8px; color: var(--ok); font-size: 12.5px; }
.credential dl { display: grid; grid-template-columns: 56px 1fr; gap: 4px 8px; margin: 0 0 10px; }
.credential dt { color: var(--text-dim); font-size: 12.5px; }
.credential dd { margin: 0; word-break: break-all; }

/* ---------------- 弹窗 / 提示 ---------------- */
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(4, 8, 16, .66);
  backdrop-filter: blur(3px);
  padding: 20px;
  z-index: 20;
}
.modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.modal-card h2 { margin: 0 0 16px; font-size: 15px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 40;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: rgba(52, 211, 153, .5); }
.toast.err { border-color: rgba(248, 113, 113, .55); color: #fecaca; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
}
