/* WireGuard Panel —— 深色现代主题 */
:root {
  --bg: #0d1117;
  --bg-soft: #141b26;
  --bg-card: #17202e;
  --bg-hover: #1d2836;
  --border: #263142;
  --text: #e6edf6;
  --text-dim: #8b98a9;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --green: #3fb960;
  --red: #f0616d;
  --orange: #f0a24c;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 10px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }

#app { min-height: 100vh; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 18px;
  font-size: 16px; font-weight: 700;
}
.brand svg { width: 26px; height: 26px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--text-dim); cursor: pointer; user-select: none;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item svg { width: 17px; height: 17px; }
.sidebar .spacer { flex: 1; }
.user-box {
  padding: 10px 12px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.user-box .name { font-weight: 600; font-size: 13px; }

.main { flex: 1; min-width: 0; padding: 26px 32px 60px; }
.page-title { font-size: 21px; font-weight: 700; margin: 0 0 4px; }
.page-sub { color: var(--text-dim); margin: 0 0 22px; }

/* ---------- 卡片 ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-bottom: 24px; }
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.card .label { color: var(--text-dim); font-size: 12.5px; margin-bottom: 6px; }
.card .value { font-size: 22px; font-weight: 700; }
.card .value.small { font-size: 15px; font-family: var(--mono); }
.card .hint { color: var(--text-dim); font-size: 12px; margin-top: 4px; }

.panel {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 20px; overflow: hidden;
}
.panel-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.panel-head h3 { margin: 0; font-size: 15px; }
.panel-body { padding: 18px; }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: var(--bg-hover); }
tbody tr.clickable { cursor: pointer; }
tr:last-child td { border-bottom: none; }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2.5px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.badge.online { background: rgba(63, 185, 96, 0.14); color: var(--green); }
.badge.online .dot { background: var(--green); }
.badge.offline { background: rgba(240, 97, 109, 0.12); color: var(--red); }
.badge.offline .dot { background: var(--red); }
.badge.neutral { background: var(--bg-hover); color: var(--text-dim); }
.badge.neutral .dot { background: var(--text-dim); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- 表单 ---------- */
.field { margin-bottom: 15px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-dim); }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; padding: 9px 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 14px; outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; font-family: var(--mono); font-size: 12.5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-hover); color: var(--text);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: filter 0.15s, background 0.15s;
}
.btn:hover { filter: brightness(1.15); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: rgba(240, 97, 109, 0.15); border-color: rgba(240, 97, 109, 0.4); color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 11px; font-size: 12.5px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 70% -10%, rgba(79, 140, 255, 0.12), transparent), var(--bg);
}
.login-card {
  width: 360px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; padding: 34px 32px; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 19px; margin: 0 0 4px; display: flex; align-items: center; gap: 10px; }
.login-card .sub { color: var(--text-dim); margin-bottom: 24px; font-size: 13px; }

/* ---------- 其他 ---------- */
.muted { color: var(--text-dim); }
.mt { margin-top: 18px; }
.pre {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; overflow-x: auto; white-space: pre;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7; color: #c9d5e3;
}
.qr-box {
  background: #fff; border-radius: 10px; padding: 14px;
  display: inline-block; line-height: 0;
}
.qr-box svg { width: 240px; height: 240px; }

.toast {
  position: fixed; bottom: 26px; right: 26px; z-index: 100;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 18px; box-shadow: var(--shadow);
  animation: rise 0.25s ease;
}
.toast.error { border-color: rgba(240, 97, 109, 0.5); }
.toast.ok { border-color: rgba(63, 185, 96, 0.5); }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }

.modal-mask {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  width: 480px; max-width: calc(100vw - 40px); max-height: 86vh; overflow-y: auto;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; padding: 24px; box-shadow: var(--shadow);
}
.modal h3 { margin: 0 0 16px; }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tab {
  padding: 7px 15px; border-radius: 8px; cursor: pointer; user-select: none;
  color: var(--text-dim); font-size: 13px; font-weight: 600;
}
.tab:hover { background: var(--bg-hover); }
.tab.active { background: var(--accent-soft); color: var(--accent); }

.chart-wrap { width: 100%; overflow: hidden; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 18px; font-size: 12.5px; color: var(--text-dim); margin-top: 8px; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }

.empty { text-align: center; padding: 42px 20px; color: var(--text-dim); }
.empty .big { font-size: 34px; margin-bottom: 10px; }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv .k { color: var(--text-dim); }

.copy-line {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; font-family: var(--mono); font-size: 12.5px;
  overflow-x: auto; white-space: nowrap;
}
.copy-line .btn { flex-shrink: 0; }

@media (max-width: 860px) {
  .sidebar { width: 62px; }
  .sidebar .brand span, .nav-item span, .user-box .name { display: none; }
  .main { padding: 18px 16px 40px; }
  .form-row { grid-template-columns: 1fr; }
}
