* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: #f5f7fa;
  color: #1e293b;
  min-height: 100vh;
  overflow: hidden;
}

/* ============ 登录页 ============ */
.login-container {
  max-width: 360px;
  margin: 100px auto;
  background: #fff;
  border-radius: 12px;
  padding: 40px 30px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  text-align: center;
}

.login-badge {
  display: inline-block;
  background: #0f172a;
  color: #38bdf8;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 20px;
  margin-bottom: 16px;
  letter-spacing: 0.05em;
}

.login-container h2 {
  margin-bottom: 30px;
  color: #1e293b;
  font-size: 22px;
}

/* ============ 顶部栏 ============ */
.topbar {
  height: 56px;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: #f8fafc;
}

.topbar-badge {
  font-size: 11px;
  background: #38bdf8;
  color: #0f172a;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 700;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: #94a3b8;
  border-radius: 1px;
  transition: all 0.3s;
}

/* ============ 布局 ============ */
.layout {
  display: flex;
  height: calc(100vh - 56px);
  margin-top: 56px;
}

/* ============ 侧边栏 ============ */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: #1e293b;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-menu {
  padding: 12px 0;
  flex: 1;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.menu-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke-width: 1.8;
}

.menu-item:hover {
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.05);
}

.menu-item.active {
  color: #fff;
  background: rgba(56, 189, 248, 0.1);
  border-left-color: #38bdf8;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 49;
}

.sidebar-overlay.visible {
  display: block;
}

/* ============ 主内容区 ============ */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  min-width: 0;
}

.content-section {
  display: none;
}

.content-section.active {
  display: block;
}

.section-header {
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: #1e293b;
}

.section-desc {
  font-size: 13px;
  color: #94a3b8;
  margin-top: 4px;
}

/* ============ 仪表板统计卡片 ============ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #f1f5f9;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.stat-card-label {
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 8px;
}

.stat-card-value {
  font-size: 32px;
  font-weight: 700;
  color: #1e293b;
}

.stat-card.accent-blue { border-left: 4px solid #3b82f6; }
.stat-card.accent-green { border-left: 4px solid #10b981; }
.stat-card.accent-amber { border-left: 4px solid #f59e0b; }
.stat-card.accent-cyan { border-left: 4px solid #06b6d4; }

/* ============ 卡片 ============ */
.card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid #f1f5f9;
}

.card-title {
  font-size: 14px;
  color: #64748b;
  font-weight: 500;
  margin-bottom: 16px;
}

/* ============ 站点列表 ============ */
.site-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.site-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: #fff;
  border-radius: 10px;
  border: 1px solid #f1f5f9;
  transition: all 0.15s;
  cursor: pointer;
}

