/* ===================== 全局样式 ===================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: #333;
  line-height: 1.6;
}

a { color: #448bff; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===================== 头部 ===================== */
.header {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  color: #fff;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
}
.logo span { color: #448bff; }

.nav a {
  color: rgba(255,255,255,0.8);
  margin-left: 24px;
  font-size: 14px;
  transition: color 0.2s;
}
.nav a:hover, .nav a.active { color: #fff; text-decoration: none; }

/* ===================== 主体布局 ===================== */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.page-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 20px;
  color: #1a1a2e;
}

/* ===================== 统计概览 ===================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.stat-card .stat-label { font-size: 13px; color: #888; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: #1a1a2e; }
.stat-card .stat-value.good { color: #67c23a; }
.stat-card .stat-value.warn { color: #e6a23c; }
.stat-card .stat-value.bad { color: #f56c6c; }

/* ===================== 监控项卡片 ===================== */
.monitor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 20px;
}

.monitor-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: transform 0.2s, box-shadow 0.2s;
}
.monitor-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title .ip { font-family: 'Courier New', monospace; }

.display-name {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a2e;
}

.card-ip {
  font-size: 12px;
  color: #999;
  margin-top: 4px;
  font-family: 'Courier New', monospace;
}

.ping-type-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  white-space: nowrap;
}
.ping-type-badge.icmp {
  background: #e8f5e9;
  color: #2e7d32;
}
.ping-type-badge.tcp {
  background: #e3f2fd;
  color: #1565c0;
}

.card-remarks {
  font-size: 12px;
  color: #999;
  margin-top: 4px;
}

