@import 'variables.css';

* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

.container {
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem;
}
.stats-page.container {
  max-width: 1200px;
  width: 100%;
}

/* Login */
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  margin-top: 4rem;
}
.login-card h1 {
  margin: 0 0 1.5rem;
  font-size: 1.5rem;
  font-weight: 600;
}
.login-card label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.login-card input {
  width: 100%;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}
.login-card input:focus {
  outline: none;
  border-color: var(--primary);
}
.login-card button {
  width: 100%;
  padding: 0.9rem;
  background: var(--primary);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
}
.login-card button:hover { background: var(--primary-hover); }
.login-card button:disabled { opacity: 0.6; cursor: not-allowed; }
.login-error {
  color: var(--danger);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* ========== Header commun (toutes les pages) — même placement qu’admin ==========
   Barre pleine largeur, contenu en bande 1200px. Titre à gauche, menu en haut à droite. */
.app-header {
  width: 100%;
  min-height: 2.5rem;
  margin-bottom: 1.5rem;
  padding: 0 1rem;
}
.app-header-inner {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  min-height: 2.5rem;
  display: flex;
  align-items: center;
}
.app-header-left {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}
.app-header-right {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
}
.app-header-right .nav-links-header {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
}
.app-header .nav-links-header a {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.app-header .nav-links-header a:hover {
  background: var(--border);
  color: var(--primary);
  text-decoration: none;
}
/* Lien actif : couleur pour indiquer la page courante */
.app-header .nav-links-header a.nav-link-active {
  background: var(--primary);
  color: var(--bg);
  border-color: var(--primary);
}
.app-header .nav-links-header a.nav-link-active:hover {
  background: var(--primary-hover, var(--primary));
  color: var(--bg);
}
/* Menu hamburger : masqué sur desktop, visible sur mobile/tablette */
.nav-toggle {
  display: none;
  flex-shrink: 0;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.nav-toggle-bar {
  display: block;
  width: 22px;
  height: 3px;
  background: var(--text);
  border-radius: 2px;
}
.app-header h1 { margin: 0; font-size: 1.35rem; }
.app-header-left-spacer { width: 0; min-width: 0; }
.app-title-under-menu {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: -0.75rem 0 0.75rem;
  text-align: left;
}

/* Header responsive : menu hamburger (3 barres) sur mobile uniquement */
@media (max-width: 768px) {
  .nav-toggle {
    display: flex !important;
  }
  .app-header-right .nav-links-wrapper {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2147483647;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 3rem 1rem 1rem;
  }
  body.nav-open .app-header { position: relative; z-index: 2147483647; }
  body.nav-open .choices__list--dropdown,
  body.nav-open .choices__list[aria-expanded] { display: none !important; }
  .app-header-right .nav-links-wrapper .nav-links-header {
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 2147483647;
    background: var(--surface);
    border-radius: 8px;
    padding: 0.5rem;
    min-width: 14rem;
    max-height: 85vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: var(--shadow);
  }
  .app-header-right .nav-links-wrapper .nav-links-header a {
    display: block;
    padding: 0.75rem 1rem;
    text-align: left;
    border: none;
    border-radius: 6px;
    margin-bottom: 0.25rem;
  }
  .app-header-right .nav-links-wrapper .nav-links-header a:last-child {
    margin-bottom: 0;
  }
  body.nav-open .app-header-right .nav-links-wrapper {
    display: flex;
  }
}
@media (min-width: 769px) {
  .nav-toggle { display: none !important; }
  .app-header-right .nav-links-wrapper {
    display: block;
  }
  .app-header-right .nav-links-wrapper .nav-links-header {
    display: flex;
  }
}

/* Recensement */
.recensement-status-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.gps-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0.5rem;
  border-radius: 6px;
}
.gps-status.gps-tappable {
  background: rgba(87, 171, 90, 0.15);
  cursor: pointer;
}
.gps-status.ok { color: var(--primary); }
.gps-status.error { color: var(--danger); }
.session-count {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}
.gps-status.simulated { color: var(--chart-3, #a371f7); }

.select-wrap {
  margin-bottom: 1.5rem;
}
.select-wrap label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.select-wrap select {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
}
.select-wrap select:focus { outline: none; border-color: var(--primary); }

.species-description-block {
  display: none;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-muted);
  white-space: pre-wrap;
}

/* Combobox recensement : champ texte recherche + dropdown */
.select-search-input {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}
.select-search-input:focus {
  outline: none;
  border-color: var(--primary);
}
.select-search-input::placeholder {
  color: var(--text-muted);
}
.select-dropdown {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  z-index: 100;
}
.select-wrap { position: relative; }
/* Champ recherche région : visible uniquement quand le dropdown est ouvert */
#regionWrap .choices:not(.is-open) .choices__input { display: none !important; }
.select-dropdown.is-open { display: block; }
.select-dropdown [role="option"] {
  padding: 0.6rem 1rem;
  cursor: pointer;
  color: var(--text);
  -webkit-user-select: none;
  user-select: none;
}
.select-dropdown [role="option"]:hover,
.select-dropdown [role="option"].is-selected {
  background: var(--primary);
  color: var(--bg);
}
.select-hidden-value {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Choices.js recensement : fond sombre, curseur pointeur */
.select-wrap .choices__inner {
  min-height: 2.8rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface) !important;
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
}
.select-wrap .choices__input {
  background: var(--surface2) !important;
  color: var(--text);
  font-size: 1rem;
}
.select-wrap .choices__input::placeholder {
  color: var(--text-muted);
}
.select-wrap .choices[data-type*="select-one"] .choices__input {
  background: var(--surface2) !important;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  margin-bottom: 0.35rem;
  width: 100%;
  display: block;
}
.select-wrap .choices__list--dropdown,
.select-wrap .choices__list[aria-expanded] {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface) !important;
  color: var(--text);
  box-shadow: var(--shadow);
}
.select-wrap .choices__list--dropdown .choices__item--selectable,
.select-wrap .choices__list[aria-expanded] .choices__item--selectable {
  padding: 0.5rem 1rem;
  background: transparent;
  cursor: pointer;
}
.select-wrap .choices__list--dropdown .choices__item--selectable.is-highlighted,
.select-wrap .choices__list[aria-expanded] .choices__item--selectable.is-highlighted {
  background: var(--primary);
  color: var(--bg);
}

.radius-wrap .radius-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.radius-value {
  min-width: 3rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.btn-radius {
  width: 2.75rem;
  height: 2.75rem;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.btn-radius:hover { border-color: var(--primary); color: var(--primary); }
.btn-radius:focus { outline: none; border-color: var(--primary); }
.radius-hint {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.my-records-wrap {
  margin-top: 1.5rem;
  padding: 1rem;
}
.my-records-actions { margin: 0 0 0.75rem; }
.btn-records-day {
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--bg);
  background: var(--primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.btn-records-day:hover { background: var(--primary-hover); }
.btn-records-day:disabled { opacity: 0.7; cursor: wait; }
.my-records-table-scroll {
  overflow-y: auto;
  overflow-x: auto;
  max-height: 220px;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.my-records-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
}
.my-records-title {
  font-size: 1rem;
  margin: 0 0 0.75rem;
  color: var(--text-muted);
}
.my-records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.my-records-table th,
.my-records-table td {
  padding: 0.4rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.my-records-table th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; }
.my-records-table td:nth-child(3) { font-variant-numeric: tabular-nums; }

.btn-record-wrap { width: 100%; cursor: pointer; }
.btn-record {
  width: 100%;
  min-height: 240px;
  padding: 1.5rem;
  background: var(--primary);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .1s, background .2s;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn-record:hover { background: var(--primary-hover); }
.btn-record:active { transform: scale(0.98); }
.btn-record:disabled { opacity: 0.7; cursor: pointer; transform: none; }

.last-record {
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--surface2);
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Toast recensement / app — non bloquant */
.app-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  max-width: 90%;
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.4;
  z-index: 9999;
  box-shadow: var(--shadow);
  transition: opacity 0.3s, visibility 0.3s;
  display: none;
  visibility: hidden;
  opacity: 0;
}
.app-toast.app-toast-error {
  background: var(--surface);
  border: 1px solid var(--danger);
  color: var(--danger);
}
.app-toast.app-toast-warning {
  background: var(--surface);
  border: 1px solid var(--chart-4, #db6d28);
  color: var(--chart-4, #db6d28);
}
.app-toast.app-toast-success {
  background: var(--surface);
  border: 1px solid var(--primary);
  color: var(--primary);
}
.app-toast.app-toast-force {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  max-width: min(95%, 22rem);
}
.app-toast.app-toast-force .toast-msg {
  flex: 1 1 100%;
}
.app-toast .toast-force-btn {
  flex-shrink: 0;
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}
.app-toast .toast-force-btn:hover {
  opacity: 0.9;
}
.app-toast .toast-force-btn:active {
  transform: scale(0.98);
}

.nav-links {
  margin-top: 2rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.nav-links-header {
  margin-top: 0;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.nav-links-header a {
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-links a {
  display: inline-block;
  padding: 0.45rem 0.85rem;
  color: var(--primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}
.nav-links a:hover {
  background: var(--border);
  text-decoration: none;
}

/* Stats (public + admin) — disposition horizontale, arrondis, couleurs */
.stats-page h1 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  font-weight: 600;
}
.stats-filters {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: flex-end;
}
.stats-filter-date-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.stats-filter-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}
.stats-filters input {
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
}
.stats-filters button {
  padding: 0.6rem 1.25rem;
  background: var(--primary);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
}
.stats-filters button:hover { background: var(--primary-hover); }
.admin-user-select-wrap { min-width: 12rem; }
.admin-user-select-wrap select {
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}
@media (min-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
/* Admin : un seul graphe avec légende et tableau */
.admin-stats-chart-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-soft);
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.admin-chart-main {
  height: 280px;
  margin-bottom: 1rem;
}
.admin-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1rem;
  padding: 0.5rem 0;
}
.admin-legend-btn {
  padding: 0.4rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.admin-legend-btn:hover {
  border-color: var(--legend-color, var(--primary));
  color: var(--legend-color, var(--primary));
}
.admin-legend-btn.admin-legend-active {
  background: var(--legend-color, var(--primary));
  border-color: var(--legend-color, var(--primary));
  color: var(--bg);
}
.admin-stats-table {
  margin-top: 0;
}

/* Zones scrollables responsive pour tous les tableaux admin */
.admin-table-scroll-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 280px;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0;
}
.admin-table-scroll-wrap .stats-table {
  margin: 0;
}
.admin-table-scroll-wrap .stats-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  box-shadow: 0 1px 0 var(--border);
}

/* Admin : trois courbes empilées verticalement (legacy) */
.admin-stats-grid {
  grid-template-columns: 1fr;
}
.stats-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.stats-section h2 {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chart-container {
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1rem;
}
.stats-section .chart-container {
  height: 200px;
}
.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  border-radius: var(--radius);
  overflow: hidden;
}
.stats-table th,
.stats-table td {
  padding: 0.6rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.stats-table tr:last-child td { border-bottom: none; }
.stats-table thead th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--surface);
}
.stats-table thead tr:first-child th:first-child { border-radius: var(--radius) 0 0 0; }
.stats-table thead tr:first-child th:last-child { border-radius: 0 var(--radius) 0 0; }
.stats-table tbody tr:last-child td:first-child { border-radius: 0 0 0 var(--radius); }
.stats-table tbody tr:last-child td:last-child { border-radius: 0 0 var(--radius) 0; }
.stats-table td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--primary);
}

.total-big {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface2) 100%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  display: inline-block;
  box-shadow: var(--shadow-soft);
}

/* Admin */

/* Admin : carte des localisations */
.admin-map-section {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.admin-map-section h2 { margin: 0 0 0.5rem; font-size: 1.2rem; }
.admin-map-intro {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
}
.admin-map-filters {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
}
/* Icône arbre sur la carte Leaflet — points fins pour nombreux arbres */
.leaflet-tree-icon {
  background: none !important;
  border: none !important;
}

.admin-map-filters + .admin-map-container {
  margin-top: 2rem;
}
.admin-map-select-wrap {
  min-width: 10rem;
  max-width: 100%;
  flex: 1 1 140px;
  margin-bottom: 0;
}
.admin-map-select-wrap select {
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
}
/* Choices.js : fond opaque pour lisibilité au-dessus de la carte */
.admin-map-select-wrap .choices {
  position: relative;
  z-index: 1000;
}
.admin-map-select-wrap .choices__inner {
  min-height: 2.5rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #161b22 !important;
  color: var(--text);
  font-size: 0.95rem;
}
.admin-map-select-wrap .choices__input {
  background: #21262d !important;
  color: var(--text);
  font-size: 0.95rem;
}
.admin-map-select-wrap .choices__input::placeholder {
  color: var(--text-muted);
}
.admin-map-select-wrap .choices[data-type*="select-one"] .choices__input {
  background: #21262d !important;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  margin-bottom: 0.25rem;
}
.admin-map-select-wrap .choices__list--dropdown,
.admin-map-select-wrap .choices__list[aria-expanded] {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #161b22 !important;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 1001;
}
.admin-map-select-wrap .choices__list--dropdown .choices__item--selectable,
.admin-map-select-wrap .choices__list[aria-expanded] .choices__item--selectable {
  padding: 0.5rem 0.75rem;
  background: transparent;
}
.admin-map-select-wrap .choices__list--dropdown .choices__item--selectable.is-highlighted,
.admin-map-select-wrap .choices__list[aria-expanded] .choices__item--selectable.is-highlighted {
  background: var(--primary);
  color: var(--bg);
}
.admin-map-select-wrap .choices__list--dropdown .choices__item,
.admin-map-select-wrap .choices__list[aria-expanded] .choices__item {
  color: var(--text);
}
.admin-map-filters input[type="date"] {
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #161b22 !important;
  min-width: 0;
  color: var(--text);
  font-size: 0.95rem;
}
.admin-map-filters button {
  padding: 0.6rem 1.25rem;
  background: var(--primary);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
}
.admin-map-filters button:hover { background: var(--primary-hover); }
.admin-map-container {
  min-height: 480px;
  height: 640px;
  max-width: 100%;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  overflow: hidden;
}
.admin-map-count {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0.5rem 0 0;
}

.admin-users-section {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.admin-users-section h2 { margin: 0 0 0.5rem; font-size: 1.2rem; }
.admin-users-intro {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
}
.admin-users-section .chart-by-user { height: 80px; margin-bottom: 1rem; }

/* Classement des contributeurs */
.admin-top-contributors-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-soft);
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.admin-top-contributors-section h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
}
.admin-top-contributors-intro {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
}
.admin-top-contributors-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.admin-top-contributors-controls input {
  width: 4rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.95rem;
}
.chart-top-contributors {
  height: 280px;
  margin-bottom: 1rem;
}
.admin-users-table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 320px;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.admin-users-table { width: 100%; min-width: 520px; }

/* Responsive admin : smartphone, tablette, ordinateur */
@media (max-width: 767px) {
  .admin-table-scroll-wrap { max-height: 220px; }
  .admin-users-table-wrap { max-height: 260px; }
  .admin-stats-filters { flex-direction: column; align-items: stretch; }
  .admin-user-select-wrap { min-width: 0; }
  .admin-chart-main { height: 220px; }
  .chart-top-contributors { height: 220px; }
  .total-big { font-size: 1.5rem; padding: 0.75rem 1rem; }
  .admin-stats-chart-section,
  .admin-top-contributors-section { padding: 1rem; }
  .admin-users-section { padding-top: 1rem; }
  .admin-users-table { min-width: 460px; }
  .admin-map-section { margin-top: 1.5rem; padding-top: 1rem; padding: 0 0.5rem; }
  .admin-map-section h2 { font-size: 1.1rem; }
  .admin-map-intro { font-size: 0.85rem; }
  .admin-map-filters { flex-direction: column; align-items: stretch; gap: 0.6rem; }
  .admin-map-filters + .admin-map-container { margin-top: 1.25rem; }
  .admin-map-select-wrap { min-width: 0; flex: 1 1 auto; width: 100%; }
  .admin-map-filters input[type="date"] { width: 100%; max-width: 12rem; }
  .admin-map-filters button { width: 100%; }
  .admin-map-container { min-height: 300px; height: calc(100vh - 380px); max-height: 420px; }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .admin-table-scroll-wrap { max-height: 260px; }
  .admin-users-table-wrap { max-height: 300px; }
  .admin-map-container { min-height: 420px; height: 520px; }
}

@media (min-width: 1024px) {
  .admin-table-scroll-wrap { max-height: 320px; }
  .admin-users-table-wrap { max-height: 400px; }
  .admin-map-container { min-height: 540px; height: 600px; }
}
.btn-invalidate {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn-invalidate:hover { background: var(--border); }
.btn-invalidate:disabled { opacity: 0.6; cursor: not-allowed; }

@media (min-width: 600px) {
  .container { padding: 1.5rem; }
  .btn-record { min-height: 200px; font-size: 1.1rem; }
}

@media (max-width: 640px) {
  .container { padding: 1rem; }
  .btn-record {
    min-height: 128px;
    padding: 1rem 1.25rem;
    font-size: 1.15rem;
  }
  .select-wrap .choices__inner { min-height: 3rem; }
  .btn-radius { width: 3rem; height: 3rem; min-width: 48px; min-height: 48px; font-size: 1.35rem; }
}

@media (max-width: 479px) {
  .container { padding: 0.75rem; }
  .admin-map-section { padding: 0 0.25rem; }
  .admin-map-container { min-height: 280px; height: 380px; }
}

/* ========== Configuration page ========== */
.config-page.container {
  max-width: 1000px;
  width: 100%;
}
.config-page h1 {
  font-size: 1.5rem;
  margin: 0 0 1rem;
  font-weight: 600;
}
.config-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.config-tab {
  padding: 0.6rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.config-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.config-tab.config-tab-active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--bg);
}
.config-section {
  display: none;
}
.config-section.config-section-active {
  display: block;
}
.config-section h2 {
  font-size: 1.1rem;
  margin: 0 0 1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.config-form-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-soft);
}
.config-form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.config-field {
  flex: 1 1 12rem;
  min-width: 0;
  margin-bottom: 1rem;
}
.config-field label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.config-field input[type="text"],
.config-field input[type="email"],
.config-field input[type="password"] {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
  font-size: 1rem;
}
.config-field textarea {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  min-height: 4rem;
}
.config-field select {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
  font-size: 1rem;
}
.config-field-check { flex: 0 0 auto; }
.config-field-check label { display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.config-hint { font-size: 0.8rem; color: var(--text-muted); }
.config-image-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.config-image-row input[type="text"] { flex: 1; min-width: 0; }
.config-image-row input[type="file"] {
  flex-shrink: 0;
  padding: 0.4rem;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
}
.config-import-wrap {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.config-import-wrap h3 { font-size: 1rem; margin: 0 0 0.5rem; }
.config-import-hint { font-size: 0.85rem; color: var(--text-muted); margin: 0 0 0.75rem; }
.config-import-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}
.config-import-actions input[type="file"] {
  padding: 0.4rem;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
}
.config-form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.config-form-actions button {
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
}
.config-form-actions button[type="submit"] {
  background: var(--primary);
  color: var(--bg);
  border: none;
}
.config-form-actions button[type="submit"]:hover { background: var(--primary-hover); }
.config-form-actions button[type="button"] {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.config-form-actions button[type="button"]:hover { border-color: var(--primary); color: var(--primary); }
.config-list-search-wrap {
  margin-bottom: 0.75rem;
}
.config-search-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.config-list-search {
  width: 100%;
  max-width: 20rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.95rem;
}
.config-list-search:focus {
  outline: none;
  border-color: var(--primary);
}
.config-list-search::placeholder {
  color: var(--text-muted);
}
.config-table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 360px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.config-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.config-table th,
.config-table td {
  padding: 0.6rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.config-table th {
  background: var(--surface2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
}
.config-table tbody tr:last-child td { border-bottom: none; }
.config-species-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  vertical-align: middle;
}
.config-table .btn-edit,
.config-table .btn-pwd,
.config-table .btn-act,
.config-table .btn-delete {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  margin-right: 0.25rem;
  margin-bottom: 0.25rem;
}
.config-table .btn-edit:hover,
.config-table .btn-pwd:hover,
.config-table .btn-act:hover { border-color: var(--primary); color: var(--primary); }
.config-table .btn-delete:hover { border-color: var(--danger); color: var(--danger); }
.config-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 1.5rem;
}
.config-dialog::backdrop { background: rgba(0,0,0,0.5); }
.config-dialog h3 { margin: 0 0 1rem; font-size: 1.1rem; }
.config-dialog .config-field { margin-bottom: 1rem; }
.config-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-weight: 500;
  z-index: 9999;
}
.config-toast-success { border-color: var(--primary); color: var(--primary); }
.config-toast-error { border-color: var(--danger); color: var(--danger); }
/* Choices.js sur config */
.config-field .choices__inner {
  background: #161b22 !important;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.config-field .choices__list--dropdown,
.config-field .choices__list[aria-expanded] {
  background: #161b22 !important;
  color: var(--text);
}

@media (max-width: 767px) {
  .config-form-row { flex-direction: column; }
  .config-field { flex: 1 1 100%; }
  .config-form-actions { flex-wrap: wrap; }
  .config-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .config-table { min-width: 480px; }
}
