/* =====================================================
   SEGESTA ERP/CRM — stylesheet.css
   CSS unique consolidé — remplace tous les CSS v5/v7
   ===================================================== */

/* ── Variables ───────────────────────────────────────── */
:root {
  --font:        "Segoe UI", "Trebuchet MS", Arial, sans-serif;

  --bg:          #f0f2f5;
  --surface:     #ffffff;
  --border:      #d9dde3;
  --text:        #111827;
  --muted:       #6b7280;

  --focus:       #2563eb;
  --focus-ring:  rgba(37, 99, 235, 0.14);

  --radius:      8px;
  --radius-lg:   12px;
  --gap:         12px;

  --fs:          15px;
  --lh:          1.5;

  --control-h:   36px;

  --sidebar-w:          220px;
  --sidebar-w-collapsed: 60px;

  --container-pad: 24px;

  --table-head:      #f3f4f6;
  --table-hover:     rgba(37, 99, 235, 0.05);

  /* Planning */
  --slot-h:      44px;
  --tech-col-w:  260px;
  --time-col-w:  80px;
  --day-col-min: 160px;
}

/* ── Reset ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body, input, select, textarea, button {
  font-family: var(--font);
  font-size:   var(--fs);
  line-height: var(--lh);
  color:       var(--text);
}
body { background: var(--bg); }

a { color: inherit; }

/* ── Layout principal ────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  background: #111827;
  color: #e5e7eb;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-title {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .02em;
  margin-bottom: 20px;
  padding: 0 6px;
  color: #fff;
}
.sidebar-title em {
  display: block;
  text-align: right;
}

.sidebar-section {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #4b5563;
  padding: 14px 8px 4px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #d1d5db;
  text-decoration: none;
  font-size: 14px;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: #1f2937; color: #fff; }
.nav-item.active {
  background: #2563eb;
  color: #ffffff;
  font-weight: 700;
}

/* ── Main content ────────────────────────────────────── */
.main-content {
  background: var(--bg);
  padding: var(--container-pad);
  min-width: 0;
}

.container {
  width: 100%;
  max-width: 100%;
}

/* ── Page header ─────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.page-header h1 { margin: 0 0 4px; }
.page-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}

/* ── Onglets ─────────────────────────────────────────── */
.tabs-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 10px 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.tab-item {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  transition: border-color .12s, box-shadow .12s;
  white-space: nowrap;
}
.tab-item:hover {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.tab-item.active {
  background: rgba(37,99,235,.10);
  border-color: rgba(37,99,235,.30);
  font-weight: 700;
}

/* ── Cartes ──────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.card + .card { margin-top: 12px; }

/* Grilles multi-colonnes (cartes côte à côte, ex. .two-col/.three-col/
   .four-col/.kpi-row) : l'espacement entre cartes y est déjà géré par
   `gap`. Sans cette annulation, la règle générale ci-dessus s'applique
   quand même (les cartes sont des frères adjacents dans le DOM) et
   ajoute un margin-top parasite à toutes les cartes sauf la 1ʳᵉ de la
   ligne, qui démarre alors visiblement plus haut que les autres. */
.two-col > .card + .card,
.three-col > .card + .card,
.four-col > .card + .card,
.kpi-row > .card + .card,
.stats-top-grid > .card + .card { margin-top: 0; }

.card-title {
  font-weight: 800;
  font-size: 16px;
  margin: 0 0 4px;
}
.card-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ── Helpers ─────────────────────────────────────────── */
.help {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}

/* ── Boutons ─────────────────────────────────────────── */
.btn-outline {
  height: var(--control-h);
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  transition: border-color .12s, box-shadow .12s;
}
.btn-outline:hover {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.btn-primary {
  height: var(--control-h);
  padding: 0 16px;
  border-radius: 999px;
  border: none;
  background: var(--focus);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: opacity .12s;
}
.btn-primary:hover { opacity: .88; }
.btn-sm { height: 28px; padding: 0 12px; font-size: 12px; }

.btn-vivid {
  height: var(--control-h);
  padding: 0 18px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #f97316, #ef4444);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: filter .15s, transform .1s;
  letter-spacing: .01em;
}
.btn-vivid:hover { filter: brightness(1.08); }
.btn-vivid:active { filter: brightness(.96); }

/* ── Champ obligatoire ───────────────────────────────── */
.req { color: #ef4444; font-weight: 700; }

/* ── Grille adresse client final (fiche-mission) ────────
   Externe : 1/3 — 2/3   |   Interne : label 120px — input
   Société/Enseigne, Adresse, Complément et Code postal
   s'alignent car ils partagent la même colonne label. ── */
.cf-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 8px 20px;
}
.cf-grid .cf-full { grid-column: 1 / -1; }
.cf-grid .field,
.cf-field {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: center;
  column-gap: 10px;
}
.cf-field { margin-bottom: 12px; }
.cf-grid .field label,
.cf-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-align: right;
}
@media (max-width: 680px) {
  .cf-grid { grid-template-columns: 1fr; }
  .cf-grid .cf-full { grid-column: 1; }
}

/* ── Ligne pairée mission : [label][input][label][input] ─ */
.mission-row {
  display: grid;
  grid-template-columns: 120px 1fr 120px 1fr;
  column-gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}
.mission-row > label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-align: right;
}
@media (max-width: 680px) {
  .mission-row {
    grid-template-columns: 120px 1fr;
    row-gap: 8px;
  }
}

