/* =========================================================
   CALADE AIR — Design System
   Aviation d'affaires : sobre, professionnel, premium
   ========================================================= */

:root {
  /* Palette */
  --color-bg: #f5f7fa;
  --color-surface: #ffffff;
  --color-surface-2: #fafbfc;
  --color-border: #e3e8ef;
  --color-border-strong: #cbd5e1;

  --color-text: #0f172a;
  --color-text-muted: #475569;
  --color-text-soft: #94a3b8;

  --color-primary: #0b3d91;     /* bleu aviation */
  --color-primary-dark: #082c6b;
  --color-primary-light: #e6edf9;
  --color-accent: #d4af37;      /* doré discret */

  --color-success: #16a34a;
  --color-warning: #ea580c;
  --color-danger: #dc2626;
  --color-info: #0284c7;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
a { color: var(--color-primary); text-decoration: none; }

/* =========================================================
   LOGIN
   ========================================================= */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--color-bg);
}

.login-hero {
  background: linear-gradient(135deg, #0b3d91 0%, #082c6b 50%, #051f4d 100%);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  color: #fff;
}

.login-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.08) 0%, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(212,175,55,0.12) 0%, transparent 40%);
}

.login-hero-content { position: relative; z-index: 1; }

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.login-brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, #d4af37, #b8932a);
  display: grid;
  place-items: center;
  font-size: 22px;
}

.login-hero-title {
  font-size: 38px;
  font-weight: 700;
  line-height: 1.15;
  margin-top: auto;
  max-width: 460px;
}

.login-hero-subtitle {
  margin-top: 18px;
  font-size: 16px;
  opacity: 0.85;
  max-width: 420px;
}

.login-hero-footer {
  position: relative;
  z-index: 1;
  font-size: 13px;
  opacity: 0.6;
}

.login-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.login-card {
  width: 100%;
  max-width: 420px;
}

.login-card h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text);
}

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

.login-form { margin-top: 32px; display: flex; flex-direction: column; gap: 16px; }

.demo-accounts {
  margin-top: 28px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.demo-accounts-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-text-soft);
  font-weight: 600;
  margin-bottom: 10px;
}

.demo-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

.demo-account:hover { background: var(--color-primary-light); }

.demo-account-role {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.demo-account-role.admin  { background: #fef3c7; color: #92400e; }
.demo-account-role.pilote { background: #dbeafe; color: #1e40af; }
.demo-account-role.client { background: #dcfce7; color: #166534; }

@media (max-width: 900px) {
  .login-page { grid-template-columns: 1fr; }
  .login-hero { display: none; }
}

/* =========================================================
   FORM CONTROLS
   ========================================================= */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--color-text); }
.form-hint { font-size: 12px; color: var(--color-text-soft); }

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: 14px;
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(11, 61, 145, 0.12);
}

/* Input qui affiche systématiquement en MAJUSCULES (noms, prénoms, OACI…) */
.form-input.uppercase { text-transform: uppercase; }
.form-input.uppercase::placeholder { text-transform: none; }

.form-textarea { resize: vertical; min-height: 80px; }

.form-error { color: var(--color-danger); font-size: 13px; margin-top: 4px; }

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
}

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

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

.btn-secondary {
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  color: var(--color-text);
}

.btn-secondary:hover { background: var(--color-surface-2); border-color: var(--color-primary); }

.btn-ghost { color: var(--color-text-muted); background: transparent; }
.btn-ghost:hover { background: var(--color-surface-2); color: var(--color-text); }

.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 13px 22px; font-size: 15px; }

/* =========================================================
   APP LAYOUT
   ========================================================= */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #ffffff;
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 18px;
}

.sidebar-brand-text {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.3px;
}

.sidebar-brand-sub {
  font-size: 11px;
  color: var(--color-text-soft);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-text-soft);
  padding: 12px 12px 6px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 7px;
  color: var(--color-text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: var(--color-surface-2); color: var(--color-text); }
