/* ========================================================
   Abstenscan — Feuille de style principale
   ======================================================== */

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

:root {
  --primary:       #003189;
  --primary-dark:  #001f5c;
  --primary-light: #e8ecf8;
  --accent:        #E63946;
  --success:       #16a34a;
  --success-bg:    #dcfce7;
  --warning:       #d97706;
  --warning-bg:    #fef3c7;
  --danger:        #dc2626;
  --danger-bg:     #fee2e2;
  --info:          #0284c7;
  --info-bg:       #e0f2fe;
  --bg:            #f1f5f9;
  --surface:       #ffffff;
  --surface-2:     #f8fafc;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --border:        #e2e8f0;
  --shadow:        0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:     0 4px 6px -1px rgba(0,0,0,.10), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg:     0 10px 25px -3px rgba(0,0,0,.15), 0 4px 6px -2px rgba(0,0,0,.05);
  --radius:        8px;
  --radius-sm:     4px;
  --radius-lg:     12px;
}

/* --------------------------------------------------------
   Base
   -------------------------------------------------------- */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-size: 0.85em;
  font-family: 'Consolas', 'Courier New', monospace;
}

/* --------------------------------------------------------
   Layout
   -------------------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--primary);
  height: 64px;
  box-shadow: var(--shadow-md);
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-icon  { font-size: 1.4rem; }
.brand-name  { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; }
.header-nav  { display: flex; align-items: center; gap: 16px; }
.username    { color: rgba(255,255,255,.75); font-size: .85rem; }

.app-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px;
}
.app-footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: .75rem;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}
.footer-analyze { margin-top: 6px; }
.footer-analyze-link {
  color: var(--border);
  font-size: .7rem;
  text-decoration: none;
  transition: color .2s;
}
.footer-analyze-link:hover { color: var(--text-muted); text-decoration: underline; }

/* --------------------------------------------------------
   Page header
   -------------------------------------------------------- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title    { font-size: 1.65rem; font-weight: 700; letter-spacing: -0.025em; }
.page-subtitle { color: var(--text-muted); margin-top: 4px; font-size: .9rem; }

/* Fil d'Ariane */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.breadcrumb a   { color: var(--primary); }
.breadcrumb-sep { color: var(--border); }

/* --------------------------------------------------------
   Statistiques
   -------------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  border-left: 4px solid transparent;
}
.stat-card--success { border-left-color: var(--success); }
.stat-card--danger  { border-left-color: var(--accent); }

.stat-value         { font-size: 1.7rem; font-weight: 700; line-height: 1; }
.stat-label         { font-size: .78rem; color: var(--text-muted); margin-top: 5px; }
.stat-sub           { font-size: .75rem; color: var(--warning); margin-top: 4px; font-weight: 500; }
.stat-pct           { font-size: .82rem; font-weight: 700; }
.stat-pct--success  { color: var(--success); }
.stat-pct--danger   { color: var(--accent); }

/* Mini barre de progression dans les stat-cards */
.stat-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 10px;
  overflow: hidden;
}
.stat-bar-fill             { height: 100%; border-radius: 2px; transition: width .4s ease; }
.stat-bar-fill--success    { background: var(--success); }
.stat-bar-fill--danger     { background: var(--accent); }

/* --------------------------------------------------------
   Card
   -------------------------------------------------------- */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 24px;
}
.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.card-title { font-size: .95rem; font-weight: 600; }
.card-body  { padding: 24px; }

/* --------------------------------------------------------
   Table
   -------------------------------------------------------- */
