:root,
[data-theme="dark"] {
  --bg-base: #070b14;
  --bg-surface: rgba(15, 23, 42, 0.74);
  --bg-surface-elevated: rgba(20, 30, 54, 0.94);
  --bg-subtle: rgba(30, 41, 69, 0.48);
  --bg-input: rgba(10, 16, 30, 0.82);
  --border-color: rgba(148, 163, 184, 0.14);
  --border-highlight: rgba(56, 189, 248, 0.38);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-cyan: #38bdf8;
  --accent-indigo: #818cf8;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --shadow-card: 0 18px 40px -15px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --shadow-modal: 0 28px 70px -12px rgba(0, 0, 0, 0.78), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --orb-opacity: 0.28;
}

[data-theme="light"] {
  --bg-base: #f1f5f9;
  --bg-surface: rgba(255, 255, 255, 0.86);
  --bg-surface-elevated: rgba(255, 255, 255, 0.98);
  --bg-subtle: rgba(241, 245, 249, 0.9);
  --bg-input: #ffffff;
  --border-color: rgba(15, 23, 42, 0.1);
  --border-highlight: rgba(14, 165, 233, 0.42);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --accent-cyan: #0284c7;
  --accent-indigo: #4f46e5;
  --accent-emerald: #059669;
  --accent-amber: #d97706;
  --accent-rose: #e11d48;

  --shadow-card: 0 12px 32px -12px rgba(15, 23, 42, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --shadow-modal: 0 24px 60px -12px rgba(15, 23, 42, 0.22);
  --orb-opacity: 0.16;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

/* ==================== AMBIENT BACKGROUND ==================== */
.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(95px);
  opacity: var(--orb-opacity);
  animation: floatOrb 18s ease-in-out infinite alternate;
}

.orb-1 {
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, #38bdf8, transparent 70%);
  top: -160px;
  left: -100px;
}

.orb-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, #6366f1, transparent 70%);
  top: 18%;
  right: -180px;
  animation-delay: -6s;
}

.orb-3 {
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, #10b981, transparent 70%);
  bottom: -160px;
  left: 28%;
  animation-delay: -11s;
}

.grid-overlay {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(148, 163, 184, 0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(148, 163, 184, 0.04) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(ellipse at center, black 45%, transparent 90%);
}

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(35px, 28px) scale(1.08); }
}

/* ==================== TOPBAR ==================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding-top: env(safe-area-inset-top);
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 13px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.logo-svg {
  width: 28px;
  height: 28px;
}

.live-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
}

.brand-text {
  min-width: 0;
}

.brand-text h1 {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-text p {
  font-size: 0.76rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}

.telemetry-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.77rem;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
}

.pulse-ring {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  50% { opacity: 0.75; box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

/* ==================== BUTTONS ==================== */
button, a.client-btn {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.icon-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-highlight);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.sub-hub-btn,
.auto-deploy-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #10b981 0%, #0284c7 100%);
  box-shadow: 0 6px 18px -4px rgba(16, 185, 129, 0.42);
}

.sub-hub-btn:hover,
.auto-deploy-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.sub-hub-btn svg,
.auto-deploy-btn svg,
.switch-mode-btn svg,
.primary-btn svg,
.secondary-btn svg,
.ghost-btn svg {
  width: 16px;
  height: 16px;
}

.switch-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 11px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffffff;
  background: linear-gradient(135deg, #0284c7 0%, #4f46e5 100%);
  box-shadow: 0 6px 20px -4px rgba(56, 189, 248, 0.42);
}

.switch-mode-btn.in-admin {
  background: linear-gradient(135deg, #059669 0%, #0284c7 100%);
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 10px;
  font-size: 0.86rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  box-shadow: 0 6px 18px -4px rgba(14, 165, 233, 0.4);
}

.primary-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.07);
}

.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
}

.secondary-btn:hover {
  border-color: var(--border-highlight);
  background: var(--bg-surface-elevated);
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-color);
}

