:root {
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --bg-muted: #f5f5f5;
  --bg-hover: #f4f4f5;
  --panel: #ffffff;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #09090b;
  --text-muted: #71717a;
  --text-subtle: #a1a1aa;
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-soft: #ecfdf5;
  --primary-text: #047857;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 30px -10px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06);
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
/* Force the page scrollbar to always be present. scrollbar-gutter alone wasn't
   enough — some browsers / nested layouts still flicker. overflow-y: scroll
   guarantees the gutter is always taken. */
html { scrollbar-gutter: stable; overflow-y: scroll; }
body {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}
#root { height: 100%; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button { cursor: pointer; border: 0; background: transparent; }
a { color: inherit; text-decoration: none; }

/* ------------ Login ------------ */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
}
.login-left {
  position: relative;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    radial-gradient(circle at 80% 20%, rgba(16, 185, 129, 0.10), transparent 50%),
    radial-gradient(circle at 20% 80%, rgba(16, 185, 129, 0.06), transparent 50%),
    #0a0a0a;
  color: #fafafa;
  overflow: hidden;
}
.login-left::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(circle at center, #000 30%, transparent 70%);
  pointer-events: none;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  position: relative;
}
.login-brand-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #10b981, #059669);
  display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.login-hero {
  position: relative;
}
.login-hero h1 {
  font-size: 36px;
  font-weight: 600;
  margin: 0 0 16px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.login-hero p {
  color: #a1a1aa;
  font-size: 14px;
  margin: 0;
  max-width: 380px;
}
.login-stats {
  position: relative;
  display: flex;
  gap: 32px;
  margin-top: 32px;
}
.login-stat-num {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 500;
  color: var(--primary);
}
.login-stat-label {
  font-size: 12px;
  color: #71717a;
  margin-top: 2px;
}
.login-footer {
  position: relative;
  font-size: 12px;
  color: #52525b;
  font-family: var(--mono);
}
.login-right {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}
.login-card {
  width: 100%;
  max-width: 360px;
}
.login-card h2 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
.login-card .sub {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 32px;
}

/* ------------ Form ------------ */
.field { margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:hover { border-color: var(--border-strong); }
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}
.input::placeholder { color: var(--text-subtle); }
.input-with-icon {
  position: relative;
}
.input-with-icon .input { padding-left: 36px; }
.input-with-icon svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
}

/* ------------ Button ------------ */
.btn {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn-primary {
  background: var(--text);
  color: #fff;
}
.btn-primary:hover { background: #27272a; }
.btn-accent {
  background: var(--primary);
  color: #fff;
}
.btn-accent:hover { background: var(--primary-hover); }
.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger {
  background: var(--bg);
  color: var(--danger);
  border-color: var(--border);
}
.btn-danger:hover { background: #fef2f2; border-color: #fca5a5; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.kbd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--bg-subtle);
  color: var(--text-muted);
}

/* ------------ Layout ------------ */
.app-shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  height: 100vh;
  overflow: hidden;
}
.sidebar {
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 16px;
}
.sidebar-brand-mark {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, #10b981, #059669);
  display: grid; place-items: center;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.25);
}
.sidebar-brand-name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
}
.sidebar-brand-tag {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-muted);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: auto;
}
.sidebar-section-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-subtle);
  padding: 12px 8px 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: background 0.12s, color 0.12s;
}
.sidebar-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.sidebar-item.active {
  background: #fff;
  color: var(--text);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}
.sidebar-item .badge {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-subtle);
}
.sidebar-spacer { flex: 1; }
.sidebar-user {
  border-top: 1px solid var(--border);
  margin-top: 12px;
  padding: 12px 8px 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #d1fae5;
  color: #047857;
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 600;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 12px; font-weight: 500; }
.sidebar-user-role { font-size: 11px; color: var(--text-muted); }

/* ------------ Topbar ------------ */
.main-col {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.topbar {
  height: 52px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  background: var(--bg);
  flex-shrink: 0;
}
.topbar-title {
  font-size: 14px;
  font-weight: 500;
}
.topbar-crumb {
  color: var(--text-subtle);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.search-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  min-width: 220px;
}
.search-mini:hover { background: var(--bg-hover); }

/* ------------ Main content ------------ */
.main {
  flex: 1;
  overflow: auto;
  padding: 24px 32px 64px;
}
.page-header { margin-bottom: 20px; }
.page-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 4px;
}
.page-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

