/* Nouvelle DA : surfaces gris clair, grandes zones arrondies, bleu en couleur d'action,
   vert pour les états "ok" (--success), marine/vert anis du logo SAMS pour les accents de marque. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #d9d9dd;            /* fond de la page, derrière la coque */
  --shell: #e8e8eb;         /* coque de l'application */
  --bg-elevated: #ffffff;   /* champs, modales, pastilles posées sur une carte */
  --card: #f2f2f4;
  --card-hover: #e9e9ed;
  --panel: #e1e1e5;
  --border: #d2d2d7;
  --text: #1c1c21;
  --text-muted: #6b6b75;
  --text-faint: #9b9ba5;
  --accent: #2f78e4;
  --accent-dark: #2565c4;
  --accent-soft: rgba(47, 120, 228, 0.13);
  --success: #2fb94d;
  --success-soft: rgba(47, 185, 77, 0.15);
  --amber: #e0912c;
  --amber-soft: rgba(224, 145, 44, 0.16);
  --navy: #1a2f5c;
  --lime: #8bc53f;
  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, 0.12);
  --info: #2f78e4;
  --radius: 14px;
  --radius-sm: 10px;
  --seg-bg: #d0d0d6;          /* fond des boutons gris et des contrôles segmentés */
  --btn-hover: #c6c6cd;
  --surface-hover: #fafafb;   /* survol d'une ligne/carte */
  --track: #d9d9de;           /* rails de barres, avatars vides */
  --nav-active: #d5d5da;
  --handle-bg: #d0d0d5;
  --pill-bg: #d4d4d9;
  --hover-overlay: rgba(0, 0, 0, 0.05);
  --menu-bg: rgba(250, 250, 251, 0.96);
  --ok-text: #1f8a38;
  --amber-text: #9a5d0a;
  color-scheme: light;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: inherit; }

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

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.topbar-left img {
  height: 36px;
  width: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.topbar-title {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--card-hover);
  color: var(--text);
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

.card {
  background: var(--card);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--seg-bg);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}

a.btn { text-decoration: none; }
.btn:hover { background: var(--btn-hover); }
.btn:active { transform: scale(0.98); }

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

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

.btn-danger {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

.btn-danger:hover { background: rgba(229, 72, 77, 0.2); }

.btn-sm { padding: 6px 12px; font-size: 13px; }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); }

label {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.field { margin-bottom: 16px; }

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

.checkbox-row input { width: auto; }

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-card img {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  margin-bottom: 14px;
  object-fit: cover;
}

.login-card h1 {
  font-size: 18px;
  margin: 0 0 4px;
}

.login-card p.subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 22px;
}

.error-box {
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.error-box.visible { display: block; }

.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.app-tile-image {
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.app-tile-image:hover { border-color: var(--accent); transform: translateY(-2px); }

.app-tile-image img {
  display: block;
  width: 100%;
  height: auto;
}

.app-tile-image .app-tile-image-label {
  padding: 12px 14px;
  font-weight: 600;
  font-size: 14.5px;
  text-align: center;
  border-top: 1px solid var(--border);
}

h2.page-title {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin: 0 0 4px;
}

p.page-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 22px;
}

/* Onglets : contrôle segmenté (pastille claire sur fond gris, comme la maquette). */
.tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--seg-bg);
  border-radius: 12px;
  margin-bottom: 20px;
  max-width: 100%;
  overflow-x: auto;
}

.tab-btn {
  padding: 7px 16px;
  background: transparent;
  border: none;
  border-radius: 9px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.section-title svg { color: var(--accent); flex-shrink: 0; }

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 26px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-card .stat-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card .stat-value {
  font-size: 21px;
  font-weight: 700;
  line-height: 1.2;
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.week-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.week-nav .week-label {
  font-weight: 600;
  font-size: 14px;
  min-width: 220px;
  text-align: center;
}

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

.member-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  cursor: pointer;
}

.member-row:hover { border-color: var(--accent); background: var(--card-hover); }

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-elevated);
  flex-shrink: 0;
}

.member-info { flex: 1; min-width: 0; }
.member-name { font-weight: 600; font-size: 14px; }
.member-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

.badge {
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 100px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.member-total {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 13.5px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 30, 0.45);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}

.modal-backdrop.visible { display: flex; }

.context-menu {
  position: fixed;
  display: none;
  min-width: 230px;
  background: var(--menu-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1), 0 14px 34px rgba(0, 0, 0, 0.2);
  padding: 5px;
  z-index: 300;
  opacity: 0;
  transform: scale(0.95) translateY(-3px);
  transform-origin: top left;
  transition: opacity 0.1s ease-out, transform 0.1s ease-out;
}

.context-menu.open { display: block; }

.context-menu.open.visible {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 11px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 13px;
  line-height: 1.2;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: background 0.08s, color 0.08s;
}

.context-menu-item svg { flex-shrink: 0; color: var(--text-faint); transition: color 0.08s; }

.context-menu-item:hover,
.context-menu-item:focus-visible {
  background: var(--card-hover);
  outline: none;
}

.context-menu-item.success:hover { background: var(--success-soft); color: var(--ok-text); }
.context-menu-item.success:hover svg { color: var(--ok-text); }
.context-menu-item.danger:hover { background: var(--danger-soft); color: var(--danger); }
.context-menu-item.danger:hover svg { color: var(--danger); }

.context-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 5px 6px;
}

.modal {
  width: 100%;
  max-width: 640px;
  background: var(--shell);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 24px 70px rgba(20, 20, 40, 0.28);
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.modal-header .close-btn { margin-left: auto; }

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

.chart-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.chart-box h4 {
  margin: 0 0 10px;
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* Carte jour x heure de la page "Plages horaires" : une colonne d'étiquette de jour
   + 24 colonnes (une par heure), l'intensité de couleur indique le volume d'activité. */
.heatmap-grid {
  display: grid;
  grid-template-columns: 70px repeat(24, minmax(22px, 1fr));
  gap: 2px;
  min-width: 700px;
}

.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  background: var(--bg-elevated);
}

.heatmap-hour-label,
.heatmap-day-label {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.heatmap-day-label {
  justify-content: flex-start;
  font-weight: 600;
  font-size: 11.5px;
  color: var(--text);
  white-space: nowrap;
}

.heatmap-legend-swatch {
  width: 16px;
  height: 12px;
  border-radius: 2px;
}

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

table.data-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

table.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

table.data-table tr:last-child td { border-bottom: none; }

.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
}

.rank-pill {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.rank-pill.gold { background: rgba(255, 200, 60, 0.2); border-color: #e6aa1c; color: #a87400; }
.rank-pill.silver { background: rgba(150, 150, 165, 0.2); border-color: #9a9aa8; color: #62626e; }
.rank-pill.bronze { background: rgba(200, 130, 70, 0.2); border-color: #c07a3c; color: #8d5222; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
  flex-wrap: wrap;
}

.perm-list { display: flex; flex-direction: column; gap: 8px; }

.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.session-row:last-child { border-bottom: none; }

.session-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.session-delete-btn { color: var(--danger); }
.session-delete-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.type-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.type-card-emoji { font-size: 22px; line-height: 1; }
.type-card-label { font-weight: 600; font-size: 14.5px; }

.type-card-total {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
}

.type-card-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.type-top-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  padding: 4px 0;
}

.type-top-row .avatar { width: 22px; height: 22px; }
.type-top-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.type-top-row .value { color: var(--text-muted); white-space: nowrap; }

.type-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: none;
  margin-bottom: 18px;
}

.back-link:hover { color: var(--text); }

/* -------- Aperçu (facture / classement) + mascotte -------- */
.preview-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.preview-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-height: 82vh;
  overflow: auto;
  width: 100%;
}

.preview-image-wrap {
  position: relative;
  width: 100%;
  display: flex;
  flex-shrink: 0;
}

.preview-modal-image {
  /* width fixé en % par preview.js (zoom) ; margin:auto (plutôt que
     justify-content:center sur .preview-image-wrap) pour que le débordement
     reste bien atteignable au scroll des deux côtés quand on zoome. */
  max-width: none;
  width: 100%;
  flex-shrink: 0;
  margin: 0 auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  transition: width 0.1s ease;
}

/* -------- Calendrier -------- */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.calendar-day-header {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 0 8px;
}

.calendar-day-cell {
  min-height: 96px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--card);
  cursor: pointer;
  transition: border-color 0.15s;
}

