:root { --muted: #888; }
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

body {
  font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
  background: #f5f5f5;
  color: #222;
  font-size: 14px;
  min-height: 100vh;
}

/* ─── Header ──────────────────────────────────────────────── */
header {
  background: #000;
  color: #fff;
  padding: 14px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar {
  max-width: 1500px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
header h1 { font-size: 18px; font-weight: 700; letter-spacing: 1px; }
header .user { font-size: 12px; color: #ccc; }

/* ─── Layout ──────────────────────────────────────────────── */
main {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px;
}

/* ─── Filtres ──────────────────────────────────────────────── */
.filters {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 1px 6px rgba(0,0,0,.08);
  padding: 16px 20px;
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 12px;
  align-items: end;
}
.filter-group { display: grid; gap: 5px; }
.filter-search { grid-column: 1 / -1; }
@media (min-width: 901px) { .filter-search { grid-column: span 2; } }
.filter-group label {
  font-size: 11px;
  font-weight: 700;
  color: #444;
  text-transform: uppercase;
  letter-spacing: .3px;
}

select, input[type=text], input[type=number] {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 2px;
  padding: 7px 9px;
  font: inherit;
  background: #fff;
  color: #222;
  outline: none;
}
select:focus, input:focus { border-color: #999; }

.btn-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

button, .btn {
  background: #000;
  border: none;
  border-radius: 2px;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
button:hover, .btn:hover { background: #222; }

.btn-secondary {
  background: #fff;
  border: 1px solid #999;
  color: #111;
}
.btn-secondary:hover { background: #f5f5f5; }

.btn-export {
  background: #FBBC04;
  color: #000;
  margin-left: auto;
}
.btn-export:hover { background: #e5a800; }

/* ─── Tableau ──────────────────────────────────────────────── */
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}
.list-head .count { font-size: 13px; color: #666; }

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

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 1px 6px rgba(0,0,0,.08);
  font-size: 13px;
}

thead tr { background: #f0f0f0; }
th {
  padding: 9px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: #333;
  text-transform: uppercase;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
th:hover { background: #e8e8e8; }
th.sorted { background: #e8e8e8; }
th .sort-icon { margin-left: 3px; color: #999; font-size: 10px; }
th.sorted .sort-icon { color: #333; }

tbody tr { border-bottom: 1px solid #eee; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #fafafa; cursor: pointer; }
td { padding: 9px 10px; vertical-align: top; }
td.nb { font-weight: 700; }
td.muted { color: #888; font-size: 12px; }

/* ─── Badges statut ──────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-a_contacter { background: #fff3cd; color: #856404; }
.badge-contacte    { background: #d1e7dd; color: #0f5132; }
.badge-rdv_pris    { background: #cfe2ff; color: #084298; }
.badge-sans_suite  { background: #f0f0f0; color: #666; }
.badge-none        { color: #bbb; font-size: 11px; }

/* ─── Fiche client ──────────────────────────────────────── */
.page-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 18px;
}

.fiche-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 720px) { .fiche-grid { grid-template-columns: 1fr; } }

.card {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 1px 6px rgba(0,0,0,.08);
  padding: 20px;
}
.card h2 {
  font-size: 11px;
  font-weight: 700;
  color: #333;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 14px;
  border-bottom: 1px solid #eee;
  padding-bottom: 8px;
}

.info-list { display: flex; flex-direction: column; gap: 7px; }
.info-row { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; }
.info-row .label { color: #888; min-width: 110px; font-size: 12px; padding-top: 1px; flex-shrink: 0; }
.info-row .value { font-weight: 500; word-break: break-word; }
.info-row .value a { color: #1a73e8; text-decoration: none; }
.info-row .value a:hover { text-decoration: underline; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #333;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}
.back-link:hover { text-decoration: underline; }

/* ─── Formulaire contact ─────────────────────────────────── */
.contact-form { display: flex; flex-direction: column; gap: 12px; }
.radio-group { display: flex; flex-wrap: wrap; gap: 7px; }
.radio-btn input { display: none; }
.radio-btn label {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 2px;
  border: 1px solid #ddd;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  background: #fff;
  transition: all .12s;
}
.radio-btn input:checked + label { background: #000; color: #fff; border-color: #000; }

textarea {
  border: 1px solid #ddd;
  border-radius: 2px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  resize: vertical;
  min-height: 80px;
  width: 100%;
}
textarea:focus { outline: none; border-color: #999; }

/* ─── Mini table (cumul modèles) ─────────────────────────── */
.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.mini-table th {
  background: #f0f0f0;
  padding: 7px 9px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: #333;
  text-transform: uppercase;
  cursor: default;
}
.mini-table td {
  padding: 7px 9px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}
.mini-table tbody tr:last-child td { border-bottom: none; }
.mini-table .avoir { color: #c0392b; }

/* ─── Toast ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #222;
  color: #fff;
  padding: 11px 18px;
  border-radius: 3px;
  font-size: 13px;
  font-weight: 500;
  z-index: 999;
  opacity: 0;
  transform: translateY(8px);
  transition: all .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #1a7340; }
.toast.error { background: #c0392b; }

/* ─── États vides / loader ───────────────────────────────── */
.empty {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 1px 6px rgba(0,0,0,.08);
  text-align: center;
  padding: 48px 20px;
  color: #888;
  font-size: 13px;
}
.loader {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 1px 6px rgba(0,0,0,.08);
  text-align: center;
  padding: 32px;
  color: #888;
  font-size: 13px;
}

/* ─── Pagination ─────────────────────────────────────────── */
.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.page-btn {
  background: #fff;
  border: 1px solid #ddd;
  color: #222;
  border-radius: 2px;
  padding: 6px 11px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  min-width: 36px;
  justify-content: center;
}
.page-btn:hover:not(:disabled) { background: #f0f0f0; border-color: #999; }
.page-btn.current { background: #000; color: #fff; border-color: #000; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-gap { padding: 0 4px; color: #999; }

/* ─── Lien WhatsApp ──────────────────────────────────────── */
.wa-link {
  display: inline-block;
  margin-left: 8px;
  font-size: 11px;
  font-weight: 700;
  color: #fff !important;
  background: #25D366;
  padding: 1px 7px;
  border-radius: 2px;
  text-decoration: none !important;
}
.wa-link:hover { background: #1da851; }

/* ─── Filtres historique fiche ───────────────────────────── */
.hist-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.hist-filters select { width: auto; min-width: 130px; }
.hist-total { font-size: 13px; color: #444; margin-left: auto; }
.mini-table td.nb { font-weight: 600; text-align: right; }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 900px) {
  main { padding: 14px; }
  .filters { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .filters { grid-template-columns: 1fr; }
  header { padding: 12px 14px; }
  table { display: block; overflow-x: auto; }
}
