:root {
  --bg: #0b0f17;
  --bg-elevated: #121826;
  --bg-card: #151c2c;
  --bg-hover: #1c2538;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.3);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --online: #22c55e;
  --offline: #ef4444;
  --checking: #f59e0b;
  --unknown: #64748b;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}
:root[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f8fafc;
  --border: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(15, 23, 42, 0.22);
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.app-shell { max-width: 1180px; margin: 0 auto; padding: 24px 20px 48px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-icon { width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, #3b82f6, #06b6d4); color: #fff; display: grid; place-items: center; flex-shrink: 0; box-shadow: 0 6px 18px rgba(59, 130, 246, 0.35); }
.brand-icon svg { width: 24px; height: 24px; }
.brand h1 { margin: 0; font-size: 1.35rem; letter-spacing: -0.02em; }
.subtitle { margin: 2px 0 0; font-size: 0.85rem; color: var(--text-muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 500; border: 1px solid var(--border); }
.badge-muted { color: var(--text-muted); background: var(--bg-elevated); }
.badge-cloud { color: #38bdf8; background: rgba(56, 189, 248, 0.12); border-color: rgba(56, 189, 248, 0.3); }
.btn { border: 1px solid transparent; border-radius: 10px; padding: 9px 15px; font-size: 0.88rem; font-weight: 500; cursor: pointer; transition: all 0.16s ease; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--bg-elevated); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--border-strong); background: var(--bg-hover); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--bg-hover); }
.btn-danger-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-danger-ghost:hover { color: var(--offline); background: rgba(239, 68, 68, 0.1); }
.btn-sm { padding: 6px 11px; font-size: 0.8rem; border-radius: 8px; }
.icon-btn { background: transparent; border: none; color: var(--text-muted); font-size: 1.05rem; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { color: var(--text); background: var(--bg-hover); }
.stats-bar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; justify-content: center; box-shadow: var(--shadow); }
.stat-label { font-size: 0.78rem; color: var(--text-muted); }
.stat-value { font-size: 1.5rem; margin-top: 2px; font-weight: 700; }
.stat-online { color: var(--online); }
.stat-offline { color: var(--offline); }
.stat-actions { flex-direction: row; align-items: center; justify-content: flex-end; gap: 8px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.search-wrap { flex: 1 1 260px; max-width: 400px; }
.search-wrap input { width: 100%; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; color: var(--text); font-size: 0.9rem; outline: none; transition: border-color 0.15s; }
.search-wrap input:focus { border-color: var(--primary); }
.group-tabs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tab-btn { background: var(--bg-card); color: var(--text-muted); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; font-size: 0.83rem; cursor: pointer; transition: all 0.15s; }
.tab-btn:hover { color: var(--text); border-color: var(--border-strong); }
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.router-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.router-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); transition: transform 0.15s ease, border-color 0.15s ease; }
.router-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-title-group h3 { margin: 0; font-size: 1.06rem; display: flex; align-items: center; gap: 8px; }
.card-meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.pill { font-size: 0.73rem; padding: 2px 8px; border-radius: 6px; background: var(--bg-hover); color: var(--text-muted); border: 1px solid var(--border); }
.status-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 0.76rem; color: var(--text-muted); white-space: nowrap; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--unknown); flex-shrink: 0; }
.status-dot.online { background: var(--online); box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.18); }
.status-dot.offline { background: var(--offline); box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.18); }
.status-dot.checking { background: var(--checking); animation: pulse 1s infinite ease-in-out; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.card-urls { display: flex; flex-direction: column; gap: 6px; font-size: 0.83rem; }
.url-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }
.url-text { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 0.79rem; }
.copy-btn { background: transparent; border: none; color: var(--text-muted); font-size: 0.75rem; cursor: pointer; padding: 2px 6px; border-radius: 5px; flex-shrink: 0; }
.copy-btn:hover { color: var(--text); background: var(--bg-hover); }
.card-note { margin: 0; font-size: 0.83rem; color: var(--text-muted); word-break: break-word; }
.card-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border); }
.card-actions-left, .card-actions-right { display: flex; align-items: center; gap: 6px; }
.empty-state { margin-top: 32px; }
.empty-card { max-width: 520px; margin: 0 auto; text-align: center; background: var(--bg-card); border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 36px 24px; }
.empty-card h2 { margin: 0 0 10px; font-size: 1.2rem; }
.empty-card p { margin: 0 0 20px; color: var(--text-muted); font-size: 0.9rem; }
.empty-card code { background: var(--bg-hover); padding: 2px 6px; border-radius: 6px; font-size: 0.84rem; }
.empty-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.footer { margin-top: 36px; text-align: center; font-size: 0.8rem; color: var(--text-muted); }
.modal { padding: 0; border: none; border-radius: var(--radius); background: transparent; color: var(--text); max-width: 540px; width: calc(100% - 28px); }
.modal::backdrop { background: rgba(0, 0, 0, 0.62); backdrop-filter: blur(4px); }
.modal-card { background: var(--bg-card); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.modal-header { display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { margin: 0; font-size: 1.1rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.83rem; color: var(--text-muted); }
.field input, .field select, .field textarea { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 9px; padding: 9px 12px; color: var(--text); font-size: 0.9rem; font-family: inherit; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.auth-desc { margin: 0; font-size: 0.86rem; color: var(--text-muted); }
.error-text { margin: 0; font-size: 0.82rem; color: var(--offline); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--bg-card); color: var(--text); border: 1px solid var(--border-strong); padding: 10px 18px; border-radius: 999px; font-size: 0.85rem; box-shadow: var(--shadow); z-index: 100; }
@media (max-width: 720px) {
  .stats-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-actions { justify-content: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .router-grid { grid-template-columns: 1fr; }
}