/* ==========================================================================
   PulixAI Hub — 设计系统
   ========================================================================== */

:root {
  --bg: #f5f6fa;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f9fafc;
  --border: #e3e6ee;
  --border-strong: #cfd4e0;
  --text: #16181f;
  --text-2: #4a5162;
  --muted: #7b8296;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-soft: #eef0ff;
  --accent-text: #4338ca;
  --success: #0f9d58;
  --success-soft: #e6f6ed;
  --danger: #d92d20;
  --danger-soft: #fdecea;
  --warn: #b45309;
  --warn-soft: #fef3e2;
  --shadow-sm: 0 1px 2px rgba(16, 20, 34, .06), 0 1px 3px rgba(16, 20, 34, .04);
  --shadow-md: 0 4px 12px rgba(16, 20, 34, .07), 0 1px 3px rgba(16, 20, 34, .05);
  --shadow-lg: 0 18px 40px rgba(16, 20, 34, .12), 0 4px 12px rgba(16, 20, 34, .06);
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1014;
    --bg-elev: #161920;
    --surface: #171a21;
    --surface-2: #1c2028;
    --border: #262b36;
    --border-strong: #343b4a;
    --text: #e9ebf1;
    --text-2: #b6bdcc;
    --muted: #8b93a5;
    --accent: #7c7bf5;
    --accent-2: #a78bfa;
    --accent-soft: #1e1f3d;
    --accent-text: #b3b1ff;
    --success: #34d399;
    --success-soft: #10321f;
    --danger: #f87171;
    --danger-soft: #3a1614;
    --warn: #fbbf24;
    --warn-soft: #3a2a10;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, .45);
    --shadow-lg: 0 18px 44px rgba(0, 0, 0, .55);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.015em; line-height: 1.25; }

code, .mono { font-family: var(--mono); font-size: .875em; }

::selection { background: var(--accent-soft); }

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

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 62px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16.5px;
  letter-spacing: -.02em;
  color: var(--text);
}
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 17px;
  box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 35%, transparent);
  flex: none;
}

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

.topbar-spacer { flex: 1; }

.nav-links { display: flex; gap: 4px; align-items: center; }

.nav-link {
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 550;
  font-size: 14px;
  transition: background .14s, color .14s;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent-text); }

/* --------------------------- 用户下拉 --------------------------- */

.userbox { position: relative; }

.userbtn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 11px 5px 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  transition: border-color .14s, box-shadow .14s;
}
.userbtn:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 650;
  font-size: 13px;
  flex: none;
}
.avatar.lg { width: 46px; height: 46px; font-size: 19px; border-radius: 13px; }

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 224px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  z-index: 60;
}
.menu.open { display: block; animation: pop .14s ease-out; }

@keyframes pop {
  from { opacity: 0; transform: translateY(-5px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

.menu-head {
  padding: 10px 11px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.menu-head .name { font-weight: 620; font-size: 14px; }
.menu-head .meta { color: var(--muted); font-size: 12.5px; }

.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  text-align: left;
  transition: background .12s;
}
.menu-item:hover { background: var(--surface-2); text-decoration: none; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }

/* ----------------------------- 按钮 ----------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 560;
  cursor: pointer;
  transition: background .14s, border-color .14s, transform .06s, box-shadow .14s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 32%, transparent);
}
.btn-primary:hover { filter: brightness(1.07); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ----------------------------- 卡片 ----------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }

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

.field { margin-bottom: 16px; }

.label {
  display: block;
  font-size: 13px;
  font-weight: 580;
  color: var(--text-2);
  margin-bottom: 6px;
}

.input, .select, .textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  transition: border-color .14s, box-shadow .14s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--accent) 16%, transparent);
}
.input::placeholder { color: var(--muted); }
.textarea { resize: vertical; min-height: 74px; }
.select { cursor: pointer; }

.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }

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

.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.8px;
  margin-bottom: 16px;
  border: 1px solid transparent;
  line-height: 1.5;
}
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 26%, transparent); }
.alert-ok    { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 26%, transparent); }
.alert-warn  { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 26%, transparent); }
.alert-info  { background: var(--accent-soft); color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 22%, transparent); }
.alert[hidden] { display: none; }

/* --------------------------- 徽标 ------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2.5px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 620;
  letter-spacing: .01em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-admin { background: var(--accent-soft); color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 24%, transparent); }
.badge-user  { background: var(--surface-2); color: var(--text-2); border-color: var(--border); }
.badge-on    { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 24%, transparent); }
.badge-off   { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 24%, transparent); }
.badge-mute  { background: var(--surface-2); color: var(--muted); border-color: var(--border); }

/* --------------------------- 状态点 ----------------------------- */

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  background: var(--muted);
}
.dot.up   { background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 20%, transparent); }
.dot.down { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }
.dot.checking { background: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------------------------- 表格 ------------------------------ */

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

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

th {
  text-align: left;
  padding: 11px 15px;
  background: var(--surface-2);
  color: var(--text-2);
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: .02em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td { padding: 12px 15px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }

.td-actions { display: flex; gap: 6px; justify-content: flex-end; }

.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}
.empty .icon { font-size: 34px; opacity: .5; margin-bottom: 10px; }

/* ---------------------------- 标签页 ---------------------------- */

.tabs {
  display: flex;
  gap: 3px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
}

.tab {
  padding: 10px 16px;
  border: 0;
  background: none;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 560;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color .14s, border-color .14s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-text); border-bottom-color: var(--accent); }

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

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(12, 15, 24, .5);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.modal-mask.open { display: flex; animation: fade .16s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  animation: rise .18s cubic-bezier(.2, .8, .3, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 19px 22px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-head h3 { font-size: 16.5px; }

.modal-body { padding: 22px; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  position: sticky;
  bottom: 0;
}

.x-btn {
  border: 0;
  background: none;
  font-size: 21px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 3px 7px;
  border-radius: 7px;
}
.x-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------------------------- 骨架屏 ---------------------------- */

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------------------------- 工具类 ---------------------------- */

.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.hidden { display: none !important; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
