:root {
  --bg-deepest: #0a0a0f;
  --bg-deep: #0f1019;
  --bg-panel: #141520;
  --bg-card: #1a1b2e;
  --bg-card-hover: #1f2038;
  --bg-input: #12131f;
  --border: #2a2b45;
  --border-focus: #4f46e5;
  --text-primary: #e8e8f0;
  --text-secondary: #8888a8;
  --text-muted: #55556e;
  --accent-indigo: #6366f1;
  --accent-indigo-dim: #4f46e5;
  --accent-cyan: #22d3ee;
  --accent-green: #34d399;
  --accent-amber: #fbbf24;
  --accent-red: #f87171;
  --accent-pink: #f472b6;
  --accent-orange: #fb923c;
  --glow-indigo: rgba(99, 102, 241, 0.15);
  --glow-cyan: rgba(34, 211, 238, 0.1);
  --glow-red: rgba(248, 113, 113, 0.15);
  --border-hover: #3a3b55;
  --radius: 10px;
  --radius-lg: 16px;
  --font-mono: 'JetBrains Mono', monospace;
  --font-sans: 'Noto Sans KR', -apple-system, sans-serif;
}

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

body {
  background: var(--bg-deepest);
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── Top Nav ─── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.topbar-logo {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-weight: 700; font-size: 15px;
  letter-spacing: -0.5px;
}
.topbar-logo .icon {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-cyan));
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.topbar-nav { display: flex; gap: 2px; }
.topbar-nav button {
  background: none; border: none; color: var(--text-secondary);
  font-family: var(--font-sans); font-size: 13px; font-weight: 500;
  padding: 8px 16px; border-radius: 8px; cursor: pointer;
  transition: all 0.2s;
}
.topbar-nav button:hover { color: var(--text-primary); background: var(--bg-card); }
.topbar-nav button.active {
  color: var(--accent-cyan); background: rgba(34, 211, 238, 0.08);
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-status {
  font-family: var(--font-mono); font-size: 11px; color: var(--accent-green);
  display: flex; align-items: center; gap: 6px;
}
.topbar-status .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent-green);
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ─── Layout ─── */
.main { padding-top: 56px; min-height: 100vh; }

/* ─── Screen: Test Config ─── */
.screen { display: none; animation: fadeIn 0.3s ease; }
.screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.config-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: calc(100vh - 56px);
}

/* Left sidebar - test type selector */
.config-sidebar {
  background: var(--bg-deep);
  border-right: 1px solid var(--border);
  padding: 24px 20px;
  overflow-y: auto;
}
.sidebar-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--text-muted);
  margin-bottom: 16px;
}
.test-type-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.test-type-card::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: transparent; transition: background 0.2s;
}
.test-type-card:hover { background: var(--bg-card-hover); border-color: var(--border-hover); }
.test-type-card.selected {
  border-color: var(--accent-indigo);
  background: rgba(99, 102, 241, 0.06);
}
.test-type-card.selected::before { background: var(--accent-indigo); }
.test-type-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.test-type-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.test-type-icon.rest { background: rgba(99, 102, 241, 0.15); }
.test-type-icon.web { background: rgba(34, 211, 238, 0.15); }
.test-type-icon.ws { background: rgba(52, 211, 153, 0.15); }
.test-type-icon.graphql { background: rgba(244, 114, 182, 0.15); }
.test-type-icon.queue { background: rgba(251, 191, 36, 0.15); }
.test-type-name { font-size: 14px; font-weight: 600; }
.test-type-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
.test-type-tags { display: flex; gap: 4px; margin-top: 10px; flex-wrap: wrap; }
.tag {
  font-family: var(--font-mono); font-size: 10px; padding: 2px 8px;
  border-radius: 4px; background: var(--bg-input); color: var(--text-muted);
  border: 1px solid var(--border);
}