.site-row:hover {
  border-color: #e2e8f0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.site-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.site-status-dot.online { background: #22c55e; }
.site-status-dot.offline { background: #ef4444; }
.site-status-dot.unknown { background: #94a3b8; }

.site-info {
  flex: 1;
  min-width: 0;
}

.site-name {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 2px;
}

.site-url {
  font-size: 12px;
  color: #94a3b8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-stats {
  display: flex;
  gap: 24px;
  flex-shrink: 0;
}

.site-stat {
  text-align: center;
}

.site-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: #1e293b;
}

.site-stat-label {
  font-size: 11px;
  color: #94a3b8;
}

.site-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ============ 数据表格 ============ */
.data-table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  background: #f8fafc;
  color: #64748b;
  font-weight: 600;
  border-bottom: 1px solid #e2e8f0;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #475569;
}

.data-table tr:hover td { background: #f8fafc; }
.nowrap { white-space: nowrap; }

/* ============ 表单 ============ */
.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  font-size: 14px;
  color: #64748b;
  margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="url"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
  outline: none;
  background: #fff;
  font-family: inherit;
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
}

.site-select {
  padding: 8px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  min-width: 200px;
  background: #fff;
}

.site-select:focus {
  border-color: #38bdf8;
}

.error {
  color: #ef4444;
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 18px;
}

/* ============ 按钮 ============ */
.btn {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; border-radius: 6px; }

.btn-primary { background: #0ea5e9; color: #fff; }
.btn-primary:hover { background: #0284c7; }

.btn-success { background: #10b981; color: #fff; }
.btn-success:hover { background: #059669; }

.btn-danger {
  background: transparent;
  color: #ef4444;
  border: 1px solid #fecaca;
}
.btn-danger:hover { background: #fef2f2; }

.btn-outline {
  background: transparent;
  color: #64748b;
  border: 1px solid #e2e8f0;
}
.btn-outline:hover { background: #f8fafc; }

.btn-ghost {
  background: transparent;
  color: #94a3b8;
  padding: 6px 10px;
}
.btn-ghost:hover { color: #f8fafc; }

.btn-block { width: 100%; display: block; text-align: center; justify-content: center; }

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

.modal.hidden { display: none; }

.modal-content {
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.modal-content h3 {
  font-size: 18px;
  margin-bottom: 24px;
  color: #1e293b;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ============ 面包屑 ============ */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 16px;
}

.breadcrumb a {
  color: #0ea5e9;
  text-decoration: none;
  cursor: pointer;
}

.breadcrumb a:hover { text-decoration: underline; }

/* ============ 标签页 ============ */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #f1f5f9;
  margin-bottom: 20px;
}

.tab-item {
  padding: 10px 20px;
  font-size: 14px;
  color: #94a3b8;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}

.tab-item:hover { color: #475569; }

.tab-item.active {
  color: #0ea5e9;
  border-bottom-color: #0ea5e9;
  font-weight: 600;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============ API密钥 ============ */
.apikey-value {
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 12px;
  background: #f1f5f9;
  padding: 4px 8px;
  border-radius: 4px;
  word-break: break-all;
  max-width: 300px;
  display: inline-block;
}

/* 状态标签 */
.status-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
}

.status-tag.active { background: #dcfce7; color: #16a34a; }
.status-tag.inactive { background: #fee2e2; color: #dc2626; }
.status-tag.super { background: #dbeafe; color: #2563eb; }
.status-tag.admin { background: #f1f5f9; color: #64748b; }

/* ============ Canvas 图表 ============ */
.chart-wrap {
  width: 100%;
  overflow: hidden;
}

.chart-wrap canvas {
  width: 100%;
  height: 240px;
  display: block;
}

/* ============ 空状态 ============ */
.empty-state {
  text-align: center;
  color: #cbd5e1;
  font-size: 14px;
  padding: 40px 0;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  stroke: #e2e8f0;
  margin-bottom: 12px;
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 10px 28px;
  border-radius: 20px;
  font-size: 14px;
  pointer-events: none;
  z-index: 9999;
  display: none;
}

.toast.show { display: block; }

/* ============ 实时动态 ============ */
.realtime-feed {
  max-height: 320px;
  overflow-y: auto;
}

.feed-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
}

.feed-item:last-child { border-bottom: none; }

.feed-site {
  background: #0ea5e9;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.feed-ip {
  font-family: monospace;
  color: #64748b;
  font-size: 12px;
}

.feed-region { color: #475569; }
.feed-device { color: #94a3b8; font-size: 12px; }
.feed-time { color: #94a3b8; font-size: 12px; margin-left: auto; white-space: nowrap; }

/* ============ 分组标签 ============ */
.group-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  margin-left: 6px;
  vertical-align: middle;
}

/* ============ 复选框 ============ */
.site-checkbox {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: #0ea5e9;
}

/* ============ 详情单元格 ============ */
.detail-cell {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============ 响应式 ============ */
@media (max-width: 1024px) {
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .site-stats {
    display: none;
  }
}

@media (max-width: 768px) {
  .menu-toggle {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 56px;
    left: -260px;
    bottom: 0;
    z-index: 50;
    width: 260px;
    transition: left 0.3s ease;
  }

  .sidebar.open {
    left: 0;
  }

  .main-content {
    padding: 16px;
  }

  .stats-row {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat-card { padding: 14px; }
  .stat-card-value { font-size: 24px; }

  .site-row {
    flex-wrap: wrap;
    gap: 10px;
  }

  .site-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .section-header h2 {
    font-size: 18px;
  }

  .tabs {
    overflow-x: auto;
  }
}

/* Switch 开关 */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #555;
  border-radius: 26px;
  transition: 0.3s;
}

.switch-slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.switch input:checked + .switch-slider {
  background-color: #07c160;
}

.switch input:checked + .switch-slider::before {
  transform: translateX(22px);
}