.nav-item.active { background: var(--color-primary-light); color: var(--color-primary); font-weight: 600; }
.nav-item-icon { font-size: 16px; width: 18px; display: inline-block; text-align: center; }

.sidebar-footer {
  border-top: 1px solid var(--color-border);
  padding: 14px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 14px;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-role { font-size: 11px; color: var(--color-text-soft); text-transform: uppercase; letter-spacing: 0.3px; }

.sidebar-logout {
  margin-top: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--color-text-muted);
  border-radius: 6px;
  text-align: left;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logout:hover { background: #fef2f2; color: var(--color-danger); }

/* =========================================================
   MAIN CONTENT
   ========================================================= */
.main { padding: 0; min-width: 0; }

.page-header {
  padding: 28px 36px 18px;
  border-bottom: 1px solid var(--color-border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.page-title { font-size: 22px; font-weight: 700; color: var(--color-text); }
.page-subtitle { font-size: 13px; color: var(--color-text-muted); margin-top: 4px; }

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

.page-body { padding: 28px 36px; }

/* =========================================================
   CARDS
   ========================================================= */
.card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card-title { font-size: 15px; font-weight: 600; }
.card-subtitle { font-size: 12px; color: var(--color-text-soft); }

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: grid;
  place-items: center;
  font-size: 18px;
  margin-bottom: 6px;
}

.stat-icon.success { background: #dcfce7; color: #166534; }
.stat-icon.warning { background: #ffedd5; color: #9a3412; }
.stat-icon.danger  { background: #fee2e2; color: #991b1b; }

.stat-label { font-size: 12px; color: var(--color-text-soft); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--color-text); }
.stat-meta { font-size: 12px; color: var(--color-text-muted); }

/* =========================================================
   TABLES
   ========================================================= */
.table-wrapper {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--color-text-soft);
  padding: 14px 18px;
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
}

.table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--color-surface-2); }

.table-row-clickable { cursor: pointer; }

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--color-text-soft);
}

.empty-state-icon { font-size: 42px; opacity: 0.4; margin-bottom: 12px; }
.empty-state-title { font-size: 15px; font-weight: 600; color: var(--color-text-muted); margin-bottom: 4px; }
.empty-state-text { font-size: 13px; }

