/* ═══════════════════════════════════════════════════ VARIABLES */
:root {
  --bg: #0a0f1e;
  --bg2: #0d1424;
  --card: #111827;
  --card2: #1a2235;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.12);
  --text: #f0f4ff;
  --text2: #8892a4;
  --text3: #4a5568;
  --blue: #3b82f6;
  --blue-d: #2563eb;
  --blue-bg: rgba(59,130,246,0.12);
  --blue-bg2: rgba(59,130,246,0.2);
  --green: #10b981;
  --green-d: #059669;
  --green-bg: rgba(16,185,129,0.12);
  --red: #ef4444;
  --red-bg: rgba(239,68,68,0.12);
  --red-border: rgba(239,68,68,0.3);
  --yellow: #f59e0b;
  --radius: 14px;
  --radius-sm: 9px;
  --radius-xs: 6px;
  --shadow: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-sm: 0 2px 12px rgba(0,0,0,0.3);
  --header-h: 60px;
  --font: 'DM Sans', system-ui, sans-serif;
  --serif: 'DM Serif Display', Georgia, serif;
}

/* ═══════════════════════════════════════════════════ RESET */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
a { color: inherit; }

.serif { font-family: var(--serif); font-style: italic; }
.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════ LOGIN */
#login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
}
.login-bg {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(59,130,246,0.18) 0%, transparent 70%),
              radial-gradient(ellipse 60% 40% at 80% 80%, rgba(16,185,129,0.1) 0%, transparent 60%);
  pointer-events: none;
}
.login-container {
  width: 100%; max-width: 520px;
  position: relative; z-index: 1;
}
.login-header { text-align: center; margin-bottom: 40px; }
/* Logo Normbel (fond blanc) présenté en carte arrondie sur le fond sombre */
.login-logo {
  width: 210px; max-width: 70%;
  background: #fff;
  border-radius: 18px;
  padding: 8px 14px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 0 40px rgba(59,130,246,0.4);
}
.login-logo img { width: 100%; display: block; }
.logo-n { font-family: var(--serif); }
.login-title {
  font-size: 2.2rem; font-weight: 300; letter-spacing: -0.5px;
  margin-bottom: 8px;
}
.login-sub { color: var(--text2); font-size: 0.95rem; }

.profiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.profile-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.profile-card:hover {
  border-color: var(--blue);
  background: var(--card2);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(59,130,246,0.2);
}
.profile-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 700;
  flex-shrink: 0;
}
.profile-name { font-size: 0.9rem; font-weight: 500; line-height: 1.3; }
.profile-role {
  font-size: 0.72rem; color: var(--text2);
  background: var(--bg2); border-radius: 20px;
  padding: 2px 10px;
}