/* Right panel - config form */
.config-main {
  padding: 28px 36px;
  overflow-y: auto;
  max-height: calc(100vh - 56px);
}
.config-section {
  margin-bottom: 32px;
}
.config-section-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-muted);
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.config-section-title .num {
  width: 20px; height: 20px; border-radius: 5px;
  background: var(--accent-indigo); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.form-row.full { grid-template-columns: 1fr; }
.form-row.triple { grid-template-columns: 1fr 1fr 1fr; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: 12px; font-weight: 500; color: var(--text-secondary);
  display: flex; align-items: center; gap: 6px;
}
.form-label .hint {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--text-muted); background: var(--bg-input);
  padding: 1px 6px; border-radius: 3px;
}

input[type="text"], input[type="number"], input[type="url"], select, textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent-indigo);
  box-shadow: 0 0 0 3px var(--glow-indigo);
}
textarea { resize: vertical; min-height: 80px; font-size: 12px; }
select { cursor: pointer; }

.method-selector { display: flex; gap: 4px; }
.method-btn {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  padding: 8px 14px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg-input);
  color: var(--text-muted); cursor: pointer; transition: all 0.15s;
}
.method-btn:hover { border-color: var(--border-hover); color: var(--text-secondary); }
.method-btn.active { border-color: var(--accent-indigo); background: var(--glow-indigo); color: var(--accent-indigo); }

/* Slider */
.slider-group { display: flex; flex-direction: column; gap: 8px; }
.slider-header { display: flex; justify-content: space-between; align-items: center; }
.slider-value {
  font-family: var(--font-mono); font-size: 20px; font-weight: 700;
  color: var(--accent-cyan);
}
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; border-radius: 3px;
  background: var(--bg-input); outline: none; border: none; padding: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px;
  border-radius: 50%; background: var(--accent-indigo);
  border: 2px solid var(--bg-panel); cursor: pointer;
  box-shadow: 0 0 10px var(--glow-indigo);
}
.slider-labels {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 10px; color: var(--text-muted);
}

/* Ramp-up visual */
.rampup-visual {
  height: 60px; background: var(--bg-input); border-radius: 8px;
  border: 1px solid var(--border); position: relative; overflow: hidden;
  margin-top: 8px;
}
.rampup-line {
  position: absolute; bottom: 0; left: 0;
  width: 100%; height: 100%;
}

/* Toggle */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--bg-card); border-radius: 8px;
  border: 1px solid var(--border); margin-bottom: 8px;
}
.toggle-info { display: flex; flex-direction: column; gap: 2px; }
.toggle-title { font-size: 13px; font-weight: 500; }
.toggle-desc { font-size: 11px; color: var(--text-muted); }
.toggle {
  width: 40px; height: 22px; border-radius: 11px;
  background: var(--border); cursor: pointer;
  position: relative; transition: background 0.2s;
}
.toggle.on { background: var(--accent-indigo); }
.toggle::after {
  content: '';
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: transform 0.2s;
}
.toggle.on::after { transform: translateX(18px); }

/* Action buttons */
.action-bar {
  display: flex; gap: 12px; align-items: center;
  padding: 20px 0; border-top: 1px solid var(--border);
  margin-top: 16px;
}
.btn-primary {
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent-indigo), #7c3aed);
  color: #fff; border: none; padding: 12px 28px;
  border-radius: 10px; font-size: 14px; font-weight: 600;
  font-family: var(--font-sans); cursor: pointer;
  transition: all 0.2s; box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 30px rgba(99, 102, 241, 0.4); }
.btn-secondary {
  background: var(--bg-card); color: var(--text-secondary);
  border: 1px solid var(--border); padding: 12px 24px;
  border-radius: 10px; font-size: 14px; font-weight: 500;
  font-family: var(--font-sans); cursor: pointer; transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--border-hover); color: var(--text-primary); }

/* ─── Screen: Dashboard (Live Test) ─── */
.dashboard-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  padding: 24px 28px;
}