.ghost-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.danger-btn {
  color: var(--accent-rose);
  border-color: rgba(244, 63, 94, 0.28);
  background: rgba(244, 63, 94, 0.08);
}

.mini-btn {
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25);
}

/* ==================== LAYOUT CONTAINER ==================== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 22px 24px 40px;
}

.view-section {
  animation: fadeSlideIn 0.25s ease-out;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== KPI GRID ==================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--bg-surface);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--kpi-color, var(--accent-cyan)), transparent);
  opacity: 0.8;
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-secondary);
  font-size: 0.79rem;
  font-weight: 500;
}

.kpi-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  color: var(--kpi-color, var(--accent-cyan));
  flex-shrink: 0;
}

.kpi-icon svg {
  width: 16px;
  height: 16px;
}

.kpi-value {
  font-size: 1.48rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

/* ==================== FILTER & SEARCH TOOLBAR ==================== */
.toolbar-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.region-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 2px;
}

.region-tabs::-webkit-scrollbar {
  display: none;
}

.region-tab {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.region-tab.active {
  color: #fff;
  background: linear-gradient(135deg, #0284c7, #4f46e5);
  border-color: transparent;
  box-shadow: 0 4px 14px -3px rgba(56, 189, 248, 0.45);
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
}

.search-box svg {
  position: absolute;
  left: 12px;
  width: 15px;
  height: 15px;
  color: var(--text-muted);
}

.search-box input {
  width: 250px;
  padding: 8px 14px 8px 36px;
  border-radius: 10px;
  font-size: 0.84rem;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  outline: none;
}

.search-box input:focus {
  border-color: var(--accent-cyan);
}

.ip-mask-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  padding: 7px 12px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
}

.ip-mask-toggle input {
  accent-color: var(--accent-cyan);
}

/* ==================== VPS SERVER CARDS GRID ==================== */
.vps-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.vps-card {
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: border-color 0.22s ease;
  position: relative;
  overflow: hidden;
}

.vps-card:hover {
  border-color: var(--border-highlight);
}

.vps-card.is-stopped {
  opacity: 0.78;
  border-color: rgba(244, 63, 94, 0.22);
}

.vps-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.vps-title-wrap {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.flag-box {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  flex-shrink: 0;
}

.vps-title-info {
  min-width: 0;
  flex: 1;
}

.vps-title-info h3 {
  font-size: 1.04rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.provider-tag {
  font-size: 0.69rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.22);
}

.agent-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.vps-meta-row {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.ip-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.73rem;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
}

.vps-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-pill.online {
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.28);
}

.status-pill.stopped {
  color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.28);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status-pill.online .status-dot {
  box-shadow: 0 0 8px currentColor;
}

.sparkline-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
}

.sparkline-svg {
  width: 72px;
  height: 22px;
}

.probe-btn {
  padding: 4px 9px;
  border-radius: 7px;
  font-size: 0.73rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
}

/* ==================== TELEMETRY METRICS ==================== */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.metric-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.metric-val {
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-bar {
  height: 5px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  overflow: hidden;
}

.mini-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s ease;
}

/* ==================== TRAFFIC PROGRESS ==================== */
.traffic-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 13px;
  padding: 11px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.traffic-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  gap: 8px;
  flex-wrap: wrap;
}

.traffic-label {
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 7px;
}

.reset-badge {
  font-size: 0.69rem;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(129, 140, 248, 0.13);
  color: var(--accent-indigo);
  border: 1px solid rgba(129, 140, 248, 0.25);
}

.traffic-numbers {
  font-weight: 600;
  color: var(--text-primary);
}

.traffic-bar {
  height: 7px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  overflow: hidden;
}

.traffic-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, #818cf8, #34d399);
  transition: width 0.5s ease;
}

.traffic-bar-fill.warn {
  background: linear-gradient(90deg, #f59e0b, #f43f5e);
}

/* ==================== 3 NODES PANEL ==================== */
.nodes-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nodes-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.nodes-header-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.copy-all-btn,
.vps-sub-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 8px;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.24);
}