/* ═══════════════════════════════════════════════════ PIN MODAL */
.pin-card {
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 32px 28px;
  width: 100%; max-width: 340px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: slide-up 0.25s ease;
}
.pin-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 700;
  margin: 0 auto 14px;
}
.pin-name { font-size: 1.2rem; font-weight: 600; margin-bottom: 6px; }
.pin-hint { color: var(--text2); font-size: 0.85rem; margin-bottom: 24px; }
.pin-dots {
  display: flex; justify-content: center; gap: 14px;
  margin-bottom: 8px;
}
.pin-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border2);
  background: transparent;
  transition: all 0.15s;
}
.pin-dot.filled { background: var(--blue); border-color: var(--blue); }
.pin-dot.error { background: var(--red); border-color: var(--red); }
.pin-error {
  color: var(--red); font-size: 0.82rem;
  margin-bottom: 16px; min-height: 18px;
}
.numpad {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin: 20px 0 16px;
}
.numpad-btn {
  height: 56px;
  border-radius: var(--radius-sm);
  background: var(--card2);
  border: 1px solid var(--border);
  font-size: 1.3rem; font-weight: 500; color: var(--text);
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.numpad-btn:hover { background: var(--bg2); border-color: var(--border2); }
.numpad-btn:active { transform: scale(0.95); }
.numpad-action { color: var(--text2); font-size: 1rem; }

/* ═══════════════════════════════════════════════════ HEADER */
.app-header {
  position: sticky; top: 0; z-index: 100;
  /* + encoche / barre d'état iPhone (0 sur PC) pour l'app en plein écran */
  height: calc(var(--header-h) + env(safe-area-inset-top));
  background: rgba(10,15,30,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: env(safe-area-inset-top) 20px 0;
}
.header-brand {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
/* Logo Normbel dans l'en-tête : petite carte blanche arrondie (fond sombre) */
.header-logo-img {
  height: 34px; width: auto;
  background: #fff;
  border-radius: 9px;
  padding: 3px 8px;
  display: block;
}
.header-title { font-size: 1rem; font-weight: 500; white-space: nowrap; }

.header-stats {
  display: flex; gap: 8px; flex: 1; justify-content: center;
  overflow-x: auto; scrollbar-width: none;
}
.header-stats::-webkit-scrollbar { display: none; }

.stat-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.8rem; font-weight: 500;
  white-space: nowrap; border: 1px solid transparent;
  flex-shrink: 0;
}
.stat-chip svg { width: 14px; height: 14px; }
.stat-chip.blue { background: var(--blue-bg); color: var(--blue); border-color: rgba(59,130,246,0.2); }
.stat-chip.green { background: var(--green-bg); color: var(--green); border-color: rgba(16,185,129,0.2); }
.stat-chip.muted { background: rgba(255,255,255,0.05); color: var(--text2); border-color: var(--border); }

.header-user {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}
.user-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px 4px 4px;
  font-size: 0.82rem;
}
.user-av {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700;
}
.btn-logout {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text2); transition: all 0.15s;
}
.btn-logout svg { width: 16px; height: 16px; }
.btn-logout:hover { color: var(--red); border-color: var(--red); background: var(--red-bg); }

/* ═══════════════════════════════════════════════════ MAIN LAYOUT */
.app-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px calc(80px + env(safe-area-inset-bottom));
}

/* ═══════════════════════════════════════════════════ TABS
   Onglets « boutons » : plus grands, encadrés, lisibles (demande utilisateur) */