/* =========================================================
   BADGES
   ========================================================= */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.badge-primary { background: var(--color-primary-light); color: var(--color-primary); }
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #ffedd5; color: #9a3412; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #e0f2fe; color: #075985; }
.badge-neutral { background: #f1f5f9; color: #475569; }

/* =========================================================
   MODAL
   ========================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 24px;
  animation: fadeIn 0.15s;
}

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.2s;
}

.modal-lg { max-width: 860px; }

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 17px; font-weight: 600; }
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 18px;
  color: var(--color-text-soft);
}
.modal-close:hover { background: var(--color-surface-2); color: var(--color-text); }

.modal-body { padding: 24px; overflow-y: auto; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;            /* retour à la ligne si trop de boutons */
  background: var(--color-surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Les boutons du footer ne doivent jamais déborder sur petit écran */
.modal-footer .btn {
  flex-shrink: 0;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* =========================================================
   TOASTS
   ========================================================= */
#toast-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}

.toast {
  background: #fff;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  box-shadow: var(--shadow-md);
  font-size: 14px;
  min-width: 260px;
  max-width: 360px;
  animation: slideInRight 0.2s;
}
.toast.success { border-left-color: var(--color-success); }
.toast.error   { border-left-color: var(--color-danger); }
.toast.warning { border-left-color: var(--color-warning); }

@keyframes slideInRight { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* =========================================================
   FORM GRID
   ========================================================= */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid-full { grid-column: 1 / -1; }

/* =========================================================
   PLANNING / CALENDAR
   ========================================================= */
.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.calendar-nav { display: flex; align-items: center; gap: 8px; }

.calendar-current {
  font-size: 16px;
  font-weight: 600;
  min-width: 200px;
  text-align: center;
}

.calendar-view-switch {
  display: inline-flex;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.calendar-view-switch button {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  border-radius: 4px;
}

.calendar-view-switch button.active { background: #fff; color: var(--color-primary); box-shadow: var(--shadow-sm); }

/* Month grid */
.calendar-month {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.calendar-day-header {
  padding: 10px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-soft);
  background: var(--color-surface-2);
  text-align: center;
  border-bottom: 1px solid var(--color-border);
}

.calendar-day {
  min-height: 110px;
  padding: 6px 8px;
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  position: relative;
  transition: background 0.1s;
}

.calendar-day:nth-child(7n) { border-right: none; }
.calendar-day:hover { background: var(--color-surface-2); }
.calendar-day.other-month { color: var(--color-text-soft); background: #fafbfc; }
.calendar-day.today .calendar-day-number {
  background: var(--color-primary);
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.calendar-day-number {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
}

.calendar-event {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-left: 3px solid var(--color-primary);
  font-weight: 500;
}

.calendar-unavail {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  background: repeating-linear-gradient(
    45deg,
    #f1f5f9,
    #f1f5f9 4px,
    #e2e8f0 4px,
    #e2e8f0 8px
  );
  color: #475569;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-left: 3px solid #94a3b8;
  font-weight: 500;
  cursor: pointer;
}

.calendar-unavail.mine {
  background: repeating-linear-gradient(
    45deg,
    #fef3c7,
    #fef3c7 4px,
    #fde68a 4px,
    #fde68a 8px
  );
  color: #78350f;
  border-left-color: #f59e0b;
}

.calendar-unavail-chip {
  display: inline-block;
  font-size: 10px;
  padding: 2px 6px;
  margin: 2px 2px 0;
  border-radius: 3px;
  background: #f1f5f9;
  color: #475569;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.calendar-unavail-chip.mine {
  background: #fef3c7;
  color: #78350f;
}

.calendar-event.completed { background: #dcfce7; color: #166534; border-left-color: #16a34a; }
.calendar-event.cancelled { background: #f1f5f9; color: #64748b; border-left-color: #94a3b8; text-decoration: line-through; }
.calendar-event.in-progress { background: #ffedd5; color: #9a3412; border-left-color: #ea580c; }

/* Week / day view */
.calendar-week {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.calendar-time-col {
  background: var(--color-surface-2);
  border-right: 1px solid var(--color-border);
}

.calendar-time-cell {
  height: 50px;
  font-size: 11px;
  color: var(--color-text-soft);
  text-align: center;
  border-bottom: 1px solid var(--color-border);
  padding-top: 2px;
}

.calendar-week-col { border-right: 1px solid var(--color-border); position: relative; }
.calendar-week-col:last-child { border-right: none; }
.calendar-week-col-header {
  text-align: center;
  padding: 10px 6px;
  font-size: 12px;
  font-weight: 600;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-2);
}

.calendar-week-col-header .day-num { font-size: 16px; color: var(--color-text); }
.calendar-week-col-header.today .day-num { color: var(--color-primary); }
.calendar-week-col-header .day-name { color: var(--color-text-soft); text-transform: uppercase; }

.calendar-hour-cell {
  height: 50px;
  border-bottom: 1px solid var(--color-border);
}

.calendar-week-event {
  position: absolute;
  /* left + width sont calculés inline pour gérer le chevauchement (cf _computeOverlapLayout) */
  background: var(--color-primary-light);
  border: 1px solid var(--color-primary);
  border-left: 3px solid var(--color-primary);
  color: var(--color-primary);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  overflow: hidden;
  z-index: 1;
}

.calendar-week-event.completed { background: #dcfce7; border-color: #16a34a; color: #166534; }
.calendar-week-event.in-progress { background: #ffedd5; border-color: #ea580c; color: #9a3412; }

/* =========================================================
   ADDRESS AUTOCOMPLETE (BAN + OSM)
   ========================================================= */
.address-autocomplete-dropdown {
  position: absolute;
  background: #fff;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  /* Doit passer AU-DESSUS des modales (z-index 2000) car les dropdowns sont attachées au <body> */
  z-index: 2500;
  max-height: 320px;
  overflow-y: auto;
  display: none;
  min-width: 280px;
}
.address-autocomplete-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
  transition: background 0.1s;
}
.address-autocomplete-item:last-child { border-bottom: none; }
.address-autocomplete-item:hover,
.address-autocomplete-item.active { background: var(--color-primary-light); }
.address-autocomplete-icon { font-size: 18px; flex-shrink: 0; }
.address-autocomplete-info { flex: 1; min-width: 0; }
.address-autocomplete-label {
  font-size: 13px; font-weight: 600; color: var(--color-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.address-autocomplete-context { font-size: 11px; color: var(--color-text-soft); margin-top: 1px; }
.address-autocomplete-source {
  font-size: 9px; font-weight: 700;
  background: var(--color-surface-2); color: var(--color-text-soft);
  padding: 2px 6px; border-radius: 4px; letter-spacing: 0.5px;
}

/* =========================================================
   COMBOBOX + CHIPS (sélection passagers, etc.)
   ========================================================= */
.combo-wrap { position: relative; }
.combo-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  background: #fff;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 240px;
  overflow-y: auto;
  margin-top: 4px;
}
.combo-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
}
.combo-item:last-child { border-bottom: none; }
.combo-item:hover, .combo-item.active { background: var(--color-primary-light); }
.combo-item-name { font-weight: 600; color: var(--color-text); }
.combo-item-meta { font-size: 11px; color: var(--color-text-soft); margin-top: 2px; }
.combo-item.add-manual {
  background: #ecfdf5;
  color: #166534;
  font-weight: 600;
}
.combo-item.add-manual:hover { background: #d1fae5; }

.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  min-height: 36px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.chip.manual {
  background: #fef3c7;
  color: #78350f;
}
.chip-remove {
  cursor: pointer;
  width: 16px; height: 16px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(0,0,0,0.08);
  font-size: 10px;
  line-height: 1;
}
.chip-remove:hover { background: rgba(0,0,0,0.18); }

/* =========================================================
   FLATPICKR — Sélecteur de date français
   On override quelques styles pour s'aligner sur notre design.
   ========================================================= */
input.flatpickr-input.form-input,
.flatpickr-input + .form-input.input {
  background: var(--color-surface);
}

/* L'input "alt" (texte visible) hérite déjà de .form-input */
.flatpickr-calendar {
  font-family: var(--font-sans) !important;
  font-size: 13px !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-lg) !important;
  border: 1px solid var(--color-border-strong) !important;
}

.flatpickr-day.selected,
.flatpickr-day.selected:hover,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
  background: var(--color-primary) !important;
  border-color: var(--color-primary) !important;
}

.flatpickr-day.today {
  border-color: var(--color-primary) !important;
  color: var(--color-primary) !important;
}

.flatpickr-day.today:hover {
  background: var(--color-primary-light) !important;
}

.flatpickr-months .flatpickr-month,
.flatpickr-current-month,
.flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year {
  color: var(--color-text) !important;
  font-weight: 500;
}

span.flatpickr-weekday {
  color: var(--color-text-soft) !important;
  font-weight: 600;
}

/* =========================================================
   AIRPORT AUTOCOMPLETE
   ========================================================= */
.airport-autocomplete-dropdown {
  position: absolute;
  background: #fff;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  /* Doit passer AU-DESSUS des modales (z-index 2000) car les dropdowns sont attachées au <body> */
  z-index: 2500;
  max-height: 320px;
  overflow-y: auto;
  display: none;
  min-width: 280px;
}

.airport-autocomplete-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
  transition: background 0.1s;
}

.airport-autocomplete-item:last-child { border-bottom: none; }
.airport-autocomplete-item:hover,
.airport-autocomplete-item.active { background: var(--color-primary-light); }

.airport-autocomplete-code {
  font-family: ui-monospace, "SF Mono", Monaco, monospace;
  font-weight: 700;
  color: var(--color-primary);
  font-size: 13px;
  background: var(--color-primary-light);
  padding: 3px 8px;
  border-radius: 4px;
  flex-shrink: 0;
  min-width: 50px;
  text-align: center;
}

.airport-autocomplete-info { flex: 1; min-width: 0; }

.airport-autocomplete-city {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.airport-autocomplete-name {
  font-size: 11px;
  color: var(--color-text-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.airport-autocomplete-empty {
  padding: 12px 14px;
  font-size: 12px;
  color: var(--color-text-soft);
  text-align: center;
  font-style: italic;
}

/* =========================================================
   DOCUMENTS (upload widget)
   ========================================================= */
.doc-field { display: block; }

.doc-empty {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 2px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  transition: border-color 0.15s, background 0.15s;
}

.doc-empty:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.doc-empty-icon {
  font-size: 28px;
  opacity: 0.5;
}

.doc-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff;
}

.doc-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--color-primary-light);
  border-radius: var(--radius-sm);
  font-size: 22px;
}

.doc-info {
  flex: 1;
  min-width: 0;
}

.doc-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-meta {
  font-size: 12px;
  color: var(--color-text-soft);
  margin-top: 2px;
}

.doc-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.doc-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.doc-badge:hover { background: var(--color-primary); color: #fff; }

.doc-badge-empty {
  background: var(--color-surface-2);
  color: var(--color-text-soft);
}

/* =========================================================
   UTILITIES
   ========================================================= */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--color-text-muted); }
.text-soft  { color: var(--color-text-soft); }
.text-sm    { font-size: 13px; }
.text-xs    { font-size: 12px; }
.font-bold  { font-weight: 700; }
.font-semibold { font-weight: 600; }

/* =========================================================
   MOBILE TOPBAR & SIDEBAR DRAWER
   Cachés sur desktop, activés sous 768px.
   ========================================================= */
.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }
.sidebar-close-mobile { display: none; }

@media (max-width: 768px) {
  /* === Layout général === */
  body { font-size: 15px; }                       /* lecture confortable */
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  /* === Topbar fixe en haut === */
  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border-bottom: 1px solid var(--color-border);
    padding: 10px 14px;
    position: sticky;
    top: 0;
    z-index: 50;
    grid-column: 1 / -1;
    grid-row: 1;
  }
  .mobile-menu-btn {
    width: 38px; height: 38px;
    font-size: 22px;
    border-radius: 6px;
    color: var(--color-text);
  }
  .mobile-menu-btn:active { background: var(--color-surface-2); }
  .mobile-topbar-title {
    display: flex; gap: 8px; align-items: center;
    font-weight: 700;
    font-size: 15px;
    color: var(--color-primary);
    letter-spacing: 0.3px;
  }
  .mobile-topbar-logo {
    display: grid; place-items: center;
    width: 28px; height: 28px;
    background: var(--color-primary);
    color: #fff;
    border-radius: 6px;
    font-size: 14px;
  }

  /* === Sidebar transformée en drawer === */
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    width: 80vw; max-width: 320px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
    box-shadow: var(--shadow-lg);
  }
  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
  }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 150;
  }
  .app-shell.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  .sidebar-close-mobile {
    display: grid;
    place-items: center;
    width: 36px; height: 36px;
    margin-left: auto;
    font-size: 22px;
    color: var(--color-text-soft);
    border-radius: 6px;
  }
  .sidebar-close-mobile:active { background: var(--color-surface-2); }

  /* === Padding / textes contenu === */
  .page-header, .page-body { padding-left: 16px; padding-right: 16px; }
  .page-title { font-size: 18px; }
  .page-subtitle { font-size: 12px; }

  /* === Stat cards en 1 colonne === */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 16px;
  }
  .stat-value { font-size: 22px; }

  /* === Forms en 1 colonne === */
  .form-grid { grid-template-columns: 1fr; }
  .form-input, .form-select, .form-textarea {
    font-size: 16px;                  /* iOS : évite le zoom auto */
    min-height: 44px;                 /* tap target */
  }

  /* === Modals plein écran === */
  .modal-overlay { padding: 0; }
  .modal, .modal-lg {
    max-width: 100%;
    max-height: 100vh;
    width: 100%;
    height: 100vh;
    border-radius: 0;
  }
  .modal-body { padding: 16px; }
  .modal-header, .modal-footer { padding: 12px 16px; }
  .modal-footer .btn {
    flex: 1 1 auto;
    min-height: 44px;
  }

  /* === Tableaux : scroll horizontal === */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { min-width: 600px; }
  .table th, .table td { padding: 10px 12px; }

  /* === Boutons : tap target confortable === */
  .btn { min-height: 38px; padding: 10px 16px; font-size: 14px; }
  .btn-sm { min-height: 30px; padding: 6px 10px; }
  .btn-lg { min-height: 48px; }

  /* === Cartes dashboard : 1 colonne === */
  .page-body > div[style*="grid-template-columns: 2fr 1fr"],
  .page-body > div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* === Calendrier mois compact === */
  .calendar-day { min-height: 70px; padding: 4px; }
  .calendar-day-number { font-size: 11px; width: 18px; height: 18px; margin-bottom: 2px; }
  .calendar-event { font-size: 9px; padding: 1px 4px; }
  .calendar-day-header { padding: 6px 4px; font-size: 10px; }

  /* === Calendrier semaine : compact === */
  .calendar-week { grid-template-columns: 38px repeat(7, minmax(50px, 1fr)); }
  .calendar-time-cell { font-size: 9px; }
  .calendar-week-col-header { padding: 6px 2px; font-size: 10px; }
  .calendar-week-col-header .day-num { font-size: 14px; }
  .calendar-week-event { font-size: 9px; padding: 2px 3px; }

  /* === Toolbar planning : wrap + stack === */
  .calendar-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .calendar-nav { justify-content: center; }
  .calendar-current { min-width: auto; font-size: 14px; }

  /* === Sidebar dashboard : passe en pleine largeur === */
  .card { padding: 14px; }

  /* === Toasts : largeur réduite === */
  #toast-root { left: 16px; right: 16px; bottom: 16px; }
  .toast { min-width: auto; max-width: 100%; font-size: 13px; }

  /* === Page header : actions empilées au besoin === */
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-actions { width: 100%; display: flex; gap: 8px; flex-wrap: wrap; }
  .page-actions .btn { flex: 1 1 auto; }

  /* === Documents widget compact === */
  .doc-card, .doc-empty { padding: 10px 12px; }
  .doc-actions { flex-wrap: wrap; }

  /* === LiveMap : hauteur réduite + sidebar dessous === */
  .card > div[style*="grid-template-columns: 2fr 1fr"][style*="380px"] {
    grid-template-columns: 1fr !important;
  }
}

/* =========================================================
   PETITE TABLETTE / GRAND TÉLÉPHONE (entre 768 et 480)
   ========================================================= */
@media (min-width: 481px) and (max-width: 768px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* =========================================================
   LEAFLET — confinement du contexte d'empilement
   Sans ça, les z-index internes de Leaflet (jusqu'à 1000 sur ses
   contrôles) remontent au-dessus des modales, toasts et drawer mobile.
   `isolation: isolate` crée un contexte local : tous les z-index Leaflet
   restent confinés à l'intérieur de son conteneur.
   ========================================================= */
.leaflet-container {
  isolation: isolate;
  z-index: 0;
}

/* Sécurité : remonter les overlays critiques bien au-dessus de Leaflet */
.modal-overlay { z-index: 2000 !important; }
#toast-root    { z-index: 2100 !important; }

@media (max-width: 768px) {
  .mobile-topbar    { z-index: 1100 !important; }
  .sidebar-backdrop { z-index: 1150 !important; }
  .sidebar          { z-index: 1200 !important; }
}