.table-responsive { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th {
  padding: 10px 16px;
  text-align: left;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover          { background: var(--surface-2); }
tr.not-signed td               { background: #fff5f5; }
tr.not-signed:hover td         { background: #ffe8e8; }

/* Colonne adresse : autorise le retour à la ligne sur les longues adresses */
.table-electeurs td:nth-child(4) { word-break: break-word; min-width: 160px; }
/* Colonnes courtes : pas de coupure forcée */
.table-electeurs td:nth-child(5),
.table-electeurs td:nth-child(6) { white-space: nowrap; }

/* --------------------------------------------------------
   Progress
   -------------------------------------------------------- */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 110px;
}
.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width .5s ease;
  min-width: 2px;
}
.progress-text { font-size: .75rem; color: var(--text-muted); white-space: nowrap; }

/* --------------------------------------------------------
   Boutons
   -------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none;
  transition: all .15s ease;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:hover    { text-decoration: none; }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--surface-2); }

.btn-ghost {
  background: transparent;
  color: rgba(255,255,255,.85);
  border: 1px solid rgba(255,255,255,.3);
}
.btn-ghost:hover { background: rgba(255,255,255,.12); color: white; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { filter: brightness(.9); }

.btn-danger  { background: var(--danger); color: white; }
.btn-danger:hover  { filter: brightness(.9); }

.btn-sm   { padding: 5px 10px; font-size: .8rem; }
.btn-full { width: 100%; justify-content: center; }

.action-btns { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }

.btn-delete-bureau {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: #dc2626;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: background .15s;
}
.btn-delete-bureau:hover { background: #b91c1c; }
.action-btns--col { flex-direction: column; align-items: stretch; gap: 5px; }
.action-btns--col .btn { justify-content: center; text-align: center; }

/* --------------------------------------------------------
   Badges
   -------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .02em;
}
.badge-pending    { background: var(--warning-bg); color: var(--warning); }
.badge-processing { background: var(--info-bg);    color: var(--info);    }
.badge-done       { background: var(--success-bg); color: var(--success); }
.badge-error      { background: var(--danger-bg);  color: var(--danger);  }
.badge-warning    { background: var(--warning-bg); color: var(--warning); }
.badge-voted      { background: var(--success-bg); color: var(--success); }
.badge-not-voted  { background: var(--danger-bg);  color: var(--danger);  }

/* --------------------------------------------------------
   Alertes
   -------------------------------------------------------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: .875rem;
}
.alert-error   { background: var(--danger-bg);  color: var(--danger);  border-left: 3px solid var(--danger);  }
.alert-success { background: var(--success-bg); color: var(--success); border-left: 3px solid var(--success); }
.alert-info    { background: var(--info-bg);    color: var(--info);    border-left: 3px solid var(--info);    }

/* Boîte info (cron) */
.info-box {
  background: var(--info-bg);
  border: 1px solid #bae6fd;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: .875rem;
  color: #0369a1;
}
.info-box a { color: #0369a1; font-weight: 600; }

/* --------------------------------------------------------
   Formulaires
   -------------------------------------------------------- */
.form-group        { margin-bottom: 16px; }
.form-group label  {
  display: block;
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: 6px;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
  outline: none;
  font-family: inherit;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-row     { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.required     { color: var(--danger); }

/* --------------------------------------------------------
   Modales
   -------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(3px);
}
.modal-dialog {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-dialog-sm { max-width: 380px; }
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: .95rem; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.4rem;
  color: var(--text-muted);
  line-height: 1;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-body   { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* --------------------------------------------------------
   Zone d'upload
   -------------------------------------------------------- */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all .2s ease;
  background: var(--surface-2);
  user-select: none;
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}
.upload-zone h3  { font-size: .95rem; font-weight: 600; margin-bottom: 6px; }
.upload-zone p   { font-size: .8rem; color: var(--text-muted); }

/* --------------------------------------------------------
   Panneau de progression global des uploads
   -------------------------------------------------------- */
#upload-global {
  display: none;
  margin-top: 16px;
  border-radius: var(--radius-lg);
  border: 1.5px solid #c7d4f0;
  background: linear-gradient(135deg, #eef2fc 0%, #f5f7ff 100%);
  overflow: hidden;
}
#upload-global.active { display: block; }

/* En-tête : compteur à gauche, pourcentage à droite */
.upload-global-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px 9px;
  gap: 10px;
}
.upload-global-title {
  font-weight: 700;
  font-size: .9rem;
  color: var(--primary-dark);
  flex: 1;
  min-width: 0;
}
.upload-global-pct {
  background: var(--primary);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  padding: 3px 11px;
  border-radius: 99px;
  flex-shrink: 0;
  letter-spacing: .02em;
}

/* Barre de progression pleine largeur */
.upload-global-bar {
  height: 6px;
  background: rgba(0,49,137,.12);
  margin: 0 16px 11px;
  border-radius: 99px;
  overflow: hidden;
}
.upload-global-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, #4d79d6 100%);
  border-radius: 99px;
  transition: width .4s ease;
}

/* Badges de statuts */
.upload-global-stats {
  display: flex;
  gap: 6px;
  padding: 0 16px 13px;
  flex-wrap: wrap;
  align-items: center;
}
.upload-stat-done,
.upload-stat-err,
.upload-stat-skip,
.upload-stat-active {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .74rem;
  font-weight: 600;
  white-space: nowrap;
}
.upload-stat-done   { background: var(--success-bg); color: var(--success); }
.upload-stat-err    { background: var(--danger-bg);  color: var(--danger);  }
.upload-stat-skip   { background: var(--warning-bg); color: var(--warning); }
.upload-stat-active { background: var(--info-bg);    color: var(--info);    font-style: normal; }

/* Bouton d'actualisation */
.upload-reload-wrap {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 0 16px 14px;
  flex-wrap: wrap;
}
.upload-reload-wrap .text-muted { font-size: .78rem; }

/* --------------------------------------------------------
   Liste des fichiers — scrollable, hauteur max 280 px
   -------------------------------------------------------- */
#upload-list {
  margin-top: 12px;
  max-height: 280px;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* Scrollbar discrète */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
#upload-list::-webkit-scrollbar       { width: 5px; }
#upload-list::-webkit-scrollbar-track { background: transparent; }
#upload-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.upload-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 5px;
  font-size: .8rem;
  transition: background .15s;
}
.upload-item:last-child { margin-bottom: 0; }

.upload-status { flex-shrink: 0; font-size: .85rem; line-height: 1; }

.upload-filename {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  color: var(--text);
}
.upload-filesize {
  color: var(--text-muted);
  font-size: .68rem;
  margin-left: 3px;
}
.upload-progress {
  width: 80px;
  height: 4px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  flex-shrink: 0;
}
.upload-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width .2s ease;
}
.upload-pct {
  font-size: .68rem;
  color: var(--text-muted);
  width: 30px;
  text-align: right;
  flex-shrink: 0;
}

/* --------------------------------------------------------
   Onglets
   -------------------------------------------------------- */