.tab-nav {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 16px 0 16px;
  margin-bottom: 8px;
}
.tab-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.98rem; font-weight: 600;
  color: var(--text2);
  background: var(--card);
  border: 1.5px solid var(--border2);
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}
.tab-btn:hover { color: var(--text); background: var(--card2); border-color: var(--blue); }
.tab-btn.active {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
  box-shadow: 0 4px 14px rgba(59,130,246,0.35);
}
.tab-btn.active .tab-dot { background: #fff !important; }
.tab-dot {
  width: 8px; height: 8px; border-radius: 50%;
}

/* ═══════════════════════════════════════════════════ CALENDAR */
.calendar-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.cal-month {
  font-size: 1.05rem; font-weight: 600;
  text-transform: capitalize;
}
.cal-dow {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; margin-bottom: 8px;
}
.cal-dow span {
  font-size: 0.72rem; font-weight: 600;
  color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em;
  padding: 4px 0;
}
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.cal-day {
  aspect-ratio: 1;
  border-radius: var(--radius-xs);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-size: 0.85rem;
  cursor: default;
  position: relative;
  min-height: 36px;
  transition: background 0.1s;
}
.cal-day.current-month { cursor: pointer; }
.cal-day.current-month:hover { background: var(--card2); }
.cal-day.other-month { color: var(--text3); }
/* Jour avec événement(s) : surligné + chiffre marqué (plus visible que les points seuls) */
.cal-day.has-events.current-month {
  background: rgba(255,255,255,0.07);
  font-weight: 700;
}
.cal-day.today.current-month {
  background: var(--blue-bg);
  font-weight: 700; color: var(--blue);
}
.cal-day.selected {
  background: var(--blue) !important;
  color: #fff !important;
}
.cal-day-dots {
  display: flex; gap: 3px; margin-top: 2px;
  position: absolute; bottom: 5px;
}
.cal-dot {
  width: 7px; height: 7px; border-radius: 50%;
}
.cal-dot.blue { background: var(--blue); }
.cal-dot.green { background: var(--green); }

/* ═══════════════════════════════════════════════════ DAY PANEL */
.day-panel {
  background: var(--card);
  border: 1px solid var(--blue);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  animation: slide-down 0.2s ease;
}
.day-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.day-panel-header h3 { font-size: 0.95rem; font-weight: 600; color: var(--blue); }

/* ═══════════════════════════════════════════════════ CONTENT */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.section-header h3 { font-size: 1rem; font-weight: 600; }

.events-list { display: flex; flex-direction: column; gap: 10px; }

.event-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; gap: 14px; align-items: flex-start;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.event-card:hover { border-color: var(--border2); background: var(--card2); }
.event-card::before {
  content: '';
  position: absolute; left: 0; top: 12px; bottom: 12px;
  width: 3px; border-radius: 0 3px 3px 0;
}
.event-card.blue::before { background: var(--blue); }
.event-card.green::before { background: var(--green); }

.event-date-box {
  flex-shrink: 0;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  text-align: center;
  min-width: 48px;
}
.event-date-day { font-size: 1.3rem; font-weight: 700; line-height: 1; }
.event-date-month { font-size: 0.65rem; color: var(--text2); text-transform: uppercase; }
.event-info { flex: 1; }
.event-title { font-size: 0.93rem; font-weight: 600; margin-bottom: 4px; }
.event-meta {
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  font-size: 0.78rem; color: var(--text2);
}
.event-meta span { display: flex; align-items: center; gap: 4px; }
.event-badge {
  font-size: 0.7rem; font-weight: 600;
  padding: 2px 8px; border-radius: 20px;
  align-self: flex-start; flex-shrink: 0; margin-top: 2px;
}
.event-badge.blue { background: var(--blue-bg); color: var(--blue); }
.event-badge.green { background: var(--green-bg); color: var(--green); }

.empty-state {
  text-align: center; padding: 48px 24px;
  color: var(--text3); font-size: 0.9rem;
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }

/* ═══════════════════════════════════════════════════ USERS GRID */
.users-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.user-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; text-align: center;
}
.user-card-av {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 700;
}
.user-card-name { font-size: 0.9rem; font-weight: 600; }
.user-card-role {
  font-size: 0.72rem;
  padding: 2px 10px; border-radius: 20px;
}
.user-card-role.dirigeant { background: var(--blue-bg); color: var(--blue); }
.user-card-role.vendeur { background: rgba(255,255,255,0.05); color: var(--text2); }
.user-card-email { font-size: 0.72rem; color: var(--text3); word-break: break-all; }
.user-card-actions { display: flex; gap: 6px; margin-top: 4px; }

