/* ============================================================
   frp-center 设计系统 —— 深色基础设施控制台
   设计令牌：一层变量驱动全站，改主题只动这里
   ============================================================ */
:root {
  /* 画布与表面 */
  --bg: #0b0f1a;
  --bg-raise: #0f1524;
  --surface: #131a2b;
  --surface-hover: #182136;
  --line: #1e2740;
  --line-strong: #2a3554;

  /* 文本 */
  --text: #e6ebf4;
  --text-dim: #8b94ab;
  --text-faint: #5a6379;

  /* 品牌与功能色 */
  --accent: #6d7cff;
  --accent-strong: #8591ff;
  --accent-soft: rgba(109, 124, 255, 0.14);
  --grad: linear-gradient(135deg, #6d7cff 0%, #46c8ff 100%);

  --ok: #3ecf8e;
  --ok-soft: rgba(62, 207, 142, 0.12);
  --warn: #f5b83d;
  --warn-soft: rgba(245, 184, 61, 0.12);
  --crit: #ff6b6b;
  --crit-soft: rgba(255, 107, 107, 0.12);
  --info-soft: rgba(109, 124, 255, 0.12);

  /* 版式 */
  --radius: 10px;
  --radius-lg: 14px;
  --font: "Inter", "Segoe UI", system-ui, "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "JetBrains Mono", Consolas, monospace;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  display: flex;
  min-height: 100vh;
}

/* ── 侧边栏 ─────────────────────────────────────── */
.sidebar {
  width: 216px;
  flex: 0 0 216px;
  background: var(--bg-raise);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px;
  text-decoration: none;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--grad);
  color: #fff; font-size: 15px;
  box-shadow: 0 0 18px rgba(109, 124, 255, 0.45);
}
.brand-name { color: var(--text); font-weight: 700; font-size: 15px; letter-spacing: 0.2px; }

.nav { flex: 1; padding: 4px 10px; overflow-y: auto; }
.nav-section {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--text-faint); padding: 14px 10px 6px;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin: 1px 0;
  border-radius: 8px;
  color: var(--text-dim); text-decoration: none;
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
}
.nav-link svg { opacity: 0.75; flex: 0 0 auto; }
.nav-link:hover { background: var(--surface-hover); color: var(--text); }
.nav-link.active {
  background: var(--accent-soft); color: var(--accent-strong);
}
.nav-link.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto;
  font-size: 11px; color: var(--text-faint);
  background: var(--surface-hover); border-radius: 10px; padding: 0 7px;
  font-variant-numeric: tabular-nums;
}
.nav-badge.hot { background: var(--crit-soft); color: var(--crit); }

.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
  color: var(--text-faint); font-size: 12px;
}
.foot-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.sidebar-foot form { margin-left: auto; }
.sidebar-foot button {
  background: none; border: 1px solid var(--line); color: var(--text-dim);
  border-radius: 6px; padding: 3px 9px; cursor: pointer; font-size: 13px;
}
.sidebar-foot button:hover { color: var(--text); border-color: var(--line-strong); }

/* ── 主区域 ─────────────────────────────────────── */
.main { flex: 1; padding: 26px 30px 60px; min-width: 0; }
.main.standalone { display: grid; place-items: center; min-height: 100vh; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 22px;
}
h1 { font-size: 21px; margin: 0 0 4px; letter-spacing: -0.01em; }
.page-sub { margin: 0; color: var(--text-dim); font-size: 13px; }
h2 { font-size: 13px; margin: 0; text-transform: none; color: var(--text); font-weight: 600; }
.sec { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; margin: 14px 0 8px; }