/* ------------ Panel / Card ------------ */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.panel-title {
  font-size: 13px;
  font-weight: 600;
}
.panel-sub {
  font-size: 12px;
  color: var(--text-muted);
}
.panel-body { padding: 16px; }
.panel-body-tight { padding: 0; }

/* ------------ Test form ------------ */
.test-form {
  display: grid;
  grid-template-columns: 1fr 200px auto;
  gap: 8px;
  align-items: end;
}
.test-form .field { margin-bottom: 0; }
.test-form-row2 {
  display: flex;
  gap: 16px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  align-items: center;
  flex-wrap: wrap;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.12s;
  user-select: none;
}
.chip:hover { background: var(--bg-hover); color: var(--text); }
.chip.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}
.chip-count {
  font-family: var(--mono);
  font-size: 10px;
  opacity: 0.7;
}

/* ------------ Stats ------------ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.stat-value {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 500;
  margin-top: 6px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.stat-unit { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; font-family: var(--mono); }
.stat-success .stat-value { color: var(--success); }
.stat-warn .stat-value { color: var(--warning); }
.stat-danger .stat-value { color: var(--danger); }

/* ------------ Table ------------ */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  /* Fixed layout: column widths are derived from <colgroup> only, never from cell
     content. Without this, expanding a row with long headers / IPs re-measures
     and shifts every other column → big visual jitter. */
  table-layout: fixed;
}
/* Cells default to no overflow; long IPs / URLs get ellipsis. */
.tbl td, .tbl th {
  overflow: hidden;
  text-overflow: ellipsis;
}
.tbl thead th {
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 14px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}
.tbl tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tbody tr:hover { background: var(--bg-subtle); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .col-mono { font-family: var(--mono); font-size: 12px; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.tbl .center { text-align: center; }
.tbl .num-unit { color: var(--text-subtle); font-size: 10.5px; margin-left: 1px; }

/* HTTP detail panel */
.http-detail-chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.http-chip {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  display: grid;
  gap: 2px;
}
.http-chip-label { font-size: 11px; color: var(--text-muted); }
.http-chip-value { font-size: 13.5px; font-weight: 600; color: var(--text); }
.http-chip-value.mono { font-family: var(--mono); font-size: 12px; font-weight: 500; }
.http-chip-sub { font-size: 11px; color: var(--text-subtle); font-family: var(--mono); }

.http-detail-collapse {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
}
.http-detail-collapse > summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.http-detail-collapse > summary::-webkit-details-marker { display: none; }
.http-detail-collapse > summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--text-muted);
  font-size: 10px;
  transition: transform 0.15s;
}
.http-detail-collapse[open] > summary::after { transform: rotate(180deg); }
.http-detail-collapse[open] > summary { border-bottom: 1px solid var(--border); }
.http-detail-collapse > *:not(summary) { padding: 10px 14px; }

.cert-row {
  background: var(--bg-subtle);
  border-radius: 6px;
  padding: 8px 12px;
}
.cert-row-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  margin-bottom: 4px;
}
.cert-idx { color: var(--text-muted); font-size: 11px; font-family: var(--mono); }
.cert-days { margin-left: auto; font-size: 11px; font-family: var(--mono); }
.cert-row-body {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--text-muted);
}

