:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ========== NAVBAR ========== */
#nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.02em;
}
.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.nav-links a:hover {
  color: var(--text);
  background: var(--border-light);
}
/* Force le bouton s'inscrire à être lisible */
.nav-links .btn-primary {
  background: var(--primary) !important;
  color: #fff !important;
  border: none !important;
  padding: 8px 16px !important;
}
.nav-links .btn-primary:hover {
  background: var(--primary-dark) !important;
  color: #fff !important;
}
.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav-user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}
.nav-user-name strong {
  color: var(--text);
  font-weight: 600;
}

/* ========== BOUTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
  background: none;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-outline {
  background: var(--surface);
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-outline:hover {
  border-color: var(--text-muted);
  color: var(--text);
  background: var(--bg);
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--border-light);
  color: var(--text);
}
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #fecaca;
}
.btn-danger:hover {
  background: #fee2e2;
}
.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 6px;
}
.btn-lg {
  padding: 14px 28px;
  font-size: 15px;
  border-radius: var(--radius);
}
.btn-block {
  width: 100%;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ========== AUTH ========== */
.auth-page {
  min-height: calc(100vh - 65px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.auth-card h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
}
.auth-sub {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 28px;
}
.auth-alt {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--text-secondary);
}
.auth-alt a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}
.auth-alt a:hover {
  text-decoration: underline;
}

/* ========== FORMULAIRES ========== */
.form-group {
  margin-bottom: 18px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: all 0.15s;
}
.form-group input::placeholder {
  color: var(--text-muted);
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='%2364748b' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
.password-wrap {
  position: relative;
}
.password-wrap input {
  padding-right: 44px;
}
.toggle-pw {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.toggle-pw:hover {
  opacity: 1;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
  border: 1px solid #fecaca;
}
.form-success {
  background: #f0fdf4;
  color: var(--success);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
  border: 1px solid #bbf7d0;
}

/* ========== DASHBOARD ========== */
.dashboard {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}
.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}
.dash-header h2 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}
.dash-header p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}
.dash-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.badge {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-success {
  background: #d1fae5;
  color: var(--success);
}
.badge-warning {
  background: #fef3c7;
  color: var(--warning);
}
.dash-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s;
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.stat-card-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}
.stat-card-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 6px;
  font-weight: 500;
}
.upgrade-banner {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid #fbbf24;
  border-radius: var(--radius);
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 14px;
}
.upgrade-banner strong {
  color: #92400e;
  font-size: 15px;
}
.upgrade-banner p {
  color: #a16207;
  font-size: 13px;
  margin-top: 2px;
}
.dash-section {
  margin-bottom: 36px;
}
.dash-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}
.dash-section h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.filter-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.filter-form h4 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 18px;
  color: var(--text);
}
.filters-list {
  display: grid;
  gap: 12px;
}
.filter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s;
}
.filter-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-light);
}
.filter-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.filter-card-header strong {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.filter-card-actions {
  display: flex;
  gap: 4px;
}
.filter-card-details {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.filter-tag {
  background: var(--bg);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border-light);
}
.test-results {
  margin-top: 14px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 320px;
  overflow-y: auto;
}
.test-offer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  gap: 12px;
}
.test-offer:last-child {
  border-bottom: none;
}
.test-offer a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}
.test-offer a:hover {
  text-decoration: underline;
}
.test-offer span {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}
.email-log-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.email-log-item + .email-log-item {
  margin-top: 8px;
}

/* ========== ADMIN ========== */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.admin-card h4 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.admin-card .big {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
}
.admin-card .big.green {
  color: var(--success);
}
.admin-card .big.blue {
  color: var(--primary);
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
}
.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
}
.admin-table tr:hover td {
  background: var(--bg);
}

/* ========== UTILS ========== */
.hidden {
  display: none !important;
}
.empty-state {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 48px 20px;
}
.error {
  color: var(--danger);
}
.success {
  color: var(--success);
}
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  align-items: center;
  flex-wrap: wrap;
}

/* Modal overlay */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden {
  display: none !important;
}
.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-content h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}

/* Admin table actions */
.admin-table .actions {
  display: flex;
  gap: 4px;
}
.admin-table .actions .btn {
  padding: 4px 8px;
  font-size: 12px;
}

/* Divider */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 640px) {
  .form-row {
    grid-template-columns: 1fr;
  }
  .dash-header {
    flex-direction: column;
  }
  .nav-inner {
    padding: 12px 16px;
  }
  .auth-card {
    padding: 28px 20px;
  }
  .upgrade-banner {
    flex-direction: column;
    align-items: flex-start;
  }
  .admin-grid {
    grid-template-columns: 1fr;
  }
  .modal-content {
    padding: 20px;
  }
}