.tabs {
  border-bottom: 1px solid var(--border);
  display: flex;
  padding: 0 24px;
  gap: 4px;
}
.tab-btn {
  padding: 12px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .15s;
  font-family: inherit;
}
.tab-btn:hover  { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane         { display: none; }
.tab-pane.active  { display: block; }

.tab-toolbar { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }

.requeue-feedback { font-size: .85rem; padding: 4px 10px; border-radius: 4px; }
.requeue-feedback--ok  { background: #dcfce7; color: #166534; }
.requeue-feedback--err { background: #fee2e2; color: #991b1b; }

/* --------------------------------------------------------
   Filtres électeurs
   -------------------------------------------------------- */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; padding: 16px 24px 0; }
.filter-btn {
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: .8rem;
  font-family: inherit;
  transition: all .15s;
}
.filter-btn:hover,
.filter-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* --------------------------------------------------------
   Photo thumbnail
   -------------------------------------------------------- */
.photo-thumb {
  width: 56px;
  height: 42px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--border);
  display: block;
}
.photo-thumb-clickable {
  cursor: zoom-in;
  transition: opacity .15s, transform .15s;
}
.photo-thumb-clickable:hover {
  opacity: .85;
  transform: scale(1.08);
}
.error-msg {
  font-size: .72rem;
  color: var(--danger);
  margin-top: 3px;
  font-style: italic;
}

/* --------------------------------------------------------
   Lien bureau dans le tableau
   -------------------------------------------------------- */
.bureau-link { color: var(--text); font-weight: 600; }
.bureau-link:hover { color: var(--primary); text-decoration: none; }
.bureau-loc  { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }

/* Cellule photos+progression */
.bureau-photos-cell { min-width: 130px; }

/* Mini stats par bureau — grille 3 colonnes : label | valeur | % */
.bureau-stats-cell  { display: grid; grid-template-columns: auto auto auto; gap: 3px 10px; align-items: center; font-size: .8rem; }
.bureau-stat-row    { display: contents; }
.bureau-stat-label  { color: var(--text-muted); white-space: nowrap; }
.bureau-stat-pct    { color: var(--text-muted); }

/* --------------------------------------------------------
   Page de connexion
   -------------------------------------------------------- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  min-height: 100vh;
  background: linear-gradient(145deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 16px;
}
.login-container { width: 100%; max-width: 400px; }
.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.brand-icon-lg { font-size: 3rem; display: block; margin-bottom: 10px; }
.login-logo h1 { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.login-logo p  { font-size: .85rem; color: var(--text-muted); margin-top: 4px; }
.login-form    { margin-top: 8px; }
.login-footer  {
  text-align: center;
  margin-top: 16px;
  font-size: .75rem;
  color: rgba(255,255,255,.55);
}
.login-footer a { color: rgba(255,255,255,.75); }

/* --------------------------------------------------------
   État vide
   -------------------------------------------------------- */
.empty-state { text-align: center; padding: 80px 24px; color: var(--text-muted); }
.empty-icon  { font-size: 3.5rem; margin-bottom: 16px; opacity: .4; }
.empty-state h2 { font-size: 1.1rem; color: var(--text); margin-bottom: 8px; }
.empty-state p  { margin-bottom: 24px; }

/* --------------------------------------------------------
   Utilitaires
   -------------------------------------------------------- */
.text-muted   { color: var(--text-muted); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.text-center  { text-align: center; }

/* --------------------------------------------------------
   Responsive — tablette (≤ 900px)
   -------------------------------------------------------- */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}

/* --------------------------------------------------------
   Responsive — mobile large (≤ 768px)
   -------------------------------------------------------- */
@media (max-width: 768px) {
  /* Layout */
  .app-main     { padding: 16px; }
  .header-inner { padding: 0 14px; }
  .app-footer   { padding: 16px; margin-top: 24px; }

  /* Header nav : masque le nom d'utilisateur */
  .username { display: none; }
  .header-nav { gap: 8px; }
  .btn-ghost.btn-sm { padding: 5px 10px; font-size: .78rem; }

  /* Stats : 2 colonnes compactes */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
  }
  .stat-card   { padding: 14px 16px; }
  .stat-value  { font-size: 1.4rem; }
  .stat-label  { font-size: .72rem; }

  /* Page header : empile titre + bouton pleine largeur */
  .page-header { flex-direction: column; align-items: stretch; margin-bottom: 20px; }
  .page-header .btn,
  .page-header .action-btns { width: 100%; }
  .page-header .action-btns { flex-direction: column; }
  .page-header .action-btns .btn { justify-content: center; }
  .page-title { font-size: 1.35rem; }

  /* Fil d'Ariane */
  .breadcrumb { font-size: .8rem; margin-bottom: 14px; }

  /* Cards */
  .card { border-radius: var(--radius); margin-bottom: 16px; }
  .card-header { padding: 14px 16px; flex-direction: column; align-items: flex-start; }
  .card-body   { padding: 16px; }

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

  /* Modales : bottom sheet */
  .modal { align-items: flex-end; padding: 0; }
  .modal-dialog {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-width: 100%;
    max-height: 92vh;
  }
  .modal-body   { padding: 16px; }
  .modal-header { padding: 16px; }
  .modal-footer { padding: 12px 16px; flex-direction: column-reverse; gap: 8px; }
  .modal-footer .btn { width: 100%; justify-content: center; }

  /* Onglets */
  .tabs { padding: 0 12px; overflow-x: auto; }
  .tab-btn { padding: 10px 12px; font-size: .8rem; white-space: nowrap; }
  .tab-pane { overflow-x: auto; }

  /* Filtres */
  .filter-bar { padding: 12px 12px 0; gap: 6px; }
  .filter-btn { padding: 5px 12px; font-size: .75rem; }

  /* Upload */
  .upload-zone { padding: 28px 16px; }
  .upload-zone h3 { font-size: .875rem; }

  /* Login */
  .login-card { padding: 28px 20px; }

  /* Info-box : wrap le code long */
  .info-box code { word-break: break-all; display: inline-block; max-width: 100%; }

  /* Tables : scroll horizontal fluide */
  .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table th,
  .table td { padding: 9px 12px; font-size: .8rem; }

  /* Tableau bureaux : masque la colonne Photos/Analyse */
  .table-bureaux th:nth-child(2),
  .table-bureaux td:nth-child(2) { display: none; }

  /* Tableau photos : masque taille et date de traitement */
  .table-photos th:nth-child(3),
  .table-photos td:nth-child(3),
  .table-photos th:nth-child(6),
  .table-photos td:nth-child(6) { display: none; }

  /* Tableau électeurs : masque adresse, CP, ville, source */
  .table-electeurs th:nth-child(1),
  .table-electeurs td:nth-child(1),
  .table-electeurs th:nth-child(4),
  .table-electeurs td:nth-child(4),
  .table-electeurs th:nth-child(5),
  .table-electeurs td:nth-child(5),
  .table-electeurs th:nth-child(6),
  .table-electeurs td:nth-child(6),
  .table-electeurs th:nth-child(8),
  .table-electeurs td:nth-child(8) { display: none; }
}

