:root {
  --bg-primary: #0a0e17;
  --bg-card: rgba(18, 26, 44, 0.75);
  --bg-card-hover: rgba(28, 39, 65, 0.85);
  --border-card: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(0, 242, 254, 0.3);
  
  --accent-cyan: #00f2fe;
  --accent-blue: #4facfe;
  --accent-purple: #7f00ff;
  --accent-green: #00f5a0;
  --accent-orange: #ff9900;
  --accent-red: #ff3366;
  
  --text-primary: #ffffff;
  --text-secondary: #8e9bb4;
  --text-muted: #53627e;
  
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 20% 15%, rgba(0, 242, 254, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 80% 85%, rgba(127, 0, 255, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(10, 14, 23, 1) 0%, rgba(5, 8, 14, 1) 100%);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 24px 16px;
  overflow-x: hidden;
}

.container {
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-card);
  border-radius: 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 242, 254, 0.4);
}

.logo-icon svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

.logo-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, #ffffff, #a5b4fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.server-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 30px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-green);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-green);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

/* Tabs */
.mode-tabs {
  display: flex;
  gap: 12px;
  background: rgba(255, 255, 255, 0.03);
  padding: 6px;
  border-radius: 16px;
  border: 1px solid var(--border-card);
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  background: transparent;
  border: none;
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s ease;
}

.tab-btn.active {
  background: var(--bg-card);
  color: #fff;
  border: 1px solid var(--border-card);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.tab-btn:hover:not(.active) {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

/* Dashboard Grid */
.dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-card);
  border-radius: 18px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  transition: background 0.3s ease;
}

.metric-card.active::before {
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
  box-shadow: 0 0 12px var(--accent-cyan);
}

.metric-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.metric-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.metric-icon {
  width: 16px;
  height: 16px;
  opacity: 0.8;
}

.metric-value-box {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 4px;
}

.metric-value {
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.metric-unit {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Speedometer Area */
.gauge-section {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-card);
  border-radius: 28px;
  padding: 36px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.gauge-container {
  position: relative;
  width: 320px;
  height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#gaugeCanvas {
  width: 320px;
  height: 240px;
}

.gauge-center-info {
  position: absolute;
  bottom: 25px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.live-speed-value {
  font-size: 3.4rem;
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(135deg, #ffffff 0%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  filter: drop-shadow(0 4px 12px rgba(0, 242, 254, 0.3));
}

.live-speed-unit {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 1px;
  margin-top: 4px;
}

.test-stage-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 2px;
}

/* Real-time Chart */
.chart-container {
  width: 100%;
  max-width: 800px;
  height: 100px;
  margin-top: 20px;
}

#liveChartCanvas {
  width: 100%;
  height: 100px;
}

/* Control Button */
.controls-area {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.btn-start {
  background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-blue) 50%, var(--accent-purple) 100%);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 16px 48px;
  font-size: 1.2rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 242, 254, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.4);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-start:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 15px 40px rgba(0, 242, 254, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.6);
}

.btn-start:active {
  transform: translateY(1px) scale(0.98);
}

.btn-start.running {
  background: linear-gradient(135deg, var(--accent-red) 0%, #a80038 100%);
  box-shadow: 0 10px 30px rgba(255, 51, 102, 0.4);
}

/* Progress bar */
.progress-bar-wrapper {
  width: 100%;
  max-width: 480px;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  overflow: hidden;
  display: none;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
  border-radius: 6px;
  transition: width 0.1s linear;
}

/* Diagnostic Log Section */
.log-section {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-card);
  border-radius: 20px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
}

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

.log-title-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
}

.btn-copy-log {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-copy-log:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.log-terminal {
  background: rgba(5, 8, 14, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.log-line {
  color: #cbd5e1;
  word-break: break-all;
}

.log-line.info { color: var(--accent-cyan); }
.log-line.success { color: var(--accent-green); }
.log-line.warn { color: var(--accent-orange); }
.log-line.error { color: var(--accent-red); }

/* Server View Hero Box */
.server-hero-box {
  padding: 48px 32px;
  text-align: center;
}

.server-status-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 640px;
}

.server-pulse-icon {
  width: 80px;
  height: 80px;
  border-radius: 24px;
  background: rgba(0, 242, 254, 0.1);
  border: 1px solid rgba(0, 242, 254, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 30px rgba(0, 242, 254, 0.2);
}

.server-title {
  font-size: 1.6rem;
  font-weight: 700;
  background: linear-gradient(90deg, #fff, #a5b4fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.server-desc {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.server-desc strong {
  color: var(--accent-cyan);
}

.server-bench-progress {
  margin-top: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.95rem;
  color: var(--accent-cyan);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(0, 242, 254, 0.2);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Footer / Meta info */
.meta-info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.meta-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.meta-icon-box {
  width: 42px;
  height: 42px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.meta-icon-box svg {
  width: 22px;
  height: 22px;
  fill: var(--accent-cyan);
}

.meta-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meta-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.meta-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Responsive */
@media (max-width: 768px) {
  .dashboard {
    grid-template-columns: repeat(2, 1fr);
  }
  .meta-info-grid {
    grid-template-columns: 1fr;
  }
  .gauge-container, #gaugeCanvas {
    width: 280px;
    height: 210px;
  }
  .live-speed-value {
    font-size: 2.8rem;
  }
}