/* ═══════════════════════════════════════════════════ MODALS */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
  animation: fade-in 0.15s ease;
}
/* Le sélecteur de date s'ouvre PAR-DESSUS les modales tournée/entretien */
#datepicker-overlay { z-index: 300; }
.modal-card {
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow);
  animation: slide-up 0.2s ease;
}
.modal-card.wide { max-width: 620px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.modal-header h2 { font-size: 1.15rem; font-weight: 700; }
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════ FORMS */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label { font-size: 0.82rem; font-weight: 500; color: var(--text2); }
.req { color: var(--red); }
input[type="text"], input[type="email"], input[type="time"], select, textarea {
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: 0.9rem;
  width: 100%;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
textarea { resize: vertical; min-height: 60px; }
input[type="text"]:focus, input[type="email"]:focus,
input[type="time"]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%238892a4'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; padding-right: 36px; }
input::placeholder { color: var(--text3); }
small { color: var(--text3); font-size: 0.75rem; }

.date-field {
  position: relative; display: flex; align-items: center;
}
.date-display {
  cursor: pointer !important; padding-right: 40px !important;
}
.date-icon {
  position: absolute; right: 12px;
  width: 18px; height: 18px; color: var(--text3);
  pointer-events: none;
}

.autocomplete-wrap { position: relative; }
.suggestions {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--card2); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); z-index: 50;
  box-shadow: var(--shadow-sm);
  max-height: 220px; overflow-y: auto;
}
.suggestion-item {
  padding: 10px 14px; cursor: pointer;
  font-size: 0.84rem; line-height: 1.4;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover { background: var(--card); }
.suggestion-main { font-weight: 500; margin-bottom: 2px; }
.suggestion-sub { color: var(--text2); font-size: 0.75rem; }

.recruiters-group {
  display: flex; flex-direction: column; gap: 10px;
}
.check-label {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: all 0.15s;
  -webkit-user-select: none; user-select: none;
}
.check-label:hover { border-color: var(--green); }
.check-label input { display: none; }
.check-box {
  width: 20px; height: 20px; border-radius: 5px;
  border: 2px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.15s;
}
.check-label input:checked ~ .check-box {
  background: var(--green); border-color: var(--green);
}
.check-label input:checked ~ .check-box::after {
  content: '✓'; color: #fff; font-size: 0.75rem; font-weight: 700;
}
.check-label input:checked + .check-box { background: var(--green); border-color: var(--green); }

.conflict-banner {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--red-bg); border: 1px solid var(--red-border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  margin-top: 12px; font-size: 0.85rem; color: var(--red);
}
.conflict-banner svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

/* ═══════════════════════════════════════════════════ DATE PICKER */
.datepicker-card {
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%; max-width: 340px;
  box-shadow: var(--shadow);
  animation: slide-up 0.2s ease;
}
.datepicker-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; font-size: 0.95rem; font-weight: 600;
}
.dp-dow { margin-bottom: 6px; }
.dp-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.dp-cell {
  aspect-ratio: 1; min-height: 36px;
  border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.82rem;
}
.dp-cell.current { cursor: pointer; }
.dp-cell.current:hover { background: var(--blue-bg); color: var(--blue); }
.dp-cell.today { font-weight: 700; color: var(--blue); }
.dp-cell.busy {
  background: var(--red-bg) !important;
  color: var(--red) !important;
  cursor: not-allowed;
  text-decoration: line-through;
  opacity: 0.7;
}
.dp-cell.other { color: var(--text3); }
.dp-cell.past { color: var(--text3); cursor: not-allowed; opacity: 0.5; }
.dp-legend {
  display: flex; gap: 16px; justify-content: center;
  margin: 12px 0; font-size: 0.75rem; color: var(--text2);
}
.dp-leg-item { display: flex; align-items: center; gap: 5px; }
.dp-leg-dot { width: 10px; height: 10px; border-radius: 50%; }
.dp-leg-dot.busy { background: var(--red); }
.dp-leg-dot.avail { background: var(--blue); }