.status-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.status-badge.online { background: #e8f5e9; color: #2e7d32; }
.status-badge.offline { background: #fff3e0; color: #e65100; }
.status-badge.error { background: #ffebee; color: #c62828; }

/* ===================== 延迟指标 ===================== */
.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  text-align: center;
  padding: 12px 8px;
  background: #f8f9fb;
  border-radius: 8px;
}
.metric .operator { font-size: 11px; color: #888; margin-bottom: 4px; }
.metric .latency { font-size: 20px; font-weight: 700; }
.metric .latency small { font-size: 12px; font-weight: 400; }
.metric .loss { font-size: 11px; color: #666; margin-top: 2px; }

.latency-good { color: #67c23a; }
.latency-normal { color: #409eff; }
.latency-warn { color: #e6a23c; }
.latency-bad { color: #f56c6c; }

/* ===================== 图表区域 ===================== */
.chart-container {
  position: relative;
  height: 160px;
  margin-top: 12px;
}

.chart-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 160px;
  background: #f8f9fb;
  border-radius: 8px;
  color: #999;
  font-size: 13px;
}

/* ===================== 排名表格 ===================== */
.ranking-section {
  margin-top: 32px;
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: #1a1a2e;
}

.ranking-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 8px 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}
.tab-btn:hover { border-color: #448bff; color: #448bff; }
.tab-btn.active { background: #448bff; color: #fff; border-color: #448bff; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.data-table th {
  background: #f8f9fb;
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
  color: #666;
  font-weight: 500;
  border-bottom: 1px solid #eee;
}
.data-table td {
  padding: 10px 16px;
  font-size: 13px;
  border-bottom: 1px solid #f0f0f0;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background: #f8f9fb; }

/* ===================== 登录/管理页面 ===================== */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #1a1a2e 0%, #1e2030 40%, #13131f 100%);
  position: relative;
  overflow: hidden;
}
/* 动态光球1 */
.auth-wrapper::before {
  content: '';
  position: absolute;
  width: 70vw; height: 70vw; max-width: 800px; max-height: 800px;
  top: -20vw; left: -15vw;
  background: radial-gradient(circle, rgba(68,139,255,0.15) 0%, transparent 65%);
  filter: blur(80px);
  border-radius: 50%;
  z-index: 0;
  pointer-events: none;
  animation: blobDriftA 20s ease-in-out infinite alternate;
}
/* 动态光球2 */
.auth-wrapper::after {
  content: '';
  position: absolute;
  width: 60vw; height: 60vw; max-width: 700px; max-height: 700px;
  bottom: -20vw; right: -15vw;
  background: radial-gradient(circle, rgba(99,102,241,0.12) 0%, transparent 65%);
  filter: blur(80px);
  border-radius: 50%;
  z-index: 0;
  pointer-events: none;
  animation: blobDriftB 25s ease-in-out infinite alternate;
}
/* 网格纹理 */
.auth-box::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  border-radius: 16px;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
  z-index: 0;
}
/* 光球动画 */
@keyframes blobDriftA {
  0% { transform: translate(0,0) scale(1); }
  50% { transform: translate(15vw, 8vh) scale(1.15); }
  100% { transform: translate(28vw, 15vh) scale(1.25); }
}
@keyframes blobDriftB {
  0% { transform: translate(0,0) scale(1); }
  50% { transform: translate(-12vw,-8vh) scale(1.12); }
  100% { transform: translate(-24vw,-18vh) scale(1.2); }
}

.auth-box {
  background: rgba(255,255,255,0.95);
  border-radius: 16px;
  padding: 40px;
  width: 400px;
  max-width: 90vw;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.08);
  position: relative;
  z-index: 1;
  backdrop-filter: blur(20px) saturate(180%);
}
.auth-box > * { position: relative; z-index: 1; }
.auth-box h2 {
  text-align: center;
  margin-bottom: 28px;
  font-size: 26px;
  font-weight: 700;
  background: linear-gradient(135deg, #448bff, #6366f1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 13px;
  color: #666;
  margin-bottom: 6px;
}
.form-group input, .form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: #448bff;
}

/* 登录错误提示 */
.login-error {
  display: none;
  background: #ffebee;
  color: #c62828;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid #ffcdd2;
}
.input-error {
  border-color: #f56c6c !important;
}
.auth-box.shake {
  animation: shake 0.5s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: #448bff;
  color: #fff;
  width: 100%;
}
.btn-primary:hover { background: #3370e0; }

.btn-danger {
  background: #f56c6c;
  color: #fff;
}
.btn-danger:hover { background: #e34848; }

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

/* ===================== 管理布局 ===================== */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: #1a1a2e;
  color: #fff;
  padding: 24px 0;
  flex-shrink: 0;
}

.sidebar .logo {
  padding: 0 24px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 16px;
}

.sidebar nav a {
  display: block;
  padding: 12px 24px;
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  transition: all 0.2s;
}
.sidebar nav a:hover, .sidebar nav a.active {
  background: rgba(255,255,255,0.08);
  color: #fff;
  text-decoration: none;
  border-left: 3px solid #448bff;
}

.admin-content {
  flex: 1;
  padding: 24px 32px;
  background: #f0f2f5;
}

.sidebar-footer {
  padding: 16px 24px;
  margin-top: auto;
  font-size: 12px;
  color: rgba(255,255,255,.5);
  border-top: 1px solid rgba(255,255,255,.1);
}

/* 首页区块 */
.home-section {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-top: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.home-section-title {
  font-size: 15px;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f0f0f0;
}

/* 设置页新布局 */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 20px;
}
.settings-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.settings-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f0f0f0;
}
.settings-card-icon {
  font-size: 28px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f7ff;
  border-radius: 10px;
}
.settings-card h3 {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a2e;
}
.btn-block { width: 100%; margin-top: 8px; }

/* 操作列按钮统一 */
.action-cell { white-space: nowrap; }
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 14px;
  border: none;
  border-radius: 6px;
  background: #f0f0f0;
  cursor: pointer;
  margin-right: 4px;
}
.btn-icon:hover { background: #e0e0e0; }
.btn-edit {
  padding: 4px 12px;
  font-size: 12px;
  border: none;
  border-radius: 6px;
  background: #e3f2fd;
  color: #1565c0;
  cursor: pointer;
  margin-right: 4px;
}
.btn-edit:hover { background: #bbdefb; }
.btn-delete {
  padding: 4px 12px;
  font-size: 12px;
  border: none;
  border-radius: 6px;
  background: #ffebee;
  color: #c62828;
  cursor: pointer;
}
.btn-delete:hover { background: #ffcdd2; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.toolbar-btns { display: flex; gap: 10px; }

.toolbar-btns .btn {
  font-size: 13px;
  padding: 8px 18px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  transition: opacity 0.2s;
}
.toolbar-btns .btn:hover { opacity: 0.85; }

.btn-primary { background: #448bff; color: #fff; }
.btn-secondary { background: #6c757d; color: #fff; }

/* ===================== 模态框 ===================== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.show { display: flex; }

.modal {
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  width: 480px;
  max-width: 90vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal h3 { margin-bottom: 20px; }

/* ===================== 空状态 ===================== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state p { font-size: 15px; }

/* ===================== 加载和提示 ===================== */
.loading {
  text-align: center;
  padding: 40px;
  color: #999;
}

.spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid #eee;
  border-top-color: #448bff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  z-index: 9999;
  animation: slideIn 0.3s ease;
}
.toast.success { background: #67c23a; }
.toast.error { background: #f56c6c; }
.toast.info { background: #409eff; }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.update-time {
  font-size: 12px;
  color: #999;
  text-align: center;
  margin-top: 24px;
}

/* ===================== 响应式 ===================== */
@media (max-width: 768px) {
  .monitor-grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .header-inner { padding: 0 16px; }
  .main { padding: 16px; }
  .admin-layout { flex-direction: column; }
  .sidebar { width: 100%; }
}