/* Stat cards row */
.stat-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.stat-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
}
.stat-card.indigo::after { background: var(--accent-indigo); }
.stat-card.cyan::after { background: var(--accent-cyan); }
.stat-card.green::after { background: var(--accent-green); }
.stat-card.amber::after { background: var(--accent-amber); }
.stat-card.red::after { background: var(--accent-red); }
.stat-label { font-size: 11px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.8px; }
.stat-value { font-family: var(--font-mono); font-size: 28px; font-weight: 700; margin: 6px 0 2px; }
.stat-card.indigo .stat-value { color: var(--accent-indigo); }
.stat-card.cyan .stat-value { color: var(--accent-cyan); }
.stat-card.green .stat-value { color: var(--accent-green); }
.stat-card.amber .stat-value { color: var(--accent-amber); }
.stat-card.red .stat-value { color: var(--accent-red); }
.stat-sub { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

/* Charts area */
.chart-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.chart-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.chart-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.chart-title { font-size: 14px; font-weight: 600; }
.chart-legend { display: flex; gap: 14px; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-secondary); }
.legend-dot { width: 8px; height: 8px; border-radius: 2px; }

/* SVG Chart placeholder */
.chart-area {
  width: 100%; height: 220px;
  background: var(--bg-input);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}

/* Live log */
.log-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  max-height: 300px;
}
.log-panel .chart-title { margin-bottom: 12px; }
.log-entries {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.8;
  overflow-y: auto;
  max-height: 240px;
}
.log-entry { padding: 2px 0; border-bottom: 1px solid rgba(42, 43, 69, 0.3); }
.log-time { color: var(--text-muted); }
.log-status-ok { color: var(--accent-green); }
.log-status-err { color: var(--accent-red); }
.log-status-warn { color: var(--accent-amber); }
.log-url { color: var(--accent-cyan); }

/* Progress bar */
.progress-bar-container {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex; align-items: center; gap: 16px;
}
.progress-info { display: flex; flex-direction: column; gap: 2px; min-width: 140px; }
.progress-label { font-size: 12px; color: var(--text-secondary); }
.progress-time { font-family: var(--font-mono); font-size: 13px; font-weight: 600; }
.progress-track { flex: 1; height: 8px; background: var(--bg-input); border-radius: 4px; overflow: hidden; }
.progress-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent-indigo), var(--accent-cyan));
  transition: width 0.5s ease;
  position: relative;
}
.progress-fill::after {
  content: '';
  position: absolute; right: 0; top: -4px; bottom: -4px; width: 20px;
  background: rgba(34, 211, 238, 0.4);
  filter: blur(8px);
}
.progress-pct { font-family: var(--font-mono); font-size: 14px; font-weight: 700; color: var(--accent-cyan); min-width: 45px; text-align: right; }
.btn-stop {
  background: var(--accent-red); color: #fff; border: none;
  padding: 8px 20px; border-radius: 8px; font-weight: 600;
  font-family: var(--font-sans); font-size: 13px; cursor: pointer;
}

/* ─── Screen: Queue Test ─── */
.queue-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  min-height: calc(100vh - 56px);
}
.queue-sidebar {
  background: var(--bg-deep);
  border-right: 1px solid var(--border);
  padding: 24px 20px;
  overflow-y: auto;
}
.queue-main {
  padding: 24px 28px;
  overflow-y: auto;
  max-height: calc(100vh - 56px);
}

/* Queue visual */
.queue-visual {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
}
.queue-pipe {
  display: flex; align-items: center; gap: 0;
  position: relative; padding: 20px 0;
}
.queue-stage {
  flex: 1; text-align: center; position: relative; z-index: 1;
}
.queue-stage-icon {
  width: 48px; height: 48px; border-radius: 12px;
  margin: 0 auto 8px; display: flex; align-items: center; justify-content: center;
  font-size: 20px; border: 2px solid var(--border);
  background: var(--bg-panel);
}
.queue-stage-icon.active { border-color: var(--accent-cyan); background: rgba(34, 211, 238, 0.08); }
.queue-stage-label { font-size: 11px; font-weight: 600; color: var(--text-secondary); }
.queue-stage-value { font-family: var(--font-mono); font-size: 18px; font-weight: 700; color: var(--accent-cyan); word-break: break-all; }
.queue-arrow {
  color: var(--text-muted); font-size: 18px; margin: 0 -4px;
  position: relative; z-index: 0;
}

