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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
}

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

header {
  background: linear-gradient(135deg, #1e40af, #7c3aed);
  color: white;
  padding: 1.2rem 1rem 0.8rem;
  text-align: center;
  box-shadow: var(--shadow);
}

header h1 {
  font-size: 1.5rem;
  margin-bottom: 0.1rem;
}

.subtitle {
  font-size: 0.85rem;
  opacity: 0.85;
  margin-bottom: 0.75rem;
}

nav {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  justify-content: center;
}

.nav-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.2s;
}

.nav-btn:hover {
  background: rgba(255,255,255,0.25);
}

.nav-btn.active {
  background: white;
  color: var(--primary);
  font-weight: 600;
}

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

h2 {
  font-size: 1.3rem;
  margin-bottom: 1rem;
  color: var(--text);
}

/* Buttons */
.btn {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #d97706; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: #6b7280; color: white; }
.btn-secondary:hover { background: #4b5563; }

/* Scanner */
.scanner-container {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  text-align: center;
}

#qr-reader {
  width: 100%;
  max-width: 400px;
  margin: 1rem auto;
  border-radius: 8px;
  overflow: hidden;
}

#scanner-controls {
  margin-top: 1rem;
}

/* Result card */
.result-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1.5rem;
  margin-top: 1rem;
  box-shadow: var(--shadow);
  border-left: 5px solid var(--primary);
}

.result-card.success { border-left-color: var(--success); }
.result-card.warning { border-left-color: var(--warning); }
.result-card.error { border-left-color: var(--danger); }

.hidden { display: none !important; }

/* Search */
.search-box {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-box input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-box input:focus { border-color: var(--primary); }

#search-results {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Participant card */
.participant-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

.participant-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 15px -3px rgba(0,0,0,0.1);
}

.participant-card.checked {
  border-left: 4px solid var(--success);
  background: #f0fdf4;
}

.participant-card.pending {
  border-left: 4px solid var(--warning);
}

.participant-info { flex: 1; }

.participant-info .dorsal {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
}

.participant-info .nombre {
  font-size: 1rem;
  font-weight: 500;
  margin: 0.2rem 0;
}

.participant-info .categoria {
  font-size: 0.8rem;
  color: var(--text-light);
  background: var(--bg);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  display: inline-block;
}

.participant-status { font-size: 1.5rem; }

/* Filters */
.filters {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filters select {
  padding: 0.5rem 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  outline: none;
  background: white;
}

#participants-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Stats */
#stats-container { display: grid; gap: 1rem; }

.stat-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.stat-card h3 {
  font-size: 1rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.stat-number {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.progress-bar {
  width: 100%;
  height: 12px;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), #4ade80);
  border-radius: 6px;
  transition: width 0.5s ease;
}

/* QR Grid */
.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.qr-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.qr-card canvas { max-width: 150px; height: auto; }

.qr-card .qr-dorsal {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 0.5rem;
}

.qr-card .qr-nombre {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}

.hint {
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* Modal */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-content {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 2rem;
  max-width: 450px;
  width: 100%;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
}

.modal-content .dorsal-big {
  font-size: 3rem;
  font-weight: 800;
  color: var(--primary);
  text-align: center;
}

.modal-content .nombre-big {
  font-size: 1.3rem;
  font-weight: 600;
  text-align: center;
  margin: 0.5rem 0;
}

.modal-content .categoria-big {
  text-align: center;
  color: var(--text-light);
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.modal-content .status-badge {
  text-align: center;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.status-badge.checked { background: #dcfce7; color: #166534; }
.status-badge.pending { background: #fef3c7; color: #92400e; }

.modal-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* Send QR View */
.send-controls {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.send-stats {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.send-stats .stat-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.send-stats .stat-item strong {
  font-size: 1.1rem;
}

.send-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.send-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.send-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.send-card .send-checkbox {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.send-card .send-checkbox input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--primary);
}

.send-card .send-checkbox input[type="checkbox"]:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.send-card .send-info {
  flex: 1;
}

.send-card .send-info .dorsal {
  font-weight: 700;
  color: var(--primary);
  font-size: 1.1rem;
}

.send-card .send-info .nombre {
  font-weight: 500;
  margin: 0.15rem 0;
}

.send-card .send-info .contacto {
  font-size: 0.8rem;
  color: var(--text-light);
}

.send-card .send-info .contacto span {
  margin-right: 0.75rem;
}

.send-card .send-buttons {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.send-card .send-buttons .btn {
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
}

.btn-whatsapp {
  background: #25D366;
  color: white;
}
.btn-whatsapp:hover { background: #1da851; }

.btn-email {
  background: #0078D4;
  color: white;
}
.btn-email:hover { background: #005a9e; }

.btn-disabled {
  background: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
}
.btn-disabled:hover { background: #cbd5e1; }

.send-card .no-contact {
  font-size: 0.75rem;
  color: var(--danger);
  font-style: italic;
}

/* Bulk send progress */
.bulk-progress {
  margin-top: 1rem;
  padding: 1rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.bulk-progress .progress-text {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

/* Print styles */
@media print {
  header, nav, .filters, .btn, .hint, .search-box, .subtitle { display: none !important; }
  .qr-grid { grid-template-columns: repeat(3, 1fr); }
  .qr-card { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; }
}

/* Responsive */
@media (max-width: 600px) {
  header h1 { font-size: 1.2rem; }
  .nav-btn { font-size: 0.7rem; padding: 0.4rem 0.5rem; }
  .stat-number { font-size: 2rem; }
  .qr-grid { grid-template-columns: repeat(2, 1fr); }
}