/* ── Suivi budgétaire : 4 colonnes (labels | Ventes | Achats | Marge) */
.contacts-grid.budget-grid {
  grid-template-columns: 18fr 22fr 22fr 38fr;
  column-gap: 12px;
}
.budget-row-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  min-height: 36px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  text-align: right;
  padding-right: 6px;
}
.budget-grid > div > input { width: 100%; margin-bottom: 8px; box-sizing: border-box; }
.budget-grid input { text-align: right; }
.budget-grid .margin-inline { margin-bottom: 8px; }

/* ── Champs Marge € et % côte à côte ────────────────────── */
.margin-inline { display: flex; align-items: center; gap: 4px; }
.margin-inline input { flex: 1; min-width: 0; }
.margin-unit {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── cf-field avec textarea : label aligné en haut ─────── */
.cf-field--textarea {
  align-items: start;
  margin-top: 8px;
}
.cf-field--textarea label { padding-top: 8px; }

/* ── Sous-titre de groupe de contacts (fiche-mission) ─── */
.contact-sub-header {
  padding: 6px 0 3px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

/* ── Ligne identification : [label ID][input ID][label Titre][input Titre] */
.ident-row {
  display: grid;
  grid-template-columns: 120px 180px 120px 1fr;
  column-gap: 10px;
  align-items: center;
}
.ident-row > label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-align: right;
}
@media (max-width: 680px) {
  .ident-row {
    grid-template-columns: 120px 1fr;
    row-gap: 8px;
  }
}

/* ── Grille 3 contacts côte à côte (fiche-mission) ────── */
.contacts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0 20px;
  margin-top: 14px;
}
.contacts-grid .field {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  column-gap: 10px;
  margin-bottom: 8px;
}
.contacts-grid .field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-align: right;
}
@media (max-width: 860px) {
  .contacts-grid { grid-template-columns: 1fr; }
  .contacts-grid .field { grid-template-columns: 200px 1fr; }
}

/* ── Inputs / Selects ────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label { font-size: 14px; font-weight: 500; }

.input,
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="time"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  height: var(--control-h);
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  outline: none;
  font-family: var(--font);
  font-size: var(--fs);
  transition: border-color .12s, box-shadow .12s;
}
textarea {
  height: auto;
  border-radius: 10px;
  padding: 10px 12px;
  resize: vertical;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* ── Grille de formulaire ────────────────────────────── */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-grid-2 .full { grid-column: 1 / -1; }

