/* =========================================================
   VibeMonitor Clean Theme (Solid, Crisp, No Glassmorphism)
   Clean, high-contrast, modern flat card UI without blur
   ========================================================= */

.node-management { position: relative; display: inline-block; }
.node-management > summary { list-style: none; }
.node-management > summary::-webkit-details-marker { display: none; }
.node-management-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  display: grid;
  gap: 6px;
  min-width: 180px;
  padding: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
}
.node-selection-list { display: grid; gap: 8px; }
.node-selection-list .btn { justify-content: flex-start; white-space: normal; overflow-wrap: anywhere; text-align: left; }

:root {
  /* Light Mode */
  --background: #f8fafc;
  --foreground: #0f172a;
  --card-bg: #ffffff;
  --card-hover: #f1f5f9;
  --card-data-bg: #f1f5f9;
  --primary: #0d9488;
  --primary-light: #ccfbf1;
  --primary-text: #ffffff;
  --muted: #e2e8f0;
  --muted-foreground: #64748b;
  --border: #e2e8f0;
  --border-focus: #0d9488;
  --success: #10b981;
  --warning: #f59e0b;
  --destructive: #ef4444;
  --control-bg: #ffffff;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

[data-theme="dark"] {
  /* Dark Mode (Default) */
  --background: #0b0f19;
  --foreground: #f8fafc;
  --card-bg: #131b2e;
  --card-hover: #19233c;
  --card-data-bg: #0b0f19;
  --primary: #10b981;
  --primary-light: rgba(16, 185, 129, 0.15);
  --primary-text: #052e16;
  --muted: #1e293b;
  --muted-foreground: #94a3b8;
  --border: #1e293b;
  --border-focus: #10b981;
  --success: #10b981;
  --warning: #f59e0b;
  --destructive: #f43f5e;
  --control-bg: #131b2e;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--background);
  color: var(--foreground);
  min-height: 100vh;
  line-height: 1.5;
  transition: background-color 0.2s ease, color 0.2s ease;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 24px 60px;
}

/* Solid Clean Navigation Bar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
  padding: 16px 24px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: var(--card-data-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.brand-icon svg {
  width: 22px;
  height: 22px;
  display: block;
}

.brand-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--foreground);
}

.brand-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-speed {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted-foreground);
  font-size: 13px;
  white-space: nowrap;
}

.nav-speed span:first-child { color: var(--success); }
.nav-speed span:last-child { color: #3b82f6; }

/* Solid Stats Overview Bar */
.stats-banner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.stat-box:hover {
  transform: translateY(-2px);
  border-color: var(--border-focus);
}

.stat-label {
  font-size: 12px;
  color: var(--muted-foreground);
  font-weight: 500;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--foreground);
  display: flex;
  align-items: baseline;
  gap: 6px;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  font-size: 13px;
  color: var(--muted-foreground);
  font-weight: 400;
}

/* Controls & Filter Bar */
.controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 22px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--control-bg);
  color: var(--foreground);
  transition: all 0.15s ease;
  user-select: none;
}

.btn:hover {
  background: var(--card-hover);
  border-color: var(--border-focus);
}

.btn.active, .btn-primary {
  background: var(--primary);
  color: var(--primary-text);
  font-weight: 700;
  border-color: var(--primary);
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.12);
  color: var(--destructive);
  border-color: rgba(244, 63, 94, 0.25);
}

.btn-danger:hover {
  background: var(--destructive);
  color: white;
}

/* Node Grid - Solid Modern Cards */
.node-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.node-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.node-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-focus);
  box-shadow: var(--shadow-md);
}

.node-card.offline {
  opacity: 0.65;
}

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

.node-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.node-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #64748b;
  position: relative;
  flex-shrink: 0;
}

.node-status-dot.online {
  background: var(--success);
}

.node-status-dot.online::after {
  content: "";
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  border-radius: 50%;
  border: 1.5px solid var(--success);
  animation: cleanPulse 2s infinite ease-out;
}

@keyframes cleanPulse {
  0% { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(2.2); opacity: 0; }
}

.node-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--foreground);
  word-break: break-word;
  letter-spacing: -0.2px;
}

.node-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--card-data-bg);
  color: var(--muted-foreground);
  border: 1px solid var(--border);
}

.badge-region {
  background: var(--primary-light);
  color: var(--primary);
  border-color: transparent;
}

.node-specs {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--muted-foreground);
  padding: 8px 12px;
  background: var(--card-data-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

/* Metric Bars */
.metric-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.metric-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.metric-name {
  color: var(--muted-foreground);
  font-weight: 500;
}

.metric-value {
  color: var(--foreground);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--card-data-bg);
  border-radius: 9999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar {
  height: 100%;
  border-radius: 9999px;
  background: var(--primary);
  transition: width 0.3s ease, background-color 0.2s ease;
}

.progress-bar.high {
  background: var(--warning);
}

.progress-bar.critical {
  background: var(--destructive);
}

/* Network & Stats Box */
.node-footer {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 10px 12px;
  background: var(--card-data-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
}

.footer-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.footer-label {
  color: var(--muted-foreground);
  font-size: 11px;
}

.footer-val {
  color: var(--foreground);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Mini Sparkline */
.sparkline-box {
  height: 32px;
  width: 100%;
}

/* Latency / Ping Section */
.node-ping-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--card-data-bg);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.ping-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted-foreground);
  font-weight: 600;
}

