:root {
  --bg-primary: #0a0b0f;
  --bg-surface: #12141a;
  --bg-elevated: #1a1d24;
  --border: #1e293b;
  --border-light: #2d3748;

  --accent-cyan: #22d3ee;
  --accent-cyan-glow: rgba(34, 211, 238, 0.4);
  --accent-amber: #f59e0b;
  --accent-green: #10b981;
  --accent-red: #ef4444;

  --text-primary: #e6e9ef;
  --text-secondary: #9aa4b2;
  --text-muted: #64748b;

  --font-display: 'JetBrains Mono', monospace;
  --font-body: 'IBM Plex Sans', sans-serif;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --transition: 0.2s ease;
}

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

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

/* Subtle grid background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(34, 211, 238, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: 0;
}

.dashboard {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 20px;
  gap: 20px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

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

.logo-mark {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-cyan-glow));
  border-radius: var(--radius-sm);
  box-shadow: 0 0 20px var(--accent-cyan-glow);
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 20px var(--accent-cyan-glow); }
  50% { box-shadow: 0 0 30px var(--accent-cyan-glow), 0 0 40px var(--accent-cyan-glow); }
}

.logo-text {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 2px;
}

.logo-sub {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 3px;
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-green);
  letter-spacing: 2px;
}

.live-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-green);
  border-radius: 50%;
  animation: blink 1s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.clock {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 1px;
}

/* Stats Row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-cyan), transparent);
}

.stat-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-trend {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--accent-green);
  margin-top: 8px;
}

.stat-spark {
  height: 30px;
  margin-top: 12px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
}

.spark-bar {
  flex: 1;
  background: var(--accent-cyan);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  opacity: 0.6;
  transition: height 0.3s ease;
}

/* Main Grid */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  grid-template-rows: 1fr 1fr;
  gap: 16px;
  flex: 1;
}

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-secondary);
}

.panel-badge {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-elevated);
  color: var(--accent-cyan);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.panel-badge.pulse {
  animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 10px var(--accent-cyan-glow); }
}

/* Activations Panel */
.activations-panel {
  grid-row: span 2;
}

.activations-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.activation-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: slide-in 0.3s ease;
}

.activation-card.new {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px var(--accent-cyan-glow);
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.activation-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.activation-serial {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-cyan);
}

.activation-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
}

.activation-time {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--text-muted);
}

/* Geo Panel */
.geo-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.geo-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 6px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}

.geo-location {
  font-size: 13px;
  color: var(--text-primary);
}

.geo-count {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-cyan);
}

.geo-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.geo-bar-fill {
  height: 100%;
  background: var(--accent-cyan);
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* Events Panel */
.events-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  font-family: var(--font-display);
  font-size: 12px;
}

.event-item {
  padding: 8px 10px;
  margin-bottom: 4px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  display: flex;
  gap: 10px;
  align-items: center;
  animation: fade-in 0.2s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.event-type {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.event-type.tap { background: var(--accent-cyan); color: var(--bg-primary); }
.event-type.consent { background: var(--accent-green); color: var(--bg-primary); }
.event-type.click { background: var(--accent-amber); color: var(--bg-primary); }

.event-serial {
  color: var(--text-secondary);
}

.event-time {
  margin-left: auto;
  color: var(--text-muted);
}

/* Devices Panel */
.devices-chart {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.device-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.device-label {
  font-size: 13px;
  color: var(--text-secondary);
  width: 80px;
}

.device-bar-container {
  flex: 1;
  height: 24px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.device-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-cyan-glow));
  border-radius: var(--radius-sm);
  transition: width 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
}

.device-percent {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  color: var(--bg-primary);
}

/* Footer */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.footer-left, .footer-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.campaign-label {
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 2px;
}

.campaign-select {
  font-family: var(--font-display);
  font-size: 12px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: pointer;
}

.campaign-select:focus {
  outline: none;
  border-color: var(--accent-cyan);
}

#last-update {
  font-size: 12px;
  color: var(--text-muted);
}

.api-status {
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--accent-green);
}

.api-status.error {
  color: var(--accent-red);
}

/* Empty State */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 100px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Auth Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  width: 100%;
  max-width: 360px;
}

.modal-logo {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-cyan-glow));
  border-radius: var(--radius-md);
  margin: 0 auto 24px;
  box-shadow: 0 0 30px var(--accent-cyan-glow);
}

.modal-content h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.modal-content p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.modal-content input {
  width: 100%;
  font-family: var(--font-display);
  font-size: 14px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  text-align: center;
  letter-spacing: 2px;
}

.modal-content input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-cyan-glow);
}

.modal-content button {
  width: 100%;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 2px;
  background: var(--accent-cyan);
  color: var(--bg-primary);
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  transition: var(--transition);
}

.modal-content button:hover {
  background: #06b6d4;
  box-shadow: 0 0 20px var(--accent-cyan-glow);
}

.auth-error {
  color: var(--accent-red);
  font-size: 13px;
  margin-top: 16px;
  min-height: 20px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-elevated);
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

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

  .main-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .activations-panel {
    grid-row: span 1;
    max-height: 400px;
  }
}

@media (max-width: 768px) {
  .dashboard {
    padding: 12px;
  }

  .header {
    flex-direction: column;
    gap: 12px;
  }

  .logo-sub {
    display: none;
  }

  .stats-row {
    grid-template-columns: 1fr;
  }

  .stat-value {
    font-size: 28px;
  }
}
