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

:root {
  --primary: #f6821f;
  --primary-dark: #e5711a;
  --accent: #8b5cf6;
  --accent-dark: #7c3aed;
  --secondary: #404040;
  --success: #10b981;
  --success-dark: #059669;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-hover: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 2.5rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
}

.section-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* Info Panel */
.info-panel {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 2rem;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  flex-wrap: wrap;
}

.info-item {
  text-align: center;
}

.info-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.info-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.badge-enabled {
  color: var(--success) !important;
}

/* Controls Section */
.controls {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.button-group {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.stats-panel {
  display: flex;
  gap: 2rem;
  justify-content: center;
  flex-wrap: wrap;
}

.stat {
  text-align: center;
  padding: 1rem 2rem;
  background: var(--bg);
  border-radius: 8px;
  min-width: 120px;
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-accent {
  background: var(--accent);
  color: white;
}

.btn-accent:hover {
  background: var(--accent-dark);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: var(--success-dark);
}

.btn-secondary {
  background: var(--secondary);
  color: white;
}

.btn-secondary:hover {
  background: #505050;
}

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

.btn-danger:hover {
  background: #dc2626;
}

.btn-warning {
  background: var(--warning);
  color: black;
}

.btn-warning:hover {
  background: #d97706;
}

.btn-info {
  background: var(--info);
  color: white;
}

.btn-info:hover {
  background: #2563eb;
}

.btn-large {
  padding: 1rem 2.5rem;
  font-size: 1.125rem;
}

/* Benchmarks Section */
.benchmarks {
  margin-bottom: 2rem;
}

.benchmarks h2 {
  margin-bottom: 0.5rem;
  color: var(--text);
}

.benchmark-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.benchmark-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  transition: border-color 0.2s ease;
}

.benchmark-card:hover {
  border-color: var(--primary);
}

.benchmark-card.card-cached {
  border-color: var(--accent);
  border-width: 2px;
}

.benchmark-card.card-cached:hover {
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.2);
}

.benchmark-card.card-replication {
  border-color: var(--success);
  border-width: 2px;
}

.benchmark-card.card-replication:hover {
  border-color: var(--success);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.benchmark-card h3 {
  color: var(--text);
  margin-bottom: 0.5rem;
}

.benchmark-card p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.benchmark-card .btn {
  width: 100%;
  justify-content: center;
}

.benchmark-card .result {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  font-size: 0.875rem;
  min-height: 60px;
  display: none;
}

.benchmark-card .result.visible {
  display: block;
}

.benchmark-card .result.success {
  border-left: 3px solid var(--success);
}

.benchmark-card .result.error {
  border-left: 3px solid var(--danger);
}

.benchmark-card .result.cache-hit {
  border-left: 3px solid var(--accent);
}

.benchmark-card .result.replica {
  border-left: 3px solid var(--success);
}

.replica-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 0.5rem;
}

.replica-badge.primary {
  background: rgba(246, 130, 31, 0.2);
  color: var(--primary);
}

.replica-badge.replica {
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
}

/* Comparison Section */
.comparison-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  text-align: center;
}

.comparison-section h2 {
  margin-bottom: 0.5rem;
}

.suite-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1rem;
  flex-wrap: wrap;
}

/* Comparison Results */
.comparison-summary {
  display: flex;
  gap: 2rem;
  justify-content: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.speedup-badge {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  padding: 1rem 2rem;
  border-radius: 12px;
  text-align: center;
}

.speedup-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: white;
}

.speedup-label {
  font-size: 0.875rem;
  color: rgba(255,255,255,0.8);
}

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.comparison-column {
  background: var(--bg);
  border-radius: 12px;
  padding: 1rem;
}

.comparison-column h3 {
  text-align: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.comparison-item {
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--bg-card);
  border-radius: 8px;
}

.comparison-item .op-name {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.comparison-item .op-duration {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.comparison-item.cache-hit .op-duration {
  color: var(--accent);
}

/* Results Section */
.results-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.results-section h2 {
  margin-bottom: 1.5rem;
}

.results-summary {
  display: flex;
  gap: 2rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.summary-item {
  background: var(--bg);
  padding: 1rem 1.5rem;
  border-radius: 8px;
  text-align: center;
}

.summary-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.summary-label {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Chart */
.results-chart {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
}

.chart-bar {
  display: flex;
  align-items: center;
  margin-bottom: 0.75rem;
}

.chart-label {
  width: 200px;
  font-size: 0.875rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.chart-bar-container {
  flex: 1;
  height: 24px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-right: 1rem;
}

.chart-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: 4px;
  transition: width 0.5s ease;
}

.chart-bar-fill.cached {
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
}

.chart-value {
  width: 80px;
  text-align: right;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  font-size: 0.875rem;
  color: var(--text);
}

/* Results Table */
.results-table {
  width: 100%;
  border-collapse: collapse;
}

.results-table th,
.results-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.results-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.results-table td {
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  font-size: 0.875rem;
}

.results-table tbody tr:hover {
  background: var(--bg-hover);
}

.status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-badge.success {
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
}

.status-badge.error {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

.status-badge.cache-hit {
  background: rgba(139, 92, 246, 0.2);
  color: var(--accent);
}

/* History Section */
.history-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.history-section h2 {
  margin-bottom: 1rem;
}

.history-list {
  max-height: 300px;
  overflow-y: auto;
}

.history-item {
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
}

.history-item .timestamp {
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.history-item .duration {
  font-weight: 600;
  color: var(--primary);
}

/* Loading State */
.loading {
  position: relative;
  color: transparent !important;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Responsive */
@media (max-width: 1024px) {
  .comparison-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }

  header h1 {
    font-size: 1.75rem;
  }

  .button-group {
    flex-direction: column;
  }

  .button-group .btn {
    width: 100%;
    justify-content: center;
  }

  .stats-panel {
    gap: 1rem;
  }

  .stat {
    padding: 0.75rem 1rem;
    min-width: 90px;
  }

  .chart-label {
    width: 120px;
    font-size: 0.75rem;
  }

  .results-table {
    font-size: 0.75rem;
  }

  .results-table th,
  .results-table td {
    padding: 0.5rem;
  }

  .suite-buttons {
    flex-direction: column;
  }

  .suite-buttons .btn {
    width: 100%;
  }
}