/* ── 卡片 / 面板 / 统计 ─────────────────────────── */
.card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin: 0 0 18px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.stat-grid { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.stat {
  flex: 1; min-width: 180px;
  display: flex; align-items: center; gap: 14px;
}
.stat b { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; display: block; line-height: 1.1; }
.stat div span { font-size: 12px; color: var(--text-dim); }
.stat-ico {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center; font-size: 16px;
  flex: 0 0 auto;
}
.i-violet { background: var(--accent-soft); color: var(--accent-strong); }
.i-cyan   { background: rgba(70, 200, 255, 0.12); color: #46c8ff; }
.i-amber  { background: var(--warn-soft); color: var(--warn); }
.stat-warn { border-color: rgba(245, 184, 61, 0.35); }

/* ── 表格 ───────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-faint);
  padding: 6px 10px; border-bottom: 1px solid var(--line);
}
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: var(--surface-hover); }
.strong { font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty {
  text-align: center; color: var(--text-faint);
  padding: 26px 10px !important; font-size: 13px;
}
.resolved td { opacity: 0.45; }
.row-critical td { background: var(--crit-soft); }
.row-warning td { background: var(--warn-soft); }

/* ── 徽标 / 状态点 ──────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 20px; padding: 2px 10px; font-size: 12px;
  background: var(--surface-hover); color: var(--text-dim);
  white-space: nowrap;
}
.pill i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok   { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.crit { background: var(--crit-soft); color: var(--crit); }
.pill.info { background: var(--info-soft); color: var(--accent-strong); }
.pill.off  { color: var(--text-faint); }

/* ── 按钮 / 链接 / 表单 ─────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 8px; padding: 7px 14px;
  font-size: 13px; font-family: var(--font);
  cursor: pointer; text-decoration: none;
  border: 1px solid var(--line-strong);
  background: var(--surface-hover); color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn.primary:hover { background: var(--accent-strong); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--crit); border-color: rgba(255, 107, 107, 0.3); }
.btn.danger:hover { background: var(--crit-soft); }
.btn.block { width: 100%; justify-content: center; }
.link { color: var(--accent-strong); text-decoration: none; font-size: 13px; }
.link:hover { text-decoration: underline; }

label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-dim); }
input, textarea {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 11px;
  color: var(--text); font-size: 13.5px; font-family: var(--font);
  min-width: 150px;
}
input:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.form-err { color: var(--crit); font-size: 13px; margin: 8px 0 0; }
.inline { display: inline; }

/* ── 提示条 / 代码 ──────────────────────────────── */
.alert {
  border-radius: var(--radius); padding: 12px 16px;
  margin: 0 0 18px; font-size: 13.5px; line-height: 1.7;
}
.alert.err { background: var(--crit-soft); border: 1px solid rgba(255, 107, 107, 0.3); color: var(--crit); }
.alert.ok  { background: var(--ok-soft); border: 1px solid rgba(62, 207, 142, 0.3); color: var(--ok); }
.code, pre.code, .mono {
  font-family: var(--mono); font-size: 12.5px;
}
pre.code {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; overflow-x: auto;
  color: var(--text-dim); line-height: 1.7;
}
code { color: var(--accent-strong); }
pre.code code { color: inherit; }

/* ── 项目卡片网格 ───────────────────────────────── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.proj { display: block; text-decoration: none; color: var(--text); transition: border-color 0.15s, transform 0.15s; }
.proj:hover { border-color: var(--accent); transform: translateY(-2px); }
.proj-head { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.proj-ico {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-strong);
}
.proj-meta { display: flex; justify-content: space-between; gap: 10px; margin-top: 12px; font-size: 12px; }
.proj p { margin: 8px 0 0; font-size: 13px; }
.proj .proj-meta .muted { white-space: nowrap; }
.card.proj { position: relative; }
.proj-link { display: block; text-decoration: none; color: inherit; }
.proj-del { position: absolute; top: 10px; right: 12px; }
.proj-del .btn { padding: 2px 10px; font-size: 12px; }
.dl-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px 24px; margin-bottom: 14px; }
.kv { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.kv > span { color: var(--text-faint); min-width: 90px; }

/* ── 登录页（独立布局）────────────────────────────── */
body.standalone { background: radial-gradient(1000px 600px at 70% -10%, rgba(109, 124, 255, 0.16), transparent 60%), var(--bg); }
.login-hero { width: 100%; max-width: 400px; padding: 24px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 34px 32px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-mark {
  width: 52px; height: 52px; margin: 0 auto 14px;
  border-radius: 14px; display: grid; place-items: center;
  background: var(--grad); color: #fff; font-size: 24px;
  box-shadow: 0 0 34px rgba(109, 124, 255, 0.5);
}
.login-card h1 { font-size: 20px; margin: 0 0 6px; }
.login-sub { color: var(--text-dim); font-size: 13px; margin: 0 0 22px; }
.login-card form { text-align: left; display: flex; flex-direction: column; gap: 16px; }
.login-card .btn { margin-top: 4px; }
.login-foot { text-align: center; color: var(--text-faint); font-size: 12px; margin-top: 26px; }

/* ── 响应式 ─────────────────────────────────────── */
@media (max-width: 860px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .nav { display: flex; flex-wrap: wrap; }
  .nav-section { display: none; }
  .main { padding: 18px 14px 40px; }
}

/* ── 拓扑血缘图 ── */
.topo, .topo ul { list-style: none; margin: 0; padding-left: 22px; }
.topo > li { padding-left: 0; }
.topo li { position: relative; padding: 5px 0 5px 16px; }
.topo li::before { content: ""; position: absolute; left: 2px; top: -8px; bottom: 0; border-left: 1px solid var(--border); }
.topo > li::before { display: none; }
.topo li::after { content: ""; position: absolute; left: 2px; top: 20px; width: 13px; border-top: 1px solid var(--border); }
.topo li:last-child::before { bottom: auto; height: 21px; }
.tnode { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); position: relative; flex-wrap: wrap; }
.tnode.on { border-color: var(--accent-soft); }
.tlink { color: var(--text); text-decoration: none; }
.tlink:hover { color: var(--accent); }
.tbadge { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); }
.tb-frps { background: #2b3a55; color: #9ec1ff; }
.tb-中继 { background: #3d2f55; color: #c9a8ff; }
.tb-代理 { background: var(--bg); color: var(--muted); }
.tdot { width: 8px; height: 8px; border-radius: 50%; background: #e5484d; flex: none; }
.tdot.on { background: #30a46c; }
.tseen { font-size: 12px; }
.ttip { display: none; position: absolute; left: 0; top: calc(100% + 6px); z-index: 20; min-width: 260px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); box-shadow: 0 8px 24px rgba(0,0,0,.4); white-space: pre-line; font-size: 12px; line-height: 1.7; color: var(--text); }
.tnode:hover .ttip { display: block; }

/* ── 拓扑 SVG 血缘图 ── */
.tcanvas { overflow: auto; max-height: calc(100vh - 190px); }
.tsvg { display: block; }
.tedge { fill: none; stroke: #39415a; stroke-width: 1.6; }
.tnrect { fill: var(--surface); stroke: var(--border); stroke-width: 1.2; }
a:hover .tnrect, .tng:hover .tnrect { stroke: var(--accent); }
.tng:hover .tnrect { filter: drop-shadow(0 2px 10px rgba(109,124,255,.25)); }
.tnname { fill: var(--text); font-size: 13px; font-weight: 600; }
.tnbadge { fill: #9ec1ff; font-size: 11px; }
.tntime { fill: var(--muted); font-size: 11px; }
.tdotc { fill: #6b7280; }
.tdotc.on { fill: #30a46c; }
.tdotc.off { fill: #e5484d; }
.tnalr { fill: #e5484d; }
.tnalrt { fill: #fff; font-size: 11px; font-weight: 700; }

/* ── 项目页标签页 ── */
.tabs { display: flex; gap: 4px; margin: 0 0 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab { padding: 9px 18px; color: var(--muted); text-decoration: none; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-strong); border-bottom-color: var(--accent); font-weight: 600; }
label.chk { display: inline-flex; align-items: center; gap: 6px; }
label.hidden { display: none; }

/* ── 模态对话框 ── */
dialog.modal {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 24px;
  min-width: 520px;
  max-width: 90vw;
  box-shadow: 0 16px 48px rgba(0,0,0,.5);
}
dialog.modal::backdrop { background: rgba(0,0,0,.55); }
dialog.modal h3 { margin: 0 0 16px; font-size: 16px; color: var(--accent-strong); }
dialog.modal .form-row { flex-wrap: wrap; gap: 10px; }
dialog.modal label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
dialog.modal label input, dialog.modal label select { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text); padding: 7px 10px; font-size: 13px; }
dialog.modal label input[disabled] { opacity: .5; cursor: not-allowed; }
dialog.modal .modal-actions { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; }
dialog.modal .modal-close { position: absolute; top: 12px; right: 14px; background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; }