.vps-sub-btn {
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.26);
}

.copy-all-btn:disabled,
.vps-sub-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.node-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
}

.node-item.node-disabled {
  opacity: 0.55;
}

.node-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.node-avail-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.node-avail-dot.ok {
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.75);
}

.node-avail-dot.down {
  background: #f43f5e;
}

.node-avail-dot.off {
  background: #64748b;
}

.proto-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  flex-shrink: 0;
  border: 1px solid transparent;
}

.proto-vless {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.26);
}

.proto-hy2 {
  color: #a78bfa;
  background: rgba(167, 139, 250, 0.13);
  border-color: rgba(167, 139, 250, 0.28);
}

.proto-trojan {
  color: #34d399;
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.26);
}

.proto-other {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.26);
}

.node-name {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-right {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.node-stat-chip {
  font-size: 0.72rem;
  color: var(--text-secondary);
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.09);
}

.latency-chip {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
}

.lat-fast { color: var(--accent-emerald); background: rgba(16, 185, 129, 0.12); }
.lat-mid { color: var(--accent-cyan); background: rgba(56, 189, 248, 0.12); }
.lat-slow { color: var(--accent-amber); background: rgba(245, 158, 11, 0.14); }
.lat-off { color: var(--text-muted); background: rgba(100, 116, 139, 0.14); }

.copy-node-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.76rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #0284c7, #4f46e5);
}

.copy-node-btn.copied {
  background: linear-gradient(135deg, #059669, #10b981);
}

.copy-node-btn:disabled {
  background: rgba(100, 116, 139, 0.25);
  color: var(--text-muted);
  cursor: not-allowed;
}

.detail-node-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-color);
}

.detail-node-btn svg {
  width: 15px;
  height: 15px;
}

/* ==================== SUBSCRIPTION HUB & QR CODE ==================== */
.sub-scope-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-subtle);
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.sub-scope-bar label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.sub-scope-bar select {
  flex: 1;
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
}

.sub-layout {
  display: grid;
  grid-template-columns: 1.45fr 0.95fr;
  gap: 20px;
  align-items: start;
}

.sub-left {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.client-import-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.client-btn {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.client-btn:hover {
  border-color: var(--accent-cyan);
  transform: translateY(-1px);
}

.client-btn strong {
  font-size: 0.86rem;
}

.client-btn span {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.sub-url-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.sub-url-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sub-url-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 5px 10px;
  min-width: 0;
}

.sub-url-info input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  outline: none;
  min-width: 0;
}

.sub-qr-panel {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.qr-mode-tabs,
.deploy-mode-tabs {
  display: flex;
  width: 100%;
  background: var(--bg-input);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  gap: 4px;
}

.qr-tab,
.deploy-tab {
  flex: 1;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
}

.qr-tab.active,
.deploy-tab.active {
  color: #fff;
  background: linear-gradient(135deg, #0284c7, #4f46e5);
}

.qr-box {
  width: 196px;
  height: 196px;
  padding: 8px;
  background: #fff;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.qr-box.qr-sm {
  width: 168px;
  height: 168px;
}

.qr-svg {
  width: 100%;
  height: 100%;
}

.qr-caption {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.4;
}

.single-node-qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: var(--bg-subtle);
  border-radius: 14px;
  border: 1px solid var(--border-color);
}

/* ==================== AUTO DEPLOY TERMINAL ==================== */
.deploy-pane {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.terminal-box {
  background: #050811;
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 12px;
  overflow: hidden;
}

.terminal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(15, 23, 42, 0.9);
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  font-size: 0.76rem;
  color: #94a3b8;
}

.terminal-box pre {
  padding: 12px 14px;
  max-height: 210px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.76rem;
  color: #34d399;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.5;
}

/* ==================== BACKEND ADMIN CONSOLE ==================== */
.admin-banner {
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 22px 24px;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.admin-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 9px;
  border-radius: 6px;
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.28);
  margin-bottom: 6px;
}

.admin-banner-info h2 {
  font-size: 1.22rem;
  font-weight: 700;
}

.admin-banner-info p {
  font-size: 0.83rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.admin-banner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-vps-card {
  background: var(--bg-surface);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.admin-vps-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-color);
}

.admin-vps-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.admin-vps-meta h3 {
  font-size: 1.02rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-vps-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 3px;
  word-break: break-all;
}

.admin-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.81rem;
  font-weight: 600;
  user-select: none;
  padding: 6px 11px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
}