/* --------------------------------------------------------
   Recherche globale
   -------------------------------------------------------- */
.search-block {
  margin-bottom: 28px;
}
.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
  flex-shrink: 0;
}
.search-input {
  width: 100%;
  padding: 13px 44px 13px 44px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: .95rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  box-shadow: var(--shadow);
}
.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,49,137,.1);
}
.search-input::placeholder { color: var(--text-muted); }
/* Masque l'icône × native sur Chrome/Safari */
.search-input::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 50%;
  transition: background .15s, color .15s;
}
.search-clear:hover { background: var(--border); color: var(--text); }

/* Panneau de résultats */
.search-results {
  margin-top: 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: fadeIn .15s ease;
}
.search-results-header {
  padding: 10px 18px;
  font-size: .8rem;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.search-results-header strong { color: var(--text); }
.search-no-results {
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: .9rem;
}
.search-loading {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: .875rem;
}

/* Groupe par bureau */
.search-group { border-bottom: 1px solid var(--border); }
.search-group:last-child { border-bottom: none; }
.search-group-header {
  padding: 10px 18px;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.search-group-name {
  font-weight: 600;
  font-size: .875rem;
  color: var(--primary-dark);
}
.search-group-link {
  font-size: .78rem;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
}
.search-group-link:hover { text-decoration: underline; }
.search-group-count {
  font-size: .75rem;
  color: var(--text-muted);
  background: var(--surface);
  padding: 1px 7px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* Ligne résultat */
.search-row {
  display: grid;
  grid-template-columns: 48px 1fr 1fr 2fr 80px;
  gap: 0 12px;
  align-items: center;
  padding: 9px 18px;
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
  transition: background .1s;
}
.search-row:last-child { border-bottom: none; }
.search-row:hover { background: var(--surface-2); }
.search-row-num  { color: var(--text-muted); font-size: .78rem; }
.search-row-name { font-weight: 600; }
.search-row-addr { color: var(--text-muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-row-badge { justify-self: end; }

/* Mise en valeur du terme recherché */
.search-highlight {
  background: #fff3cd;
  color: #92400e;
  border-radius: 2px;
  padding: 0 1px;
  font-weight: 600;
}

/* --------------------------------------------------------
   Lightbox photo viewer
   -------------------------------------------------------- */
.photo-source-link {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--primary);
  font-size: inherit;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
  text-align: left;
  font-family: inherit;
  transition: color .15s;
}
.photo-source-link:hover { color: var(--primary-dark); text-decoration: underline; }

.photo-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .85);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(4px);
  animation: fadeIn .15s ease;
}
.photo-viewer-close {
  position: fixed;
  top: 16px;
  right: 20px;
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  z-index: 2001;
}
.photo-viewer-close:hover { background: rgba(255,255,255,.3); }
.photo-viewer-inner {
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.photo-viewer-img {
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
}
.photo-viewer-caption {
  color: rgba(255,255,255,.75);
  font-size: .85rem;
  text-align: center;
  margin: 0;
}

/* --------------------------------------------------------
   Responsive — mobile petit (≤ 480px)
   -------------------------------------------------------- */
@media (max-width: 480px) {
  .brand-name { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card  { padding: 12px 14px; }
  .stat-value { font-size: 1.25rem; }

  /* Action buttons dans les tableaux : empilés */
  .table .action-btns { flex-direction: column; gap: 4px; }
  .table .action-btns .btn { width: 100%; justify-content: center; }
}

/* ========================================================
   Mode Terrain Mobile — Capture via caméra smartphone
   ======================================================== */

/* Corps de page terrain : fond sombre, plein écran */
.terrain-body {
  background: #0d0d0d;
  min-height: 100vh;
  overflow-x: hidden;
}

/* --------------------------------------------------------
   En-tête compact terrain
   -------------------------------------------------------- */
.terrain-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--primary-dark);
  /* Sur iOS avec viewport-fit:cover, on ajoute le safe-area-inset-top (notch/Dynamic Island) */
  height: calc(54px + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  display: flex;
  align-items: center;
  padding-left: 14px;
  padding-right: 14px;
  gap: 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,.4);
}
.terrain-header-back {
  color: rgba(255,255,255,.9);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  flex-shrink: 0;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
.terrain-header-back:hover  { background: rgba(255,255,255,.2); text-decoration: none; }
.terrain-header-back:active { background: rgba(255,255,255,.3); }
.terrain-header-title {
  flex: 1;
  color: white;
  font-weight: 700;
  font-size: .95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.terrain-header-badge {
  background: rgba(255,255,255,.18);
  color: white;
  font-size: .78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* --------------------------------------------------------
   Avertissement HTTPS
   -------------------------------------------------------- */
.terrain-https-warning {
  background: #7c2d12;
  color: #fed7aa;
  padding: 12px 18px;
  font-size: .85rem;
  line-height: 1.5;
  border-bottom: 1px solid #9a3412;
}

/* --------------------------------------------------------
   Bouton Terrain dans le header principal
   -------------------------------------------------------- */
.btn-terrain {
  background: rgba(255,255,255,.12) !important;
  border: 1px solid rgba(255,255,255,.25) !important;
  color: white !important;
  font-weight: 600;
}
.btn-terrain:hover {
  background: rgba(255,255,255,.2) !important;
  color: white !important;
  text-decoration: none;
}

/* --------------------------------------------------------
   Écran de sélection du bureau
   -------------------------------------------------------- */
.terrain-select-screen {
  padding: 24px 16px 48px;
  max-width: 560px;
  margin: 0 auto;
}
.terrain-select-intro {
  margin-bottom: 20px;
  text-align: center;
}
.terrain-select-title {
  color: white;
  font-size: 1.25rem;
  margin-bottom: 6px;
}
.terrain-select-hint {
  color: rgba(255,255,255,.55);
  font-size: .875rem;
  line-height: 1.5;
}
.terrain-bureau-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.terrain-bureau-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  text-decoration: none;
  transition: background .12s, border-color .12s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.terrain-bureau-card:hover,
.terrain-bureau-card:active {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: scale(.985);
  text-decoration: none;
}
.terrain-bureau-icon   { font-size: 1.5rem; flex-shrink: 0; }
.terrain-bureau-info   { flex: 1; min-width: 0; }
.terrain-bureau-name   { font-size: 1rem; font-weight: 700; color: var(--text); }
.terrain-bureau-loc    { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }
.terrain-bureau-arrow  { color: var(--text-muted); flex-shrink: 0; }
.terrain-empty {
  text-align: center;
  color: rgba(255,255,255,.6);
  padding: 48px 24px;
}
.terrain-empty-icon { font-size: 3rem; margin-bottom: 12px; }
.terrain-empty p    { line-height: 1.6; }

/* --------------------------------------------------------
   Écran caméra
   -------------------------------------------------------- */
.terrain-camera-screen {
  display: flex;
  flex-direction: column;
}

/* Zone vidéo */
.cam-viewport {
  position: relative;
  background: #000;
  width: 100%;
  height: 55svh;  /* small viewport height → stable sur iOS */
  height: 55vh;   /* fallback */
  overflow: hidden;
  flex-shrink: 0;
}
@supports (height: 55svh) {
  .cam-viewport { height: 55svh; }
}
#cam-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Flash blanc au moment de la capture */
.cam-flash {
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  pointer-events: none;
}

/* Overlay chargement caméra */
.cam-overlay {
  position: absolute;
  inset: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cam-overlay-inner {
  text-align: center;
  color: rgba(255,255,255,.7);
}
.cam-overlay-icon { font-size: 2.5rem; margin-bottom: 12px; }
.cam-overlay-text { font-size: .875rem; }

/* --------------------------------------------------------
   Barre de contrôles (déclencheur)
   -------------------------------------------------------- */
.cam-bar {
  background: #111;
  padding: 14px 24px calc(14px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}
.cam-counter {
  text-align: center;
  min-width: 60px;
}
.cam-counter #cam-count {
  display: block;
  color: white;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.1;
}
.cam-counter-label {
  display: block;
  color: rgba(255,255,255,.5);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* Bouton déclencheur */
.cam-shutter {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: transparent;
  border: 3.5px solid rgba(255,255,255,.85);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform .1s, border-color .1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.cam-shutter:active  { transform: scale(.91); }
.cam-shutter:disabled { opacity: .38; cursor: not-allowed; }
.cam-shutter-inner {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: white;
  display: block;
  transition: background .1s, transform .1s;
}
.cam-shutter:active .cam-shutter-inner { background: #ccc; transform: scale(.95); }
.cam-shutter:disabled .cam-shutter-inner { background: #888; }

.cam-bar-link {
  text-align: center;
  min-width: 60px;
  color: rgba(255,255,255,.7);
  font-size: .72rem;
  text-decoration: none;
  line-height: 1.4;
  padding: 6px 8px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.06);
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
.cam-bar-link:hover { background: rgba(255,255,255,.12); color: white; text-decoration: none; }

/* --------------------------------------------------------
   Messages (erreur / fallback)
   -------------------------------------------------------- */
.cam-message {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 32px 24px;
  gap: 8px;
}
.cam-message--error { background: #1a0a0a; color: rgba(255,255,255,.8); }
.cam-message--warn  { background: #1a150a; color: rgba(255,255,255,.8); }
.cam-message-icon   { font-size: 2.5rem; margin-bottom: 4px; }
.cam-message h3     { color: white; font-size: 1.05rem; }
.cam-message p      { font-size: .875rem; line-height: 1.5; color: rgba(255,255,255,.65); }
.cam-message-or     { color: rgba(255,255,255,.35); font-size: .8rem; }

/* --------------------------------------------------------
   Liste des captures de la session
   -------------------------------------------------------- */
.cam-list-section {
  background: var(--bg);
  flex: 1;
}
.cam-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  font-weight: 700;
  font-size: .78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.cam-list-link {
  font-size: .78rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--primary);
  text-decoration: none;
}
.cam-list-link:hover { text-decoration: underline; }
.cam-list-empty {
  padding: 28px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: .875rem;
  line-height: 1.6;
}
.cam-list {
  padding: 4px 0;
}

/* Item capture */
.cam-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  animation: camItemIn .2s ease;
}
@keyframes camItemIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cam-item:last-child { border-bottom: none; }
.cam-item-thumb {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--border);
}
.cam-item-info   { flex: 1; min-width: 0; }
.cam-item-name   { font-size: .875rem; font-weight: 600; }
.cam-item-label  { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.cam-item-progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.cam-item-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width .25s ease;
}
.cam-item-status { font-size: 1.2rem; flex-shrink: 0; }

/* ========================================================
   QR Code — modale admin + impression
   ======================================================== */

.btn-qr { gap: 5px; }

/* Contenu de la modale */
.qr-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  padding-bottom: 24px;
}

/* Cadre du QR code généré */
.qr-container {
  padding: 16px;
  background: white;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 256px;
  min-height: 256px;
}
.qr-container canvas,
.qr-container img { display: block; }

.qr-bureau-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}
.qr-hint {
  font-size: .82rem;
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 320px;
}
.qr-url-block {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 360px;
}
.qr-url-input {
  flex: 1;
  font-size: .72rem;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-muted);
  min-width: 0;
  cursor: text;
}
.qr-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.qr-regen-warn {
  font-size: .75rem;
  color: var(--text-muted);
  max-width: 300px;
  line-height: 1.4;
}

/* --------------------------------------------------------
   Impression QR — @media print masque tout sauf .qr-print-area
   -------------------------------------------------------- */
.qr-print-area {
  display: none;
}

@media print {
  body * { visibility: hidden !important; }
  .qr-print-area { display: block !important; visibility: visible !important; position: fixed !important; top: 0 !important; left: 0 !important; width: 100% !important; z-index: 9999 !important; background: white !important; }
  .qr-print-area * { visibility: visible !important; }

  .qr-print-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  }
  .qr-print-logo {
    font-size: 1.1rem;
    font-weight: 700;
    color: #003189;
  }
  .qr-print-code canvas,
  .qr-print-code img { display: block; }
  .qr-print-bureau {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1e293b;
    text-align: center;
  }
  .qr-print-loc {
    font-size: .9rem;
    color: #64748b;
    text-align: center;
  }
  .qr-print-instructions {
    font-size: .85rem;
    color: #475569;
    text-align: center;
    max-width: 300px;
    line-height: 1.5;
    border: 1px dashed #cbd5e1;
    padding: 10px 16px;
    border-radius: 6px;
  }
  .qr-print-url {
    font-size: .65rem;
    color: #94a3b8;
    word-break: break-all;
    text-align: center;
    max-width: 340px;
  }
}

/* ========================================================
   Page publique capture.php — éléments spécifiques
   ======================================================== */

/* En-tête sans lien retour */
.terrain-header-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

/* -------------------------------------------------------
   capture-camera-wrap :
   Flex column qui remplit exactement l'écran sous le header.
   Le viewport vidéo (flex:1) prend tout l'espace disponible,
   la barre de contrôles reste toujours visible en bas.
   ------------------------------------------------------- */
/*
  Sur la page capture (QR code) : corps fixe, pas de scroll global.
  Permet à capture-camera-wrap d'occuper exactement l'écran.
*/
.capture-page {
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
}

/* -------------------------------------------------------
   capture-camera-wrap :
   Flex colonne couvrant exactement l'écran sous le header.
   Testé Android + iOS Safari.
   ------------------------------------------------------- */
.capture-camera-wrap {
  display: flex;
  flex-direction: column;
  /* 54px = hauteur header de base ; env() ajoute le safe-area iOS (notch/Dynamic Island) */
  height: calc(100vh - 54px - env(safe-area-inset-top, 0px));
  height: calc(100svh - 54px - env(safe-area-inset-top, 0px));
  overflow: hidden;
  /* manipulation : désactive le zoom double-tap sans bloquer les taps sur les boutons enfants */
  touch-action: manipulation;
}

/* Indication discrète : adresse + consigne */
.capture-hint {
  flex: 0 0 auto;
  background: rgba(0, 0, 0, .60);
  color: rgba(255, 255, 255, .65);
  font-size: .72rem;
  text-align: center;
  padding: 5px 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/*
  Clé iOS Safari :
  - height:0 !important  →  supprime 55vh/55svh hérités ; la vidéo interne
                             (height:100%) se base sur 0 puis recalcule
                             une fois que flex-grow distribue l'espace.
  - flex: 1 1 0%         →  grow + shrink + basis:0 explicite (Safari l'exige)
  - min-height: 0        →  autorise le rétrécissement en flex
*/
.capture-camera-wrap .cam-viewport {
  flex: 1 1 0%;
  height: 0 !important;
  min-height: 0;
  overflow: hidden;
}

/* Barre de contrôles toujours visible */
.capture-camera-wrap .cam-bar {
  flex: 0 0 auto;
}

/* Messages d'erreur/fallback : occupent la place du viewport */
.capture-camera-wrap .cam-message {
  flex: 1 1 0%;
  height: 0;
  min-height: 0;
}

/* Pied de page discret */
.capture-footer {
  display: flex;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: .7rem;
  color: rgba(255,255,255,.25);
  background: #0d0d0d;
  border-top: 1px solid rgba(255,255,255,.05);
}

/* Page lien invalide */
.capture-invalid {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.capture-invalid-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  text-align: center;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.capture-invalid-icon { font-size: 3rem; margin-bottom: 16px; }
.capture-invalid-card h1 { font-size: 1.3rem; color: var(--text); margin-bottom: 10px; }
.capture-invalid-card p  { font-size: .9rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 8px; }
.capture-invalid-hint    { font-size: .8rem !important; color: var(--text-muted) !important; }

/* ========================================================
   Carte de chaleur — Heatmap Leaflet
   ======================================================== */

.card-map {
  margin-top: 24px;
}

.card-header--map {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.card-subtitle {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.map-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.map-legend-item {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.map-legend-gradient {
  width: 80px;
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(to right, #003189, #0284c7, #16a34a, #d97706, #E63946);
}

.map-legend-toggle {
  display: flex;
  gap: 6px;
  margin-left: 8px;
}

.map-layer-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Conteneur de la carte */
.map-container {
  position: relative;
  width: 100%;
  height: 460px;
  background: #e8ecf8;
  border-radius: 0 0 0 0;
  overflow: hidden;
}

.map-container .leaflet-container {
  width: 100%;
  height: 100%;
  font-family: inherit;
}

/* Spinner de chargement */
.map-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #e8ecf8;
  z-index: 1000;
  font-size: .875rem;
  color: var(--text-muted);
}

.map-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: map-spin .7s linear infinite;
}

@keyframes map-spin {
  to { transform: rotate(360deg); }
}

/* Pied de carte */
.map-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  font-size: .75rem;
  color: var(--text-muted);
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  flex-wrap: wrap;
  gap: 8px;
}

.map-credit a {
  color: var(--text-muted);
  text-decoration: underline dotted;
}

.map-geocode-notice {
  font-style: italic;
  color: var(--warning);
}

/* Marqueurs personnalisés */
.map-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 32px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  position: relative;
  cursor: pointer;
}

.map-marker::after {
  content: '';
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 8px solid currentColor;
  border-top-color: inherit;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.2));
}

.map-marker-pct {
  font-size: .72rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.01em;
  text-shadow: 0 1px 2px rgba(0,0,0,.3);
  pointer-events: none;
  user-select: none;
}

/* Popups */
.map-popup {
  min-width: 180px;
}

.map-popup-title {
  display: block;
  font-size: .875rem;
  color: var(--primary);
  margin-bottom: 4px;
  line-height: 1.3;
}

.map-popup-addr {
  font-size: .75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  line-height: 1.4;
}

.map-popup-stats {
  width: 100%;
  border-collapse: collapse;
  font-size: .8rem;
  margin-bottom: 10px;
}

.map-popup-stats td {
  padding: 3px 0;
}

.map-popup-stats td:first-child {
  color: var(--text-muted);
  padding-right: 12px;
}

.badge-pct {
  background: var(--primary-light);
  color: var(--primary);
  font-size: .7rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 10px;
}

.map-popup-link {
  display: inline-block;
  font-size: .78rem;
  color: var(--primary);
  font-weight: 600;
}

.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }

/* --------------------------------------------------------
   Ligne de bureau cliquable
   -------------------------------------------------------- */
.bureau-row-clickable {
  cursor: pointer;
  transition: background .12s;
}

/* Ligne actions — sous la ligne de données, même groupe visuel */
.bureau-row-clickable td {
  border-bottom: none;
  padding-bottom: 4px;
}

.bureau-row-actions td {
  padding-top: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.bureau-row-actions:last-child td { border-bottom: none; }

/* Hover : colorie les deux lignes du groupe */
.bureau-row-clickable:hover ~ .bureau-row-actions td,
.bureau-row-actions:hover td,
.bureau-row-actions:hover ~ .bureau-row-clickable td {
  background: var(--bg) !important;
}

/* --------------------------------------------------------
   Filtre rapide dans la card
   -------------------------------------------------------- */
.card-filter {
  padding: 10px 20px 10px;
  border-bottom: 1px solid var(--border);
}

.filter-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.filter-icon {
  position: absolute;
  left: 10px;
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
  flex-shrink: 0;
}

.filter-input {
  width: 100%;
  padding: 7px 32px 7px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .85rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.filter-input:focus {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(0,49,137,.08);
}

.filter-input::placeholder { color: var(--text-muted); }

.filter-clear {
  position: absolute;
  right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: var(--border);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-muted);
  font-size: .85rem;
  line-height: 1;
  transition: background .12s, color .12s;
}

.filter-clear:hover { background: var(--text-muted); color: #fff; }

.filter-no-results {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: .88rem;
}

/* --------------------------------------------------------
   Dashboard — Layout split : carte (sticky gauche) + liste
   -------------------------------------------------------- */
.dashboard-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: start;
}

/* Panneau carte : reste visible pendant le défilement de la liste */
.dashboard-split__map {
  position: sticky;
  top: calc(64px + 16px); /* header 64px + marge */
}

.dashboard-split__map .card-map {
  margin-top: 0;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 64px - 48px);
  min-height: 480px;
}

/* La carte Leaflet remplit tout l'espace disponible dans la card */
.dashboard-split__map .map-container {
  flex: 1;
  height: auto;
  min-height: 0;
}

/* Masquer la colonne Photos/Analyse dans la vue split (trop chargé visuellement) */
.dashboard-split__list .table-bureaux th:nth-child(2),
.dashboard-split__list .table-bureaux td:nth-child(2) {
  display: none;
}

/* Colonne Bureau de vote : occupe tout l'espace disponible */
.dashboard-split__list .table-bureaux th:nth-child(1),
.dashboard-split__list .table-bureaux td:nth-child(1) {
  width: 100%;
}

/* Colonne Photos traitées : compacte, centrée */
.photos-ratio {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: .85rem;
}

/* Bouton agrandir : léger highlight quand actif */
.map-expand-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ---- Mode carte plein format (toggle) ---- */
.dashboard-split--map-full {
  grid-template-columns: 1fr;
}

.dashboard-split--map-full .dashboard-split__list {
  display: none;
}

.dashboard-split--map-full .dashboard-split__map {
  position: static;
}

.dashboard-split--map-full .dashboard-split__map .card-map {
  height: calc(100vh - 64px - 48px);
}

/* ---- Responsive ≤ 1024px : empilement vertical ---- */
@media (max-width: 1024px) {
  .dashboard-split {
    grid-template-columns: 1fr;
  }

  .dashboard-split__map {
    position: static;
  }

  .dashboard-split__map .card-map {
    height: auto;
  }

  .dashboard-split__map .map-container {
    height: 360px;
  }

  /* Rétablir la colonne Photos sur mobile (plus de contrainte de largeur) */
  .dashboard-split__list .table-bureaux th:nth-child(2),
  .dashboard-split__list .table-bureaux td:nth-child(2) {
    display: table-cell;
  }
}

/* --------------------------------------------------------
   Mode édition manuelle des votes
   -------------------------------------------------------- */

/* Bouton dans le tableau des photos traitées */
.btn-edit-votes {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid #c7d2ee;
  font-weight: 600;
}
.btn-edit-votes:hover {
  background: #d4dcf3;
  color: var(--primary-dark);
}

/* Modal grande largeur (image + liste côte à côte) */
.modal-edit-votes-dialog {
  max-width: 1060px;
  width: 96vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}

.edit-votes-body {
  display: flex;
  gap: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Colonne gauche — image */
.edit-votes-left {
  flex: 0 0 50%;
  background: #0f172a;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

/* Barre boutons rotation */
.edit-votes-rotate-bar {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  background: rgba(255,255,255,.06);
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}

.ev-rotate-btn {
  background: rgba(255,255,255,.12);
  color: #e2e8f0;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius-sm);
  padding: 4px 14px;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  transition: background .15s;
}
.ev-rotate-btn:hover {
  background: rgba(255,255,255,.22);
}

/* Conteneur image (centrage + overflow pour les rotations 90/270°) */
.edit-votes-img-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
}

.edit-votes-photo {
  max-width: 100%;
  max-height: 68vh;
  object-fit: contain;
  display: block;
}

/* Colonne droite — liste électeurs */
.edit-votes-right {
  flex: 0 0 50%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* Résumé votants / absents */
.edit-votes-summary {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}

.ev-chip {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 700;
}
.ev-chip-voted  { background: var(--success-bg); color: #15803d; }
.ev-chip-absent { background: #f1f5f9; color: var(--text-muted); }

/* Liste scrollable */
.edit-votes-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* Tableau électeurs dans la modal */
.edit-votes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.edit-votes-table thead th {
  position: sticky;
  top: 0;
  background: #f1f5f9;
  padding: 8px 12px;
  text-align: left;
  color: var(--text-muted);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  z-index: 2;
}
.edit-votes-table tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.edit-votes-table tbody tr:last-child td { border-bottom: none; }

/* Bouton toggle vote */
.ev-toggle-btn {
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 20px;
  padding: 4px 14px;
  font-size: .78rem;
  font-weight: 600;
  transition: all .15s ease;
  white-space: nowrap;
}
.ev-voted {
  background: var(--success-bg);
  color: #15803d;
  border-color: #86efac;
}
.ev-voted:hover {
  background: #bbf7d0;
}
.ev-not-voted {
  background: #f1f5f9;
  color: var(--text-muted);
  border-color: var(--border);
}
.ev-not-voted:hover {
  background: #e2e8f0;
  color: var(--text);
}

/* Barre d'actions (bas de la colonne droite) */
.edit-votes-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.edit-votes-actions .btn-primary {
  margin-left: auto;
}

/* Responsive : empilé sur mobile */
@media (max-width: 700px) {
  .edit-votes-body     { flex-direction: column; }
  .edit-votes-left,
  .edit-votes-right    { flex: unset; width: 100%; }
  .edit-votes-left     { max-height: 45vh; border-right: none; border-bottom: 1px solid var(--border); }
  .edit-votes-img-wrap { max-height: 36vh; }
  .edit-votes-actions .btn-primary { margin-left: 0; }
}
