:root {
  color-scheme: dark;
  --bg: #0a0f17;
  --panel: #111926;
  --panel-2: #0d1420;
  --panel-3: #162235;
  --line: #223149;
  --line-soft: #1a2638;
  --text: #e8effb;
  --muted: #8fa2bd;
  --accent: #2bd4a5;
  --accent-strong: #1fae86;
  --warn: #f4b64a;
  --bad: #f06b6b;
  --blue: #6fa9ff;
  --radius: 8px;
  --radius-card: 12px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

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

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

button, input, textarea { font: inherit; }

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { min-height: 20px; margin: 10px 0 0; color: var(--bad); font-size: 13px; }

/* 登录 */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: min(400px, 100%);
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: inline-block;
  margin-bottom: 18px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .16em;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 24px;
  line-height: 1.3;
}

.login-card > .muted { margin: 0 0 24px; font-size: 13px; }

.field {
  display: block;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.field > input,
.field > textarea,
.field > select {
  display: block;
  width: 100%;
  margin-top: 7px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
}

.field > input:focus,
.field > textarea:focus,
.field > select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(43, 212, 165, .12);
}

.field textarea { resize: vertical; min-height: 84px; }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 14px;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .12s ease, background .12s ease, color .12s ease;
}

.btn:hover { border-color: #35506f; background: rgba(255, 255, 255, .03); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; margin-top: 18px; }
.btn.primary { color: #042019; background: var(--accent); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { color: var(--muted); }
.btn.danger { color: #2a0a0a; background: var(--bad); border-color: var(--bad); font-weight: 600; }
.btn.danger:hover { background: #d95c5c; border-color: #d95c5c; }

/* 顶栏 */
.admin-view { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
  padding: 0 24px;
  background: rgba(10, 15, 23, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(43, 212, 165, .12); }
.brand strong { font-size: 15px; letter-spacing: .04em; }
.brand-sub { color: var(--muted); font-size: 13px; }
.top-actions { display: flex; align-items: center; gap: 8px; }

/* 页面 */
.page {
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 24px;
}

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

.stat {
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}

.stat span { display: block; color: var(--muted); font-size: 12px; }
.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 26px;
  line-height: 1.2;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.panel {
  margin-top: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}

.tabs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
}

.tab:hover { color: var(--text); background: rgba(255, 255, 255, .03); }
.tab.active { color: var(--text); background: var(--panel-3); border-color: var(--line); }
.tab em {
  min-width: 18px;
  padding: 0 5px;
  color: var(--muted);
  background: rgba(255, 255, 255, .06);
  border-radius: 999px;
  font-style: normal;
  font-size: 11px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.search {
  width: 280px;
  height: 34px;
  padding: 0 12px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
}

.search:focus { border-color: var(--accent); }
.search::placeholder { color: #64748b; }

.table-wrap { width: 100%; overflow-x: auto; }

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

thead th {
  padding: 11px 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line-soft);
}

tbody td {
  padding: 13px 16px;
  vertical-align: top;
  border-bottom: 1px solid var(--line-soft);
}

tbody tr:hover { background: rgba(255, 255, 255, .015); }
tbody tr:last-child td { border-bottom: none; }

.time { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.nick { font-weight: 600; }
.contact { display: grid; gap: 2px; font-size: 13px; }
.contact span { color: var(--muted); font-size: 12px; }
.device {
  max-width: 220px;
  overflow: hidden;
  color: var(--muted);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}
.pill.warn { color: var(--warn); background: rgba(244, 182, 74, .12); }
.pill.ok { color: var(--accent); background: rgba(43, 212, 165, .12); }
.pill.bad { color: var(--bad); background: rgba(240, 107, 107, .12); }
.pill.muted { color: var(--muted); background: rgba(143, 162, 189, .12); }

.trial { white-space: nowrap; font-variant-numeric: tabular-nums; }
.trial strong { font-size: 15px; }
.trial span { color: var(--muted); font-size: 12px; }

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

.link-btn {
  padding: 0;
  color: var(--blue);
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--bad); }
.link-btn.ok { color: var(--accent); }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--line-soft);
}
.pager-btns { display: flex; gap: 8px; }

.empty { padding: 48px 16px; color: var(--muted); text-align: center; }

/* 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, .62);
}

.modal-card {
  width: min(560px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.modal-head h2 { margin: 0; font-size: 17px; }

.icon-btn {
  width: 30px;
  height: 30px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.icon-btn:hover { color: var(--text); border-color: #35506f; }

.modal-body { padding: 18px 20px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--line-soft);
}

.detail-grid {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 9px 12px;
  font-size: 13px;
}
.detail-grid dt { color: var(--muted); margin: 0; }
.detail-grid dd { margin: 0; overflow-wrap: anywhere; }
.detail-code { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12px; color: var(--muted); }

.radio-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 7px; }
.radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
}
.radio input { accent-color: var(--accent); }

.modal-note { margin: 10px 0 0; color: var(--muted); font-size: 13px; }

.modal-foot-inline {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  color: var(--text);
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity .15s ease, transform .15s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: rgba(240, 107, 107, .5); }

@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { align-items: stretch; }
  .tools { width: 100%; }
  .search { flex: 1; width: auto; min-width: 0; }
}

@media (max-width: 640px) {
  .topbar { height: auto; padding: 12px 16px; flex-wrap: wrap; }
  .page { padding: 16px; }
  .brand-sub { display: none; }
  .stat strong { font-size: 22px; }
  .modal { padding: 12px; }
  .detail-grid { grid-template-columns: 80px minmax(0, 1fr); }
}