/* ── Formulaire inline (label gauche · champ droite) ─── */
.form-inline {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.form-inline .field {
  display: grid;
  grid-template-columns: 200px 1fr;
  align-items: center;
  column-gap: 16px;
}
.form-inline .field label {
  text-align: right;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}
/* Texte d'aide sous le champ */
.form-inline .field .help {
  grid-column: 2;
  margin-top: 2px;
  margin-bottom: 2px;
}
/* Textarea / multi-select : aligner le label en haut */
.form-inline .field:has(textarea),
.form-inline .field:has(select[multiple]) { align-items: start; }
.form-inline .field:has(textarea) label,
.form-inline .field:has(select[multiple]) label { padding-top: 8px; }
/* Champ contenant uniquement un label-wrapper (ex : checkbox) */
.form-inline .field > label:only-child {
  grid-column: 1 / -1;
  text-align: left;
  padding-left: 216px;
  color: inherit;
}
/* Responsive : empilé sous 680 px */
@media (max-width: 680px) {
  .form-inline .field {
    grid-template-columns: 1fr;
  }
  .form-inline .field label { text-align: left; }
  .form-inline .field .help { grid-column: 1; }
  .form-inline .field > label:only-child { padding-left: 0; }
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ── Toolbar recherche ───────────────────────────────── */
.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 0 14px;
  height: var(--control-h);
  min-width: 280px;
  transition: border-color .12s, box-shadow .12s;
}
.search-box:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.search-box input {
  border: 0;
  outline: none;
  width: 100%;
  height: 100%;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

/* ── Multi-filter dropdown ───────────────────────────── */
.multi-filter { position: relative; }

.multi-filter-btn {
  height: var(--control-h);
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  transition: border-color .12s, box-shadow .12s;
}
.multi-filter-btn:hover {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: #fff;
}
.chip-count-dim { opacity: .55; }

.multi-filter-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 300px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.10);
  padding: 10px;
  z-index: 50;
  display: none;
}
.multi-filter-panel.open { display: block; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.panel-actions { display: flex; gap: 10px; }

.link-btn {
  border: 0;
  background: transparent;
  color: var(--focus);
  cursor: pointer;
  padding: 0;
  font-size: 13px;
}
.link-btn:hover { text-decoration: underline; }

.panel-body {
  padding-top: 8px;
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
}
.check-item:hover { background: rgba(17,24,39,.04); }
.check-item input { width: 16px; height: 16px; flex-shrink: 0; }

/* ── Tables ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}
.data-table thead th {
  background: var(--table-head);
  text-align: left;
  padding: 10px 12px;
  font-weight: 700;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 10px 12px;
  border-top: 1px solid #e5e7eb;
  vertical-align: middle;
  font-size: 14px;
}
.data-table tbody tr:hover { background: var(--table-hover); }
.data-table tbody tr.row-link { cursor: pointer; }

/* ── Badges statut ───────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  white-space: nowrap;
  background: #fff;
}
.badge.internal  { background: rgba(14,165,233,.14); border-color: rgba(14,165,233,.30); }
.badge.external  { background: rgba(168,85,247,.14); border-color: rgba(168,85,247,.30); }

/* Codes de référence auto-générés (SUP-YYYYMMDD-XXXX, MIS-, PJT-, CTR-, RPT-) */
.ref-code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 12px;
  font-weight: 600;
  color: #2563eb;
  letter-spacing: .02em;
  white-space: nowrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.status-nouveau     { background: rgba(59,130,246,.12);  border: 1px solid rgba(59,130,246,.28);  }
.status-assigne     { background: rgba(99,102,241,.12);  border: 1px solid rgba(99,102,241,.28);  }
.status-encours     { background: rgba(245,158,11,.14);  border: 1px solid rgba(245,158,11,.30);  }
.status-planifie    { background: rgba(14,165,233,.14);  border: 1px solid rgba(14,165,233,.30);  }
.status-facturation { background: rgba(168,85,247,.12);  border: 1px solid rgba(168,85,247,.28);  }
.status-complete    { background: rgba(34,197,94,.14);   border: 1px solid rgba(34,197,94,.30);   }
.status-abandonne   { background: rgba(239,68,68,.12);   border: 1px solid rgba(239,68,68,.28);   }
.badge-corporate    { background: rgba(14,165,233,.12);  border: 1px solid rgba(14,165,233,.28);  color: #0369a1; }
.badge-retail       { background: rgba(168,85,247,.12);  border: 1px solid rgba(168,85,247,.28);  color: #7e22ce; }
.badge-sites        { background: rgba(34,197,94,.12);   border: 1px solid rgba(34,197,94,.28);   color: #15803d; }

/* ── Chips planning ──────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid rgba(17,24,39,.10);
}
.chip.internal { background: rgba(14,165,233,.14); border-color: rgba(14,165,233,.28); }
.chip.external { background: rgba(168,85,247,.14); border-color: rgba(168,85,247,.28); }

/* ── ================================================== */
/*    DASHBOARD                                          */
/* ── ================================================== */
.dash-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.dash-header h1 { margin: 0; }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

/* Étiquette de section entre deux rangées de KPIs */
.kpi-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin-bottom: 8px;
  margin-top: 4px;
}
.kpi {
  display: flex;
  align-items: flex-start;   /* contenu ancré en haut */
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  min-height: 112px;         /* plancher commun pour toutes les cartes */
  box-sizing: border-box;
}
.kpi-title { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.kpi-value { font-size: 30px; font-weight: 800; line-height: 1.1; }
.kpi-foot  { font-size: 12px; color: var(--muted); margin-top: 6px; }
.kpi-icon  {
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(17,24,39,.10);
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}

.two-col {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}

.alerts { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.alert {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(17,24,39,.08);
  background: #fff;
}
.alert .dot {
  width: 10px; height: 10px; border-radius: 999px;
  margin-top: 6px; flex-shrink: 0;
  background: rgba(239,68,68,.8);
}
.alert.warn .dot  { background: rgba(245,158,11,.9); }
.alert.info .dot  { background: rgba(14,165,233,.9); }
.alert .a-title   { font-weight: 700; font-size: 14px; }
.alert .a-desc    { color: var(--muted); font-size: 13px; margin-top: 2px; }

.timeline { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.t-item {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(17,24,39,.08);
  background: #fff;
}
.t-time   { font-weight: 700; color: var(--muted); font-size: 12px; padding-top: 2px; white-space: nowrap; }
.t-title  { font-weight: 700; font-size: 14px; }
.t-desc   { color: var(--muted); font-size: 13px; margin-top: 2px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid rgba(17,24,39,.10);
  background: #fff;
}
.pill.internal { background: rgba(14,165,233,.14); border-color: rgba(14,165,233,.28); }
.pill.external { background: rgba(168,85,247,.14); border-color: rgba(168,85,247,.28); }

/* ── ================================================== */
/*    PLANNING — COMMUN                                  */
/* ── ================================================== */
.planning-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.planning-header h1 { margin: 0; }
.planning-subtitle  { color: var(--muted); font-size: 13px; }

.planning-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.toolbar-chip {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  height: var(--control-h);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
}

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

/* ── PLANNING JOUR ───────────────────────────────────── */
.planning-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #fff;
}

.planning-grid {
  display: grid;
  grid-template-columns: var(--time-col-w) repeat(4, var(--tech-col-w));
  min-width: calc(var(--time-col-w) + 4 * var(--tech-col-w));
}

.pg-cell {
  border-bottom: 1px solid #eef0f3;
  border-right: 1px solid #eef0f3;
  min-height: var(--slot-h);
  position: relative;
}

.pg-head {
  position: sticky; top: 0;
  background: var(--table-head);
  z-index: 5;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  font-weight: 700;
}
.pg-head.tech { display: flex; flex-direction: column; gap: 4px; }
.pg-head .meta { font-weight: 400; font-size: 12px; color: var(--muted); }

.time-cell {
  position: sticky; left: 0;
  background: #fff; z-index: 4;
  padding: 10px 12px;
  color: var(--muted); font-size: 12px;
  border-right: 1px solid var(--border);
  white-space: nowrap;
}
.time-head {
  position: sticky; left: 0; top: 0;
  background: var(--table-head); z-index: 6;
  border-right: 1px solid var(--border);
}
.hour-line { border-bottom: 1px solid #dce0e8; }

.day-col { position: relative; }

.event {
  position: absolute;
  left: 6px; right: 6px;
  border-radius: 8px;
  padding: 6px 10px;
  border: 1px solid rgba(17,24,39,.12);
  box-shadow: 0 4px 10px rgba(0,0,0,.06);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow .15s;
}
.event:hover { box-shadow: 0 6px 18px rgba(0,0,0,.12); }
.event .title { font-weight: 700; font-size: 12px; }
.event .sub   { font-size: 11px; opacity: .85; margin-top: 1px; }
.event .time  { font-size: 11px; opacity: .75; margin-top: 3px; }
.event.internal { background: rgba(14,165,233,.14); border-color: rgba(14,165,233,.30); }
.event.external { background: rgba(168,85,247,.14); border-color: rgba(168,85,247,.30); }

/* ── PLANNING SEMAINE ────────────────────────────────── */
.week-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #fff;
}
.week-grid {
  display: grid;
  grid-template-columns: var(--time-col-w) repeat(7, minmax(var(--day-col-min), 1fr));
  min-width: calc(var(--time-col-w) + 7 * var(--day-col-min));
}
.wg-head {
  position: sticky; top: 0; z-index: 5;
  background: var(--table-head);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  font-weight: 700;
  text-transform: capitalize;
  font-size: 13px;
}
.wg-tech-head { position: sticky; left: 0; z-index: 6; border-right: 1px solid var(--border); }
.wg-tech {
  position: sticky; left: 0; z-index: 4;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 10px 12px;
}
.wg-cell {
  border-bottom: 1px solid #eef0f3;
  border-right: 1px solid #eef0f3;
  padding: 10px 12px;
  min-height: 90px;
}
.wg-cell:hover { background: var(--table-hover); }
.tech-name { font-weight: 700; font-size: 14px; }
.tech-meta { margin-top: 4px; }
.cell-events { display: flex; flex-direction: column; gap: 5px; }
.cell-empty  { color: var(--muted); font-size: 12px; }

/* ── PLANNING MOIS ───────────────────────────────────── */
.month-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #fff;
  margin-top: 12px;
}
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(140px, 1fr));
  min-width: 900px;
}
.mg-head {
  position: sticky; top: 0; z-index: 5;
  background: var(--table-head);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  font-weight: 700;
  text-transform: capitalize;
  font-size: 13px;
}
.day-cell {
  border-right: 1px solid #eef0f3;
  border-bottom: 1px solid #eef0f3;
  padding: 10px 12px;
  min-height: 110px;
  display: flex; flex-direction: column; gap: 6px;
}
.day-cell:hover { background: var(--table-hover); }
.day-top { display: flex; align-items: center; justify-content: space-between; }
.day-num  { font-weight: 800; font-size: 15px; }
.day-iso  { color: var(--muted); font-size: 11px; }
.out-month { opacity: .45; }
.events-stack { display: flex; flex-direction: column; gap: 4px; }

.month-toolbar {
  display: flex; align-items: center;
  justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
}
.month-label { font-weight: 700; font-size: 15px; }

/* ── PLANNING MOIS GLISSANT ──────────────────────────── */
.rolling-toolbar {
  display: flex; align-items: center;
  justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
}
.rolling-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #fff;
  margin-top: 12px;
  max-height: 72vh;
}
.week-block { border-bottom: 1px solid var(--border); }
.week-title {
  position: sticky; top: 0; z-index: 6;
  background: #fff;
  padding: 10px 14px;
  font-weight: 800;
  border-bottom: 1px solid #eef0f3;
  display: flex; align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
}
.week-grid2 {
  display: grid;
  grid-template-columns: repeat(7, minmax(140px, 1fr));
  min-width: 900px;
}
.wg2-head {
  background: var(--table-head);
  padding: 8px 12px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  text-transform: capitalize;
}
.wg2-cell {
  border-right: 1px solid #eef0f3;
  border-bottom: 1px solid #eef0f3;
  padding: 10px 12px;
  min-height: 100px;
  display: flex; flex-direction: column; gap: 6px;
}
.wg2-cell:hover { background: var(--table-hover); }
.wg2-top  { display: flex; align-items: center; justify-content: space-between; }
.wg2-date { font-weight: 800; font-size: 15px; }
.wg2-iso  { color: var(--muted); font-size: 11px; }

/* ── ================================================== */
/*    FICHE MISSION                                      */
/* ── ================================================== */
.mission-layout {
  display: grid;
  grid-template-columns: 60% 40%;
  gap: 14px;
  align-items: start;
}
.mission-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  background: #ffffff;
}
.mission-fieldset legend {
  padding: 0 8px;
  font-weight: 700;
  font-size: 14px;
}

