/* ====================== ✅ 全局主题变量（适配暗色科技风格） ====================== */
:root {
  --bg: #0a0a1a;
  --bg-card: rgba(0, 0, 0, 0.5);
  --bg-glass: rgba(0, 0, 0, 0.72);
  --fg: #ffffff;
  --fg-dim: rgba(255, 255, 255, 0.7);
  --fg-muted: rgba(255, 255, 255, 0.5);
  --ac: #00f7ff;
  --ac-hover: #00d4e6;
  --ac-light: rgba(0, 247, 255, 0.1);
  --tl: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bd: rgba(0, 247, 255, 0.2);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 24px rgba(0, 247, 255, 0.1);
  --shadow-lg: 0 12px 48px rgba(0, 247, 255, 0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a1a;
    --bg-card: rgba(0, 0, 0, 0.5);
    --bg-glass: rgba(0, 0, 0, 0.72);
    --fg: #ffffff;
    --fg-dim: rgba(255, 255, 255, 0.7);
    --fg-muted: rgba(255, 255, 255, 0.5);
    --ac: #00f7ff;
    --ac-hover: #00d4e6;
    --ac-light: rgba(0, 247, 255, 0.1);
    --bd: rgba(0, 247, 255, 0.2);
    --shadow-md: 0 4px 24px rgba(0, 247, 255, 0.1);
    --shadow-lg: 0 12px 48px rgba(0, 247, 255, 0.15);
  }
}

/* ====================== ✅ Reset ====================== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ====================== ✅ 顶部导航 ====================== */
.topnav {
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: linear-gradient(180deg, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.7) 100%);
  border-bottom: 1px solid var(--bd);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.topnav .brand {
  color: var(--fg);
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.topnav .brand span {
  background: linear-gradient(135deg, var(--ac), #0080ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.nav-links {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  margin-left: 1rem;
}
.nav-links a {
  color: var(--fg-dim);
  text-decoration: none;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
}
.nav-links a:hover {
  color: var(--ac);
  background: var(--ac-light);
}
.nav-links a.active {
  color: var(--ac);
  background: var(--ac-light);
}
.nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 2px;
  background: var(--ac);
  border-radius: 2px;
}
.logout {
  margin-left: auto;
  color: var(--fg-dim);
  text-decoration: none;
  padding: 0.45rem 1rem;
  border: 1px solid var(--bd);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  transition: var(--transition);
  background: transparent;
}
.logout:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.05);
}

/* ====================== ✅ 容器 ====================== */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem;
  flex: 1;
}

/* ====================== ✅ 页面标题 ====================== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--ac), #0080ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.page-header p {
  color: var(--fg-dim);
  font-size: 0.9rem;
}

/* ====================== ✅ 卡片 ====================== */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 1.5rem;
  transition: var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-lg);
  border-color: rgba(0, 247, 255, 0.3);
}
.card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ac);
}

/* ====================== ✅ 网格布局 ====================== */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.5rem; margin-bottom: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.5rem; margin-bottom: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }

/* ====================== ✅ 统计卡片 ====================== */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--ac), #0080ff);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(0, 247, 255, 0.3);
}
.stat-card .label {
  font-size: 0.85rem;
  color: var(--fg-dim);
  font-weight: 500;
  margin-bottom: 0.5rem;
}
.stat-card .value {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--ac), #0080ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 10px rgba(0, 247, 255, 0.3);
}

/* ====================== ✅ 表单 ====================== */
.form-group { margin-bottom: 1.2rem; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg-dim);
  margin-bottom: 0.4rem;
}
.form-control {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 1px solid var(--bd);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  background: rgba(0, 0, 0, 0.3);
  color: var(--fg);
  transition: var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--ac);
  box-shadow: 0 0 0 3px var(--ac-light);
}
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

/* ====================== ✅ 按钮 ====================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.3rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--ac), #0080ff);
  color: #000;
  box-shadow: 0 2px 8px rgba(0, 247, 255, 0.3);
}
.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(0, 247, 255, 0.4);
  transform: translateY(-1px);
}
.btn-success {
  background: var(--tl);
  color: #000;
}
.btn-success:hover {
  background: #059669;
  transform: translateY(-1px);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: #dc2626;
  transform: translateY(-1px);
}
.btn-warning {
  background: var(--warning);
  color: #000;
}
.btn-warning:hover {
  background: #d97706;
  transform: translateY(-1px);
}
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ====================== ✅ 表格 ====================== */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
  border: 1px solid var(--bd);
  background: var(--bg-card);
}
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th {
  background: rgba(0, 247, 255, 0.1);
  padding: 0.85rem 1rem;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ac);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--bd);
}
td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.9rem;
  color: var(--fg);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(0, 247, 255, 0.05); }

/* ====================== ✅ Badge ====================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-success { background: rgba(16, 185, 129, 0.2); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-danger { background: rgba(239, 68, 68, 0.2); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-primary { background: var(--ac-light); color: var(--ac); border: 1px solid rgba(0, 247, 255, 0.3); }
.badge-warning { background: rgba(245, 158, 11, 0.2); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.3); }

/* ====================== ✅ Alert ====================== */
.alert {
  padding: 1rem 1.2rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.alert-success { background: rgba(16, 185, 129, 0.1); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.2); }