.calendar-day-cell:hover { border-color: var(--accent); }
.calendar-day-cell.other-month { opacity: 0.4; }
.calendar-day-cell.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

.calendar-day-number {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.calendar-day-cell.today .calendar-day-number { color: var(--accent); }

.calendar-event-pill {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-event-pill:hover { background: var(--accent); color: #fff; }

@media (max-width: 700px) {
  .calendar-day-cell { min-height: 60px; padding: 4px; }
  .calendar-event-pill { font-size: 10px; padding: 1px 4px; }
}

/* -------- Dispatch Libre (unités glisser-déposer) -------- */
/* Même DA que la page Dispatch classique : unités empilées en pleine largeur
   dans des .card, badges/lignes de membre au même gabarit. */
.dl-units {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.dl-unit-card { transition: border-color 0.15s, background 0.15s; }
.dl-unit-card.drag-over { border-color: var(--accent); background: var(--accent-soft); }

.dl-unit-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  position: relative;
}

.dl-unit-name { font-weight: 600; font-size: 14px; }

.dl-unit-name-input {
  font-weight: 600;
  font-size: 14px;
  padding: 3px 6px;
  min-width: 140px;
}

/* -------- Boutons rapides (haut de chaque unité) : dispo / occupé / pas dispo -------- */
.dl-quick-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.dl-quick-btn {
  /* même hauteur que .btn (36px avec padding 9px + bordure) pour rester aligné avec
     "+ Prise de service" / "+ Créer une unité" / "Chef de dispatch" */
  width: 36px;
  height: 36px;
  box-sizing: border-box;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--quick-color);
  background: transparent;
  color: var(--quick-color);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.dl-quick-btn svg { width: 16px; height: 16px; }

.dl-quick-btn:hover,
.dl-quick-btn.active {
  background: var(--quick-color);
  color: #fff;
}

/* -------- Capsule de statut : bouton + menu déroulant maison (DA du site, pas le
   <select> natif du navigateur), carrée comme les autres boutons du site. -------- */
.dl-status-capsule {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  height: 36px;
  box-sizing: border-box;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  background-color: var(--pill-color, var(--text-faint));
  color: #fff;
}

.dl-status-capsule svg { flex-shrink: 0; width: 11px; height: 11px; }

.dl-status-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  z-index: 20;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 4px;
  min-width: 190px;
  display: none;
}

.dl-status-menu.open { display: block; }

.dl-status-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  border-radius: 6px;
  cursor: pointer;
}

.dl-status-menu-item:hover { background: var(--card-hover); }
.dl-status-menu-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.dl-status-menu-dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  flex-shrink: 0;
  background: var(--dot-color);
}

.dl-status-edit-btn {
  width: 36px;
  height: 36px;
  box-sizing: border-box;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.dl-status-edit-btn svg { width: 15px; height: 15px; }

.dl-status-edit-btn:hover { background: var(--card-hover); color: var(--text); }

/* -------- Zones de dépôt du bandeau du haut : "+ Créer une unité" et "Chef de
   dispatch". On y glisse une personne depuis une unité ou "En service". -------- */
.dl-drop-target {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  box-sizing: border-box;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: default;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.dl-drop-target.drag-over {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* Un chef désigné : son nom s'affiche en bleu à la place du libellé de la zone. */
.dl-drop-target.named {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.dl-chip-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 34px;
  margin-top: 12px;
}

.dl-chip {
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--bg-elevated);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: grab;
}

.dl-chip:active { cursor: grabbing; }
.dl-chip.dragging { opacity: 0.4; }

.dl-chip-icon {
  flex-shrink: 0;
  color: var(--text-faint);
  display: inline-flex;
}

.dl-chip-icon svg { width: 18px; height: 18px; }

/* Une seule ligne "Prénom Nom - Poste" (la DA de référence liste les gens ainsi). */
.dl-chip-name {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dl-chip-poste { color: var(--text-faint); font-weight: 400; }

.dl-chip-btn {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.dl-chip-btn:hover { background: var(--card-hover); color: var(--text); }
.dl-chip-btn.danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }

/* -------- Zoom de l'aperçu (boutons +/- ou Maj + molette) -------- */
.preview-zoom-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.preview-zoom-controls .zoom-btn {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.preview-zoom-controls .zoom-btn:hover { background: var(--card-hover); border-color: var(--accent); }

.preview-zoom-controls .zoom-level {
  min-width: 42px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
  user-select: none;
}

/* Fixée en bas à droite de la PAGE (pas de la popup) : ne gêne jamais l'aperçu ni son scroll.
   Entrée avec un léger rebond, décalée dans le temps (voir MASCOT_ENTRANCE_DELAY_MS dans preview.js). */
.sams-mascot-popup {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 360px;
  z-index: 200;
  opacity: 0;
  transform: translateY(40px) scale(0.8);
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sams-mascot-popup.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.sams-mascot-popup img {
  width: 100%;
  display: block;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.45));
}

.invoice-table-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
}

.invoice-table-row .agent-name { font-weight: 600; font-size: 14px; }
.invoice-table-row .agent-id { color: var(--text-muted); font-size: 12.5px; }
.invoice-table-row .amount { font-weight: 700; color: var(--text); white-space: nowrap; }

.total-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  margin-top: 16px;
  background: var(--navy);
  border-radius: 16px;
}

.total-banner .label { font-size: 13px; color: rgba(255, 255, 255, 0.7); }
.total-banner .value { font-size: 26px; font-weight: 700; color: var(--lime); letter-spacing: -0.5px; }

/* ============ Contrats (document officiel SAMS) ============
   Toujours en clair, quel que soit le thème du site : c'est un document destiné à être
   exporté/imprimé, pas une page d'interface. */

/* L'éditeur utilise les jetons du site ; seule la feuille A4 reste blanche (document exporté). */

/* Champs + barre d'outils "flottants" : restent collés en haut de l'écran pendant le
   défilement d'un document à plusieurs pages, pour rester utilisables en permanence. */
.contract-sticky-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--shell);
  padding: 0 0 10px;
}

