/* ============================================================
   V2Ray 流量面板 - 深色主题
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0a0e1a;
  --card: rgba(255, 255, 255, .035);
  --card-hover: rgba(255, 255, 255, .06);
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .16);
  --text: #e8ebf4;
  --text-dim: #94a0b8;
  --text-faint: #5d6a85;
  --accent: #6d7bff;
  --accent-2: #22d3ee;
  --grad: linear-gradient(135deg, #6d7bff 0%, #22d3ee 100%);
  --green: #34d399;
  --red: #fb7185;
  --amber: #fbbf24;
  --radius: 16px;
  --shadow: 0 12px 40px rgba(0, 0, 0, .35);
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", system-ui, sans-serif;
  --mono: "Cascadia Code", Consolas, "JetBrains Mono", monospace;
}

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* 背景光晕 */
.bg-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(600px 400px at 15% 10%, rgba(109, 123, 255, .16), transparent 65%),
    radial-gradient(700px 500px at 85% 85%, rgba(34, 211, 238, .12), transparent 65%),
    radial-gradient(500px 400px at 70% 15%, rgba(168, 85, 247, .08), transparent 60%);
}

.hidden { display: none !important; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 10px;
  padding: 9px 18px; font-size: 14px; font-family: inherit;
  cursor: pointer; transition: all .18s ease; user-select: none;
  white-space: nowrap; color: var(--text);
  background: rgba(255,255,255,.06);
}
.btn:hover { background: rgba(255,255,255,.1); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--grad); color: #fff; font-weight: 600;
  box-shadow: 0 6px 20px rgba(109, 123, 255, .35);
}
.btn-primary:hover { filter: brightness(1.1); background: var(--grad); }

.btn-danger { background: rgba(251, 113, 133, .14); color: var(--red); border-color: rgba(251,113,133,.25); }
.btn-danger:hover { background: rgba(251, 113, 133, .25); }

.btn-success { background: rgba(52, 211, 153, .12); color: var(--green); border-color: rgba(52,211,153,.25); }
.btn-success:hover { background: rgba(52, 211, 153, .22); }

.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); background: rgba(255,255,255,.04); }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

/* ============ 表单 ============ */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; color: var(--text-dim); }
.field input, .field select, .field textarea {
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px;
  color: var(--text); font-size: 14px; font-family: inherit;
  outline: none; transition: border-color .18s, box-shadow .18s;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(109, 123, 255, .18);
}
.field input::placeholder { color: var(--text-faint); }
.field select option { background: #141a2b; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* ============ 登录页 ============ */
.login-view {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: rgba(16, 22, 38, .75);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 36px 34px 28px;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  animation: fadeUp .45s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

.login-logo { text-align: center; margin-bottom: 10px; filter: drop-shadow(0 6px 18px rgba(109,123,255,.4)); }
.login-title { text-align: center; font-size: 24px; letter-spacing: .5px; }
.login-sub { text-align: center; color: var(--text-dim); font-size: 13px; margin: 4px 0 22px; }

.tabs {
  display: flex; background: rgba(255,255,255,.05);
  border: 1px solid var(--border); border-radius: 12px; padding: 4px; margin-bottom: 20px;
}
.tab {
  flex: 1; background: transparent; border: none; color: var(--text-dim);
  padding: 8px; border-radius: 9px; cursor: pointer; font-size: 14px; font-family: inherit;
  transition: all .18s;
}
.tab.active { background: var(--grad); color: #fff; font-weight: 600; }

.login-footer { margin-top: 22px; color: var(--text-faint); font-size: 12px; text-align: center; }

/* ============ 主布局 ============ */
.app { position: relative; z-index: 1; display: flex; min-height: 100vh; }

.sidebar {
  width: 232px; flex-shrink: 0;
  background: rgba(13, 18, 32, .8);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(14px);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 16px; font-size: 17px; font-weight: 700;
}
.brand-text span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.nav { flex: 1; padding: 8px 12px; overflow-y: auto; }
.nav-group { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 1px; padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 11px;
  color: var(--text-dim); cursor: pointer;
  font-size: 14px; margin-bottom: 2px;
  transition: all .16s; border: 1px solid transparent;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.05); }
.nav-item.active {
  color: #fff; background: var(--grad);
  box-shadow: 0 6px 18px rgba(109, 123, 255, .35);
}
.nav-item .nav-badge {
  margin-left: auto; font-size: 11px; padding: 1px 8px; border-radius: 20px;
  background: var(--red); color: #fff; font-weight: 700;
}

.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); }
.user-mini { display: flex; align-items: center; gap: 10px; padding: 6px 2px 12px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--grad); display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-mini-name { font-weight: 600; font-size: 14px; line-height: 1.3; }
.user-mini-role { font-size: 12px; color: var(--text-dim); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
  background: rgba(10, 14, 26, .75); backdrop-filter: blur(14px);
}
.page-title { font-size: 20px; font-weight: 700; }
.view { padding: 24px 28px 40px; max-width: 1200px; width: 100%; margin: 0 auto; }