.alert-error { background: rgba(239, 68, 68, 0.1); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.2); }

/* ====================== ✅ 登录页 ====================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(135deg, #0a0a1a 0%, #000 100%);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 2.5rem;
  box-shadow: 0 20px 60px rgba(0, 247, 255, 0.1);
  border: 1px solid rgba(0, 247, 255, 0.2);
}
.login-card h1 {
  text-align: center;
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
  background: linear-gradient(135deg, var(--ac), #0080ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-card .subtitle {
  text-align: center;
  color: var(--fg-dim);
  margin-bottom: 2rem;
  font-size: 0.9rem;
}

/* ====================== ✅ Footer ====================== */
.page-footer {
  text-align: center;
  padding: 1.5rem;
  border-top: 1px solid var(--bd);
  font-size: 0.8rem;
  color: var(--fg-muted);
  margin-top: auto;
  background: rgba(0, 0, 0, 0.3);
}
.page-footer a { color: var(--fg-dim); text-decoration: none; }
.page-footer a:hover { color: var(--ac); }

/* ====================== ✅ 响应式 ====================== */
@media (max-width: 768px) {
  .topnav { padding: 0.6rem 1rem; }
  .nav-links { margin-left: 0; width: 100%; order: 3; }
  .logout { margin-left: 0; }
  .container { padding: 1rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stat-card .value { font-size: 1.5rem; }
  .card { padding: 1.2rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 480px) {
  .login-card { padding: 1.5rem; }
}

/* ====================== ✅ 数字孪生 · 服务器机柜 ====================== */
.server-room {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.server-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  overflow: hidden;
}
.server-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: var(--shadow-lg);
}
.server-status {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.status-online {
  background: var(--tl);
  box-shadow: 0 0 8px var(--tl);
  animation: breath 2s infinite;
}
.status-offline {
  background: var(--danger);
  box-shadow: 0 0 6px var(--danger);
}
@keyframes breath {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.server-body {
  margin-top: 0.8rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.server-ip {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 0.3rem;
}
.server-pool {
  font-size: 0.75rem;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.server-version {
  font-size: 0.7rem;
  color: var(--fg-muted);
  margin-top: 0.4rem;
}
.server-index {
  position: absolute;
  bottom: 10px;
  right: 12px;
  font-size: 0.65rem;
  color: var(--fg-muted);
}
.server-body::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--ac), transparent);
  opacity: 0.3;
}
.server-card:hover .server-body::before {
  opacity: 0.6;
}

/* ====================== ✅ v2 勾选框（管理员风格 - 紫色渐变） ====================== */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-top: 0.3rem;
  justify-content: flex-end;
  margin-bottom: 1rem;
}
.toggle-label {
  font-size: 0.9rem;
  color: #555;
  font-weight: 500;
  transition: color 0.3s;
}
.toggle-label.active {
  color: #667eea;
  font-weight: 600;
}
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #ddd;
  border-radius: 34px;
  transition: 0.35s cubic-bezier(0.4, 0.0, 0.2, 1);
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
}
.toggle-slider:before {
  content: "";
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.35s cubic-bezier(0.4, 0.0, 0.2, 1);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
}
.toggle-switch input:checked + .toggle-slider {
  background: linear-gradient(135deg, #667eea, #764ba2);
  box-shadow: 0 0 12px rgba(102, 126, 234, 0.45);
}
.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(24px);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
}
.toggle-slider:after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 34px;
  opacity: 0;
  background: rgba(255, 255, 255, 0.3);
  transition: opacity 0.3s;
}
.toggle-switch input:active + .toggle-slider:after {
  opacity: 1;
}

/* ====================== ✅ v2 状态徽章（列表用） ====================== */
.v2-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: var(--transition);
}
.v2-enabled {
  background: rgba(16, 185, 129, 0.15);
  color: var(--tl);
  border: 1px solid rgba(16, 185, 129, 0.35);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.25);
}
.v2-disabled {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.15);
}

/* ====================== ✅ 管理员导航 ====================== */
.nav-links a.admin-nav {
  background: rgba(16, 185, 129, 0.1);
  border-radius: 6px;
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.2);
}
.nav-links a.admin-nav:hover {
  background: rgba(16, 185, 129, 0.2);
  color: #00ff88;
  border-color: rgba(16, 185, 129, 0.3);
}
.nav-links a.admin-nav.active {
  background: rgba(16, 185, 129, 0.25);
  color: #00ff88;
  border-color: rgba(16, 185, 129, 0.4);
}

/* ====================== ✅ 移动端优化 ====================== */
@media (max-width: 480px) {
  .toggle-wrap {
    gap: 0.6rem;
    justify-content: flex-start;
  }
  .toggle-switch {
    width: 48px;
    height: 26px;
  }
  .toggle-slider:before {
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
  }
  .toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
  }
  .toggle-label {
    font-size: 0.85rem;
  }
  .nav-links {
    gap: 0.2rem;
  }
  .nav-links a {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
  }
  .v2-status-badge {
    padding: 3px 10px;
    font-size: 0.7rem;
  }
}