.http-raw {
  margin: 0;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--text);
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.http-raw-plain {
  margin: 0;
  padding: 0;
  background: transparent;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.tbl .col-narrow { width: 1%; white-space: nowrap; }

.row-enter {
  animation: rowEnter 0.35s ease;
}
@keyframes rowEnter {
  from { background: rgba(16, 185, 129, 0.08); }
  to { background: transparent; }
}

/* pending row state — node placeholder before its result arrives */
.tbl tbody tr.row-pending td {
  color: var(--text-subtle);
}
.tbl tbody tr.row-pending td .pending-dash {
  display: inline-block;
  width: 14px;
  height: 1px;
  background: var(--border-strong);
  vertical-align: middle;
}
.tbl tbody tr.row-pending td .pending-spin {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  border-top-color: var(--text-subtle);
  animation: spin 0.9s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.row-done-flash td {
  animation: doneFlash 0.6s ease;
}
@keyframes doneFlash {
  0% { background: rgba(16, 185, 129, 0.18); }
  100% { background: transparent; }
}

/* carrier divider row */
.tbl tbody tr.carrier-divider td {
  background: var(--bg-subtle);
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.tbl tbody tr.carrier-divider td .divider-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tbl tbody tr.carrier-divider:hover td {
  background: var(--bg-subtle);
}

/* ------------ Status pills ------------ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--mono);
}
.pill-success { background: #ecfdf5; color: #047857; }
.pill-warn { background: #fffbeb; color: #b45309; }
.pill-danger { background: #fef2f2; color: #b91c1c; }
.pill-info { background: #eff6ff; color: #1d4ed8; }
.pill-neutral { background: var(--bg-muted); color: var(--text-muted); }
.pill-plain {
  font-family: var(--sans);
  font-weight: 400;
}

/* latency colors (no leading dot) */
.latency {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.lat-good { color: #047857; }
.lat-ok { color: #b45309; }
.lat-bad { color: #b91c1c; }
.lat-fail { color: #71717a; }

.spark {
  display: inline-block;
  vertical-align: middle;
}

/* ------------ Carrier swatch ------------ */
.carrier {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.carrier-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.carrier-dot.dx { background: #2563eb; }
.carrier-dot.lt { background: #f59e0b; }
.carrier-dot.yd { background: #10b981; }
.carrier-dot.bgp { background: #8b5cf6; }
.carrier-dot.edu { background: #ec4899; }
.carrier-dot.os { background: #6b7280; }

/* ------------ Tabs ------------ */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 4px;
  margin-bottom: 16px;
}
.tab {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--text);
  font-weight: 500;
  border-bottom-color: var(--text);
}

/* ------------ Progress bar (overall test) ------------ */
.progress-bar {
  height: 4px;
  background: var(--bg-muted);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.25s ease;
}
.progress-bar.indeterminate .progress-bar-fill {
  animation: indet 1.2s infinite ease-in-out;
  width: 30% !important;
}
@keyframes indet {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

/* ------------ Result detail ------------ */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 16px;
}
.timing-bar {
  display: grid;
  grid-template-columns: 120px 1fr 70px;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  font-size: 12px;
}
.timing-label { color: var(--text-muted); }
.timing-track {
  height: 8px;
  background: var(--bg-muted);
  border-radius: 4px;
  position: relative;
}
.timing-fill {
  position: absolute;
  height: 100%;
  border-radius: 4px;
}
.timing-value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.kv-list { display: grid; gap: 10px; }
.kv {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: baseline;
  font-size: 12.5px;
}
.kv-label { color: var(--text-muted); }
.kv-val { font-family: var(--mono); word-break: break-all; }

/* ------------ Map ------------ */
.map-wrap {
  position: relative;
  background:
    linear-gradient(to bottom, #fafafa, #f4f4f5);
  border-radius: 8px;
  overflow: hidden;
}
.map-svg {
  display: block;
  width: 100%;
  height: auto;
}
.map-province {
  fill: #ffffff;
  stroke: #d4d4d8;
  stroke-width: 0.6;
  transition: fill 0.15s;
}
.map-province:hover { fill: #f4f4f5; }
.map-node {
  cursor: pointer;
  transition: r 0.15s;
}
.map-node:hover { r: 6 !important; }
.map-legend {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 11px;
  display: flex;
  gap: 10px;
}
.map-legend-item { display: flex; align-items: center; gap: 4px; }
.map-legend-dot { width: 8px; height: 8px; border-radius: 50%; }

/* ------------ Scrollbar tweak ------------ */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: #e4e4e7;
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: #d4d4d8; background-clip: padding-box; border: 2px solid transparent; }

/* ------------ Flat shell (no header) ------------ */
.app-flat {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}

.main-flat {
  flex: 1;
  padding: 48px 24px 80px;
}
.test-content {
  max-width: 1200px;
  margin: 0 auto;
}

/* Floating chrome (logo top-left, user top-right) */
.floating-brand {
  position: fixed;
  top: 18px;
  left: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 13px;
  z-index: 10;
  user-select: none;
}
.floating-brand .brand-mark {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, #10b981, #059669);
  display: grid; place-items: center;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.25);
  color: #fff;
}
.floating-user {
  position: fixed;
  top: 14px;
  right: 24px;
  z-index: 10;
}
.user-btn {
  display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 10px 0 6px;
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--text);
  background: transparent;
  cursor: pointer;
}
.user-btn:hover { background: var(--bg-hover); }

/* Top tabs (centered above search) */
.top-tabs {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-bottom: 24px;
  padding: 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}
.top-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 16px;
  height: 34px;
  font-size: 13px;
  color: var(--text-muted);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
  user-select: none;
}
.top-tab:hover { color: var(--text); }
.top-tab.active {
  background: #fff;
  color: var(--text);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}
.top-tab.disabled {
  color: var(--text-subtle);
  cursor: not-allowed;
  opacity: 0.55;
}
.top-tab.disabled:hover { color: var(--text-subtle); background: transparent; }
.top-tab-badge {
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg-muted);
  color: var(--text-subtle);
  font-size: 10px;
  line-height: 1.4;
  font-weight: 400;
}

/* ------------ Big search input ------------ */
.big-input {
  display: flex;
  align-items: stretch;
  gap: 6px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.big-input:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12), 0 4px 14px rgba(16, 185, 129, 0.08);
}
.big-input.has-error {
  border-color: #ef4444;
}
.big-input.has-error:focus-within {
  border-color: #ef4444;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12), 0 4px 14px rgba(239, 68, 68, 0.08);
}
.input-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 2px 0;
  font-size: 12.5px;
}
.input-hint-error { color: #dc2626; }
.big-input-icon {
  display: grid; place-items: center;
  padding: 0 4px 0 12px;
  color: var(--text-muted);
}
.big-input input {
  flex: 1;
  height: 48px;
  border: 0; outline: 0;
  font-size: 15px;
  padding: 0 12px;
  background: transparent;
  color: var(--text);
  min-width: 0;
}
.big-input input::placeholder { color: var(--text-subtle); }
.big-input .bi-divider {
  width: 1px;
  background: var(--border);
  margin: 8px 4px;
}
.big-input select,
.big-input .bi-port {
  height: 48px;
  border: 0; outline: 0;
  padding: 0 10px;
  font-size: 13px;
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  cursor: pointer;
}
.big-input select:hover,
.big-input .bi-port:hover { background: var(--bg-subtle); border-radius: 6px; }

/* Inline dropdown — replaces native <select> in big-input rows */
.inline-dd {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.inline-dd-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 10px;
  margin: 6px 2px;
  background: var(--bg-subtle);
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
  white-space: nowrap;
}
.inline-dd-trigger:hover { background: #f1f5f9; }
.inline-dd-trigger.open {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}
.inline-dd-label {
  font-size: 11.5px;
  color: var(--text-muted);
}
.inline-dd-value {
  font-weight: 600;
  color: var(--text);
}
.inline-dd-caret {
  color: var(--text-muted);
  transition: transform 0.15s;
}
.inline-dd-trigger.open .inline-dd-caret { transform: rotate(180deg); }

.inline-dd-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(9,9,11,0.12), 0 2px 6px rgba(9,9,11,0.06);
  padding: 4px;
  z-index: 50;
  max-height: 320px;
  overflow-y: auto;
}
.inline-dd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s;
}
.inline-dd-item:hover { background: var(--bg-subtle); }
.inline-dd-item.active { background: rgba(16,185,129,0.08); }
.inline-dd-item.active .inline-dd-item-main { color: var(--primary); font-weight: 500; }
.inline-dd-item-main { flex: 1; }
.inline-dd-item-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
}
.inline-dd-check { color: var(--primary); flex-shrink: 0; }
.big-input .bi-port {
  width: 96px;
  text-align: center;
}
.start-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 48px;
  padding: 0 22px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 500;
  font-size: 14px;
  transition: background 0.15s;
}
.start-btn:hover { background: var(--primary-hover); }
.start-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.stop-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 48px;
  padding: 0 22px;
  border-radius: 8px;
  background: #fff;
  color: var(--danger);
  border: 1px solid #fecaca;
  font-weight: 500;
  font-size: 14px;
  transition: background 0.15s;
}
.stop-btn:hover { background: #fef2f2; }

/* Secondary start variant (“持续 Ping” button) */
.start-btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 48px;
  padding: 0 20px;
  border-radius: 8px;
  background: #fff;
  color: var(--primary-text);
  border: 1px solid #a7f3d0;
  font-weight: 500;
  font-size: 14px;
  transition: background 0.15s, border-color 0.15s;
}
.start-btn-outline:hover { background: var(--primary-soft); border-color: var(--primary); }
.start-btn-outline:disabled { opacity: 0.5; cursor: not-allowed; }


.sub-options {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.sub-options-hint {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ------------ Favorites ------------ */
.favorites-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.favorites-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  padding-right: 4px;
}
.fav-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 12.5px;
  transition: all 0.12s;
  user-select: none;
}
.fav-chip:hover {
  border-color: var(--primary);
  color: var(--primary-text);
  background: var(--primary-soft);
}
.fav-chip .fav-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-subtle);
}
.fav-chip:hover .fav-meta { color: var(--primary-text); opacity: 0.75; }
.fav-remove {
  display: grid; place-items: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--bg-muted);
  color: var(--text-muted);
  margin-right: -4px;
}
.fav-remove:hover { background: var(--danger); color: #fff; }
.fav-add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: transparent;
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s;
}
.fav-add:hover { color: var(--primary); border-color: var(--primary); }
.fav-manage {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  color: var(--text-muted);
  border-radius: 6px;
}
.fav-manage:hover { background: var(--bg-hover); color: var(--text); }

/* ------------ Collapsible node filter ------------ */
.filter-collapsible { margin-top: 18px; }
.filter-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s;
  width: 100%;
  text-align: left;
}
.filter-toggle:hover { background: var(--bg-hover); }
.filter-toggle.open {
  border-radius: 8px 8px 0 0;
  border-bottom-color: var(--border);
}
.filter-toggle .filter-cur {
  color: var(--text);
  font-weight: 500;
}
.filter-count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  background: #fff;
  color: var(--text);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.filter-hidden-hint {
  font-size: 11.5px;
  color: var(--text-subtle);
  cursor: pointer;
  user-select: none;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.12s, color 0.12s;
}
.filter-hidden-hint:hover {
  background: #fff;
  color: var(--text);
}

/* DNS resolution IP cards — equal-width grid, fixed height, 2-row collapse */
.dns-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px;
  align-content: start;
}
.dns-group-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  height: 30px;
  background: var(--bg-subtle);
  border-radius: 5px;
  border-left: 3px solid var(--border);
  font-size: 12px;
  box-sizing: border-box;
  overflow: hidden;
}
.dns-group-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dns-group-ips {
  font-size: 11.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}
