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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 900px;
  margin: 0 auto;
}

header {
  text-align: center;
  color: white;
  margin-bottom: 40px;
}

header h1 {
  font-size: 2.5em;
  margin-bottom: 10px;
}

header p {
  font-size: 1.1em;
  opacity: 0.9;
}

main {
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.form-section {
  padding: 40px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 30px;
  border-bottom: 2px solid #e0e0e0;
}

.tab-btn {
  padding: 12px 24px;
  border: none;
  background: none;
  color: #666;
  cursor: pointer;
  font-size: 1em;
  font-weight: 500;
  border-bottom: 3px solid transparent;
  transition: all 0.3s ease;
}

.tab-btn:hover {
  color: #333;
}

.tab-btn.active {
  color: #667eea;
  border-bottom-color: #667eea;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #333;
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 1em;
  font-family: inherit;
  transition: all 0.3s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

textarea {
  resize: vertical;
  font-family: 'Courier New', monospace;
  font-size: 0.95em;
}

.checkbox-group {
  display: grid;
  gap: 8px;
}

.checkbox-option {
  align-items: center;
  display: flex;
  gap: 10px;
  margin: 0;
  font-weight: 500;
}

.checkbox-option input {
  width: auto;
}

small {
  display: block;
  margin-top: 6px;
  color: #999;
  font-size: 0.9em;
}

/* Buttons */
.btn {
  padding: 12px 32px;
  border: none;
  border-radius: 6px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-block;
  text-align: center;
  text-decoration: none;
  margin-top: 10px;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  width: 100%;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
  background: #f0f0f0;
  color: #333;
  margin-right: 10px;
}

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

.btn-danger {
  background: #c62828;
  color: white;
}

.btn-danger:hover {
  background: #b71c1c;
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(198, 40, 40, 0.25);
}

.admin-help {
  color: #666;
  margin: 10px 0 20px;
}

.admin-status {
  align-items: flex-start;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 20px;
}

.admin-only {
  display: none;
}

body.admin-logged-in .admin-only {
  display: inline-block;
}

.delete-record,
.regenerate-record {
  margin: 0;
  padding: 6px 12px;
  font-size: 0.85em;
}

/* Results */
.result-container {
  margin-top: 30px;
  padding: 20px;
  border-radius: 8px;
  background: #f5f5f5;
}

.result-message {
  padding: 15px;
  border-radius: 6px;
  margin-bottom: 15px;
  font-weight: 500;
}

.result-message.success {
  background: #e8f5e9;
  color: #2e7d32;
}

.result-message.error {
  background: #ffebee;
  color: #c62828;
}

#downloadAllBadges {
  margin-bottom: 15px;
}

.results-list {
  list-style: none;
}

.results-list .result-item {
  padding: 12px 16px;
  margin-bottom: 8px;
  border-radius: 6px;
  background: white;
  border-left: 4px solid #667eea;
}

.results-list .result-item.error {
  border-left-color: #f44336;
  background: #ffebee;
}

.results-list .result-item.success {
  border-left-color: #4caf50;
  background: #e8f5e9;
}

.email-status {
  display: block;
  font-size: 0.85em;
  margin-top: 4px;
}

.email-status.sent {
  color: #2e7d32;
}

.email-status.failed {
  color: #c62828;
}

.email-status.skipped {
  color: #666;
}

/* History */
.history-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr) auto auto;
  gap: 15px;
  margin-bottom: 25px;
}

.history-table {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

thead {
  background: #f5f5f5;
}

th {
  padding: 15px;
  text-align: left;
  font-weight: 600;
  color: #333;
  border-bottom: 2px solid #e0e0e0;
}

.sort-btn {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  padding: 0;
  text-align: left;
  width: 100%;
}

.sort-btn:hover {
  color: #667eea;
}

td {
  padding: 15px;
  border-bottom: 1px solid #e0e0e0;
  color: #666;
}

tbody tr:hover {
  background: #f9f9f9;
}

/* Responsive */
@media (max-width: 600px) {
  header h1 {
    font-size: 1.8em;
  }

  .form-section {
    padding: 20px;
  }

  .tabs {
    flex-wrap: wrap;
  }

  .tab-btn {
    flex: 1;
    min-width: 100px;
  }

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

  .history-controls {
    grid-template-columns: 1fr;
  }

  table {
    font-size: 0.9em;
  }

  th, td {
    padding: 10px;
  }
}