/* ═══════════════════════════════════════════════════ DETAIL MODAL */
.detail-content { display: flex; flex-direction: column; gap: 12px; }
.detail-row {
  display: flex; gap: 12px; align-items: flex-start;
  font-size: 0.88rem;
}
.detail-row-label {
  font-size: 0.75rem; color: var(--text2); font-weight: 500;
  min-width: 100px; flex-shrink: 0; padding-top: 2px;
}
.detail-row-value { color: var(--text); flex: 1; }
.detail-divider { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ═══════════════════════════════════════════════════ BUTTONS */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--blue); color: #fff;
  border-radius: var(--radius-sm);
  padding: 9px 18px; font-size: 0.88rem; font-weight: 600;
  transition: all 0.15s; white-space: nowrap;
}
.btn-primary svg { width: 16px; height: 16px; }
.btn-primary:hover { background: var(--blue-d); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary.green { background: var(--green); }
.btn-primary.green:hover { background: var(--green-d); }
.btn-primary.red { background: var(--red); }
.btn-primary.red:hover { background: #dc2626; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; color: var(--text2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 9px 18px; font-size: 0.88rem; font-weight: 500;
  transition: all 0.15s; white-space: nowrap;
}
.btn-ghost:hover { border-color: var(--text2); color: var(--text); }

.btn-icon-sm {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--card2); border: 1px solid var(--border);
  color: var(--text2); font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.btn-icon-sm:hover { color: var(--text); border-color: var(--border2); }

.btn-sm {
  padding: 5px 12px; font-size: 0.78rem; border-radius: var(--radius-xs);
  font-weight: 500; transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 4px;
}
.btn-sm.blue { background: var(--blue-bg); color: var(--blue); border: 1px solid rgba(59,130,246,0.2); }
.btn-sm.blue:hover { background: var(--blue-bg2); }
.btn-sm.green { background: var(--green-bg); color: var(--green); border: 1px solid rgba(16,185,129,0.2); }
.btn-sm.red { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.btn-sm.red:hover { background: rgba(239,68,68,0.2); }

/* ═══════════════════════════════════════════════════ TOAST */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--card2); border: 1px solid var(--border2);
  border-radius: 8px; padding: 10px 20px;
  font-size: 0.88rem; color: var(--text);
  box-shadow: var(--shadow); z-index: 999;
  animation: slide-up 0.2s ease;
  white-space: nowrap;
}
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error { border-color: var(--red); color: var(--red); }

/* ═══════════════════════════════════════════════════ ANIMATIONS */
@keyframes slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slide-down {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-6px); }
  40%,80% { transform: translateX(6px); }
}
.shake { animation: shake 0.35s ease; }

/* ═══════════════════════════════════════════════════ ROLES & DISPONIBILITÉ */
.user-card-role.responsable { background: rgba(245,158,11,0.12); color: var(--yellow); }

