/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #1a73e8;
  --blue-dark: #1557b0;
  --green: #0d9e6e;
  --red: #e53935;
  --orange: #f59e0b;
  --bg: #f0f4f8;
  --sidebar: #0f172a;
  --sidebar-hover: #1e293b;
  --white: #ffffff;
  --gray-100: #f8fafc;
  --gray-200: #e2e8f0;
  --gray-400: #94a3b8;
  --gray-700: #334155;
  --text: #1e293b;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,.08);
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 220px;
  background: var(--sidebar);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 16px 10px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow: hidden;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 14px;
  font-size: 1.3rem;
  color: #fff;
  flex-shrink: 0;
}

.logo-icon { font-size: 1.6rem; }
.logo-img { width: 100%; max-width: 140px; height: auto; display: block; margin: 0 auto; }

nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-height: 0;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: #94a3b8;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.82rem;
  text-align: left;
  transition: all .15s;
  white-space: nowrap;
}

.nav-btn:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-btn.active { background: var(--blue); color: #fff; }
.nav-btn .icon { font-size: 1rem; }

/* ===== CONTENT ===== */
.content {
  margin-left: 220px;
  flex: 1;
  padding: 32px;
  min-height: 100vh;
  min-width: 0;
  overflow-x: hidden;
}

.page { display: none; }
.page.active { display: block; }

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
}

.header-actions { display: flex; gap: 10px; align-items: center; }

#dashPeriod, #filterMonth {
  border: 1px solid var(--gray-200);
  background: var(--white);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

