/* ═══ 泓连 WebUI 样式 — 暗色仪表盘 ═══ */

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-card: #1c2333;
  --bg-card-hover: #242d3e;
  --bg-input: #0d1117;
  --border-color: #30363d;
  --border-hover: #8b949e;

  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;

  --status-ok: #3fb950;
  --status-ok-bg: rgba(63, 185, 80, 0.12);
  --status-warn: #d29922;
  --status-warn-bg: rgba(210, 153, 34, 0.12);
  --status-fail: #f85149;
  --status-fail-bg: rgba(248, 81, 73, 0.12);

  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --accent-bg: rgba(88, 166, 255, 0.1);

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.4);
  --transition: 0.2s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #484f58; }

.app-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

/* ─── Header ─── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}
.header-left { display: flex; align-items: center; gap: 14px; }
.header-logo {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; color: #fff;
}
.header-title { font-size: 22px; font-weight: 700; }
.header-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 1px; }
.header-right { display: flex; align-items: center; gap: 14px; }

/* ─── 整体状态横幅 ─── */
.status-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-radius: var(--radius);
  margin-bottom: 24px;
  border: 1px solid var(--border-color);
  transition: var(--transition);
}
.status-banner.ok { background: var(--status-ok-bg); border-color: rgba(63,185,80,0.3); }
.status-banner.fail { background: var(--status-fail-bg); border-color: rgba(248,81,73,0.3); }
.status-banner-icon {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.status-banner.ok .status-banner-icon { background: var(--status-ok); }
.status-banner.fail .status-banner-icon { background: var(--status-fail); }
.status-banner-text { flex: 1; }
.status-banner-title { font-size: 18px; font-weight: 600; }
.status-banner-sub { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.status-banner-time { font-size: 12px; color: var(--text-muted); }

/* ─── 卡片网格 ─── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: var(--transition);
}
.card:hover { border-color: var(--border-hover); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-badge {
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 500;
}
.card-badge.ok { background: var(--status-ok-bg); color: var(--status-ok); }
.card-badge.fail { background: var(--status-fail-bg); color: var(--status-fail); }
.card-badge.warn { background: var(--status-warn-bg); color: var(--status-warn); }
.card-body { font-size: 13px; color: var(--text-secondary); line-height: 1.7; }
.card-body .detail-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid rgba(48,54,61,0.4);
}
.card-body .detail-row:last-child { border-bottom: none; }
.card-body .detail-label { color: var(--text-muted); }
.card-body .detail-value { color: var(--text-primary); font-family: "SF Mono", monospace; font-size: 12px; }
.card-actions { margin-top: 14px; display: flex; gap: 8px; }

/* ─── 按钮 ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-card-hover); border-color: var(--border-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}
.btn-primary:hover { background: rgba(88,166,255,0.2); }
.btn-danger {
  background: var(--status-fail-bg);
  border-color: rgba(248,81,73,0.3);
  color: var(--status-fail);
}
.btn-danger:hover { background: rgba(248,81,73,0.2); }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn-icon { padding: 6px 10px; }

/* ─── 诊断面板 ─── */
.diag-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}
.diag-section-title { font-size: 16px; font-weight: 600; margin-bottom: 14px; }
.diag-input-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.diag-input {
  flex: 1;
  padding: 8px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}
.diag-input:focus { border-color: var(--accent); }
.diag-layers { display: flex; flex-direction: column; gap: 8px; }
.diag-layer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  transition: var(--transition);
}
.diag-layer.ok { border-color: rgba(63,185,80,0.3); background: var(--status-ok-bg); }
.diag-layer.fail { border-color: rgba(248,81,73,0.3); background: var(--status-fail-bg); }
.diag-layer-idx {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.diag-layer.ok .diag-layer-idx { background: var(--status-ok); color: #fff; }
.diag-layer.fail .diag-layer-idx { background: var(--status-fail); color: #fff; }
.diag-layer-name { font-weight: 600; font-size: 13px; width: 70px; flex-shrink: 0; }
.diag-layer-detail { font-size: 13px; color: var(--text-secondary); flex: 1; }
.diag-layer-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.diag-status-text {
  margin-top: 12px;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
}
.diag-status-text.ok { background: var(--status-ok-bg); color: var(--status-ok); }
.diag-status-text.fail { background: var(--status-fail-bg); color: var(--status-fail); }

/* ─── 日志区域 ─── */
.log-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
}
.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.log-header-left { display: flex; align-items: center; gap: 10px; }
.log-title { font-size: 16px; font-weight: 600; }
.log-container {
  background: #0a0e14;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  max-height: 260px;
  overflow-y: auto;
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 12px;
  line-height: 1.7;
}
.log-line { color: var(--text-secondary); }

/* ─── Toast ─── */
.toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
  max-width: 380px;
}
.toast.success { border-color: rgba(63,185,80,0.4); background: var(--status-ok-bg); }
.toast.error { border-color: rgba(248,81,73,0.4); background: var(--status-fail-bg); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ─── Loading ─── */
.loading-spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--text-muted);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── 状态点 ─── */
.status-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.ok { background: var(--status-ok); box-shadow: 0 0 6px rgba(63,185,80,0.5); }
.status-dot.fail { background: var(--status-fail); box-shadow: 0 0 6px rgba(248,81,73,0.5); }
.status-dot.warn { background: var(--status-warn); box-shadow: 0 0 6px rgba(210,153,34,0.5); }

/* ─── 响应式：平板 & 小屏 ─── */
@media (max-width: 1024px) {
  .cards-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

@media (max-width: 700px) {
  .app-container { padding: 14px; }
  .cards-grid { grid-template-columns: 1fr; }
  .header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .header-right { width: 100%; flex-wrap: wrap; justify-content: flex-start; gap: 8px; }
  .diag-input-row { flex-direction: column; }
  .status-banner { flex-direction: column; text-align: center; padding: 14px; }
  .card-actions { flex-direction: column; }
  .card-actions .btn { width: 100%; justify-content: center; }
  .diag-layer { flex-wrap: wrap; gap: 6px; }
  .diag-layer-name { width: auto; }
  .diag-layer-time { width: 100%; text-align: right; }
}


/* ─── Tab导航 ─── */
.tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 4px;
  border: 1px solid var(--border-color);
}
.tab-btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  font-family: inherit;
}
.tab-btn:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.tab-btn.active { background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow); }
.tab-content.hidden { display: none !important; }