/* Queue metrics grid */
.queue-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.q-metric {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.q-metric-label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.q-metric-value { font-family: var(--font-mono); font-size: 22px; font-weight: 700; }

/* ─── Screen: Results ─── */
.results-layout {
  padding: 28px 36px;
  max-width: 1200px;
  margin: 0 auto;
}
.results-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}
.result-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
}
.result-card .grade {
  font-family: var(--font-mono); font-size: 42px; font-weight: 700;
  margin: 8px 0;
}
.grade.a { color: var(--accent-green); }
.grade.b { color: var(--accent-cyan); }
.grade.c { color: var(--accent-amber); }
.grade.f { color: var(--accent-red); }
.result-card .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; }
.result-card .detail { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* Percentile table */
.percentile-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 13px;
}
.percentile-table th {
  text-align: left; padding: 10px 16px;
  font-size: 11px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 1px solid var(--border);
}
.percentile-table td {
  padding: 10px 16px;
  border-bottom: 1px solid rgba(42, 43, 69, 0.3);
}
.percentile-bar-cell { width: 40%; }
.percentile-bar-bg {
  height: 6px; background: var(--bg-input); border-radius: 3px; overflow: hidden;
}
.percentile-bar-fill { height: 100%; border-radius: 3px; background: var(--accent-indigo); }

/* ─── Screen: History ─── */
.history-layout {
  padding: 28px 36px;
}
.history-table {
  width: 100%;
  border-collapse: collapse;
}
.history-table th {
  text-align: left; padding: 12px 16px;
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-deep);
}
.history-table td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid rgba(42, 43, 69, 0.3);
}
.history-table tr:hover td { background: var(--bg-card); }
.status-badge {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  padding: 3px 10px; border-radius: 4px;
}
.status-badge.pass { background: rgba(52, 211, 153, 0.12); color: var(--accent-green); }
.status-badge.fail { background: rgba(248, 113, 113, 0.12); color: var(--accent-red); }
.status-badge.warn { background: rgba(251, 191, 36, 0.12); color: var(--accent-amber); }

/* Utilities */
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* Responsive */
@media (max-width: 1200px) {
  .stat-row { grid-template-columns: repeat(3, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .config-layout, .queue-layout { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .results-summary { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .form-row.triple { grid-template-columns: 1fr 1fr; }
  .topbar-nav { flex-wrap: wrap; gap: 2px; }
  .topbar-nav button { padding: 6px 10px; font-size: 11px; }
  .queue-metrics { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .topbar { padding: 0 12px; flex-wrap: wrap; gap: 4px; }
  .topbar-logo { font-size: 14px; }
  .topbar-nav { order: 3; width: 100%; overflow-x: auto; white-space: nowrap; padding-bottom: 4px; }
  .topbar-nav button { padding: 5px 8px; font-size: 10px; }
  .stat-row { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 20px; }
  .results-summary { grid-template-columns: 1fr; }
  .chart-area { height: 160px; }
  .history-layout, .results-layout { padding: 16px; }
  .queue-metrics { grid-template-columns: 1fr; }
}

/* Animated gradient background for running test */
.running-glow {
  position: fixed;
  top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent-indigo), var(--accent-cyan), var(--accent-indigo));
  background-size: 200% 100%;
  animation: glowSlide 2s linear infinite;
  z-index: 101;
}
@keyframes glowSlide {
  0% { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}

/* Tab sub-navigation within queue */
.sub-tabs { display: flex; gap: 2px; margin-bottom: 20px; }
.sub-tab {
  font-size: 12px; font-weight: 500; color: var(--text-muted);
  padding: 6px 14px; border-radius: 6px; cursor: pointer;
  background: none; border: 1px solid transparent;
  font-family: var(--font-sans); transition: all 0.15s;
}
.sub-tab:hover { color: var(--text-secondary); }
.sub-tab.active {
  color: var(--accent-amber); background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.2);
}

/* Header with actions */
.page-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px;
}
.page-title { font-size: 20px; font-weight: 700; }
.page-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* Accessibility: focus visible */
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .running-glow { animation: none; }
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* Log filter buttons */
.log-filter-btn.active { background: rgba(99, 102, 241, 0.15) !important; border-color: var(--accent-indigo) !important; color: var(--text-primary) !important; }

/* Inline chart SVGs */
svg.sparkline { overflow: visible; }