.date-filter { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.period-range {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 4px 10px;
}
.period-range label {
  font-size: 0.8rem;
  color: var(--gray-500, #64748b);
  font-weight: 600;
}
.period-range input {
  border: none;
  background: transparent;
  padding: 4px 2px;
  font-size: 0.88rem;
  color: var(--gray-700);
}
.period-range input:focus { outline: none; }

/* ===== FILTER BAR ===== */
.filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  background: #fff;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--gray-100);
  margin-bottom: 14px;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label {
  font-size: 0.75rem;
  color: var(--gray-500, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
}
.filter-group input,
.filter-group select {
  border: 1px solid var(--gray-200);
  background: #fff;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.9rem;
}
.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: var(--blue);
}
.filter-group.filter-reset button { padding: 8px 12px; }

.filter-summary {
  font-size: 0.85rem;
  color: var(--gray-500, #64748b);
  margin-bottom: 10px;
  padding: 0 4px;
}

/* ===== KPI GRID ===== */
.kpi-grid {
  display: grid;
  /* 6 KPIs alignés : 6 colonnes en très large, 3 en moyen, 2 en mobile */
  /* minmax(0, 1fr) évite que le contenu nowrap force un overflow horizontal */
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 1300px) { .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 800px)  { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.kpi-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid transparent;
  /* Toutes les cartes ont la même hauteur, les labels alignés en haut,
     valeurs centrées, sous-textes en bas */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 110px;
}

.kpi-card.ca      { border-color: var(--blue); }
.kpi-card.depenses { border-color: var(--red); }
.kpi-card.benefice { border-color: var(--green); }
.kpi-card.lavages  { border-color: var(--orange); }
.kpi-card.panier   { border-color: #8b5cf6; }
.kpi-card.bestday  { border-color: #14b8a6; }

.kpi-label {
  font-size: 0.78rem;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .05em;
  /* hauteur fixe pour aligner même quand un label fait 2 lignes */
  min-height: 2.4em;
  line-height: 1.2;
  display: flex;
  align-items: flex-start;
}
.kpi-value {
  font-size: clamp(1rem, 1.3vw, 1.35rem);
  font-weight: 700;
  line-height: 1.1;
  margin: 4px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-sub   { font-size: 0.8rem; color: var(--gray-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.kpi-card.ca .kpi-value       { color: var(--blue); }
.kpi-card.depenses .kpi-value  { color: var(--red); }
.kpi-card.benefice .kpi-value  { color: var(--green); }
.kpi-card.lavages .kpi-value   { color: var(--orange); }
.kpi-card.panier .kpi-value    { color: #8b5cf6; }
.kpi-card.bestday .kpi-value   { color: #14b8a6; font-size: clamp(0.9rem, 1.05vw, 1.1rem); }

/* ===== CHARTS ===== */
.charts-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  min-width: 0; /* permet au canvas de rétrécir sans déborder la grille */
}

.chart-card h3 {
  font-size: 0.95rem;
  color: var(--gray-700);
  margin-bottom: 16px;
}

.chart-card canvas { max-height: 240px; }

.charts-row-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.charts-row-full { grid-template-columns: minmax(0, 1fr); }

/* ===== TABLES ===== */
.recent-section, .list-section {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-top: 8px;
}

.recent-section h3, .list-section h3 {
  font-size: 0.95rem;
  color: var(--gray-700);
  margin-bottom: 14px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--gray-100);
  color: var(--gray-400);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-200);
  color: var(--text);
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--gray-100); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-entree { background: #dcfce7; color: #166534; }
.badge-sortie { background: #fee2e2; color: #991b1b; }

.montant-entree { color: var(--green); font-weight: 600; }
.montant-sortie { color: var(--red); font-weight: 600; }

/* ===== FORMS ===== */
.form-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  max-width: 680px;
  margin-bottom: 28px;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 10px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 0.95rem;
  color: var(--text);
  transition: border-color .15s;
  background: var(--white);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--blue);
}

/* ===== BUTTONS ===== */
.btn-primary, .btn-danger, .btn-outline, .btn-del {
  padding: 10px 22px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all .15s;
}

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #c62828; }
.btn-danger-sm {
  background: transparent; color: var(--red); border: 1px solid var(--red);
  padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: .85rem;
}
.btn-danger-sm:hover { background: var(--red); color: #fff; }
.btn-danger-sm:disabled { opacity: .4; cursor: not-allowed; }

/* ===== PAGE UTILISATEURS — cartes fun ===== */
.users-stats {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin: 0 0 24px;
}
.stat-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, #fff 0%, #f8fafc 100%);
  border: 1px solid var(--gray-200);
  padding: 10px 16px; border-radius: 999px;
  font-size: .85rem; color: var(--gray-700);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  transition: transform .15s, box-shadow .15s;
}
.stat-pill:hover { transform: translateY(-1px); box-shadow: 0 4px 8px rgba(15, 23, 42, .08); }
.stat-pill .stat-icon { font-size: 1.1rem; }
.stat-pill .stat-num { font-weight: 700; color: var(--text); font-size: 1rem; }
.stat-pill .stat-label { color: #64748b; }
.stat-pill-warn { background: linear-gradient(135deg, #fef3c7, #fde68a); border-color: #fcd34d; color: #92400e; }
.stat-pill-warn .stat-num { color: #92400e; }

.users-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.users-empty {
  grid-column: 1 / -1;
  text-align: center; color: #94a3b8;
  padding: 48px 16px; font-style: italic;
  background: #f8fafc; border-radius: 12px;
}
.users-empty.error { color: #b91c1c; background: #fef2f2; }

.user-card {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: 12px; padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
  transition: transform .18s, box-shadow .18s, border-color .18s;
  position: relative; overflow: hidden;
}
.user-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, #2563eb, #7c3aed, #db2777);
  opacity: 0; transition: opacity .2s;
}
.user-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(15, 23, 42, .08);
  border-color: #cbd5e1;
}
.user-card:hover::before { opacity: 1; }
.user-card.is-inactive { opacity: .65; background: #f8fafc; }
.user-card.is-inactive::after {
  content: 'DÉSACTIVÉ'; position: absolute; top: 10px; right: -34px;
  background: #94a3b8; color: #fff; font-size: .58rem; font-weight: 700;
  padding: 2px 40px; transform: rotate(35deg); letter-spacing: 1px;
}

.user-card-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .85rem;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(15, 23, 42, .15);
}
.user-card-info { flex: 1; min-width: 0; }
.user-name {
  font-weight: 600; color: var(--text); font-size: .88rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.self-tag {
  display: inline-block; background: #dbeafe; color: #1e40af;
  font-size: .58rem; font-weight: 700; padding: 1px 6px;
  border-radius: 999px; margin-left: 4px; vertical-align: middle;
}
.user-tel { color: #64748b; font-size: .74rem; margin-top: 1px; }

.role-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 999px;
  font-size: .65rem; font-weight: 600; white-space: nowrap;
}
.role-badge-super { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; }
.role-badge-admin { background: linear-gradient(135deg, #dbeafe, #bfdbfe); color: #1e40af; }
.role-badge-agent { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #065f46; }

.user-card-controls {
  display: flex; flex-direction: column; gap: 6px;
  border-top: 1px dashed var(--gray-200); padding-top: 8px;
}
.user-control-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .76rem; color: #475569;
}
.user-control-row .ctrl-label { font-weight: 500; }
.user-control-row select {
  padding: 3px 6px; border-radius: 6px; border: 1px solid var(--gray-200);
  font-size: .76rem; background: #fff; cursor: pointer;
}
.actif-wrap { display: flex; align-items: center; gap: 8px; }
.actif-text { font-size: .72rem; color: #64748b; min-width: 26px; text-align: right; }

.user-card-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
  border-top: 1px dashed var(--gray-200); padding-top: 8px;
}
.user-card-actions button {
  flex: 1; min-width: 0;
  padding: 6px 8px;
  font-size: .72rem;
  border-radius: 7px;
}

.btn-outline {
  background: #fff;
  border: 1.5px solid var(--gray-200);
  color: var(--gray-700);
}
.btn-outline:hover { background: var(--gray-100); }

.btn-del {
  background: none;
  border: none;
  color: var(--gray-400);
  padding: 4px 8px;
  font-size: 1rem;
  cursor: pointer;
}
.btn-del:hover { color: var(--red); }

.btn-edit {
  background: none;
  border: none;
  color: var(--gray-400);
  padding: 4px 8px;
  font-size: 1rem;
  cursor: pointer;
  margin-right: 2px;
}
.btn-edit:hover { color: var(--blue); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-overlay.show { display: flex; }

.modal-card {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 620px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  animation: modalIn .18s ease-out;
}
@keyframes modalIn {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--gray-100);
}
.modal-header h3 { margin: 0; font-size: 1.1rem; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.15rem;
  color: var(--gray-400);
  cursor: pointer;
  padding: 4px 8px;
}
.modal-close:hover { color: var(--gray-700); }

.modal-form { padding: 22px; display: none; }
.modal-form.active { display: block; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: #1e293b;
  color: #fff;
  padding: 12px 22px;
  border-radius: 8px;
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(10px);
  transition: all .25s;
  pointer-events: none;
  z-index: 999;
}

.toast.show { opacity: 1; transform: translateY(0); }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  color: var(--gray-400);
  padding: 40px;
  font-size: 0.95rem;
}

/* ===== MENU TOGGLE (mobile) ===== */
.menu-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 200;
  background: var(--sidebar);
  color: #fff;
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  font-size: 1.4rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 90;
}
.sidebar-overlay.show { display: block; }

/* ===== TABLE SCROLL WRAPPER ===== */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .charts-row { grid-template-columns: minmax(0, 1fr); }
  .content { padding: 24px; }
}

@media (max-width: 640px) {
  body { display: block; }

  .menu-toggle { display: block; }

  .sidebar {
    width: 240px;
    transform: translateX(-100%);
    transition: transform .25s ease;
    padding-top: 64px;
  }
  .sidebar.open { transform: translateX(0); }

  .content {
    margin-left: 0;
    padding: 72px 14px 24px;
  }

  .logo-img { max-width: 150px; }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
  }
  .page-header h1 { font-size: 1.3rem; }
  .header-actions { width: 100%; flex-wrap: wrap; }
  .header-actions > * { flex: 1; min-width: 140px; }

  .kpi-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .kpi-card { padding: 14px; }
  .kpi-value { font-size: 1.15rem; }
  .kpi-label { font-size: 0.7rem; }
  .kpi-sub { font-size: 0.72rem; }

  .chart-card { padding: 14px; }
  .chart-card canvas { max-height: 220px; }

  .form-card { padding: 18px; }
  .form-row { grid-template-columns: 1fr; gap: 0; }

  .recent-section, .list-section { padding: 14px; }

  .table { font-size: 0.82rem; min-width: 520px; }
  .table th, .table td { padding: 8px 10px; }

  .btn-primary, .btn-danger, .btn-outline {
    width: 100%;
    padding: 12px;
  }

  .toast { left: 14px; right: 14px; bottom: 14px; text-align: center; }
}

@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #0f172a 0%, #1a73e8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-logo {
  display: block;
  width: 90px;
  height: auto;
  margin: 0 auto 20px;
}
.login-card h1 {
  text-align: center;
  font-size: 1.4rem;
  margin-bottom: 24px;
  color: var(--text);
}
.login-card .form-group { margin-bottom: 14px; }
.login-card label {
  display: block;
  font-size: .85rem;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.login-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color .15s;
}
.login-card input:focus { border-color: var(--blue); }
.login-card .btn-primary {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  font-size: 1rem;
}
.login-card .btn-primary:disabled {
  opacity: .6;
  cursor: not-allowed;
}
.login-error {
  margin-top: 12px;
  color: var(--red);
  font-size: .8rem;
  line-height: 1.3;
  text-align: center;
  min-height: 1.2em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Pendant la vérification de session au chargement, on masque tout */
body.auth-loading .login-screen,
body.auth-loading .sidebar,
body.auth-loading .content,
body.auth-loading .menu-toggle { display: none !important; }

/* Une fois connecté, le login est masqué */
body.authed .login-screen { display: none; }

/* Tant que pas authentifié, on masque l'app */
body:not(.authed) .sidebar,
body:not(.authed) .content,
body:not(.authed) .menu-toggle { display: none !important; }

/* Masquage des éléments réservés à l'admin/super_admin pour les agents */
body.role-agent .admin-only { display: none !important; }
/* Éléments réservés au super_admin (page Utilisateurs) cachés pour les autres */
body.role-admin .super-admin-only,
body.role-agent .super-admin-only { display: none !important; }

/* ===== SIDEBAR FOOTER (user info + logout) ===== */
.sidebar-footer {
  flex-shrink: 0;
  padding: 10px 6px 4px;
  border-top: 1px solid var(--sidebar-hover);
  background: var(--sidebar);
}
.user-info {
  padding: 4px 4px 8px;
  font-size: .75rem;
}
.user-email {
  color: #fff;
  font-weight: 500;
  word-break: break-all;
}
.user-role {
  color: var(--gray-400);
  text-transform: uppercase;
  font-size: .7rem;
  letter-spacing: .5px;
  margin-top: 2px;
}
.btn-logout {
  width: 100%;
  padding: 6px 10px;
  background: transparent;
  color: #e2e8f0;
  border: 1px solid var(--sidebar-hover);
  border-radius: 7px;
  cursor: pointer;
  font-size: .78rem;
  transition: background .15s;
}
.btn-logout:hover { background: var(--sidebar-hover); }

/* ===== CLIENTS ===== */
.modal-large { max-width: 880px; }
.modal-body  { padding: 22px; }
.modal-body h4 { margin: 18px 0 10px; font-size: .95rem; color: var(--gray-700); }

.client-hint { font-size: .85rem; margin-top: 6px; min-height: 18px; }
.hint-ok  { color: #166534; }
.hint-new { color: #92400e; }
.hint-new a { color: #1e40af; text-decoration: underline; cursor: pointer; }

.badge-particulier { background: #dbeafe; color: #1e40af; padding: 2px 8px; border-radius: 999px; font-size: .8rem; }
.badge-entreprise  { background: #fef3c7; color: #92400e; padding: 2px 8px; border-radius: 999px; font-size: .8rem; }

tr.row-click { cursor: pointer; }
tr.row-click:hover { background: var(--gray-50, #f9fafb); }

.vehicules-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.vehicule-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border: 1px solid var(--gray-100); border-radius: 8px;
  background: #f9fafb; font-size: .9rem;
}
.vehicule-item.pending { background: #fffbeb; border-color: #fde68a; }
.vehicule-add-row { gap: 8px; }
.vehicule-add-row input { flex: 1; }

.empty-inline { color: var(--gray-400); font-style: italic; font-size: .9rem; padding: 6px 0; }

.fiche-info .info-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 12px;
}
.fiche-info .info-grid > div {
  background: #f9fafb; padding: 10px 12px; border-radius: 8px;
}
.fiche-info .info-grid span { display: block; font-size: .75rem; color: var(--gray-400); text-transform: uppercase; }
.fiche-info .info-grid b { font-size: .95rem; }

.fiche-vehicules { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.veh-pill {
  display: inline-block; padding: 6px 12px; border-radius: 999px;
  background: #eef2ff; color: #3730a3; font-size: .85rem;
}

/* La modal-form (clients) doit être affichée par défaut quand .active */
#formClient.active { display: block; }

/* ===== RESERVATIONS ===== */
.nav-badge {
  display: inline-block;
  margin-left: auto;
  background: #ef4444;
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
}
.statut-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
}
.statut-prevu  { background: #dbeafe; color: #1e40af; }
.statut-arrive { background: #dcfce7; color: #166534; }
.statut-annule { background: #fee2e2; color: #991b1b; }

.resa-actions { white-space: nowrap; display: flex; gap: 4px; flex-wrap: wrap; }
.resa-online { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  background: #e0f2fe; color: #075985; font-size: .72rem; font-weight: 600; white-space: nowrap; }
.btn-mini {
  padding: 4px 8px;
  font-size: .8rem;
  border: 1px solid var(--gray-100);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
}
.btn-mini:hover { background: var(--gray-50, #f9fafb); }
.btn-mini.btn-ok { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.btn-mini.btn-ok:hover { background: #bbf7d0; }
.btn-mini.btn-cancel { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.btn-mini.btn-edit { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.btn-mini.btn-del { background: #fee2e2; color: #991b1b; border-color: #fecaca; }

.resa-client-toggle { display: flex; gap: 6px; }
.btn-toggle {
  padding: 6px 14px;
  border: 1px solid var(--gray-100);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: .85rem;
}
.btn-toggle.active { background: #1e40af; color: #fff; border-color: #1e40af; }

.resa-suggest {
  margin-top: 6px;
  border: 1px solid var(--gray-100);
  border-radius: 8px;
  max-height: 200px;
  overflow-y: auto;
  background: #fff;
}
.resa-suggest:empty { display: none; }
.resa-suggest-item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--gray-100); font-size: .9rem; }
.resa-suggest-item:last-child { border-bottom: none; }
.resa-suggest-item:hover { background: #f0f9ff; }
.resa-suggest-empty { padding: 10px 12px; color: var(--gray-400); font-style: italic; font-size: .85rem; }

.resa-client-note { color: var(--gray-400); font-size: .8rem; margin: 6px 0 4px; }

/* Calendrier + créneaux de la modale réservation */
.resa-cal { border: 1px solid var(--gray-100); border-radius: 10px; padding: 10px; }
.resa-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.resa-cal-month { font-weight: 700; text-transform: capitalize; }
.resa-cal-nav { width: 32px; height: 32px; border: 1px solid var(--gray-100); background: #fff; border-radius: 8px; cursor: pointer; font-size: 1rem; line-height: 1; }
.resa-cal-nav:disabled { opacity: .35; cursor: not-allowed; }
.resa-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.resa-cal-dow { text-align: center; font-size: .68rem; font-weight: 700; color: var(--gray-400); text-transform: uppercase; padding-bottom: 2px; }
.resa-cal-day { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: #f1f5f9; cursor: pointer; font-size: .9rem; border: 1px solid transparent; }
.resa-cal-day.empty { background: transparent; cursor: default; }
.resa-cal-day.past { color: #cbd5e1; background: transparent; cursor: not-allowed; }
.resa-cal-day.today { box-shadow: inset 0 0 0 1px var(--blue); font-weight: 800; }
.resa-cal-day.selected { background: var(--blue); color: #fff; font-weight: 700; }
.resa-cal-day:not(.empty):not(.past):hover { border-color: var(--blue); }
.resa-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; }
.resa-slot { padding: 9px 4px; border: 1px solid var(--gray-100); border-radius: 8px; background: #fff; cursor: pointer; font-size: .95rem; }
.resa-slot:hover { border-color: var(--blue); }
.resa-slot.selected { background: var(--blue); color: #fff; border-color: var(--blue); font-weight: 700; }
.resa-slots-hint { color: var(--gray-400); font-size: .85rem; margin: 6px 0 0; }

.resa-selected { margin-top: 8px; }
.resa-selected-card {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  padding: 10px 14px;
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: .9rem;
}
.resa-selected-card .btn-mini { margin-left: auto; }
.resa-veh-pick { flex-basis: 100%; margin-top: 4px; }
.resa-veh-pick label { display: flex; gap: 8px; align-items: center; font-size: .85rem; }
.resa-veh-pick select { flex: 1; }

/* ===== TARIFS (page admin) ===== */
.tarifs-hint {
  color: #64748b;
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.5;
}
.tarifs-accordion {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.tarif-cat {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(15,23,42,0.04);
  transition: box-shadow .2s;
}
.tarif-cat[open] {
  box-shadow: 0 4px 12px rgba(15,23,42,0.06);
}
.tarif-cat > summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-weight: 600;
  user-select: none;
  background: linear-gradient(180deg,#f8fafc,#f1f5f9);
  border-bottom: 1px solid transparent;
  transition: background .15s, border-color .15s;
}
.tarif-cat[open] > summary {
  border-bottom-color: #e2e8f0;
  background: linear-gradient(180deg,#f1f5f9,#e2e8f0);
}
.tarif-cat > summary::-webkit-details-marker { display: none; }
.tarif-cat > summary:hover { background: #eef2f7; }
.tarif-cat-icon { font-size: 22px; line-height: 1; }
.tarif-cat-name { flex: 1; font-size: 1.05rem; color: #0f172a; }
.tarif-cat-count {
  background: #0d9e6e;
  color: #fff;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: .75rem;
  font-weight: 700;
}
.tarif-cat-chevron {
  color: #64748b;
  transition: transform .2s;
  font-size: 14px;
}
.tarif-cat[open] .tarif-cat-chevron { transform: rotate(180deg); }
.tarif-cat-detailing .tarif-cat-count { background: #6366f1; }
.tarif-cat-entretien .tarif-cat-count { background: #f59e0b; }
.cat-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .15s;
}
.tarif-cat:hover .cat-actions,
.tarif-cat[open] .cat-actions { opacity: 1; }
.cat-action {
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: .9rem;
  transition: background .15s;
}
.cat-action:hover { background: rgba(15,23,42,0.08); }
.cat-del:hover { background: #fee2e2; }
.tarif-list {
  display: flex;
  flex-direction: column;
}
.tarif-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid #f1f5f9;
  transition: background .25s;
}
.tarif-row:first-child { border-top: 0; }
.tarif-row:hover { background: #fafbfc; }
.tarif-row.saved { background: #d1fae5; }
.tarif-row.dragging { opacity: .35; background: #e0f2fe; }
.tarif-handle {
  color: #cbd5e1;
  cursor: grab;
  user-select: none;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
  letter-spacing: -2px;
  flex-shrink: 0;
  transition: color .15s;
}
.tarif-row:hover .tarif-handle { color: #64748b; }
.tarif-handle:active { cursor: grabbing; }
.tarif-name {
  flex: 1;
  color: #1e293b;
  font-size: .95rem;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.tarif-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tarif-rename {
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: .9rem;
  opacity: .35;
  transition: opacity .15s, background .15s;
}
.tarif-row:hover .tarif-rename { opacity: .85; }
.tarif-rename:hover { background: #f1f5f9; opacity: 1; }
.tarif-edit {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tarif-input {
  width: 110px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: .95rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  transition: border-color .15s, box-shadow .15s;
}
.tarif-input:focus {
  outline: none;
  border-color: #0d9e6e;
  box-shadow: 0 0 0 3px rgba(13,158,110,0.15);
}
.tarif-currency {
  color: #94a3b8;
  font-size: .8rem;
  font-weight: 500;
}
.tarif-save {
  background: #0d9e6e;
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 1rem;
  transition: background .15s, transform .1s;
}
.tarif-save:hover { background: #0b8a60; }
.tarif-save:active { transform: scale(.94); }
.tarif-save:disabled { opacity: .6; cursor: wait; }
.tarif-save.saving { background: #64748b; }
@media (max-width: 540px) {
  .tarif-row { flex-wrap: wrap; }
  .tarif-name { flex-basis: 100%; }
  .tarif-input { flex: 1; width: auto; }
}

/* Toggle switch (actif/inactif) */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.switch input { display: none; }
.switch .slider {
  position: absolute; cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #cbd5e1;
  border-radius: 22px;
  transition: background .2s;
}
.switch .slider::before {
  position: absolute; content: "";
  height: 16px; width: 16px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch input:checked + .slider { background: #0d9e6e; }
.switch input:checked + .slider::before { transform: translateX(18px); }

.tarif-row.inactive { opacity: .55; }
.tarif-row.inactive .tarif-name { text-decoration: line-through; }
.badge-off {
  background: #f1f5f9;
  color: #64748b;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: .7rem;
  font-weight: 600;
  margin-left: 6px;
  vertical-align: middle;
}
.tarif-cat-select {
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: .85rem;
  background: #fff;
  cursor: pointer;
}
.tarif-cat-select:focus {
  outline: none;
  border-color: #0d9e6e;
  box-shadow: 0 0 0 3px rgba(13,158,110,0.15);
}

/* Barre d'ajout (services / véhicules) */
.vt-add-bar {
  display: flex;
  gap: 10px;
  margin: 0 0 16px;
  flex-wrap: wrap;
  align-items: center;
}
.vt-add-bar input,
.vt-add-bar select {
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: .95rem;
}
.vt-add-bar input[type="text"] { flex: 1; min-width: 180px; }
.vt-add-bar input[type="number"] { width: 130px; }
.vt-add-bar input:focus,
.vt-add-bar select:focus {
  outline: none;
  border-color: #0d9e6e;
  box-shadow: 0 0 0 3px rgba(13,158,110,0.15);
}

/* ===== MODALE UTILISATEUR (création / édition) ===== */
.user-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  animation: userModalFade .2s ease-out;
}
@keyframes userModalFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.user-modal-card {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 440px;
  max-height: 94vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
  animation: userModalIn .25s cubic-bezier(.16,1,.3,1);
}
@keyframes userModalIn {
  from { transform: translateY(20px) scale(.96); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.user-modal-hero {
  position: relative;
  background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 60%, #4338ca 100%);
  color: #fff;
  padding: 18px 18px 14px;
  text-align: center;
}
.user-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background .15s;
}
.user-modal-close:hover { background: rgba(255,255,255,0.32); }

.user-modal-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  margin: 0 auto 8px;
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fff;
  text-transform: uppercase;
  transition: transform .2s;
}
.user-modal-avatar.pulse { transform: scale(1.05); }

.user-modal-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}
.user-modal-subtitle {
  margin: 2px 0 0;
  font-size: .72rem;
  opacity: .85;
}

.user-modal-form {
  padding: 14px 16px 14px;
  overflow-y: auto;
}

.user-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 10px;
}
.user-form-grid .form-group { margin-bottom: 0; }
.user-form-grid .form-group-full { grid-column: 1 / -1; }

.user-modal-form .form-group label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 3px;
  display: block;
}
.user-modal-form .form-group input {
  width: 100%;
  padding: 7px 10px;
  border: 1.5px solid var(--gray-200, #e5e7eb);
  border-radius: 8px;
  font-size: .85rem;
  transition: border-color .15s, box-shadow .15s;
}
.user-modal-form .form-group input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}
.input-with-icon .input-icon {
  position: absolute;
  left: 10px;
  font-size: .85rem;
  pointer-events: none;
  opacity: .7;
}
.input-with-icon input {
  padding-left: 30px !important;
}
.input-with-icon .input-action {
  position: absolute;
  right: 4px;
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: .85rem;
  transition: background .15s;
}
.input-with-icon .input-action:hover { background: var(--gray-100, #f3f4f6); }
.input-with-icon:has(.input-action) input { padding-right: 34px !important; }

.form-hint {
  display: block;
  margin-top: 3px;
  font-size: .65rem;
  color: var(--gray-400, #9ca3af);
}

/* Sélecteur de rôle en cartes */
.role-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.role-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8px 4px;
  border: 1.5px solid var(--gray-200, #e5e7eb);
  border-radius: 9px;
  cursor: pointer;
  transition: all .15s;
  background: #fff;
}
.role-card input { position: absolute; opacity: 0; pointer-events: none; }
.role-card:hover { border-color: #93c5fd; background: #f8fafc; }
.role-card-icon { font-size: 1.05rem; margin-bottom: 2px; }
.role-card-name {
  font-size: .72rem;
  font-weight: 600;
  color: var(--gray-700);
}
.role-card-desc {
  font-size: .6rem;
  color: var(--gray-400);
  margin-top: 1px;
  line-height: 1.2;
}
.role-card:has(input:checked) {
  border-color: #2563eb;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.role-card:has(input:checked) .role-card-name { color: #1e40af; }

.user-modal-error {
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: .75rem;
  margin-top: 10px;
  display: none;
}
.user-modal-error:not(:empty) { display: block; }

.user-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-100, #f3f4f6);
}
.user-modal-actions .btn-primary,
.user-modal-actions .btn-outline {
  padding: 7px 16px;
  font-size: .82rem;
  font-weight: 600;
  border-radius: 8px;
}

@media (max-width: 540px) {
  .user-form-grid { grid-template-columns: 1fr; }
  .role-cards { grid-template-columns: 1fr; }
  .role-card { flex-direction: row; gap: 10px; text-align: left; padding: 10px 12px; }
  .role-card-icon { margin-bottom: 0; }
  .user-modal-card { max-width: 100%; }
}