/* Rich-text editor (contenteditable) */
.rich-editor-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: visible;
  background: #fff;
}
.rich-editor-wrap > .rich-editor {
  border-radius: var(--radius) var(--radius) 0 0;
}
.rich-editor-wrap > .rich-toolbar {
  border-radius: 0 0 var(--radius) var(--radius);
}
.rich-editor-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.rich-editor {
  min-height: calc(10 * 1.5 * 14px); /* 10 lignes — surchargé pour les notes */
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: transparent;
  outline: none;
  line-height: 1.5;
  overflow-wrap: break-word;
  word-break: break-word;
  border: none;
}
.note-item .rich-editor { min-height: 0; }
.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  pointer-events: none;
}
/* Toolbar */
.rich-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 8px;
  border-top: 1px solid var(--border);
  background: var(--bg-alt, #f8fafc);
  flex-wrap: wrap;
}
.rtb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: background .12s, border-color .12s;
  padding: 0;
  flex-shrink: 0;
}
.rtb-btn:hover  { background: #e8edf5; border-color: var(--border); }
.rtb-btn.active { background: #dbeafe; border-color: #93c5fd; color: var(--primary); }
.rtb-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}
/* Icône surlignage */
.rtb-icon-hl {
  display: inline-block;
  font-weight: 700;
  font-size: 13px;
  background: #fde047;
  padding: 0 2px;
  border-radius: 2px;
  line-height: 1.3;
}
/* Icône couleur texte */
.rtb-icon-color {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-weight: 700;
  font-size: 14px;
  color: #e63946;
  line-height: 1;
  box-sizing: border-box;
}
#txtColorPicker {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
/* Split button surlignage */
.rtb-split {
  display: inline-flex;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 5px;
  overflow: hidden;
}
.rtb-split:hover { border-color: var(--border); }
.rtb-split .rtb-btn {
  border-radius: 0;
  border: none;
}
.rtb-split .rtb-btn:hover { border: none; }
.rtb-split-main  { width: 24px; }
.rtb-split-arrow {
  width: 16px;
  height: 28px;
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-left: 1px solid var(--border) !important;
  padding: 0;
}
.rtb-split-arrow:hover { background: #e8edf5; }
#hilitePicker {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
/* Table picker */
.rtb-table-wrap {
  position: relative;
  display: inline-flex;
}
.rtb-table-picker {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  padding: 10px;
  z-index: 200;
  min-width: 140px;
}
.rtb-table-picker.open { display: block; }
.rtb-table-grid {
  display: grid;
  grid-template-columns: repeat(8, 18px);
  gap: 3px;
}
.rtb-table-grid .tg-cell {
  width: 18px;
  height: 18px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: #fff;
  cursor: pointer;
  box-sizing: border-box;
  transition: background .08s, border-color .08s;
}
.rtb-table-grid .tg-cell.hover {
  background: #dbeafe;
  border-color: #93c5fd;
}
.rtb-table-label {
  margin-top: 8px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.rtb-table-manual {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}
.rtb-table-manual label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.rtb-table-manual input[type="number"] {
  width: 44px;
  padding: 3px 6px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
  text-align: center;
  -moz-appearance: textfield;
}
.rtb-table-manual input[type="number"]::-webkit-inner-spin-button,
.rtb-table-manual input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
.rtb-table-manual-sep {
  font-size: 13px;
  color: var(--muted);
}
.rtb-manual-insert {
  margin-left: auto;
  padding: 4px 10px;
}
.rtb-table-header-label {
  margin-top: 10px;
  margin-bottom: 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.rtb-table-header-opts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.rtb-hopt {
  padding: 4px 6px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  color: var(--text);
  transition: background .1s, border-color .1s, color .1s;
}
.rtb-hopt:hover  { background: #e8edf5; border-color: var(--border); }
.rtb-hopt.active { background: #dbeafe; border-color: #93c5fd; color: var(--primary); font-weight: 600; }

/* Tableaux collés depuis Word/Excel */
.rich-editor table {
  border-collapse: collapse;
  width: 100%;
  margin: 6px 0;
  font-size: 13px;
}
.rich-editor table td,
.rich-editor table th {
  border: 1px solid var(--border);
  padding: 4px 8px;
  vertical-align: top;
}
.rich-editor table th {
  background: var(--bg-alt, #f8fafc);
  font-weight: 600;
}

/* Dropzone pièces jointes */
.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: var(--bg-alt, #f8fafc);
}
.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--primary);
  background: #eff6ff;
}
.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.dropzone-body { pointer-events: none; }
.dropzone-icon { font-size: 28px; margin-bottom: 6px; }
.dropzone-text { font-size: 14px; color: var(--text); }
.dropzone-link { color: var(--primary); font-weight: 600; text-decoration: underline; }

/* Liste des fichiers */
.attach-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}
.attach-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  font-size: 13px;
}
.attach-icon { font-size: 18px; flex-shrink: 0; }
.attach-info { flex: 1; min-width: 0; }
.attach-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attach-meta { font-size: 11px; color: var(--muted); margin-top: 1px; }
.attach-preview {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.attach-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color .1s, background .1s;
}
.attach-remove:hover { color: #dc2626; background: #fee2e2; }

.notes-list { display: flex; flex-direction: column; gap: 8px; }
.note-item  { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.note-item textarea { resize: vertical; }
.note-item-actions { display: flex; gap: 8px; }

/* Note validée (saisie manuelle) */
.note-validated {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius);
  background: #eff6ff;
  border-left: 3px solid #3b82f6;
  font-size: 13px;
  color: #1e3a5f;
}
.note-validated-icon { flex-shrink: 0; font-size: 13px; margin-top: 1px; }
.note-validated-body { flex: 1; min-width: 0; }
.note-validated-text {
  white-space: pre-wrap;
  line-height: 1.5;
  word-break: break-word;
}
.note-validated-meta {
  margin-top: 4px;
  font-size: 11px;
  color: #3b82f6;
  font-weight: 500;
}
.note-validated-edit {
  color: #6b7280;
  font-style: italic;
  font-weight: 400;
}
.note-edit-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  flex-shrink: 0;
  align-self: flex-start;
  opacity: 0.5;
  transition: opacity .15s, background .15s;
}
.note-validated:hover .note-edit-btn { opacity: 1; }
.note-edit-btn:hover { background: #dbeafe; }

/* Entrées de log automatique */
.note-log {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius);
  background: #f1f5f9;
  border-left: 3px solid #94a3b8;
  font-size: 12px;
  color: #475569;
}
.note-log-icon { flex-shrink: 0; font-size: 13px; margin-top: 1px; }
.note-log-text { flex: 1; line-height: 1.5; }
.note-log-text strong { color: #1e293b; font-weight: 600; }

/* ── Modal ─────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--text); }
.modal-close {
  background: none; border: none; font-size: 22px; cursor: pointer;
  color: var(--muted); line-height: 1; padding: 0 4px;
  border-radius: 4px; transition: background .1s, color .1s;
}
.modal-close:hover { background: #f1f5f9; color: var(--text); }
.modal-body { padding: 20px; }
.modal-intro { font-size: 13px; color: var(--muted); margin: 0 0 14px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
/* Options de génération */
.generate-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.gen-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.gen-option:hover {
  border-color: var(--primary);
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.08);
}
.gen-icon  { font-size: 24px; }
.gen-label { font-size: 14px; font-weight: 700; color: var(--text); }
.gen-desc  { font-size: 11px; color: var(--muted); line-height: 1.4; }

/* ── Modal large (e-mail) ────────────────────────────── */
.modal-box--wide {
  max-width: 780px;
  width: 95vw;
  max-height: 90vh;
  overflow: hidden;
}
.modal-box--wide .modal-body { overflow-y: auto; }

/* ── Sélection pièces jointes ────────────────────────── */
.attach-check-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 280px;
  overflow-y: auto;
  padding: 2px 0;
}
.attach-check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}
.attach-check-item:hover { background: var(--bg-alt, #f8fafc); }
.attach-check-item input[type="checkbox"] {
  width: 16px; height: 16px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--focus);
}

/* ── Toggle "Client direct / Client indirect" ─────────── */
.tc-switch-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* Place le champ conditionnel (ex. Donneur d'ordre) à droite du switch plutôt qu'en dessous */
.tc-row { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.tc-row .field { margin: 0; }
.tc-switch {
  position: relative; display: inline-block;
  width: 42px; height: 22px; flex-shrink: 0;
}
.tc-switch input { opacity: 0; width: 0; height: 0; }
.tc-switch-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: #cbd5e1; border-radius: 999px; transition: background .18s;
}
.tc-switch-slider::before {
  content: ""; position: absolute; height: 16px; width: 16px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: transform .18s;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.tc-switch input:checked + .tc-switch-slider { background: #2563eb; }
.tc-switch input:checked + .tc-switch-slider::before { transform: translateX(20px); }
.tc-switch-label { font-size: 13px; color: var(--muted); font-weight: 400; transition: color .15s, font-weight .15s; }
.tc-switch-label.active { color: var(--text); font-weight: 700; }

/* ── Modal e-mail ────────────────────────────────────── */
.email-att-section {
  background: var(--bg-alt, #f8fafc);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 14px;
}
.email-att-label { font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 6px; }
.email-att-item  { font-size: 13px; color: #475569; padding: 2px 0; }
/* Destinataires */
.email-dest-section { background: var(--bg-alt,#f8fafc); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; }
.email-dest-header  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.email-dest-label   { font-weight: 600; font-size: 13px; color: var(--text); }
.email-dest-list    { display: flex; flex-direction: column; gap: 4px; }
.email-dest-item    { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text); padding: 3px 0; }
.email-dest-name    { font-weight: 500; }
.email-dest-role         { font-size: 11px; color: var(--muted); background: #e2e8f0; border-radius: 4px; padding: 1px 6px; }
.email-dest-addr         { font-size: 12px; color: var(--muted); font-style: italic; }
.email-dest-addr--empty  { color: #f59e0b; font-style: italic; }
.email-dest-role--ext    { background: #fef3c7; color: #92400e; }
/* Ligne objet */
.email-subject-row  { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.email-subject-label{ font-weight: 600; font-size: 13px; color: var(--text); white-space: nowrap; }
.email-compose-label { font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 8px; }
.email-compose-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  max-height: 360px;
  overflow-y: auto;
  background: #fff;
  font-size: 13px;
  line-height: 1.5;
}

/* ── Structure fiche mission (aperçu e-mail + impression) */
.fiche-sec  { margin-bottom: 14px; }
.fiche-sh   { font-size: 12px; font-weight: 700; color: #1e3a8a; background: #eff6ff; padding: 4px 10px; margin-bottom: 6px; border-left: 3px solid #2563eb; }
.fiche-table { border-collapse: collapse; width: 100%; margin-bottom: 6px; }
.fiche-table td { padding: 3px 8px; border-bottom: 1px solid #f1f5f9; vertical-align: top; font-size: 12px; }
.fiche-label { color: #64748b; width: 130px; white-space: nowrap; font-size: 11px; }
.fiche-value { color: #1e293b; }
.fiche-contacts { display: flex; gap: 12px; flex-wrap: wrap; }
.fiche-contact-col { flex: 1; min-width: 110px; }
.fiche-contact-head { font-weight: 700; font-size: 10px; color: #475569; border-bottom: 1px solid #e2e8f0; padding-bottom: 2px; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.fiche-desc-label { font-weight: 600; font-size: 11px; color: #64748b; margin: 8px 0 4px 8px; }
.fiche-desc-content { padding: 6px 10px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 4px; font-size: 12px; }
.fiche-desc-content table { border-collapse: collapse; width: 100%; }
.fiche-desc-content td, .fiche-desc-content th { border: 1px solid #cbd5e1; padding: 3px 6px; }
.fiche-desc-content th { background: #f1f5f9; }
.fiche-pj-imgs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.fiche-pj-img img { max-width: 180px; max-height: 140px; border: 1px solid #e2e8f0; border-radius: 3px; }
.fiche-pj-list { margin: 4px 0 0 16px; padding: 0; font-size: 11px; color: #475569; }
.fiche-pj-list li { margin-bottom: 2px; }

/* ── ================================================== */
/*    PARAMÈTRES                                         */
/* ── ================================================== */
.params-overview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 14px;
}
.param-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex; flex-direction: column; gap: 8px;
  background: #fff;
  text-decoration: none;
  transition: box-shadow .14s, border-color .14s;
  color: var(--text);
}
.param-card:hover {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.param-card-icon { font-size: 26px; }
.param-card-title { font-weight: 800; font-size: 16px; }
.param-card-desc  { font-size: 13px; color: var(--muted); }

/* ── ================================================== */
/*    RESPONSIVE                                         */
/* ── ================================================== */
@media (max-width: 1100px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(200px, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
  .layout { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
  .sidebar-title, .sidebar-section, .nav-item span, .sidebar-io-user { display: none; }
  .nav-item { padding: 12px; justify-content: center; font-size: 18px; }
  .sidebar-footer { justify-content: center; padding: 8px 4px; }
  :root { --container-pad: 16px; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .form-grid-2 .full { grid-column: 1; }
  .mission-layout { grid-template-columns: 1fr; }
  .params-overview { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .kpi-row { grid-template-columns: 1fr; }
  .search-box { min-width: 100%; }
  .toolbar-left, .toolbar-right { width: 100%; }
}

/* ── Sidebar — nav scrollable + footer collé en bas ─── */
.sidebar      { overflow-y: hidden; }
.sidebar-nav  { flex: 1; overflow-y: auto; }

/* ── Sidebar footer (bouton I/O) ─────────────────────── */
.sidebar-footer {
  flex-shrink: 0;
  padding: 8px 12px;
  border-top: 1px solid #1f2937;
  margin-top: 10px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-io-user {
  font-size: 13.5px;
  font-weight: 600;
  color: #d1d5db;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.sidebar-io-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1.5px solid #374151;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
  flex-shrink: 0;
}
.sidebar-io-btn:hover {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239,68,68,.10);
}

.sidebar-account-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0; right: 0;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: var(--radius-lg);
  box-shadow: 0 -6px 24px rgba(0,0,0,.35);
  overflow: hidden;
  display: none;
  z-index: 300;
}
.sidebar-account-menu.open { display: block; }

.sidebar-account-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  font-size: 13px; font-weight: 500;
  color: #d1d5db;
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background .12s, color .12s;
  font-family: var(--font);
  line-height: 1.4;
}
.sidebar-account-item:hover { background: #374151; color: #fff; }
.sidebar-account-item--danger { color: #f87171; }
.sidebar-account-item--danger:hover { background: rgba(239,68,68,.14); color: #fca5a5; }