/* Barre d'outils façon Google Docs : boutons sans bordure, surbrillance grise au survol,
   et un fond bleu léger quand le format est actif sous le curseur (voir contrats.js). */
.contract-full-toolbar .icon-btn { border-color: transparent; }
.contract-full-toolbar .icon-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}
.contract-full-toolbar select {
  border-color: transparent;
  background: transparent;
}
.contract-full-toolbar select:hover { background: var(--card-hover); }

.contract-font-size-stepper {
  display: flex;
  align-items: center;
  gap: 2px;
}
.contract-font-size-stepper input {
  width: 34px;
  text-align: center;
  padding: 5px 2px;
  -moz-appearance: textfield;
}
.contract-font-size-stepper input::-webkit-outer-spin-button,
.contract-font-size-stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Version compacte des cartes/champs, seulement dans ce bandeau : il reste affiché en
   permanence à l'écran, donc autant qu'il prenne le moins de place possible. */
.contract-sticky-header .card { padding: 10px 12px; }
.contract-sticky-header label { margin-bottom: 3px; font-size: 11px; }
.contract-sticky-header input,
.contract-sticky-header select {
  padding: 6px 10px;
  font-size: 13px;
}
.contract-sticky-header .icon-btn {
  width: 30px;
  height: 30px;
  font-size: 14px;
}
.contract-sticky-header .btn-sm { padding: 5px 10px; font-size: 12.5px; }

/* La page (bannière, ligne d'en-tête, bas de page) doit toujours garder le vert officiel
   SAMS, même si l'éditeur autour adopte la palette bleue façon Google Docs. */
.contract-sheet-wrap {
  --accent: #8bc53f;
  --accent-dark: #6fa02f;
  --accent-soft: rgba(139, 197, 63, 0.14);
  overflow-x: auto;
  padding: 4px 4px 40px;
}

/* Un contrat peut avoir autant de pages que voulu : chacune est un .contract-page
   (barre outil + feuille) empilé verticalement dans #contract-pages. */
.contract-page { margin-top: 24px; }
.contract-page:first-child { margin-top: 4px; }

.contract-page-toolbar {
  width: 900px;
  max-width: none;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: 'Open Sans', Arial, sans-serif;
}

