:root {
  --bg: #090d16;
  --panel: #111827;
  --panel-alt: #161f33;
  --border: #23304c;
  --ink: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0284c7;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 12px;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.88rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 0.84rem; }

.app-shell {
  max-width: 1420px;
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  padding: 0.9rem 1.2rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.brand-group { display: flex; align-items: center; gap: 0.75rem; }
.logo-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.7);
}
.brand-title { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em; }
.brand-sub { font-size: 0.8rem; color: var(--muted); }

.top-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem; }

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.48rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--ink);
  background: var(--panel-alt);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent-strong); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #0369a1; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--ink); }
.btn-outline:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); }
.btn-danger { background: rgba(239, 68, 68, 0.16); border-color: rgba(239, 68, 68, 0.4); color: #fca5a5; }
.btn-danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.28); }
.btn-sm { padding: 0.3rem 0.62rem; font-size: 0.78rem; }
.full-width { width: 100%; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.pill-ok { background: rgba(34, 197, 94, 0.14); border-color: rgba(34, 197, 94, 0.35); color: #86efac; }
.pill-warn { background: rgba(245, 158, 11, 0.14); border-color: rgba(245, 158, 11, 0.35); color: #fcd34d; }
.pill-bad { background: rgba(239, 68, 68, 0.14); border-color: rgba(239, 68, 68, 0.35); color: #fca5a5; }
.pill-muted { background: rgba(148, 163, 184, 0.12); border-color: var(--border); color: var(--muted); }

/* Server Selector Strip */
.server-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.1rem;
}
@media (max-width: 1100px) { .server-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 680px) { .server-strip { grid-template-columns: repeat(1, minmax(0, 1fr)); } }

.srv-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
  text-align: left;
  color: inherit;
}
.srv-card:hover { border-color: #3b5582; transform: translateY(-1px); }
.srv-card.active {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.11), var(--panel));
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.3);
}
.srv-head { display: flex; justify-content: space-between; align-items: center; gap: 0.4rem; margin-bottom: 0.35rem; }
.srv-title { font-weight: 700; font-size: 0.96rem; display: flex; align-items: center; gap: 0.4rem; }
.srv-ip { font-size: 0.8rem; color: var(--accent); font-family: ui-monospace, monospace; margin-bottom: 0.25rem; }
.srv-role { font-size: 0.76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.srv-probe-line { margin-top: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.35rem; font-size: 0.73rem; }

/* Detail Workspace */
.detail-view { display: flex; flex-direction: column; gap: 1rem; }

.hero-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.3rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.hero-meta h2 { font-size: 1.25rem; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.hero-sub { color: var(--muted); font-size: 0.86rem; margin-top: 0.25rem; }
.hero-links { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
@media (max-width: 960px) { .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.05rem 1.2rem;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}
.card-title { font-size: 1rem; font-weight: 700; }

/* Meters */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; }
.stat-box { background: var(--panel-alt); border: 1px solid var(--border); border-radius: 9px; padding: 0.7rem 0.85rem; }
.stat-label { font-size: 0.76rem; color: var(--muted); }
.stat-val { font-size: 1.12rem; font-weight: 700; margin: 0.18rem 0; }
.bar { height: 6px; border-radius: 99px; background: #1e293b; overflow: hidden; margin-top: 0.35rem; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
th, td { padding: 0.55rem 0.6rem; border-bottom: 1px solid rgba(35, 48, 76, 0.7); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; }

/* Nodes list */
.node-list { display: flex; flex-direction: column; gap: 0.65rem; }
.node-item {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem 0.95rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
}
.node-info { flex: 1; min-width: 240px; }
.node-name { font-weight: 700; font-size: 0.94rem; display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.node-note { font-size: 0.8rem; color: var(--muted); margin-top: 0.2rem; }
.node-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.speed-box {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem;
  margin-top: 0.75rem;
}
.log-box {
  background: #05080f;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.8rem;
  font-family: ui-monospace, monospace;
  font-size: 0.76rem;
  color: #cbd5e1;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin-top: 0.75rem;
}

/* Forms & Modals */
.inline-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-end; margin-bottom: 0.8rem; }
.field { display: flex; flex-direction: column; gap: 0.25rem; }
.field label { font-size: 0.76rem; color: var(--muted); }
input, select, textarea {
  background: #0b1120;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.48rem 0.65rem;
  font-size: 0.85rem;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

.overlay {
  position: fixed; inset: 0;
  background: rgba(5, 8, 15, 0.82);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; z-index: 100;
}
.login-card, .modal-card {
  width: 100%; max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
}
.login-badge {
  display: inline-block; font-size: 0.74rem; font-weight: 700;
  background: rgba(56, 189, 248, 0.14); color: var(--accent);
  padding: 0.2rem 0.6rem; border-radius: 999px; margin-bottom: 0.65rem;
}
.login-card h1 { font-size: 1.35rem; margin-bottom: 0.35rem; }
.login-card form, #nodeAddForm { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 1rem; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.icon-close { background: transparent; border: none; color: var(--muted); font-size: 1.15rem; cursor: pointer; }
.qr-box { display: flex; justify-content: center; padding: 0.75rem; background: #fff; border-radius: 10px; margin-bottom: 0.85rem; }
.uri-box { width: 100%; font-family: ui-monospace, monospace; font-size: 0.78rem; margin-bottom: 0.8rem; }
.error-text { color: #fca5a5; font-size: 0.84rem; }

.empty-state {
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
}

.toast {
  position: fixed; bottom: 1.4rem; right: 1.4rem;
  background: #0f172a; border: 1px solid var(--accent);
  color: #fff; padding: 0.65rem 1rem; border-radius: 10px;
  font-size: 0.86rem; font-weight: 600; z-index: 200;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
}