.toggle-switch input {
  display: none;
}

.slider-pill {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.45);
  transition: background 0.2s;
  flex-shrink: 0;
}

.slider-pill::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .slider-pill {
  background: var(--accent-emerald);
}

.toggle-switch input:checked + .slider-pill::after {
  transform: translateX(16px);
}

.admin-nodes-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.admin-node-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-node-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.admin-node-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.83rem;
  font-weight: 600;
  min-width: 0;
}

.admin-node-title span.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-node-uri {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.73rem;
  color: var(--text-muted);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 6px 9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-node-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.73rem;
  color: var(--text-secondary);
}

/* ==================== MODALS ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(3, 7, 18, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  animation: fadeIn 0.18s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  width: 100%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 90dvh;
}

.modal-sm { max-width: 430px; }
.modal-md { max-width: 560px; }
.modal-lg { max-width: 880px; }

.shake {
  animation: shakeAnim 0.36s ease;
}

@keyframes shakeAnim {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  50% { transform: translateX(8px); }
  75% { transform: translateX(-5px); }
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.modal-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.25);
  flex-shrink: 0;
}

.modal-icon svg {
  width: 19px;
  height: 19px;
}

.modal-header h3 {
  font-size: 1.02rem;
  font-weight: 700;
}

.modal-header p {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.close-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--text-secondary);
  background: transparent;
  flex-shrink: 0;
}

.modal-body {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.scrollable-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.form-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--accent-cyan);
  padding-bottom: 7px;
  border-bottom: 1px dashed var(--border-color);
}

.mt-lg { margin-top: 6px; }

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.form-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.span-2 { grid-column: span 2; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input,
.form-group select,
.mono-textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 0.86rem;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.mono-textarea:focus {
  border-color: var(--accent-cyan);
}

.mono-textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  resize: vertical;
  line-height: 1.45;
}

.password-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrap input { padding-right: 40px; }

.pwd-eye-btn {
  position: absolute;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pwd-eye-btn svg { width: 16px; height: 16px; }

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.form-hint code {
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--bg-subtle);
  color: var(--accent-cyan);
}

.form-error {
  font-size: 0.8rem;
  color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.25);
  padding: 8px 12px;
  border-radius: 9px;
}

.switch-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8rem;
  color: var(--text-primary);
  cursor: pointer;
}

.switch-inline input { accent-color: var(--accent-emerald); }

.nodes-editor-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.node-editor-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.node-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 700;
}

.node-detail-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.detail-stat-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 9px 10px;
}

.detail-stat-box span {
  display: block;
  font-size: 0.71rem;
  color: var(--text-secondary);
}

.detail-stat-box strong {
  font-size: 0.9rem;
  color: var(--text-primary);
}

.divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 4px 0;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

/* ==================== MOBILE BOTTOM NAVIGATION (Hidden on Desktop) ==================== */
.mobile-bottom-nav {
  display: none;
}