.dns-group-ip {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.dns-group-count {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Inline carrier + DNS config bar */
.carrier-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 12px 18px;
  margin-top: 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 1px 2px rgba(9,9,11,0.04);
}
.carrier-chk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  color: var(--text);
  padding: 4px 2px;
  border-radius: 4px;
  transition: color 0.12s;
}
.carrier-chk:hover {
  color: var(--primary);
}
.carrier-chk input[type="checkbox"],
.carrier-chk input[type="radio"] {
  accent-color: var(--primary);
  cursor: pointer;
  margin: 0;
  width: 14px; height: 14px;
}
.carrier-chk-all span:last-child {
  font-weight: 500;
}
.carrier-bar-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 2px;
}
.carrier-bar-spacer { flex: 1; }
.carrier-bar-count {
  font-size: 12px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.carrier-dns-input {
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
  font-family: var(--mono);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  width: 150px;
  outline: none;
  transition: border-color 0.12s, background 0.12s;
}
.carrier-dns-input:focus {
  border-color: var(--primary);
}
.carrier-dns-input:disabled {
  background: var(--bg-subtle);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* Inline filter bar above result tables */
.result-filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
}
.result-filter-bar .rfb-label {
  color: var(--text-muted);
  font-weight: 500;
  margin-right: 2px;
}
.result-filter-bar .rfb-sep {
  color: var(--border);
  margin: 0 4px;
  user-select: none;
}
.result-filter-bar .rfb-meta {
  margin-left: auto;
  color: var(--text-subtle);
  font-family: var(--mono);
  font-size: 11px;
}
.chip.chip-xs {
  padding: 2px 8px;
  font-size: 11.5px;
  height: 22px;
  line-height: 18px;
}
.chip-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  margin-left: 6px;
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  font-family: var(--mono);
  font-weight: 600;
  line-height: 1;
}
.chip.active .chip-badge {
  background: #fff;
  color: #ef4444;
}
.filter-body {
  padding: 16px;
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: #fff;
}