/* ============ 卡片 ============ */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  transition: background .2s, transform .2s;
}
.card:hover { background: var(--card-hover); }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.card-title .sub { font-size: 12px; color: var(--text-dim); font-weight: 400; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-main { grid-template-columns: 2fr 1fr; }

@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2, .grid-main { grid-template-columns: 1fr; }
  .sidebar { width: 76px; }
  .sidebar-brand span, .nav-item span:not(.nav-badge), .user-mini-info { display: none; }
  .nav-item { justify-content: center; }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .view { padding: 16px; }
  .topbar { padding: 14px 16px; }
  .form-grid { grid-template-columns: 1fr; }
}

/* 统计卡片 */
.stat-card { display: flex; align-items: center; gap: 14px; }
.stat-icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(109,123,255,.14); color: var(--accent);
}
.stat-icon.green { background: rgba(52,211,153,.14); color: var(--green); }
.stat-icon.cyan { background: rgba(34,211,238,.14); color: var(--accent-2); }
.stat-icon.red { background: rgba(251,113,133,.14); color: var(--red); }
.stat-icon.amber { background: rgba(251,191,36,.14); color: var(--amber); }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-dim); }

/* ============ 进度条 ============ */
.progress { height: 8px; background: rgba(255,255,255,.08); border-radius: 20px; overflow: hidden; }
.progress > div { height: 100%; border-radius: 20px; background: var(--grad); transition: width .5s ease; }
.progress.warn > div { background: linear-gradient(90deg, #fbbf24, #fb7185); }
.progress.danger > div { background: linear-gradient(90deg, #fb7185, #f43f5e); }

/* ============ 徽章 ============ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; padding: 2px 10px; border-radius: 20px; font-weight: 600;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.green { background: rgba(52,211,153,.12); color: var(--green); }
.badge.red { background: rgba(251,113,133,.12); color: var(--red); }
.badge.amber { background: rgba(251,191,36,.12); color: var(--amber); }
.badge.blue { background: rgba(109,123,255,.12); color: var(--accent); }
.badge.cyan { background: rgba(34,211,238,.12); color: var(--accent-2); }
.badge.gray { background: rgba(255,255,255,.08); color: var(--text-dim); }
.badge.purple { background: rgba(168,85,247,.14); color: #c084fc; }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th {
  text-align: left; font-size: 12px; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .6px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  font-weight: 600;
}
td { padding: 12px; border-bottom: 1px solid rgba(255,255,255,.05); font-size: 14px; vertical-align: middle; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: rgba(255,255,255,.03); }
tr:last-child td { border-bottom: none; }

/* ============ 链接卡片 ============ */
.link-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 12px; background: rgba(255,255,255,.03);
  margin-bottom: 10px; transition: border-color .18s, background .18s;
}
.link-row:hover { border-color: var(--border-strong); background: rgba(255,255,255,.05); }
.link-proto {
  width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px;
}
.proto-vless { background: rgba(109,123,255,.15); color: #9aa6ff; }
.proto-vmess { background: rgba(34,211,238,.14); color: #67e8f9; }
.proto-trojan { background: rgba(168,85,247,.15); color: #c084fc; }
.proto-ss { background: rgba(52,211,153,.14); color: #6ee7b7; }
.link-main { flex: 1; min-width: 0; }
.link-remark { font-weight: 600; font-size: 14px; }
.link-meta { font-size: 12px; color: var(--text-dim); }
.link-actions { display: flex; gap: 6px; }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 8, 16, .7); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto;
  background: #121828; border: 1px solid var(--border-strong);
  border-radius: 18px; box-shadow: var(--shadow); padding: 24px;
  animation: popIn .22s ease;
}
@keyframes popIn { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: none; } }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 20px; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ============ Toast ============ */
#toast-root { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  padding: 12px 18px; border-radius: 12px; font-size: 14px;
  background: #1a2236; border: 1px solid var(--border-strong);
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px;
  animation: slideIn .25s ease; max-width: 360px;
}
.toast.success { border-color: rgba(52,211,153,.4); }
.toast.success::before { content: "✓"; color: var(--green); font-weight: 700; }
.toast.error { border-color: rgba(251,113,133,.4); }
.toast.error::before { content: "✕"; color: var(--red); font-weight: 700; }
.toast.info { border-color: rgba(109,123,255,.4); }
.toast.info::before { content: "ℹ"; color: var(--accent); font-weight: 700; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.toast.out { opacity: 0; transform: translateX(20px); transition: all .3s; }

/* ============ 订阅链接框 ============ */
.sub-box {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.04); border: 1px dashed var(--border-strong);
  border-radius: 12px; padding: 10px 14px;
}
.sub-box .sub-url {
  flex: 1; font-family: var(--mono); font-size: 12px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 空状态 */
.empty { text-align: center; padding: 40px 20px; color: var(--text-dim); }
.empty .empty-icon { font-size: 40px; margin-bottom: 10px; opacity: .6; }

/* 加载 */
.loading { display: flex; align-items: center; justify-content: center; padding: 60px; color: var(--text-dim); gap: 10px; }
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.15); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 提示条 */
.alert {
  padding: 12px 16px; border-radius: 12px; font-size: 13px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px;
}
.alert.warn { background: rgba(251,191,36,.1); border: 1px solid rgba(251,191,36,.3); color: #fcd34d; }
.alert.info { background: rgba(109,123,255,.1); border: 1px solid rgba(109,123,255,.3); color: #a5b4fc; }
.alert.danger { background: rgba(251,113,133,.1); border: 1px solid rgba(251,113,133,.3); color: #fda4af; }

/* 流量环形图容器 */
.traffic-ring { display: flex; align-items: center; gap: 24px; }
.traffic-ring canvas { width: 180px; height: 180px; flex-shrink: 0; }
.ring-info { flex: 1; }
.ring-value { font-size: 26px; font-weight: 700; }
.ring-label { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.ring-detail { margin-top: 12px; font-size: 13px; color: var(--text-dim); display: flex; flex-direction: column; gap: 4px; }
.ring-detail b { color: var(--text); font-weight: 600; }
@media (max-width: 560px) { .traffic-ring { flex-direction: column; } }

.chart-box { width: 100%; height: 220px; position: relative; }
.chart-box canvas { width: 100%; height: 100%; }
.chart-legend { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--text-dim); }
.chart-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }

/* 搜索框 */
.search-bar { display: flex; gap: 10px; margin-bottom: 16px; }
.search-bar input {
  flex: 1; background: rgba(255,255,255,.05); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 14px; color: var(--text); outline: none; font-size: 14px;
}
.search-bar input:focus { border-color: var(--accent); }

/* 开关 */
.switch { position: relative; display: inline-block; width: 42px; height: 23px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; cursor: pointer;
  background: rgba(255,255,255,.12); border-radius: 23px; transition: .25s;
}
.switch .slider::before {
  content: ""; position: absolute; width: 17px; height: 17px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .25s;
}
.switch input:checked + .slider { background: var(--grad); }
.switch input:checked + .slider::before { transform: translateX(19px); }