/* ==================== TOASTS ==================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  min-width: 240px;
  max-width: 360px;
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-card);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-primary);
  animation: toastIn 0.25s ease-out;
}

.toast.success { border-left: 4px solid var(--accent-emerald); }
.toast.error { border-left: 4px solid var(--accent-rose); }
.toast.info { border-left: 4px solid var(--accent-cyan); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 20px;
  background: var(--bg-surface);
  border: 1px dashed var(--border-color);
  border-radius: 18px;
  color: var(--text-secondary);
}

/* ==================== TABLET & MOBILE ADAPTATION ==================== */
@media (max-width: 1180px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .vps-grid {
    grid-template-columns: 1fr;
  }
  .admin-nodes-grid {
    grid-template-columns: 1fr;
  }
  .sub-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  body {
    padding-bottom: calc(74px + env(safe-area-inset-bottom));
  }

  .hide-mobile,
  .hide-mobile-nav {
    display: none !important;
  }

  .topbar-inner {
    padding: 10px 15px;
  }

  .brand-text p {
    display: none;
  }

  .brand-text h1 {
    font-size: 1rem;
  }

  .container {
    padding: 14px 14px 28px;
  }

  /* 2-column KPI on mobile, last card spans full width cleanly */
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
  }

  .kpi-card {
    padding: 13px 14px;
  }

  .kpi-card:last-child {
    grid-column: span 2;
  }

  .kpi-value {
    font-size: 1.25rem;
  }

  /* Filter & Search stacked smoothly */
  .toolbar-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 16px;
  }

  .region-tabs {
    width: 100%;
  }

  .toolbar-right {
    width: 100%;
  }

  .search-box input {
    width: 100%;
    font-size: 16px; /* Prevents iOS Safari zoom on focus */
    padding: 9px 12px 9px 36px;
  }

  /* Mobile VPS Card layout */
  .vps-card {
    padding: 15px;
    border-radius: 16px;
    gap: 13px;
  }

  .vps-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .vps-header-right {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding-top: 8px;
    border-top: 1px dashed var(--border-color);
  }

  .metrics-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  /* Touch-friendly 2-row Node Item on Mobile */
  .node-item {
    flex-direction: column;
    align-items: stretch;
    gap: 9px;
    padding: 11px 12px;
  }

  .node-right {
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
  }

  .copy-node-btn {
    flex: 1;
    min-height: 36px;
    font-size: 0.8rem;
  }

  .detail-node-btn {
    width: 36px;
    height: 36px;
  }

  /* Admin console mobile */
  .admin-banner {
    padding: 16px;
    border-radius: 16px;
  }

  .admin-banner-actions {
    width: 100%;
  }

  .admin-banner-actions button {
    flex: 1;
    min-height: 40px;
  }

  .admin-vps-card {
    padding: 15px;
  }

  .admin-controls {
    width: 100%;
  }

  .admin-controls .secondary-btn,
  .admin-controls .ghost-btn {
    flex: 1;
    min-height: 38px;
  }

  /* Bottom Sheet Modals on Mobile */
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card {
    max-width: 100%;
    max-height: 92dvh;
    border-radius: 22px 22px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .modal-header {
    padding: 15px 16px;
  }

  .modal-body {
    padding: 16px;
  }

  .form-grid-3,
  .form-grid-4,
  .client-import-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

  .form-group input,
  .form-group select,
  .mono-textarea,
  .sub-scope-bar select {
    font-size: 16px; /* Prevents iOS zoom */
  }

  .deploy-mode-tabs {
    flex-direction: column;
  }

  /* Mobile Fixed Bottom Navigation Bar */
  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: var(--bg-surface-elevated);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    border-top: 1px solid var(--border-color);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 25px rgba(0, 0, 0, 0.3);
  }

  .m-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 5px 4px;
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 600;
  }

  .m-nav-item svg {
    width: 20px;
    height: 20px;
  }

  .m-nav-item.active {
    color: var(--accent-cyan);
    background: rgba(56, 189, 248, 0.1);
  }

  /* Toast positioned cleanly above mobile bottom bar */
  .toast-container {
    left: 14px;
    right: 14px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    align-items: center;
  }

  .toast {
    width: 100%;
    max-width: 100%;
  }
}

@media (max-width: 420px) {
  .hide-xs {
    display: none !important;
  }
}