/* results section spacing */
.results-section { margin-top: 28px; }
.results-section .stats-row { margin-bottom: 16px; }

/* ------------ Node multi-select ------------ */
.node-select-wrap {
  margin-top: 18px;
  position: relative;
}
.node-select {
  min-height: 52px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  cursor: text;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.node-select:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.10);
}
.node-select-placeholder {
  color: var(--text-subtle);
  font-size: 13px;
  padding: 0 6px;
}
.node-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px 0 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-text);
  font-size: 12.5px;
  border: 1px solid #a7f3d0;
}
.node-chip .x-btn {
  display: grid; place-items: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  cursor: pointer;
  margin-left: 2px;
}
.node-chip .x-btn:hover { background: rgba(4, 120, 87, 0.15); }
.node-select-input {
  flex: 1;
  min-width: 140px;
  height: 30px;
  border: 0; outline: 0;
  font-size: 13px;
  background: transparent;
}
.node-select-meta {
  margin-left: auto;
  padding-right: 4px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
}
.node-select-pop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  max-height: 360px;
  overflow: auto;
  z-index: 20;
  padding: 4px 0;
}
.node-pop-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}
.node-pop-section {
  padding: 6px 12px 2px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
}
.node-pop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  font-size: 12.5px;
  cursor: pointer;
}
.node-pop-item:hover { background: var(--bg-hover); }
.node-pop-item.selected { background: var(--primary-soft); color: var(--primary-text); }
.node-pop-item.disabled { opacity: 0.4; cursor: not-allowed; }
.node-pop-item .np-check {
  width: 14px; height: 14px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.node-pop-item.selected .np-check {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.node-pop-item .np-name {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}
.node-pop-item .np-ip {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-subtle);
}

/* DNS radio group inline with big input */
.dns-segment {
  display: inline-flex;
  align-items: center;
  height: 36px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.dns-segment label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-muted);
}
.dns-segment label:hover { color: var(--text); }
.dns-segment input[type="radio"] {
  appearance: none;
  width: 12px; height: 12px;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  display: inline-block;
  position: relative;
}
.dns-segment input[type="radio"]:checked {
  border-color: var(--primary);
}
.dns-segment input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  inset: 2px;
  background: var(--primary);
  border-radius: 50%;
}
.dns-segment input[type="radio"]:checked + span { color: var(--text); font-weight: 500; }
.dns-input {
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  padding: 0 10px;
  font-family: var(--mono);
  font-size: 12.5px;
  width: 160px;
  outline: none;
}
.dns-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.10); }
.dns-input:disabled { background: var(--bg-muted); color: var(--text-subtle); }
.hr { height: 1px; background: var(--border); border: 0; margin: 16px 0; }
.muted { color: var(--text-muted); }
.mono { font-family: var(--mono); }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.items-center { align-items: center; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.mb-3 { margin-bottom: 12px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text-muted); }

.empty-state {
  padding: 56px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state-mark {
  width: 48px; height: 48px;
  margin: 0 auto 14px;
  border-radius: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  color: var(--text-subtle);
}
.empty-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}
.empty-sub { font-size: 12.5px; }

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  position: relative;
  margin-right: 6px;
  vertical-align: middle;
}
.live-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  opacity: 0.4;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0% { transform: scale(0.8); opacity: 0.6; }
  100% { transform: scale(1.8); opacity: 0; }
}

.tag {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-muted);
  color: var(--text-muted);
  font-family: var(--mono);
}

.dropdown {
  position: relative;
  display: inline-block;
}
.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  padding: 4px;
  z-index: 50;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  font-size: 12.5px;
  border-radius: 5px;
  cursor: pointer;
}
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-sep { height: 1px; background: var(--border); margin: 4px 0; }