.contract-page-label { font-size: 12.5px; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.contract-page-overflow-warning { display: none; color: var(--danger); font-size: 12px; flex: 1; }
.contract-page-delete-btn { margin-left: auto; white-space: nowrap; }

/* Format A4 fixe (ratio 210x297mm) à 900px de large : toujours la même taille, quel
   que soit le contenu — voir .contract-page-overflow-warning pour prévenir le dépassement. */
.contract-sheet {
  position: relative;
  width: 900px;
  height: 1273px;
  max-width: none;
  margin: 0 auto;
  background: #ffffff;
  color: #111111;
  font-family: 'Open Sans', Arial, sans-serif;
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.3), 0 4px 10px rgba(60, 64, 67, 0.18);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Photo de l'hôpital en fond de bannière (comme le modèle), avec un dégradé diagonal posé
   par-dessus : assombrit la partie gauche (lisibilité du logo/texte) et couvre entièrement
   la partie droite d'un vert opaque (le titre s'y détache, la photo n'y est plus visible).
   Photo en <img> + dégradé en div séparée (pas en background-image composé, pas en
   clip-path) : c'est la combinaison la plus fidèlement rendue par html2canvas à l'export. */
/* Positionnement en absolute (photo + overlay) volontairement HORS d'un parent flex :
   html2canvas positionne mal les enfants absolus d'un conteneur display:flex, d'où ce
   conteneur non-flex + une div interne .contract-banner-content dédiée à la mise en page. */
.contract-banner {
  position: relative;
  flex: 0 0 195px;
  overflow: hidden;
  background-color: #10151c;
}

.contract-banner-photo {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.contract-banner-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  /* Dégradé à plusieurs paliers : sombre (photo assombrie) -> fin liseré vert clair
     -> vert plein opaque, pour un bord diagonal à deux tons net, comme le modèle. */
  background: linear-gradient(
    108deg,
    rgba(10, 15, 20, 0.62) 0%,
    rgba(10, 15, 20, 0.62) 41%,
    #c3ea87 42%,
    #c3ea87 43%,
    var(--accent) 44%,
    var(--accent) 100%
  );
}

.contract-banner-content {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  align-items: stretch;
}

.contract-banner-left {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 30px;
  min-width: 0;
}

.contract-logo {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.contract-org-name {
  color: #ffffff;
  font-weight: 700;
  font-size: 20px;
  line-height: 1.3;
  font-family: 'Open Sans', Arial, sans-serif;
  font-style: normal;
}

.contract-banner-right {
  width: 48%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  text-align: right;
  padding: 0 34px;
}

.contract-doc-title {
  color: #ffffff;
  font-weight: 800;
  font-size: 32px;
  line-height: 1.12;
  font-family: 'Open Sans', Arial, sans-serif;
  text-transform: uppercase;
  word-break: break-word;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.contract-doc-date {
  color: #ffffff;
  font-weight: 600;
  font-size: 15px;
  margin-top: 10px;
  font-family: 'Open Sans', Arial, sans-serif;
  letter-spacing: 1px;
}

.contract-body {
  flex: 1 1 auto;
  min-height: 0; /* laisse .contract-editable défiler au lieu de pousser la page hors du format A4 */
  display: flex;
  flex-direction: column;
  padding: 36px 55px 20px;
}

.contract-editable {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  font-size: 15.5px;
  line-height: 1.6;
  outline: none;
}
.contract-editable:focus { box-shadow: 0 0 0 2px var(--accent-soft); border-radius: 4px; }
.contract-editable p { margin: 0 0 16px; }
.contract-editable ul, .contract-editable ol { margin: 0 0 16px; padding-left: 24px; }
.contract-editable li { margin-bottom: 6px; }
.contract-editable h1 { font-size: 26px; font-weight: 800; margin: 0 0 14px; line-height: 1.25; }
.contract-editable h2 { font-size: 21px; font-weight: 700; margin: 0 0 12px; line-height: 1.3; }
.contract-editable h3 { font-size: 18px; font-weight: 700; margin: 0 0 10px; line-height: 1.3; }
.contract-editable blockquote {
  margin: 0 0 16px;
  padding-left: 16px;
  border-left: 3px solid var(--accent);
  color: #444444;
  font-style: italic;
}
.contract-editable a { color: #1a56db; text-decoration: underline; }

/* ============ Blocs librement positionnables (zones de texte + signatures) ============
   Posés directement sur .contract-sheet (position:relative), ils peuvent être placés
   n'importe où sur la page, y compris par-dessus la bannière ou le bas de page. */
.contract-overlay-item {
  position: absolute;
  box-sizing: border-box;
  border: 1px dashed transparent;
}
/* Images et signatures : centrées dans leur bloc, jamais étirées. html2canvas ne respecte
   pas correctement object-fit à l'export (l'image ressort écrasée/déformée) — la taille
   réelle de l'image est donc calculée en JS (voir fitOverlayMedia dans contrats.js) et
   posée en pixels explicites ; ce conteneur ne fait que la centrer. */
.contract-overlay-item[data-type="image"],
.contract-overlay-item[data-type="signature"] {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.contract-overlay-item:hover,
.contract-overlay-item.is-selected {
  border-color: var(--accent);
}

.contract-overlay-handle {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 14px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 4px;
  background: var(--accent);
  color: #ffffff;
  font-size: 9.5px;
  font-family: 'Open Sans', Arial, sans-serif;
  line-height: 1;
  cursor: move;
  user-select: none;
}
.contract-overlay-item:hover .contract-overlay-handle,
.contract-overlay-item.is-selected .contract-overlay-handle {
  display: flex;
}

.contract-overlay-delete {
  border: none;
  background: transparent;
  color: #ffffff;
  cursor: pointer;
  font-size: 10px;
  line-height: 1;
  padding: 0 2px;
}

.contract-overlay-resize-handle {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 2px;
  cursor: nwse-resize;
  display: none;
}
.contract-overlay-item:hover .contract-overlay-resize-handle,
.contract-overlay-item.is-selected .contract-overlay-resize-handle {
  display: block;
}

.contract-overlay-editable {
  width: 100%;
  height: 100%;
  padding: 4px;
  box-sizing: border-box;
  overflow: hidden;
  outline: none;
  font-size: 14px;
  line-height: 1.4;
}

.contract-overlay-signature-img,
.contract-overlay-image-img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  pointer-events: none;
  -webkit-user-drag: none;
}

/* À l'export, seul le contenu des blocs doit apparaître : on masque toute la "chrome"
   d'édition (poignées, bouton supprimer, contour de sélection). */
.contract-exporting .contract-overlay-handle,
.contract-exporting .contract-overlay-resize-handle {
  display: none !important;
}
.contract-exporting .contract-overlay-item {
  border-color: transparent !important;
}

.contract-signature-picker {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  padding: 6px;
  min-width: 200px;
  max-height: 260px;
  overflow-y: auto;
  z-index: 50;
}
.contract-signature-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
.contract-signature-picker-item:hover { background: var(--card-hover); }
.contract-signature-picker-item img { max-width: 60px; max-height: 24px; background: #fff; border-radius: 3px; padding: 2px; }
.contract-signature-picker-empty { padding: 10px; font-size: 12.5px; color: var(--text-muted); text-align: center; }

.contract-footer-bar {
  flex: 0 0 14px;
  background: linear-gradient(90deg, #10213b 0%, #10213b 55%, var(--accent) 55%, var(--accent) 100%);
}

/* Seule la première page porte l'en-tête complet (photo + logo + titre) : les pages
   suivantes n'ont qu'une simple ligne, identique à celle du bas de page, en haut ET en bas. */
.contract-banner-line {
  flex: 0 0 14px;
  background: linear-gradient(90deg, #10213b 0%, #10213b 55%, var(--accent) 55%, var(--accent) 100%);
}

.contract-page:first-child .contract-banner-line { display: none; }
.contract-page:not(:first-child) .contract-banner { display: none; }

.contract-cmd-btn { font-family: 'Open Sans', Arial, sans-serif; font-size: 14px; }


/* -------- Administration : droits par rôle Discord (une carte par rôle) -------- */
.role-card {
  margin-bottom: 12px;
  padding: 16px 18px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.role-card.role-dirty { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.role-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.role-card-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.role-card-title .role-name { font-weight: 700; font-size: 15px; }
.role-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; background: var(--text-faint); }
.role-card-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.role-card .save-btn {
  min-width: 128px;
  justify-content: center;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s, transform 0.08s;
}
.role-card .save-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.role-card .save-btn:not(:disabled):active { transform: scale(0.97); }
.role-card .save-btn.saved { background: var(--success-soft); border-color: var(--success); color: var(--ok-text); opacity: 1; }

.perm-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.perm-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.08s;
}
.perm-chip { position: relative; }
.perm-chip input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; pointer-events: none; }
.perm-chip::before {
  content: '';
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--text-faint);
  background: center / 10px no-repeat;
  transition: background-color 0.12s, border-color 0.12s;
}
.perm-chip:hover:not(.is-disabled) { border-color: var(--accent); color: var(--text); }
.perm-chip:active:not(.is-disabled) { transform: scale(0.97); }
.perm-chip:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.perm-chip.on { background: var(--success-soft); border-color: var(--success); color: var(--ok-text); font-weight: 600; }
.perm-chip.on::before {
  background-color: var(--success);
  border-color: var(--success);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>");
}
.perm-chip.admin.on { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.perm-chip.admin.on::before { background-color: var(--danger); border-color: var(--danger); }
.perm-chip.is-disabled { cursor: not-allowed; opacity: 0.55; }

/* ============ Coque de l'application : en-tête + barre latérale (voir shell.js) ============ */
body.has-shell { background: var(--bg); overflow: hidden; }

.app { height: 100vh; padding: 14px; display: flex; flex-direction: column; }

.shell {
  flex: 1;
  min-height: 0;
  background: var(--shell);
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 12px 40px rgba(20, 20, 40, 0.12);
}

.has-shell .topbar { flex-shrink: 0; padding: 12px 24px; }
.has-shell .topbar-left img { height: 44px; width: 44px; }
.has-shell .topbar-title { font-size: 15px; font-weight: 600; letter-spacing: 0; line-height: 1.2; }
.has-shell .topbar-sub { color: var(--text-faint); font-size: 12px; font-weight: 500; }
.has-shell .topbar-sub b { color: var(--text); font-weight: 700; }
.has-shell .topbar-right { gap: 12px; }
.has-shell #user-label { font-weight: 700; font-size: 14px; color: var(--text) !important; }

.me-pill {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--danger);
  background: var(--pill-bg);
  border-radius: 999px;
  padding: 2px 10px;
  letter-spacing: 0.3px;
}

.me-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.shell-body { flex: 1; min-height: 0; display: flex; position: relative; }

.sidebar {
  width: 236px;
  padding: 16px 12px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
  overflow-y: auto;
  transition: width 0.18s;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s;
}

.nav-item:hover { background: var(--hover-overlay); }
.nav-item.active { background: var(--nav-active); font-weight: 700; }
.nav-item svg { flex-shrink: 0; }
.nav-sep { height: 1px; background: var(--border); margin: 10px 6px; }

.collapse-handle {
  position: absolute;
  left: 225px;
  top: 50%;
  width: 22px;
  height: 34px;
  border-radius: 8px;
  background: var(--handle-bg);
  border: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 5;
  transition: left 0.18s;
  color: var(--text-muted);
}

.sidebar.collapsed { width: 72px; }
.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 11px 0; }
.sidebar.collapsed + .collapse-handle { left: 61px; }
.sidebar.collapsed + .collapse-handle svg { transform: rotate(180deg); }

.shell-content { flex: 1; min-width: 0; overflow: auto; padding: 22px 26px 30px; }
.has-shell .container { max-width: none; margin: 0; padding: 0; }
.has-shell .back-link { display: none; }

@media (max-width: 960px) {
  .sidebar { width: 72px; }
  .sidebar .nav-label { display: none; }
  .sidebar .nav-item { justify-content: center; padding: 11px 0; }
  .collapse-handle { display: none; }
  .shell-content { padding: 16px; }
  .app { padding: 6px; }
  .shell { border-radius: 18px; }
  .has-shell .topbar-sub, .me-pill { display: none; }
}

/* Accueil : cartes d'accès aux applications */
.home-tile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background 0.12s, transform 0.1s, box-shadow 0.12s;
}
.home-tile:hover { background: var(--surface-hover); transform: translateY(-2px); box-shadow: 0 8px 22px rgba(20, 20, 40, 0.1); }
.home-tile-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
}
.home-tile-name { font-weight: 700; font-size: 15px; }
.home-tile-desc { color: var(--text-muted); font-size: 12.5px; line-height: 1.45; }

/* Page de connexion */
.login-shell { background: linear-gradient(135deg, #cfd6e6, #e8e8eb 60%); }
.login-card.card {
  background: var(--shell);
  border-radius: 26px;
  padding: 34px 30px;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(20, 20, 40, 0.18);
}
.login-card h1 { font-size: 21px; }
#discord-login-btn { background: #5865f2; border-color: #5865f2; padding: 12px; border-radius: 12px; font-size: 14px; }
#discord-login-btn:hover { background: #4752c4; border-color: #4752c4; }

/* ============ Accueil : tableau de bord ============ */
.dash-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.dash-stat-card { padding: 16px 18px; }
.dash-stat-label { color: var(--text-muted); font-size: 12.5px; font-weight: 600; }
.dash-stat-value { font-size: 24px; font-weight: 800; margin: 4px 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-stat-sub { color: var(--text-faint); font-size: 12px; min-height: 15px; }

.home-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-bottom: 8px; }
.panel { background: var(--panel); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px; }
.panel-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.panel-count { color: var(--text-faint); font-weight: 600; margin-left: 4px; }
.panel-link { font-size: 12.5px; font-weight: 600; color: var(--text-muted); text-decoration: none; }
.panel-link:hover { color: var(--accent); }
.panel-body { display: flex; flex-direction: column; gap: 8px; }

.list-row { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.list-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.list-main { flex: 1; min-width: 0; }
.list-title { font-weight: 700; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-desc { color: var(--text-muted); font-size: 12px; }
.list-meta { color: var(--text-faint); font-size: 11.5px; white-space: nowrap; flex-shrink: 0; }
.status-pill { background: var(--success-soft); color: var(--ok-text); font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 10px; white-space: nowrap; max-width: 45%; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.home-section { margin: 22px 0 12px; }

/* ============ Navigation sans rechargement (app.html + cadre) ============ */
.nav-item { transition: background 0.15s; }
.nav-item.active:hover { background: var(--nav-active); }
.host .shell-content { padding: 0; overflow: hidden; }
.host #view { display: block; width: 100%; height: 100%; border: 0; background: transparent; opacity: 1; transition: opacity 0.18s ease-out; }
.host #view.loading { opacity: 0; transition: opacity 0.1s ease-in; }
.me-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
/* Page affichée dans le cadre : pas d’en-tête propre, le décor de la coque tout autour. */
html:has(body.framed), body.framed { background: var(--shell); }
.framed .topbar, .framed .back-link { display: none; }
.framed .container { max-width: none; margin: 0; padding: 22px 26px 30px; }
@media (max-width: 960px) { .framed .container { padding: 16px; } }

/* ============ Gestion Service (voir maquette) ============ */
.gs-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.gs-head p.page-subtitle { margin: 0; }
.gs-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gs-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

.seg { display: inline-flex; align-items: center; gap: 2px; padding: 3px; background: var(--seg-bg); border-radius: 12px; }
.seg-btn { border: 0; background: transparent; border-radius: 9px; padding: 6px 12px; font: inherit; font-size: 14px; font-weight: 700; color: var(--text-muted); cursor: pointer; transition: background 0.12s, color 0.12s; }
.seg-btn:hover:not(:disabled) { background: var(--card); color: var(--text); }
.seg-btn:disabled { opacity: 0.35; cursor: default; }
.seg-label { padding: 6px 12px; background: var(--card); border-radius: 9px; font-size: 13px; font-weight: 600; white-space: nowrap; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }

.gs-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.gs-stat { background: var(--card); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.gs-stat-label { color: var(--text-muted); font-size: 12.5px; font-weight: 600; }
.gs-stat-value { font-size: 26px; font-weight: 800; margin: 4px 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-stat-sub { color: var(--text-faint); font-size: 12px; }
.gs-stat-sub.up { color: var(--ok-text); font-weight: 600; }
.gs-stat-sub.down { color: var(--danger); font-weight: 600; }
.gs-stats > .empty-state { grid-column: 1 / -1; }

.gs-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: -4px 0 16px; font-size: 12px; color: var(--text-muted); }
.gs-legend[hidden] { display: none; }
.gs-legend-item { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.gs-legend-item i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.gs-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; align-items: start; }

.gs-search { position: relative; }
.gs-search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }
.gs-search input { padding-left: 36px; }

.gs-rank, .gs-row { background: var(--card); border-radius: 12px; padding: 11px 14px; cursor: pointer; transition: background 0.12s; }
.gs-rank:hover, .gs-row:hover { background: var(--surface-hover); }
.gs-rank-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.gs-rank-name { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.gs-rank-n { color: var(--text-faint); font-weight: 700; font-size: 13px; min-width: 20px; }
.gs-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-total { font-weight: 800; font-size: 14px; white-space: nowrap; }
.gs-bar { height: 7px; border-radius: 99px; background: var(--track); overflow: hidden; margin-top: 8px; }
.gs-bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }

.gs-row { display: flex; align-items: center; gap: 12px; }
.gs-avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: var(--track); flex-shrink: 0; }
.gs-row-main { flex: 1; min-width: 0; }
.gs-pills { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.gs-pill { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.gs-pill.green { background: var(--success-soft); color: var(--ok-text); }
.gs-pill.blue { background: var(--accent-soft); color: var(--accent-dark); }
.gs-pill.amber { background: var(--amber-soft); color: var(--amber-text); }
.gs-pill.grey { background: var(--track); color: var(--text-muted); }

.gs-chart { background: var(--card); border-radius: 12px; padding: 12px; }
.heatmap-cell { background: var(--bg-elevated); }
.chart-row > *, .chart-box { min-width: 0; }
.chart-box canvas { max-width: 100%; }

/* Déconnexion : en bas du menu latéral */
.nav-spacer { flex: 1; min-height: 12px; }
button.nav-item { width: 100%; border: 0; background: transparent; font: inherit; font-size: 14px; font-weight: 500; text-align: left; cursor: pointer; }
button.nav-item:hover { background: var(--hover-overlay); }
#logout-btn:hover { color: var(--danger); }

/* ============ Facture Service Public + Éditeur de texte (voir maquette) ============ */
.seg-btn.active { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
.seg-btn[data-service] { font-size: 13px; }
.seg-select { width: auto; border: 0; background: var(--seg-bg); border-radius: 11px; padding: 7px 12px; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-sm.btn-accent { padding: 7px 13px; }

.panel-hint { color: var(--text-faint); font-size: 12px; }
.panel-title-solo { margin: 0 0 12px; font-size: 15px; font-weight: 700; }
.panel-note { color: var(--text-faint); font-size: 12px; margin: 12px 2px 0; }

.fac-cols { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); }
.fac-side { display: flex; flex-direction: column; gap: 14px; }
.fac-side .total-banner { margin-top: 0; flex-wrap: wrap; gap: 10px; }
.total-banner .total-sub { font-size: 12px; color: rgba(255, 255, 255, 0.7); }
.total-banner .value { font-size: 28px; }
.total-count { background: rgba(255, 255, 255, 0.15); color: #fff; border-radius: 7px; font-size: 11.5px; font-weight: 700; padding: 3px 10px; }
.total-count:empty { display: none; }
.fac-doc-btn { width: 100%; justify-content: center; padding: 11px 18px; font-size: 13.5px; border-radius: 11px; }
.fac-side .fac-doc-btn:not(.btn-accent) { background: var(--seg-bg); border-color: transparent; color: var(--text); }
.fac-side .fac-doc-btn:not(.btn-accent):hover { background: var(--btn-hover); }

.pay-row { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 12px; padding: 11px 14px; transition: background 0.12s; }
.pay-row:hover { background: var(--surface-hover); }
.pay-main { flex: 1; min-width: 0; }
.pay-title { font-weight: 700; font-size: 13.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pay-meta { color: var(--text-faint); font-size: 11.5px; margin-top: 3px; font-weight: 500; }
.pay-amount { font-weight: 800; font-size: 14px; white-space: nowrap; }
.pay-row .icon-btn { background: transparent; border-color: transparent; }
.pay-row .icon-btn:hover { background: var(--hover-overlay); }

.ed-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 16px; align-items: start; }
.ed-history { position: sticky; top: 0; max-height: calc(100vh - 150px); overflow-y: auto; }
.ed-doc { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 12px; padding: 10px 12px; cursor: pointer; transition: background 0.12s; }
.ed-doc:hover { background: var(--surface-hover); }
.ed-doc.active { background: var(--bg-elevated); box-shadow: inset 0 0 0 2px var(--accent); }
.ed-doc-main { flex: 1; min-width: 0; }
.ed-doc-title { font-weight: 600; font-size: 13.5px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-doc-meta { color: var(--text-faint); font-size: 11px; margin-top: 4px; font-weight: 500; }
.ed-doc .icon-btn { background: transparent; border-color: transparent; width: 28px; height: 28px; }
.ed-doc .icon-btn:hover { background: var(--danger-soft); color: var(--danger); }
.ed-main { min-width: 0; }
.ed-fields { margin-bottom: 8px; }
.contract-full-toolbar { display: flex; flex-direction: row; gap: 5px; flex-wrap: wrap; align-items: center; padding: 8px; margin-bottom: 4px; }
.contract-full-toolbar select { border-radius: 8px; }
.contract-sheet-wrap { padding: 4px 0 40px; }
@media (max-width: 900px) { .ed-layout, .fac-cols { grid-template-columns: 1fr; } .ed-history { position: static; max-height: 260px; } }

/* ============ Documents médicaux : formulaire + feuille A4 ============ */
.md-filter-select { width: 100%; margin-bottom: 10px; }
#type-seg { flex-wrap: wrap; }
.md-line-row { display: grid; grid-template-columns: 1fr 96px 34px; gap: 6px; margin-bottom: 6px; }
.md-line-row .icon-btn { width: 34px; height: 34px; }
.md-line-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; font-size: 13px; }
.ed-history .gs-search { margin-bottom: 10px; }
.md-typebar { display: flex; align-items: center; justify-content: space-between; flex-direction: row; gap: 12px; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 14px; }
.md-status { color: var(--text-muted); font-size: 12.5px; font-weight: 600; }
.md-cols { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 14px; align-items: start; }
.md-form-panel { gap: 0; }
.md-sec { margin-bottom: 14px; }
.md-sec-title { color: #fff; font-weight: 700; font-size: 12.5px; padding: 6px 12px; border-radius: 8px; margin-bottom: 10px; }
.md-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.md-grid .field { margin-bottom: 10px; min-width: 0; }
.md-grid .field.wide { grid-column: 1 / -1; }
.md-grid .field label { font-size: 11.5px; }
.md-grid input, .md-grid select, .md-grid textarea { padding: 7px 10px; font-size: 13px; }
.md-grid textarea { resize: vertical; min-height: 60px; font-family: inherit; }
.md-warning { color: var(--danger); background: var(--danger-soft); border-radius: 10px; padding: 8px 12px; font-size: 12.5px; font-weight: 600; margin: 4px 0 0; }
.md-warning[hidden] { display: none; }
.md-preview { min-width: 0; position: sticky; top: 0; }
#sheet-holder { width: 794px; transform-origin: top left; }

/* La feuille : toujours blanche et au format A4 (794 x 1123 px), c'est elle qui est exportée.
   Même habillage que les rapports médicaux de la facture : en-tête à droite, tableau aux libellés verts,
   barre marine, pied de page marine. */
.md-sheet { width: 794px; height: 1123px; background: #fff; color: #1b1d23; font-family: 'Inter', 'Segoe UI', Roboto, Arial, sans-serif; padding: 44px 50px 0; box-sizing: border-box; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 4px 22px rgba(20, 20, 40, 0.18); position: relative; }
.md-head { display: flex; align-items: flex-start; justify-content: space-between; }
.md-logo { width: 78px; height: 78px; object-fit: contain; }
.md-org { text-align: right; font-size: 10.5px; line-height: 1.5; color: #4a4d58; display: flex; flex-direction: column; }
.md-org b { font-size: 14px; color: #111; }
.md-rule { height: 1px; background: #cfd2d9; margin: 12px 0 16px; }
.md-title { text-align: center; font-size: 19px; font-weight: 700; color: #111; margin: 0; }
.md-subtitle { text-align: center; font-size: 11.5px; color: #4a4d58; margin-top: 4px; min-height: 14px; }
.md-body { margin-top: 14px; min-height: 0; }
.md-h { font-size: 12px; font-weight: 700; text-transform: uppercase; margin: 14px 0 6px; }
.md-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.md-table td { border: 1px solid #222; padding: 8px 9px; font-size: 12px; vertical-align: middle; word-break: break-word; }
.md-table td.md-lab { background: #e4efd2; font-weight: 700; width: 17%; font-size: 11px; }
.md-table td.md-val { width: 33%; }
.md-table td.md-val[colspan] { width: auto; }
.md-table td.md-val.tall { height: 64px; vertical-align: top; white-space: pre-wrap; }
.md-bar { background: #1a2f5c; color: #fff; text-align: center; font-size: 12px; font-weight: 700; text-transform: uppercase; padding: 9px; margin-top: 20px; }
.md-box { background: #e9f1db; padding: 14px 18px; }
.md-line { font-size: 12.5px; margin: 0 0 12px; line-height: 1.45; }
.md-line:last-child { margin-bottom: 0; }
.md-line.tall { white-space: pre-wrap; }
.md-sign { margin-top: auto; display: grid; grid-template-columns: 1fr 1fr; padding-bottom: 22px; }
.md-sign-box { padding: 0 18px; min-height: 130px; display: flex; flex-direction: column; }
.md-sign-box + .md-sign-box { border-left: 1px solid #c9ccd5; }
.md-lines td.md-lab, .md-lines td.md-val { width: auto; }
.md-lines td.md-lab:first-child, .md-lines td.md-val:first-child { width: 72%; }
.md-lines td.r { text-align: right; }
.md-lines td.strong { font-weight: 700; }
.md-lines td.md-val { height: 26px; }
.md-chk { display: inline-block; width: 13px; height: 13px; border: 1.5px solid #222; margin-right: 9px; vertical-align: -2px; text-align: center; line-height: 11px; font-size: 11px; font-weight: 700; }
.md-chk.on::after { content: '✓'; }
.md-sign-label { font-weight: 700; font-size: 12.5px; text-align: center; color: #1a2f5c; }
.md-sign-area { flex: 1; font-size: 12.5px; text-align: center; padding-top: 14px; }
.md-sign-name { text-align: center; font-size: 11px; color: #4a4d58; min-height: 16px; }
.md-nosign .md-foot { margin-top: auto; }
.md-foot { margin: 0 -50px; background: #1a2f5c; color: #fff; text-align: center; font-size: 10.5px; padding: 15px 0; }
@media (max-width: 1000px) { .md-cols { grid-template-columns: 1fr; } .md-preview { position: static; } }

/* Aperçu (facture, classement, rapports) : tient dans la fenêtre, sans devoir dézoomer la page. */
#sams-preview-modal { align-items: center; padding: 12px; overflow: hidden; }
#sams-preview-modal .modal { display: flex; flex-direction: column; max-height: calc(100vh - 24px); padding: 14px 18px 16px; }
#sams-preview-modal .modal-header { margin-bottom: 10px; flex-shrink: 0; }
#sams-preview-modal .preview-modal-body { flex: 1; min-height: 0; gap: 12px; }
#sams-preview-modal .preview-pages { flex: 1; min-height: 0; max-height: none; }
#sams-preview-modal #sams-preview-export-btn { flex-shrink: 0; }


/* ============ Thème sombre ============ */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0f13;
  --shell: #181920;
  --bg-elevated: #2a2b33;
  --card: #22232a;
  --card-hover: #2c2d36;
  --panel: #1e1f26;
  --border: #33343d;
  --text: #ececf1;
  --text-muted: #a4a6b2;
  --text-faint: #767885;
  --accent: #4f92f2;
  --accent-dark: #3d7fe0;
  --accent-soft: rgba(79, 146, 242, 0.2);
  --success-soft: rgba(47, 185, 77, 0.2);
  --amber-soft: rgba(224, 145, 44, 0.2);
  --danger-soft: rgba(229, 72, 77, 0.2);
  --seg-bg: #2c2d35;
  --btn-hover: #383943;
  --surface-hover: #2b2c35;
  --track: #34353e;
  --nav-active: #32333d;
  --handle-bg: #32333d;
  --pill-bg: #34353e;
  --hover-overlay: rgba(255, 255, 255, 0.07);
  --menu-bg: rgba(36, 37, 44, 0.97);
  --ok-text: #54d676;
  --amber-text: #f2b45a;
}
html[data-theme="dark"] .shell { box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 12px 40px rgba(0, 0, 0, 0.5); }
html[data-theme="dark"] .login-shell { background: linear-gradient(135deg, #14203a, #181920 60%); }
html[data-theme="dark"] .rank-pill.gold { color: #f0c24a; }
html[data-theme="dark"] .rank-pill.silver { color: #c4c4d0; }
html[data-theme="dark"] .rank-pill.bronze { color: #e0a070; }
html[data-theme="dark"] .modal { box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6); }
html[data-theme="dark"] .md-sheet, html[data-theme="dark"] .contract-sheet { color-scheme: light; }

/* Bouton de thème (en-tête de app.html) */
.theme-btn { width: 38px; height: 38px; border-radius: 50%; }
.theme-btn .ico-sun { display: none; }
html[data-theme="dark"] .theme-btn .ico-sun { display: block; }
html[data-theme="dark"] .theme-btn .ico-moon { display: none; }

/* Mémoire des agents (ajout d'une facture) */
.suggest { display: flex; flex-direction: column; gap: 2px; margin: -4px 0 14px; padding: 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); }
.suggest[hidden] { display: none; }
.suggest-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.suggest-item:hover, .suggest-item:focus-visible { background: var(--btn-hover); outline: none; }
.suggest-item small { color: var(--text-faint); font-size: 11.5px; white-space: nowrap; }

/* Documents médicaux : historique */
.ed-layout { grid-template-columns: 300px minmax(0, 1fr); }
.ed-history { padding: 14px 12px; }
.ed-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 2px 12px; }
.ed-chip { border: 0; border-radius: 999px; padding: 4px 11px; font: inherit; font-size: 12px; font-weight: 600; background: var(--seg-bg); color: var(--text-muted); cursor: pointer; transition: background 0.12s, color 0.12s; }
.ed-chip:hover { background: var(--btn-hover); color: var(--text); }
.ed-chip.active { background: var(--accent); color: #fff; }
.ed-history .panel-body { display: flex; flex-direction: column; gap: 6px; padding: 0; }
.ed-group { margin: 10px 4px 2px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-faint); }
.ed-group:first-child { margin-top: 2px; }
.ed-doc { --tone: var(--text-faint); position: relative; gap: 6px; padding: 10px 8px 10px 16px; border-radius: 12px; border: 1px solid transparent; background: var(--card); overflow: hidden; }
.ed-doc::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--tone); }
.ed-doc[data-tone="blue"] { --tone: var(--accent); }
.ed-doc[data-tone="green"] { --tone: var(--success); }
.ed-doc[data-tone="amber"] { --tone: var(--amber); }
.ed-doc[data-tone="violet"] { --tone: #8a63d2; }
.ed-doc:hover { background: var(--surface-hover); border-color: var(--border); }
.ed-doc.active { background: var(--bg-elevated); box-shadow: none; border-color: var(--tone); }
.ed-doc-title { font-size: 14px; font-weight: 700; }
.ed-doc-meta { display: flex; align-items: center; gap: 7px; margin-top: 5px; font-size: 11.5px; color: var(--text-muted); min-width: 0; }
.ed-doc-meta > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-doc .doc-delete-btn { opacity: 0; transition: opacity 0.12s; }
.ed-doc:hover .doc-delete-btn, .ed-doc.active .doc-delete-btn, .ed-doc .doc-delete-btn:focus-visible { opacity: 1; }
@media (hover: none) { .ed-doc .doc-delete-btn { opacity: 1; } }
.gs-pill.violet { background: rgba(138, 99, 210, 0.16); color: #8a63d2; }
@media (max-width: 900px) { .ed-layout { grid-template-columns: 1fr; } }

/* Documents médicaux : 5 types de documents, la barre passe à la ligne au lieu de déborder de l'écran. */
.md-typebar .seg { flex-wrap: wrap; max-width: 100%; }
.md-typebar .seg-btn { font-size: 13px; padding: 6px 10px; }

/* ============ Lifeguard ============ */
.lg-hint { color: var(--text-faint); font-size: 12.5px; margin: 0 0 12px; }
.lg-count { color: var(--text-faint); font-weight: 600; }
.lg-total { display: flex; flex-direction: column; align-items: center; min-width: 64px; line-height: 1.1; }
.lg-total b { font-size: 22px; font-weight: 800; }
.lg-total span { font-size: 11px; color: var(--text-faint); font-weight: 600; }

.lg-table { overflow-x: auto; border-radius: var(--radius); background: var(--card); padding: 6px; }
.lg-tr { display: grid; grid-template-columns: minmax(200px, 2.4fr) repeat(5, minmax(78px, 1fr)); align-items: center; gap: 8px; padding: 9px 12px; border-radius: 10px; font-size: 13.5px; min-width: 620px; }
.lg-tr:not(.lg-th):hover { background: var(--surface-hover); }
.lg-tr > span:not(.lg-who) { text-align: center; }
.lg-th { color: var(--text-muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.lg-zero { opacity: 0.55; }
.lg-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.lg-who .avatar { width: 32px; height: 32px; }
.lg-who > span { display: flex; flex-direction: column; min-width: 0; }
.lg-who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-who small { color: var(--text-faint); font-size: 11.5px; }

.lg-report { --tone: var(--accent); position: relative; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 16px 14px 20px; margin-bottom: 10px; cursor: pointer; overflow: hidden; }
.lg-report::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--tone); }
.lg-report[data-tone="intervention"] { --tone: var(--amber); }
.lg-report:hover { background: var(--card-hover); }
.lg-report-title { font-weight: 700; font-size: 14px; }
.lg-report-meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--text-muted); font-size: 12.5px; }
.lg-report-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }


.lg-map { position: relative; line-height: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--card); }
.lg-map img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.lg-map-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.lg-map.editable .lg-map-svg { cursor: crosshair; }
.lg-zone { fill: rgba(229, 72, 77, 0.28); stroke: #e5484d; stroke-linejoin: round; }
.lg-zone-line { fill: none; stroke: #e5484d; stroke-linejoin: round; }
.lg-pt { fill: #fff; stroke: #e5484d; }
.lg-pt.first { fill: #e5484d; stroke: #fff; }
.lg-map-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* Lifeguard : sélecteur de membres */
.lg-picker { display: flex; flex-direction: column; gap: 10px; }
.lg-picker-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.lg-picker-bar .gs-search { flex: 1; min-width: 180px; }
.lg-chosen { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 34px; padding: 6px 8px; border: 1px dashed var(--border); border-radius: 12px; background: var(--card); }
.lg-chosen-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 4px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-dark); font-size: 12.5px; font-weight: 700; }
.lg-chosen-chip .avatar { width: 22px; height: 22px; }
.lg-chosen-chip button { border: 0; background: transparent; color: inherit; width: 20px; height: 20px; border-radius: 50%; font-size: 11px; cursor: pointer; opacity: 0.7; }
.lg-chosen-chip button:hover { opacity: 1; background: rgba(0, 0, 0, 0.08); }
.lg-members { max-height: 280px; overflow-y: auto; padding-right: 2px; }
.lg-pick-group { margin: 10px 2px 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-faint); }
.lg-pick-group:first-child { margin-top: 2px; }
.lg-pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.lg-tile { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 34px 8px 10px; border: 1px solid transparent; border-radius: 12px; background: var(--card); color: var(--text); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer; transition: background 0.12s, border-color 0.12s; }
.lg-tile:hover { background: var(--card-hover); }
.lg-tile .avatar { width: 30px; height: 30px; }
.lg-tile-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-tile-check { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; color: transparent; }
.lg-tile.on { background: var(--accent-soft); border-color: var(--accent); }
.lg-tile.on .lg-tile-check { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Lifeguard : sélecteur de date et d'heure */
.lg-dt { position: relative; }
.lg-dt-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-elevated); color: var(--text); font: inherit; font-size: 14px; font-weight: 600; text-align: left; cursor: pointer; }
.lg-dt-btn:hover, .lg-dt-btn:focus-visible { border-color: var(--accent); outline: none; }
.lg-dt-btn svg:first-child { color: var(--accent); flex-shrink: 0; }
.lg-dt-text { flex: 1; min-width: 0; }
.lg-dt-pop { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: min(340px, 100%); min-width: 300px; padding: 14px; border: 1px solid var(--border); border-radius: 16px; background: var(--menu-bg, var(--shell)); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1), 0 16px 40px rgba(0, 0, 0, 0.22); }
.lg-dt-pop[hidden] { display: none; }
.lg-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.lg-cal-head .icon-btn { width: 30px; height: 30px; font-size: 18px; }
.lg-cal-week, .lg-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.lg-cal-week { margin-bottom: 4px; color: var(--text-faint); font-size: 11.5px; font-weight: 700; }
.lg-day { aspect-ratio: 1; border: 0; border-radius: 10px; background: transparent; color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.lg-day:hover:not(:disabled) { background: var(--accent-soft); }
.lg-day.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.lg-day.sel { background: var(--accent); color: #fff; }
.lg-day:disabled { opacity: 0.3; cursor: default; }
.lg-time { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.lg-time-label { margin: 6px 0 5px; color: var(--text-muted); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.lg-hours { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.lg-mins { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.lg-chip { padding: 6px 0; border: 0; border-radius: 8px; background: var(--seg-bg); color: var(--text); font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.lg-chip:hover { background: var(--btn-hover); }
.lg-chip.sel { background: var(--accent); color: #fff; }
.lg-dt-foot { display: flex; align-items: center; gap: 6px; margin-top: 12px; }
.lg-dt-now { flex: 1; text-align: center; font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Tableau de statistiques à 4 colonnes de chiffres (STRAPZ) */
.lg-table.cols-4 .lg-tr { grid-template-columns: minmax(200px, 2.4fr) repeat(4, minmax(78px, 1fr)); min-width: 540px; }

.lg-dt-pop.right { left: auto; right: 0; }

/* Sélecteur de date : fond opaque, pied de fenêtre sur deux lignes, libellé sur une seule ligne */
.lg-dt-pop { width: 340px; min-width: 0; max-width: calc(100vw - 32px); background: var(--shell); -webkit-backdrop-filter: none; backdrop-filter: none; }
.lg-dt-pop .btn { white-space: nowrap; flex-shrink: 0; }
.lg-dt-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lg-dt-foot { flex-direction: column; align-items: stretch; gap: 10px; }
.lg-dt-step { display: flex; align-items: center; justify-content: center; gap: 12px; }
.lg-dt-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lg-dt-now { flex: none; min-width: 64px; }