.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-title { font-size: 16px; font-weight: 600; margin-bottom: 14px; }
.section-header .section-title { margin-bottom: 0; }
.loading-text { color: var(--text-muted); text-align: center; padding: 30px; font-size: 13px; }

/* ─── 设备卡片 ─── */
.servers-grid { display: flex; flex-direction: column; gap: 12px; }
.server-card {
  padding: 16px 18px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.server-card:hover { border-color: var(--border-hover); }
.server-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.server-name { font-weight: 600; font-size: 15px; }
.server-status {
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 500;
}
.server-status.ok { background: var(--status-ok-bg); color: var(--status-ok); }
.server-status.fail { background: var(--status-fail-bg); color: var(--status-fail); }
.server-detail {
  display: flex;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 3px 0;
  border-bottom: 1px solid rgba(48,54,61,0.3);
}
.server-detail:last-child { border-bottom: none; }
.server-detail .det-lbl { color: var(--text-muted); min-width: 50px; }

/* ─── 审计日志 ─── */
.audit-container {
  max-height: 400px;
  overflow-y: auto;
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 12px;
  line-height: 1.8;
  background: #0a0e14;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.audit-line {
  display: flex;
  gap: 10px;
  padding: 2px 0;
  align-items: baseline;
}
.audit-line.audit-ok { color: var(--text-secondary); }
.audit-line.audit-fail { color: var(--status-fail); }
.audit-time { color: var(--text-muted); min-width: 60px; flex-shrink: 0; }
.audit-action { min-width: 70px; flex-shrink: 0; }
.audit-component { color: var(--accent); min-width: 100px; flex-shrink: 0; }
.audit-detail { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── 图表样式 (P2) ─── */
.chart-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.chart-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: var(--text-secondary); }
.chart-wrapper {
  position: relative;
  height: 200px;
}
@media (max-width: 700px) {
  .chart-section { grid-template-columns: 1fr; }
  .chart-wrapper { height: 180px; }
}

/* ─── 快捷概览 ─── */
.quick-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.quick-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}
.quick-card:hover { border-color: var(--border-hover); }
.quick-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.quick-value { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.quick-value.ok { color: var(--status-ok); }
.quick-value.fail { color: var(--status-fail); }
.quick-value.dim { color: var(--text-muted); }
@media (max-width: 700px) {
  .quick-summary { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .app-container { padding: 10px; }
  .header-title { font-size: 18px; }
  .header-logo { width: 32px; height: 32px; font-size: 14px; }
  .header-right .btn { font-size: 11px; padding: 3px 8px; }
  .status-banner-title { font-size: 15px; }
  .status-banner-icon { width: 36px; height: 36px; font-size: 16px; }
  .card { padding: 14px 16px; }
  .diag-section, .log-section { padding: 14px; }
  .toast { max-width: calc(100vw - 40px); font-size: 12px; }
}

/* ─── 代理节点样式 ─── */
.proxy-summary, .proxy-groups { margin-bottom: 16px; }
.group-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 8px;
  transition: var(--transition);
}
.group-card:hover { border-color: var(--border-hover); }
.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.group-name { font-weight: 600; font-size: 14px; }
.group-now {
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 20px;
  background: var(--accent-bg);
  color: var(--accent);
}
.group-nodes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.node-chip {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
}
.node-chip:hover { border-color: var(--accent); color: var(--accent); }
.node-chip.active { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
.node-chip.testing { opacity: 0.5; cursor: wait; }
.node-chip .delay-badge {
  font-size: 10px;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(48,54,61,0.5);
}
.node-chip .delay-badge.fast { color: var(--status-ok); }
.node-chip .delay-badge.slow { color: var(--status-warn); }
.node-chip .delay-badge.timeout { color: var(--status-fail); }
.node-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
}
.node-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  transition: var(--transition);
}
.node-item:hover { border-color: var(--border-hover); }
.node-item .node-name { font-weight: 600; color: var(--text-primary); }
.node-item .node-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.node-item .node-delay { font-size: 12px; font-weight: 500; margin-top: 4px; }
.node-item .node-delay.fast { color: var(--status-ok); }
.node-item .node-delay.slow { color: var(--status-warn); }
.node-item .node-delay.timeout { color: var(--status-fail); }

/* ─── AI中转站样式 ─── */
.relay-status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}
.relay-stat {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}
.relay-stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.relay-stat-value { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.relay-stat-value.ok { color: var(--status-ok); }
.relay-stat-value.fail { color: var(--status-fail); }
@media (max-width: 700px) {
  .relay-status-grid { grid-template-columns: 1fr; }
  .node-list { grid-template-columns: 1fr; }
}