.ping-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ping-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--foreground);
  font-weight: 600;
}

.ping-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ping-pill.good {
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.25);
  background: rgba(16, 185, 129, 0.08);
}
.ping-pill.good .ping-dot {
  background: var(--success);
}

.ping-pill.warn {
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.25);
  background: rgba(245, 158, 11, 0.08);
}
.ping-pill.warn .ping-dot {
  background: var(--warning);
}

.ping-pill.bad {
  color: var(--destructive);
  border-color: rgba(244, 63, 94, 0.25);
  background: rgba(244, 63, 94, 0.08);
}
.ping-pill.bad .ping-dot {
  background: var(--destructive);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 90%;
  max-width: 500px;
  padding: 26px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 18px;
  transform: translateY(12px);
  transition: transform 0.2s ease;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--foreground);
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted-foreground);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}

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

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted-foreground);
}

.form-input {
  background: var(--card-data-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--foreground);
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.code-box {
  background: #020617;
  color: var(--primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  word-break: break-all;
  user-select: all;
}

/* Ping Latency Fluctuation Modal */
.modal-lg {
  max-width: 760px;
}

.ping-pill {
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.ping-pill:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.time-range-group {
  display: inline-flex;
  background: var(--control-bg);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.range-btn {
  background: transparent;
  border: none;
  color: var(--muted-foreground);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.range-btn:hover {
  color: var(--foreground);
}
.range-btn.active {
  background: var(--primary);
  color: #ffffff;
}

.target-pill-btn {
  background: var(--control-bg);
  border: 1px solid var(--border);
  color: var(--foreground);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.target-pill-btn:hover {
  border-color: var(--primary);
}
.target-pill-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.ping-stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
@media (max-width: 600px) {
  .ping-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.ping-stat-card {
  background: var(--control-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}
.ping-stat-label {
  font-size: 11px;
  color: var(--muted-foreground);
  margin-bottom: 4px;
}
.ping-stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--foreground);
}

.ping-chart-container {
  position: relative;
  width: 100%;
  height: 240px;
  background: var(--control-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

#pingChartSvg {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-tooltip {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(15, 23, 42, 0.9);
  color: #f8fafc;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  z-index: 10;
}

@media (max-width: 768px) {
  .container {
    padding: 16px 16px 40px;
  }
  .navbar {
    flex-direction: column;
    align-items: stretch;
    padding: 16px 18px;
  }
  .nav-actions {
    justify-content: space-between;
  }
  .controls-bar {
    flex-direction: column;
    align-items: stretch;
  }
}

/* Compact node overview with independent targets and billing. */
.node-metrics, .billing-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 14px; }
.node-metrics { align-items: start; }
.node-metrics .metric-meta { flex-wrap: wrap; gap: 4px; }
.node-metrics .metric-value { font-size: 12px; }
.node-card { gap: 12px; padding: 16px; }
.price-badge { margin-left: auto; font-weight: 600; }
.billing-reset { font-weight: 600; white-space: nowrap; }
.billing-form { margin: 16px 0; }
.billing-form label { display: grid; gap: 6px; font-size: 13px; }
.billing-summary { display:flex; flex-wrap:wrap; gap:8px 16px; background:var(--card-data-bg); border-radius:12px; padding:10px 12px; font-size:12px; }
.node-summary { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; }
.summary-box { display:flex; flex-direction:column; justify-content:center; gap:5px; min-height:64px; padding:10px 12px; border-radius:12px; background:var(--card-data-bg); color:var(--muted-foreground); }
.summary-value { font-size:13px; font-weight:600; white-space:nowrap; }
.summary-value.up { color:var(--success); } .summary-value.down { color:#2563eb; }
.ping-panels { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.ping-panel { min-width:0; padding:12px; background:var(--card-data-bg); border-radius:14px; }
.panel-label, .ping-empty { color:var(--muted-foreground); font-size:13px; }
.ping-sample-row { display:block; width:100%; background:transparent; color:var(--foreground); border:0; padding:10px 0 0; cursor:pointer; text-align:left; }
.ping-row-heading { display:flex; justify-content:space-between; gap:4px; font-size:12px; margin-bottom:7px; }
.ping-row-heading > span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ping-row-heading strong { white-space:nowrap; }
.target-dot { display:inline-block; width:8px; height:8px; border-radius:50%; margin-right:5px; }
.target-0 { background:#fb7185; } .target-1 { background:#34d399; } .target-2 { background:#60a5fa; }
.sample-bars { display:flex; gap:2px; }
.sample-bar { flex:1; height:13px; border-radius:2px; background:var(--border); }
.sample-bar.fast { background:#a3e635; } .sample-bar.received { background:#35a680; }
.sample-bar.slow { background:#fbbf24; } .sample-bar.lost { background:#fb7185; }
.sample-bar.empty { opacity:.35; }
@media (max-width:400px) { .ping-panels { grid-template-columns:1fr; } }
@media (max-width:480px) { .node-summary { gap:6px; } .summary-box { padding:8px; } .summary-value { font-size:11px; } }
