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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: radial-gradient(circle at 15% 15%, rgba(255, 1, 154, 0.25), transparent 45%),
    linear-gradient(135deg, var(--ak-blue-deep, #01153a) 0%, var(--ak-blue, #0161E8) 100%);
  min-height: 100vh;
  color: var(--ak-ink, #00F1FF);
  padding: 20px;
}

.app {
  max-width: 1600px;
  margin: 0 auto;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 30px;
}

.header h1 {
  font-size: 2rem;
  margin-bottom: 8px;
  background: linear-gradient(90deg, var(--ak-cyan, #00F1FF), var(--ak-pink, #FF019A));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--ak-ink-muted, rgba(0, 241, 255, 0.7));
  font-size: 1rem;
}

/* Controls */
.controls {
  background: rgba(1, 97, 232, 0.25);
  border: 1px solid var(--ak-border, rgba(0, 241, 255, 0.5));
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-end;
  justify-content: center;
}

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

.control-group.buttons {
  flex-direction: row;
  align-items: flex-end;
}

.control-group label {
  font-size: 0.8rem;
  color: var(--ak-ink-muted, rgba(0, 241, 255, 0.7));
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

select, button, input[type="number"] {
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  font-size: 0.95rem;
  cursor: pointer;
}

select, input[type="number"] {
  background: rgba(1, 97, 232, 0.4);
  color: var(--ak-ink, #00F1FF);
  border: 1px solid rgba(0, 241, 255, 0.3);
  min-width: 120px;
}

input[type="number"] {
  width: 80px;
}

button {
  background: linear-gradient(90deg, var(--ak-cyan, #00F1FF), var(--ak-pink, #FF019A));
  color: var(--ak-ink-dark, #001a3d);
  font-weight: 600;
  transition: transform 0.2s, box-shadow 0.2s;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(0, 241, 255, 0.45);
}

button:active {
  transform: translateY(0);
}

button.toggle-btn {
  background: rgba(1, 97, 232, 0.45);
  color: var(--ak-ink, #00F1FF);
  border: 1px solid var(--ak-border, rgba(0, 241, 255, 0.5));
}

button.toggle-btn.active {
  background: linear-gradient(90deg, var(--ak-cyan, #00F1FF), var(--ak-pink, #FF019A));
  color: var(--ak-ink-dark, #001a3d);
}

button.toggle-btn:hover {
  box-shadow: 0 5px 20px rgba(0, 241, 255, 0.35);
}

#reset-btn {
  background: linear-gradient(90deg, var(--ak-pink, #FF019A), var(--ak-purple, #9B00E8));
  color: #fff;
}

input[type="range"] {
  width: 100px;
  cursor: pointer;
}

#concurrency-value {
  color: #fff;
  font-weight: bold;
  min-width: 20px;
  text-align: center;
}

.spike-indicator {
  background: var(--ak-pink, #FF019A);
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: bold;
  animation: pulse 1s ease-in-out infinite;
}

.spike-indicator.hidden {
  display: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* View Toggle */
.view-toggle {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
}

.view-btn {
  background: rgba(1, 97, 232, 0.45);
  color: var(--ak-ink, #00F1FF);
  border: 1px solid var(--ak-border, rgba(0, 241, 255, 0.5));
  padding: 10px 30px;
}

.view-btn.active {
  background: linear-gradient(90deg, var(--ak-cyan, #00F1FF), var(--ak-pink, #FF019A));
  color: var(--ak-ink-dark, #001a3d);
}

/* Queue Columns - Card View */
.queues-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 30px;
}

.queue-column {
  background: rgba(1, 97, 232, 0.2);
  border: 1px solid rgba(0, 241, 255, 0.2);
  border-radius: 12px;
  padding: 20px;
}

.queue-column h2 {
  font-size: 1.3rem;
  margin-bottom: 4px;
  color: var(--ak-cyan, #00F1FF);
}

.queue-description {
  font-size: 0.85rem;
  color: var(--ak-ink-muted, rgba(0, 241, 255, 0.7));
  margin-bottom: 20px;
}

.queue-section {
  margin-bottom: 20px;
}

.queue-section h3 {
  font-size: 0.9rem;
  color: var(--ak-ink-muted, rgba(0, 241, 255, 0.7));
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.queue-section .count {
  background: rgba(0, 241, 255, 0.15);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.8rem;
}

.queue-section.pending h3 { color: #ffc107; }
.queue-section.in-flight h3 { color: #17a2b8; }
.queue-section.completed h3 { color: #28a745; }

.messages {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 40px;
  padding: 10px;
  background: rgba(1, 19, 45, 0.35);
  border-radius: 8px;
  max-height: 150px;
  overflow-y: auto;
}

/* Message Cards */
.message-card {
  width: 50px;
  height: 50px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: bold;
  animation: popIn 0.3s ease-out;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
}

.message-card:hover {
  transform: scale(1.1);
  z-index: 10;
}

.message-card .tenant-initial {
  font-size: 1rem;
}

.message-card .message-id {
  font-size: 0.6rem;
  opacity: 0.8;
}

.message-card.processing {
  animation: processing 0.5s ease-in-out infinite;
  box-shadow: 0 0 15px currentColor;
}

@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes processing {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Tenant Colors */
.tenant-slack { background: #4A154B; color: #fff; }
.tenant-google { background: #4285F4; color: #fff; }
.tenant-salesforce { background: #00A1E0; color: #fff; }
.tenant-hubspot { background: #FF7A59; color: #fff; }
.tenant-notion { background: #000000; color: #fff; border: 1px solid #333; }

/* Noisy Neighbor Indicator */
.message-card.noisy-neighbor {
  opacity: 0.7;
  box-shadow: 0 0 0 3px #dc3545, 0 0 15px rgba(220, 53, 69, 0.6);
  animation: noisyPulse 1s ease-in-out infinite;
}

.message-card.noisy-neighbor.processing {
  animation: noisyPulse 1s ease-in-out infinite;
}

@keyframes noisyPulse {
  0%, 100% {
    box-shadow: 0 0 0 3px #dc3545, 0 0 15px rgba(220, 53, 69, 0.6);
  }
  50% {
    box-shadow: 0 0 0 3px #dc3545, 0 0 25px rgba(220, 53, 69, 0.9);
  }
}

.noisy-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #dc3545;
  color: #fff;
  font-size: 0.6rem;
  padding: 3px 6px;
  border-radius: 4px;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  animation: badgePulse 1s ease-in-out infinite;
  z-index: 5;
}

@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* Noisy tenant indicator in legend/header */
.noisy-tenant-alert {
  background: rgba(220, 53, 69, 0.2);
  border: 1px solid #dc3545;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #dc3545;
  animation: alertPulse 2s ease-in-out infinite;
}

.noisy-tenant-alert::before {
  content: "âš ";
  font-size: 1rem;
}

@keyframes alertPulse {
  0%, 100% { background: rgba(220, 53, 69, 0.2); }
  50% { background: rgba(220, 53, 69, 0.35); }
}

/* Timeline View */
.timeline-container {
  background: rgba(1, 97, 232, 0.2);
  border: 1px solid rgba(0, 241, 255, 0.2);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 30px;
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.timeline-header h2 {
  color: var(--ak-cyan, #00F1FF);
}

.timeline-legend {
  display: flex;
  gap: 15px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 3px;
}

.timeline-queues {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.timeline-queue h3 {
  font-size: 1rem;
  color: var(--ak-ink-muted, rgba(0, 241, 255, 0.7));
  margin-bottom: 15px;
}

.timeline-chart {
  background: rgba(1, 19, 45, 0.35);
  border-radius: 8px;
  padding: 15px;
  min-height: 200px;
}

.timeline-row {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.timeline-tenant {
  width: 80px;
  font-size: 0.8rem;
  color: var(--ak-ink-muted, rgba(0, 241, 255, 0.7));
  flex-shrink: 0;
}

.timeline-bars {
  flex: 1;
  height: 24px;
  background: rgba(1, 97, 232, 0.2);
  border-radius: 4px;
  display: flex;
  gap: 2px;
  padding: 2px;
  overflow: hidden;
}

.timeline-bar {
  height: 100%;
  border-radius: 2px;
  min-width: 4px;
  transition: width 0.3s;
}

.timeline-bar.noisy {
  box-shadow: 0 0 8px rgba(220, 53, 69, 0.8);
  border: 1px solid #dc3545;
}

/* Noisy tenant row highlighting in timeline */
.timeline-row.noisy-row {
  background: rgba(220, 53, 69, 0.15);
  border-radius: 4px;
  padding: 4px;
  margin: -4px;
  margin-bottom: 8px;
}

.timeline-row.noisy-row .timeline-tenant {
  color: #dc3545;
  font-weight: bold;
}

.timeline-row.noisy-row .timeline-tenant::after {
  content: " âš ";
  font-size: 0.7rem;
}

/* Noisy indicator in timeline legend */
.legend-item.noisy .legend-color {
  box-shadow: 0 0 0 2px #dc3545, 0 0 8px rgba(220, 53, 69, 0.6);
  animation: legendNoisyPulse 1s ease-in-out infinite;
}

.legend-item.noisy::after {
  content: "NOISY";
  background: #dc3545;
  color: white;
  font-size: 0.6rem;
  padding: 2px 4px;
  border-radius: 3px;
  margin-left: 4px;
  font-weight: bold;
}

@keyframes legendNoisyPulse {
  0%, 100% { box-shadow: 0 0 0 2px #dc3545, 0 0 8px rgba(220, 53, 69, 0.6); }
  50% { box-shadow: 0 0 0 2px #dc3545, 0 0 15px rgba(220, 53, 69, 0.9); }
}

/* Stats Container */
.stats-container {
  background: rgba(1, 97, 232, 0.2);
  border: 1px solid rgba(0, 241, 255, 0.2);
  border-radius: 12px;
  padding: 20px;
}

.stats-container h2 {
  color: var(--ak-cyan, #00F1FF);
  margin-bottom: 20px;
  text-align: center;
}

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

.stats-column h3 {
  font-size: 1rem;
  color: var(--ak-ink-muted, rgba(0, 241, 255, 0.7));
  margin-bottom: 15px;
  text-align: center;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(1, 19, 45, 0.35);
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.stat-label {
  color: var(--ak-ink-muted, rgba(0, 241, 255, 0.7));
}

.stat-value {
  font-weight: bold;
  color: #fff;
}

.stat-value.best {
  color: #28a745;
}

.stat-value.worst {
  color: #dc3545;
}

.tenant-stat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(1, 19, 45, 0.35);
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 0.85rem;
}

.tenant-stat .tenant-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.tenant-stat .tenant-name {
  flex: 1;
  color: var(--ak-ink-muted, rgba(0, 241, 255, 0.7));
}

.tenant-stat .tenant-value {
  font-weight: bold;
}

/* Responsive */
@media (max-width: 1200px) {
  .queues-container,
  .timeline-queues,
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* Empty state */
.empty-state {
  color: var(--ak-ink-muted, rgba(0, 241, 255, 0.7));
  font-style: italic;
  text-align: center;
  padding: 20px;
}
