/* ─── Variables ─────────────────────────────────────────────────── */
:root {
  --navy:          #092b4c;
  --navy-soft:     #113b61;
  --blue:          #176c9e;
  --sky:           #e8f2f8;
  --gold:          #d5a52f;
  --gold-hover:    #b98616;
  --gold-light:    #faf3df;
  --bg:            #f3f6f8;
  --card:          #ffffff;
  --border:        #d6e0e7;
  --text:          #142838;
  --text-light:    #607383;
  --danger:        #c0392b;
  --danger-hover:  #a93226;
  --danger-light:  #fdecea;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.07), 0 1px 8px rgba(0,0,0,.04);
  --shadow-md:     0 2px 8px rgba(0,0,0,.09), 0 4px 20px rgba(0,0,0,.06);
  --radius:        5px;
  --radius-sm:     4px;
  --font:          -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

/* ─── Reset minimal ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }

/* ─── Header ─────────────────────────────────────────────────────── */
.header {
  background: var(--navy);
  border-bottom: 1px solid #ffffff24;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(4, 24, 42, .22);
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ─── Brand menu ────────────────────────────────────────────────── */
.brand-menu {
  position: relative;
  flex-shrink: 0;
}
.brand-link {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .5rem .65rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .95rem;
  letter-spacing: -.01em;
  color: #fff;
  text-decoration: none;
  transition: background .15s;
}
.brand-link:hover { background: #ffffff12; }
.brand-logo { display:block; width:96px; height:auto; object-fit:contain; }
.brand-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 200px;
  padding: .3rem;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .18s, visibility .18s;
}
.brand-menu:hover .brand-dropdown {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.brand-dropdown-item {
  display: block;
  padding: .5rem .75rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--text-light);
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.brand-dropdown-item:hover { background: var(--bg); color: var(--text); }
.brand-dropdown-item.active {
  background: var(--gold-light);
  color: var(--gold);
  font-weight: 600;
}

/* ─── Header search ──────────────────────────────────────────────── */
.header-search {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex: 1;
  max-width: 340px;
}
.header-search-input { flex: 1; min-width: 0; }
.header-search-btn { flex-shrink: 0; padding: .35rem .55rem; }

/* ─── Outils menu ────────────────────────────────────────────────── */
.outils-menu {
  position: relative;
  flex-shrink: 0;
}
.outils-trigger {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .28rem .6rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: inherit;
  font-size: .875rem;
  font-weight: 500;
  color: #d6e4ed;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.outils-trigger:hover { background: #ffffff12; color: #fff; }
.outils-dropdown-primary { margin-top: .25rem; border-top: 1px solid var(--border); color: var(--navy); font-weight: 700; }
.outils-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 160px;
  padding: .3rem;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .18s, visibility .18s;
}
.outils-menu:hover .outils-dropdown {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.outils-dropdown-item {
  display: block;
  padding: .5rem .75rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--text-light);
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.outils-dropdown-item:hover { background: var(--bg); color: var(--text); }
.outils-dropdown-item.active {
  background: var(--gold-light);
  color: var(--gold);
  font-weight: 600;
}

/* ─── Header actions ─────────────────────────────────────────────── */
.header-actions {
  display: flex;
  align-items: center;
  gap: .25rem;
  margin-left: auto;
}

/* ─── User menu ──────────────────────────────────────────────────── */
.user-menu { position: relative; }
.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  color: var(--navy);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  cursor: default;
  user-select: none;
  transition: box-shadow .15s;
}
.user-menu:hover .user-avatar { box-shadow: 0 0 0 2px var(--gold-light); }
.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 155px;
  padding: .3rem;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .18s, visibility .18s;
}
.user-menu:hover .user-dropdown {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.user-dropdown-item {
  display: block;
  padding: .48rem .75rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--text-light);
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.user-dropdown-item:hover { background: var(--bg); color: var(--text); }
.user-dropdown-item.active { background: var(--gold-light); color: var(--gold); font-weight: 600; }
.user-dropdown-logout:hover { background: var(--danger-light); color: var(--danger); }
.user-dropdown-version {
  padding: .3rem .75rem .35rem;
  font-size: .72rem;
  color: var(--text-light);
  opacity: .5;
  border-top: 1px solid var(--border);
  margin-top: .25rem;
  letter-spacing: .02em;
}

/* ─── Main layout ────────────────────────────────────────────────── */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

/* ─── Card ───────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* ─── Page header ────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
}
.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--navy);
}
.page-sub {
  font-size: .85rem;
  color: var(--text-light);
  margin-top: .15rem;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .85rem;
  color: var(--text-light);
  transition: color .15s;
}
.back-link:hover { color: var(--gold); }
.btn-link-sm {
  background: none;
  border: none;
  color: var(--gold);
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-transform: uppercase;
  letter-spacing: .04em;
  transition: color .15s;
}
.btn-link-sm:hover { color: var(--gold-hover); }

/* ─── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .5rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
  line-height: 1;
}
.btn-primary {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.btn-primary:hover {
  background: var(--navy-soft);
  border-color: var(--navy-soft);
  box-shadow: 0 2px 8px rgba(9,43,76,.28);
}
.btn-ghost {
  background: transparent;
  color: var(--text-light);
  border-color: var(--border);
}
.btn-ghost:hover {
  background: var(--bg);
  color: var(--text);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger-hover); }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: .35rem .8rem; font-size: .8rem; }

/* icon buttons in table */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  color: var(--text-light);
  transition: background .15s, color .15s, border-color .15s;
  flex-shrink: 0;
}
.btn-edit:hover  { background: var(--gold-light); color: var(--gold); border-color: var(--gold); }
.btn-delete:hover { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }
.btn-calendar:hover { background: #e8f4ff; color: #1a6bb3; border-color: #1a6bb3; }
.btn-folder:hover { background: #e8f4ff; color: #1a6bb3; border-color: #1a6bb3; }
.case-unlinked { color: var(--text-light); font-size: .75rem; white-space: nowrap; }
.addr-suggestions {
  position: absolute; left: 0; top: calc(100% + 2px);
  width: 100%; margin: 0; padding: 0; list-style: none;
  background: var(--bg, #fff);
  border: 1px solid var(--border, #d1d5db);
  border-radius: var(--radius-sm, 4px);
  box-shadow: 0 4px 14px rgba(0,0,0,.13);
  z-index: 10001; max-height: 13rem; overflow-y: auto; display: none;
}
.addr-sugg-item {
  padding: .4rem .7rem; cursor: pointer; font-size: .84rem;
  color: var(--text, #111); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.addr-sugg-item:hover, .addr-sugg-item:focus { background: var(--bg-light, #f3f4f6); outline: none; }
.addr-sugg-internal { font-weight: 500; color: var(--primary, #1a6bb3); }

/* ── Icône calendrier au survol des dates en liste ───────────────── */
.date-with-calendar {
  display: inline-grid;
  grid-template-columns: max-content auto;
  align-items: center;
  gap: 0 .3rem;
  white-space: nowrap;
  vertical-align: middle;
}
.cal-time {
  grid-column: 1;
  grid-row: 2;
  font-size: .65rem;
  color: var(--text-light);
  line-height: 1;
  white-space: nowrap;
}
.date-calendar-trigger {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
  padding: .05rem .2rem;
  font-size: .8rem;
  line-height: 1;
}
.date-with-calendar:hover .date-calendar-trigger,
.date-with-calendar:focus-within .date-calendar-trigger {
  opacity: 1;
  pointer-events: auto;
}

/* ─── Table ──────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.table thead tr { border-bottom: 2px solid var(--border); }
.table th {
  padding: .75rem 1rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-light);
  white-space: nowrap;
  user-select: none;
  position: relative;
}
.th-sort { cursor: pointer; }
.th-sort:hover .th-text { color: var(--text); }
.th-sort::after { content: " ↕"; opacity: .3; font-size: .65rem; }
.th-sort.sort-asc::after  { content: " ↑"; opacity: .8; color: var(--gold); }
.th-sort.sort-desc::after { content: " ↓"; opacity: .8; color: var(--gold); }
.th-filterable { padding-right: 2rem; }
.th-actions { width: 90px; text-align: center; }

.th-text { vertical-align: middle; }

.th-filter-btn {
  position: absolute;
  right: .4rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  padding: .15rem .2rem;
  border-radius: 3px;
  line-height: 1;
  opacity: .5;
  transition: opacity .15s, color .15s, background .15s;
  display: inline-flex;
  align-items: center;
}
.th-filter-btn:hover,
.th-filter-btn.active {
  opacity: 1;
  color: var(--gold);
  background: var(--gold-light);
}

/* ─── Filter dropdown ───────────────────────────────────────────── */
.filter-dropdown {
  position: fixed;
  top: 0;
  left: 0;
  min-width: 180px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 500;
  padding: .5rem;
}
.filter-dropdown-checks {
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: .5rem;
}
.filter-dropdown-checks label {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .4rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  white-space: nowrap;
  transition: background .1s;
}
.filter-dropdown-checks label:hover { background: var(--bg); }
.filter-dropdown-checks input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--gold);
  flex-shrink: 0;
}
.filter-dropdown-actions {
  display: flex;
  gap: .4rem;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  padding-top: .4rem;
}
.th-filter-indicator {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  margin-left: .2rem;
  vertical-align: middle;
}

/* ─── Inline edit badge ─────────────────────────────────────────── */
.inline-edit-badge {
  cursor: pointer;
  transition: opacity .15s, box-shadow .15s;
}
.inline-edit-badge:hover {
  opacity: .85;
  box-shadow: 0 0 0 2px var(--gold);
}
.inline-edit-badge.popup-open {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  opacity: 1;
}

/* ─── Popup badge (liste flottante) ──────────────────────────────── */
.badge-popup {
  position: fixed;
  z-index: 600;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 165px;
  max-width: 250px;
  padding: .3rem 0;
  overflow: hidden;
}
.badge-popup-option {
  display: block;
  width: 100%;
  background: none;
  border: none;
  padding: .48rem .9rem;
  font-size: .83rem;
  font-family: var(--font);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background .1s;
  white-space: nowrap;
}
.badge-popup-option:hover {
  background: var(--bg);
}
.badge-popup-option--current {
  font-weight: 600;
  color: var(--gold-hover);
  background: var(--gold-light);
}
.badge-popup-option--current:hover {
  background: var(--gold-light);
}

/* ─── Badges — administratif ─────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 500;
  white-space: nowrap;
}
.badge-admin { background: #f3f4f6; color: #4b5563; }
.badge-admin--lm-a-faire { background: #fef2f2; color: #b91c1c; }
.badge-admin--lm-envoye  { background: #fff7ed; color: #c2410c; }
.badge-admin--lm-signe   { background: #eff6ff; color: #1d4ed8; }
.badge-admin--lm-encode  { background: #f0fdf4; color: #15803d; }
.badge-admin--termine    { background: #e5e7eb; color: #1f2937; font-weight: 600; }
.badge-admin--annule     { background: #fef9c3; color: #854d0e; font-weight: 600; }

/* ─── Badges — état avancement (Etude Patrimoniale) ─────────────── */
.badge-etat { background: #f3f4f6; color: #4b5563; }
.badge-etat--non-contacte           { background: #fef2f2; color: #b91c1c; }
.badge-etat--a-commencer            { background: #fff7ed; color: #c2410c; }
.badge-etat--en-cours-de-collecte   { background: #eff6ff; color: #1d4ed8; }
.badge-etat--big-fini               { background: #f0fdf4; color: #15803d; }
.badge-etat--restitution-realisee   { background: #dcfce7; color: #166534; }
/* historique patrimoine — conservé pour les anciennes valeurs */
.badge-etat--mission-terminee       { background: #f3f4f6; color: #4b5563; }
.badge-etat--termine                { background: #f3f4f6; color: #4b5563; }

/* ─── Badges — avancement (fiscal, ponctuel, MAHAKA) ─────────────── */
.badge-avancement { background: #f3f4f6; color: #4b5563; }
.badge-tmp { background: #fef3c7; color: #92400e; font-style: italic; }
.badge-avancement--non-contacte          { background: #fef2f2; color: #b91c1c; }
.badge-avancement--en-cours-de-collecte  { background: #fff7ed; color: #c2410c; }
.badge-avancement--saisie-dr             { background: #eff6ff; color: #1d4ed8; }
.badge-avancement--edi-transmis          { background: #f0fdf4; color: #15803d; }
.badge-avancement--edi-ok                { background: #f3f4f6; color: #4b5563; }
.badge-avancement--contacte              { background: #fff7ed; color: #c2410c; }
.badge-avancement--compte-rendu-en-cours { background: #eff6ff; color: #1d4ed8; }
.badge-avancement--compte-rendu-envoye   { background: #dcfce7; color: #166534; }
/* historique — conservé pour les anciennes valeurs */
.badge-avancement--termine               { background: #f3f4f6; color: #4b5563; }
/* MAHAKA avancement */
.badge-avancement--proposition-faite     { background: #fff7ed; color: #c2410c; }
.badge-avancement--souscription-en-cours { background: #eff6ff; color: #1d4ed8; }
.badge-avancement--souscription-terminee { background: #dcfce7; color: #166534; }
/* Retraite avancement */
.badge-avancement--a-planifier   { background: #fef2f2; color: #b91c1c; }
/* historique retraite — conservé pour les anciennes valeurs */
.badge-avancement--a-confirmer   { background: #fff7ed; color: #c2410c; }
/* états retraite actifs */
.badge-avancement--confirme      { background: #eff6ff; color: #1d4ed8; }
.badge-avancement--collecte      { background: #dbeafe; color: #1e40af; }
.badge-avancement--cerfa-envoye  { background: #f0fdf4; color: #15803d; }
.badge-avancement--depose        { background: #dcfce7; color: #166534; }
.badge-avancement--demande-comp  { background: #fff7ed; color: #c2410c; }
.badge-avancement--notifie       { background: #f3f4f6; color: #374151; }
.badge-avancement--recours       { background: #fef2f2; color: #b91c1c; }

/* ─── Table cells ────────────────────────────────────────────────── */
.table tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
.table tbody tr:last-child { border-bottom: none; }
.table tbody tr:hover { background: #faf9f6; }
.table td { padding: .7rem 1rem; vertical-align: middle; }
.td-dossier { font-weight: 600; font-family: "SF Mono", "Fira Mono", monospace; font-size: .82rem; }
.td-nom-dossier { color: var(--text-light); font-size: .875rem; }
.td-binome { font-size: .78rem; color: var(--text-light); }
.td-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .5rem .75rem;
}
.td-client-contact {
  vertical-align: middle;
  text-align: center;
  padding: .5rem .75rem;
  white-space: nowrap;
}
.contact-btn-group {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}

/* ─── Icône commentaire ───────────────────────────────────────────── */
.btn-comment {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--gold);
  text-decoration: none;
  margin-left: .3rem;
  vertical-align: middle;
  transition: color .15s;
  flex-shrink: 0;
}
.btn-comment:hover { color: var(--gold-hover); }

/* ─── Empty state ────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-light);
}

/* ─── Form page ──────────────────────────────────────────────────── */
.form-page { max-width: 760px; }
.form-card { padding: 1.75rem 2rem; }
.mission-form .form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem 1.5rem;
}
.field { display: flex; flex-direction: column; gap: .35rem; }
.field-full { grid-column: 1 / -1; }
.label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.required { color: var(--danger); }
.section-label {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gold);
  padding-top: .25rem;
  border-top: 1px solid var(--border);
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

/* ─── Form controls ──────────────────────────────────────────────── */
.input {
  display: block;
  width: 100%;
  padding: .5rem .75rem;
  font-size: .9rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
  -webkit-appearance: none;
}
.input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200,160,48,.15);
}
.input-sm { font-size: .85rem; padding: .35rem .65rem; }
select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b6860' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .65rem center;
  padding-right: 2rem;
}
input[type="date"].input { cursor: pointer; }
textarea.input { resize: vertical; min-height: 80px; line-height: 1.5; }

/* ─── Login page ─────────────────────────────────────────────────── */
body.login-page {
  min-height: 100vh;
  background: #fff;
}
.login-shell { display:grid; grid-template-columns:minmax(420px,1.08fr) minmax(360px,.92fr); min-height:100vh; }
.login-brand-panel { display:grid; place-items:center; padding:4.5rem; background:var(--navy); }
.login-brand-logo { display:block; width:min(100%,620px); height:auto; }
.login-form-panel { display:grid; place-items:center; padding:2rem; }
.login-wrapper { width:100%; max-width:390px; }
.login-card { padding:0; border:0; box-shadow:none; }
.login-title { color:var(--navy); font-size:1.75rem; font-weight:700; letter-spacing:-.025em; }
.login-subtitle {
  font-size: .85rem; color: var(--text-light);
  margin-top: .3rem; margin-bottom: 1.75rem;
}
.login-form .field { margin-bottom: 1.25rem; }

/* ─── Alert ──────────────────────────────────────────────────────── */
.alert { padding: .65rem .9rem; border-radius: var(--radius-sm); font-size: .875rem; margin-bottom: 1rem; }
.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid #f5c6c2; }

/* ─── Modal (suppression) ────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 1.75rem 2rem;
  max-width: 400px;
  width: 90%;
}
.modal-title { font-size: 1rem; font-weight: 700; margin-bottom: .5rem; }
.modal-msg { font-size: .9rem; color: var(--text-light); margin-bottom: 1.5rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; }

/* ─── Modal historique ───────────────────────────────────────────── */
.modal-history-box {
  width: min(1280px, calc(100vw - 3rem));
  max-width: none;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1.75rem;
}
.modal-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-shrink: 0;
}
.modal-history-header .modal-title { margin-bottom: 0; }
.history-content {
  overflow-y: auto;
  flex: 1;
}
.history-loading { color: var(--text-light); font-size: .9rem; }
.history-empty { color: var(--text-light); font-size: .9rem; font-style: italic; }
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
  table-layout: fixed;
}
.history-table th {
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-light);
  padding: .4rem .6rem;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.history-table td {
  padding: .45rem .6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.history-table tbody tr:last-child td { border-bottom: none; }
.history-table tbody tr:hover td { background: #faf9f6; }
.history-action {
  display: inline-block;
  padding: .1rem .45rem;
  border-radius: 10px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.history-action--creation  { background: #f0fdf4; color: #15803d; }
.history-action--modification { background: #eff6ff; color: #1d4ed8; }
.history-action--suppression { background: #fef2f2; color: #b91c1c; }
.history-old { color: var(--text-light); text-decoration: line-through; font-size: .8rem; }
.history-arrow { color: var(--text-light); padding: 0 .3rem; }
.history-new { font-weight: 500; }
.history-cal { font-size: .82rem; line-height: 1.6; }
.history-cal strong { display: block; font-size: .85rem; color: var(--text); margin-bottom: .1rem; }

/* ─── Search page ────────────────────────────────────────────────── */
.search-section { margin-bottom: 2rem; }
.search-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.search-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--gold-light);
  color: var(--gold);
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  padding: .1rem .55rem;
}

/* ─── MAHAKA avancement couleurs ─────────────────────────────────── */
.badge-avancement--etude                { background: #fef2f2; color: #b91c1c; }
.badge-avancement--proposition-faite   { background: #fff7ed; color: #c2410c; }
.badge-avancement--souscription-en-cours { background: #eff6ff; color: #1d4ed8; }
.badge-avancement--souscription-terminee { background: #f0fdf4; color: #15803d; }

/* ─── MAHAKA thèmes badges ───────────────────────────────────────── */
.badge-theme {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 500;
  background: var(--gold-light);
  color: var(--gold-hover);
  white-space: nowrap;
  margin: .1rem .1rem .1rem 0;
}
.td-themes { line-height: 1.8; }

/* ─── Checkboxes thèmes (formulaire) ─────────────────────────────── */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  padding: .4rem 0;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .9rem;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}
.checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--gold);
  flex-shrink: 0;
  cursor: pointer;
}

/* ─── Inline date edit ───────────────────────────────────────────── */
.inline-edit-date {
  cursor: pointer;
  transition: background .1s;
}
.inline-edit-date:hover {
  background: var(--gold-light) !important;
  color: var(--gold-hover);
}
.inline-edit-date.date-popup-open,
.inline-edit-date.popup-open {
  background: var(--gold-light) !important;
}

.date-popup {
  position: fixed;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: .6rem .75rem;
  z-index: 600;
  display: flex;
  flex-direction: column;
  gap: .45rem;
  min-width: 190px;
}
.date-popup-save {
  background: none;
  border: none;
  color: var(--gold);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  padding: 0;
  font-family: var(--font);
  transition: color .15s;
}
.date-popup-save:hover { color: var(--gold-hover); }
.date-popup-clear {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: .78rem;
  cursor: pointer;
  text-align: left;
  padding: 0;
  font-family: var(--font);
  transition: color .15s;
}
.date-popup-clear:hover { color: var(--danger); }

/* ─── Tooltip commentaire ────────────────────────────────────────── */
.comment-tooltip {
  position: fixed;
  z-index: 700;
  background: var(--text);
  color: var(--card);
  font-size: .78rem;
  font-weight: 400;
  line-height: 1.5;
  padding: .45rem .65rem;
  border-radius: var(--radius-sm);
  max-width: 280px;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  pointer-events: none;
  box-shadow: 0 2px 10px rgba(0,0,0,.22);
}

/* ─── Toast confirmation ─────────────────────────────────────────── */
.inline-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: #15803d;
  color: #fff;
  padding: .45rem 1.25rem;
  border-radius: 20px;
  font-size: .82rem;
  font-weight: 500;
  box-shadow: 0 2px 12px rgba(0,0,0,.2);
  z-index: 1000;
  pointer-events: none;
  opacity: 1;
  transition: opacity .4s;
  white-space: nowrap;
}
.inline-toast.fade-out { opacity: 0; }

/* ─── Badges rôle utilisateur ────────────────────────────────────────────── */
.role-badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.role-badge--admin  { background: #fef3c7; color: #92400e; }
.role-badge--editor { background: #eff6ff; color: #1d4ed8; }
.role-badge--reader { background: #f3f4f6; color: #4b5563; }

/* ─── Badges statut utilisateur ─────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-badge--active   { background: #f0fdf4; color: #15803d; }
.status-badge--inactive { background: #fef2f2; color: #b91c1c; }


/* ─── Alert success ──────────────────────────────────────────────────────── */
.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }

/* ─── Historique action labels ───────────────────────────────────────────── */
.history-action--connexion-reussie        { background: #f0fdf4; color: #15803d; }
.history-action--connexion-echouee        { background: #fef2f2; color: #b91c1c; }
.history-action--creation                 { background: #f0fdf4; color: #15803d; }
.history-action--creation-utilisateur     { background: #eff6ff; color: #1d4ed8; }
.history-action--modification             { background: #eff6ff; color: #1d4ed8; }
.history-action--modification-role        { background: #fef3c7; color: #92400e; }
.history-action--modification-utilisateur { background: #eff6ff; color: #1d4ed8; }
.history-action--suppression              { background: #fef2f2; color: #b91c1c; }
.history-action--changement-statut        { background: #f5f3ff; color: #6d28d9; }
.history-action--ajout-commentaire        { background: #fff7ed; color: #c2410c; }
.history-action--activation-utilisateur         { background: #f0fdf4; color: #15803d; }
.history-action--desactivation-utilisateur      { background: #fef2f2; color: #b91c1c; }
.history-action--reinitialisation-mot-de-passe  { background: #fef3c7; color: #92400e; }

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .header-search { display: none; }
}
@media (max-width: 768px) {
  .main { padding: 1rem .75rem 2rem; }
  .mission-form .form-grid { grid-template-columns: 1fr; }
  .table { font-size: .8rem; }
  .table th, .table td { padding: .5rem .6rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .form-card { padding: 1.25rem; }
  .brand-dropdown { min-width: 190px; }
  .brand-logo { width:88px; }
  .login-shell { display:block; background:var(--navy); }
  .login-brand-panel { min-height:240px; padding:2rem 1.5rem; }
  .login-brand-logo { width:min(100%,460px); }
  .login-form-panel { min-height:calc(100vh - 240px); padding:2.25rem 1.5rem; border-radius:20px 20px 0 0; background:#fff; }
}

/* ─── Dashboard ──────────────────────────────────────────────────────────── */
.dash-matrix { border-collapse: collapse; width: 100%; min-width: max-content; }
.dash-matrix th, .dash-matrix td { border: 1px solid var(--border); }

/* Sticky first column — collaborateur name stays visible while scrolling */
.dash-user-name {
  font-weight: 500; white-space: nowrap; padding: .5rem .75rem;
  position: sticky; left: 0; z-index: 2;
  background: var(--card);
}
.dash-matrix thead th:first-child {
  position: sticky; left: 0; z-index: 3;
  background: var(--card);
}

.dash-cell {
  text-align: center;
  padding: .45rem .4rem;
  transition: filter .12s;
  vertical-align: middle;
  min-width: 80px;
}
.dash-cell:hover { filter: brightness(.93); }
.dash-cell-rate  { font-size: .82rem; font-weight: 600; line-height: 1.2; }
.dash-cell-sub   { font-size: .7rem; color: inherit; opacity: .75; margin-top: .1rem; }

/* Load status colours */
.dash-cell--absent      { background: #f3f4f6; color: #6b7280; }
.dash-cell--peu-charge  { background: #f0f9ff; color: #0369a1; }
.dash-cell--disponible  { background: #f0fdf4; color: #15803d; }
.dash-cell--normal      { background: #fef9c3; color: #854d0e; }
.dash-cell--tendu       { background: #fff7ed; color: #c2410c; }
.dash-cell--sature      { background: #fef2f2; color: #b91c1c; }
/* Absence totale avec charge affectée — état incohérent */
.dash-cell--alerte      { outline: 2px solid #f59e0b; outline-offset: -2px; }

/* Legend */
.dash-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.25rem;
  padding: .75rem 1rem;
  border-top: 1px solid var(--border);
  font-size: .75rem;
  color: var(--text-light);
}
.dash-legend-item { display: flex; align-items: center; gap: .4rem; }
.dash-legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,.08);
  flex-shrink: 0;
}

/* Alert priority badges */
.badge-priority { display: inline-block; padding: .15rem .55rem; border-radius: 20px; font-size: .72rem; font-weight: 600; white-space: nowrap; }
.badge-priority--critique  { background: #fef2f2; color: #b91c1c; }
.badge-priority--important { background: #fff7ed; color: #c2410c; }

/* Load pct block in admin form */
.load-pct-block + .load-pct-block { margin-top: .75rem; }

/* ─── Observatoire des avancements ──────────────────────────────── */
.obs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.obs-module {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .85rem 1rem;
  background: var(--surface);
}
.obs-module-title {
  font-weight: 600;
  font-size: .88rem;
  margin-bottom: .2rem;
  color: var(--text);
}
.obs-module-total {
  font-size: .75rem;
  color: var(--text-light);
  margin-bottom: .75rem;
}
.obs-states { display: flex; flex-direction: column; gap: .2rem; }
.obs-state {
  display: grid;
  grid-template-columns: 1fr 88px;
  grid-template-rows: auto 3px;
  align-items: center;
  column-gap: .5rem;
  row-gap: .18rem;
  padding: .28rem .4rem .18rem;
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background .12s;
}
.obs-state:hover { background: var(--surface-alt, #f9fafb); }
.obs-state-label {
  grid-column: 1; grid-row: 1;
  min-width: 0; overflow: hidden;
}
.obs-state-label .badge {
  display: inline-block; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: .7rem; padding: .1rem .4rem;
}
.obs-state-stats {
  grid-column: 2; grid-row: 1;
  display: flex; flex-direction: column; align-items: flex-end;
  white-space: nowrap;
}
.obs-state-pct   { font-size: .88rem; font-weight: 700; line-height: 1.15; }
.obs-state-count { font-size: .67rem; color: var(--text-light); line-height: 1.2; }
.obs-bar-wrap    { grid-column: 1 / -1; grid-row: 2; height: 3px; background: #e5e7eb; border-radius: 2px; }
.obs-bar         { display: block; height: 3px; border-radius: 2px; background: currentColor; opacity: .6; }
.obs-empty       { font-size: .8rem; color: var(--text-light); padding: .25rem 0; }
.obs-filter-row  { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .85rem; }

/* ─── Jalons des missions en cours ──────────────────────────────── */
.mission-milestones {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}
.mission-milestone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 32px;
  padding: 0 .45rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #475569;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1;
}
.mission-milestone--planned {
  border-color: #2563eb;
  background: #dbeafe;
  color: #1d4ed8;
}
.mission-milestone--completed {
  border-color: #16a34a;
  background: #dcfce7;
  color: #15803d;
}
.mission-milestones-empty {
  color: var(--text-light);
  font-size: .75rem;
  font-style: italic;
}
.appointment-milestone { cursor: context-menu; }
.appointment-context-menu {
  display: none;
  position: fixed;
  z-index: 1000;
  min-width: 180px;
  padding: .55rem .8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  box-shadow: 0 8px 24px rgba(9, 29, 48, .18);
  color: var(--text);
  font-size: .84rem;
  font-weight: 600;
  font-family: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.appointment-context-menu.is-open { display: block; }
.appointment-context-menu:hover { background: var(--bg); }
.appointment-context-menu:disabled { opacity: .6; cursor: wait; }

/* ── Alertes personnelles (DVP v2.5.3) ────────────────────────────────────── */

/* Icône alerte dans l'en-tête */
.alert-icon-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-light, #6b7280);
  border-radius: 50%;
  transition: background .15s, color .15s;
  flex-shrink: 0;
  text-decoration: none;
}
.alert-icon-btn:hover {
  background: var(--surface-hover, #f3f4f6);
  color: var(--text, #111827);
}
/* Cloche rouge quand des alertes sont échues */
.alert-icon-btn.has-alerts {
  color: var(--danger, #c0392b);
}
.alert-icon-btn.has-alerts:hover {
  color: var(--danger-hover, #a93226);
}

/* Badge numérique — anneau blanc pour contraste sur fond clair */
.alert-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--danger, #c0392b);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  line-height: 18px;
  border-radius: 999px;
  text-align: center;
  pointer-events: none;
  display: block;
  box-shadow: 0 0 0 2px var(--card, #fff);
}

/* Panneau alertes — boîte modale plus large */
.modal-alerts-box {
  max-width: 36rem;
  max-height: 80vh;
  overflow-y: auto;
}

/* Contenu du panneau */
.alerts-panel-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.alerts-section-title {
  font-size: .93rem;
  font-weight: 700;
  margin: 0 0 .6rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.alerts-section-due    { color: var(--danger, #dc2626); }
.alerts-section-future { color: var(--text-light, #6b7280); }

.alerts-count-badge {
  display: inline-block;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--danger, #dc2626);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  line-height: 18px;
  border-radius: 9px;
  text-align: center;
}

.alerts-list {
  list-style: none;
  margin: 0;
  padding: .75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

.alert-item {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: .5rem;
  padding: .75rem 1rem;
  background: var(--surface, #fff);
}
.alert-item-due    { border-left: 3px solid var(--danger, #dc2626); }
.alert-item-future { border-left: 3px solid var(--primary, #1a56db); }

.alert-item-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .35rem;
}

.alert-due-time {
  font-size: .83rem;
  font-weight: 600;
  color: var(--text, #111827);
}

.alert-type-badge {
  font-size: .72rem;
  padding: .1rem .45rem;
  border-radius: 3px;
  font-weight: 600;
  letter-spacing: .02em;
  margin-left: auto;
}
.alert-type-unique    { background: #fef3c7; color: #92400e; }
.alert-type-recurring { background: #dbeafe; color: #1e40af; }

.alert-description {
  margin: 0 0 .35rem;
  font-size: .87rem;
  color: var(--text, #111827);
}

.alert-meta {
  display: flex;
  align-items: center;
  gap: .3rem;
  font-size: .78rem;
  color: var(--text-light, #6b7280);
  margin-bottom: .5rem;
}
.alert-sep { color: var(--border, #d1d5db); }
.alert-module-label { font-weight: 600; }
.alert-mission-link { color: var(--primary, #1a56db); text-decoration: none; }
.alert-mission-link:hover { text-decoration: underline; }

.alert-actions {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
}

.alerts-empty {
  font-size: .85rem;
  color: var(--text-light, #6b7280);
  margin: 0;
  padding: .5rem 0;
}

/* Bouton Créer une alerte dans les formulaires */
.btn-alert-create {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}