.locked-vendeur {
  background: var(--blue-bg);
  border: 1px solid rgba(59,130,246,0.3);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.locked-vendeur-name { font-weight: 700; font-size: 1rem; color: var(--blue); }
.locked-vendeur-note { font-size: 0.78rem; color: var(--text2); margin-top: 3px; }

.conflict-banner.warn {
  background: rgba(245,158,11,0.12);
  border-color: rgba(245,158,11,0.3);
  color: var(--yellow);
}

.action-group {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  width: 100%;
  padding: 8px 0;
}
.action-group-label {
  font-size: 0.78rem; color: var(--text2); font-weight: 600;
  flex-basis: 100%;
}
.action-group a, .action-group button { text-decoration: none; cursor: pointer; }

.note-section {
  display: flex; flex-direction: column; gap: 8px;
  border-top: 1px solid var(--border2);
  padding-top: 12px; margin-top: 4px;
}
.note-label { font-size: 0.78rem; font-weight: 600; color: var(--text2); }
.note-section .btn-sm { align-self: flex-end; }
.note-readonly { font-size: 0.88rem; color: var(--text); white-space: pre-wrap; }

.mail-note {
  background: rgba(59,130,246,0.08);
  border: 1px solid rgba(59,130,246,0.2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 12px;
  font-size: 0.78rem;
  color: var(--text2);
  line-height: 1.5;
}

.dp-cell.partial {
  background: rgba(245,158,11,0.15);
  color: var(--yellow);
  cursor: pointer;
}
.dp-cell.partial:hover { background: rgba(245,158,11,0.3); }
.dp-leg-dot.partial { background: var(--yellow); }

/* ═══════════════════════════════════════════════════ SCROLLBAR */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* ═══════════════════════════════════════════════════ RESPONSIVE */
@media (max-width: 600px) {
  .header-title { display: none; }
  .header-stats { gap: 6px; }
  .stat-chip { padding: 4px 8px; font-size: 0.72rem; }
  .form-row { grid-template-columns: 1fr; }
  .modal-card { padding: 20px 16px; }
  .cal-day { font-size: 0.78rem; min-height: 32px; }
  .profiles-grid { grid-template-columns: repeat(2, 1fr); }

  /* En-tête plus compact ; on garde l'avatar mais on masque le nom (place) */
  .app-header { padding-left: 12px; padding-right: 12px; gap: 8px; }
  .user-pill { padding: 4px; }
  .user-pill span { display: none; }

  /* Onglets « boutons » sur 2 colonnes : tous visibles, gros et lisibles
     (avant : défilement horizontal qui cachait des onglets hors écran) */
  .app-main { padding-left: 12px; padding-right: 12px; }
  .tab-nav { flex-wrap: wrap; gap: 8px; }
  .tab-btn {
    flex: 1 1 42%;
    justify-content: center;
    padding: 12px 8px;
    font-size: 0.92rem;
    white-space: nowrap;
  }

  /* Panneaux un peu plus compacts */
  .calendar-panel { padding: 14px; }
  .day-panel { padding: 14px; }

  /* IMPORTANT iPhone : police ≥ 16px sur les champs → empêche le zoom automatique au clic */
  input[type="text"], input[type="email"], input[type="time"], select, textarea { font-size: 16px; }

  /* Boutons de modale empilés et pleine largeur (cibles tactiles plus grandes) */
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions > * { width: 100%; }
}

/* ═══════════════════════════════════════════════ INSTALLATION (PWA) */
.install-hint {
  margin-top: 24px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.install-btn {
  background: var(--blue); color: #fff;
  padding: 11px 20px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 0.9rem;
}
.install-link {
  color: var(--text2); font-size: 0.85rem; text-decoration: underline;
  background: none; padding: 4px;
}
.install-steps { line-height: 1.75; font-size: 0.95rem; color: var(--text); }

/* ═══════════════════════════════════════════════ COMPTEUR DE CONGÉS */
.leaves-counter {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 0.9rem;
}
.leaves-counter strong { color: var(--yellow); font-size: 1.05rem; }
.leaves-counter .lc-row {
  display: flex; justify-content: space-between;
  padding: 3px 0; color: var(--text2); font-size: 0.85rem;
}

/* ═══════════════════════════════════════════════ AÉRATION DES RUBRIQUES */
.section-header { margin: 24px 0 14px; }
#tab-content-accueil .section-header:first-of-type { margin-top: 0; }
.events-list { gap: 12px; }
.calendar-panel { margin-bottom: 20px; }
.day-panel { margin-bottom: 20px; }
.group-head { margin-bottom: 8px; }

/* Jour de fermeture Normbel au calendrier */
.cal-day.closed-day {
  background: rgba(239,68,68,0.16) !important;
  color: var(--red);
  font-weight: 700;
}
@media (max-width: 400px) {
  .profiles-grid { grid-template-columns: repeat(2, 1fr); }
  .numpad-btn { height: 48px; font-size: 1.1rem; }
}

/* ═════════════════════════════════ EN-TÊTE DE GROUPE (Tournées / Entretiens) */
.group-head {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.group-head.blue { color: var(--blue); }
.group-head.green { color: var(--green); }

/* ═════════════════════════════════════ ŒIL AFFICHER/MASQUER LE MOT DE PASSE */
.password-wrap { position: relative; }
.password-wrap input { width: 100%; padding-right: 46px; }
.password-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: var(--text2); padding: 0; border-radius: var(--radius-xs);
}
.password-toggle:hover { color: var(--text); background: var(--card2); }
.password-toggle svg { width: 20px; height: 20px; }

/* Précision sous le titre de la note (confidentialité) */
.note-hint { display: block; font-size: 0.78rem; color: var(--text2); margin: 4px 0 10px; }

/* ═══════════════════════════════════════════════ FORMATIONS (violet) */
.event-card.violet::before { background: #a855f7; }
.event-badge.violet { background: rgba(168,85,247,0.14); color: #c084fc; }
.group-head.violet { color: #c084fc; }

/* ═══════════════════════════════════════════════ RÉUNIONS (orange) */
.event-card.orange::before { background: #fb923c; }
.event-badge.orange { background: rgba(251,146,60,0.16); color: #fdba74; }
.group-head.orange { color: #fdba74; }
.group-head.yellow { color: var(--yellow); }

/* Boutons export / impression (onglet Historique) */
.export-actions{display:flex;gap:6px;flex-wrap:wrap;align-items:center}

/* Tableau de bord (graphiques en barres) — thème sombre cohérent avec le reste de l'app.
   Piste sombre : une valeur 0 se lit comme « vide » (avant, la piste claire ressemblait à une barre pleine). */
#dashboard-section{background:var(--card);border:1px solid var(--border);border-radius:var(--radius);padding:18px 20px 20px}
#dashboard-section .section-header{margin:0 0 4px}
.dash-h{font-size:0.76rem;font-weight:700;color:var(--text2);margin:18px 0 10px;text-transform:uppercase;letter-spacing:0.06em}
.dash-row{display:flex;align-items:center;gap:10px;margin:7px 0}
.dash-label{flex:0 0 40%;font-size:0.84rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.dash-bar{flex:1;height:10px;background:rgba(255,255,255,0.06);border-radius:5px;overflow:hidden}
.dash-fill{display:block;height:100%;border-radius:5px;background:linear-gradient(90deg,var(--blue),#6366f1);transform-origin:left;animation:dash-grow 0.5s ease}
.dash-fill.violet{background:linear-gradient(90deg,#a855f7,#c084fc)}
.dash-fill.green{background:linear-gradient(90deg,var(--green),#34d399)}
.dash-val{flex:0 0 auto;min-width:44px;text-align:right;font-size:0.82rem;font-weight:700;font-variant-numeric:tabular-nums;color:var(--text)}
@keyframes dash-grow{from{transform:scaleX(0)}to{transform:scaleX(1)}}

/* Badge de statut du jour (retard / malade / absent) sur les tournées */
.flag-badge{background:#fef3c7;color:#92400e;border-radius:6px;padding:1px 7px;font-weight:600;white-space:nowrap}

/* Jours ouvrables du mois affiché (sous l'en-tête du calendrier) */
.cal-workdays{font-size:0.72rem;color:var(--text2);text-align:center;margin:-8px 0 10px;min-height:1em;line-height:1.4}

/* Onglet Tournées — « Cette semaine, jour par jour » */
.week-block-head{font-size:0.82rem;font-weight:600;color:var(--text2);margin-bottom:8px}
.week-row{display:flex;align-items:center;gap:10px;padding:9px 12px;background:var(--card);border:1px solid var(--border);border-radius:var(--radius-sm);margin-bottom:6px;cursor:pointer;font-size:0.85rem;transition:all 0.15s}
.week-row:hover{border-color:var(--border2);background:var(--card2)}
.week-row-date{flex:0 0 108px;font-weight:600;color:var(--blue);text-transform:capitalize;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.week-row-date.today{color:var(--green)}
.week-row-who{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.week-row-acc{color:var(--text2)}
.week-row-time{flex:0 0 auto;color:var(--text2);font-size:0.78rem}
@media (max-width:480px){
  .week-row{flex-wrap:wrap;row-gap:2px}
  .week-row-date{flex:0 0 100%}
  .week-row-who{white-space:normal}
}

/* Mode d'emploi intégré (bouton ? de l'en-tête) */
.help-card{max-width:920px;width:96%;padding:16px}
.help-frame{width:100%;height:78vh;border:0;border-radius:10px;background:#fff;margin-top:4px}

/* Graphiques en barres sur téléphone : le libellé passe sur 2 lignes au lieu d'être coupé */
@media (max-width: 520px) {
  .dash-label{flex-basis:50%;white-space:normal;line-height:1.25;font-size:12px}
  #dashboard-section{padding:14px}
}

/* Titre principal du bloc accompagnements (au-dessus des 3 groupes) */
.dash-h-main{font-size:0.92rem;color:var(--text);text-transform:none;letter-spacing:0;margin-top:26px;padding-top:18px;border-top:1px solid var(--border)}
