:root {
  --bleu: #0077B3;
  --bleu-fonce: #0056A7;
  --bleu-titre: #0088CC;
  --bleu-vif: #1863DC;
  --navy: #0B2545;
  --navy-2: #123564;
  --rouge: #E2003C;
  --fond: #F3F6F9;
  --carte: #FFFFFF;
  --bordure: #E4E9EF;
  --texte: #1D2733;
  --texte-mute: #64748B;
  --vert: #14804A;
  --vert-fond: #E5F6EC;
  --orange: #A15C00;
  --orange-fond: #FDF1DC;
  --rouge-fond: #FCE8ED;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 6px 20px -6px rgba(16,24,40,.10);
  --shadow-lg: 0 10px 15px -3px rgba(16,24,40,.08), 0 24px 48px -12px rgba(16,24,40,.18);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--texte);
  background: var(--fond);
  -webkit-font-smoothing: antialiased;
}

svg { display: block; }

/* ---------------------------------------------------------------------- */
/* Login                                                                   */
/* ---------------------------------------------------------------------- */

#login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}

.login-panel {
  position: relative;
  background:
    radial-gradient(1100px 700px at 15% -10%, rgba(24,99,220,.35), transparent 60%),
    radial-gradient(900px 600px at 100% 110%, rgba(0,136,204,.30), transparent 55%),
    linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 55%, var(--bleu-fonce) 100%);
  color: #fff;
  padding: 4.5rem 4rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.1rem;
  overflow: hidden;
}

.login-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.09) 1px, transparent 1px);
  background-size: 26px 26px;
  opacity: .5;
  pointer-events: none;
}

.login-panel-logo { height: 46px; width: auto; margin-bottom: .5rem; align-self: flex-start; }

.login-panel-wordmark {
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.01em;
}

.login-panel-eyebrow {
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .72rem;
  font-weight: 700;
  color: rgba(255,255,255,.65);
}

.login-panel h2 {
  font-size: clamp(1.6rem, 2.4vw, 2.1rem);
  line-height: 1.25;
  margin: 0;
  max-width: 20ch;
  font-weight: 700;
}

.login-panel-text {
  color: rgba(255,255,255,.78);
  max-width: 42ch;
  line-height: 1.6;
  margin: 0;
  font-size: .96rem;
}

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

.login-panel-points li {
  position: relative;
  padding-left: 1.5rem;
  color: rgba(255,255,255,.85);
  font-size: .9rem;
}

.login-panel-points li::before {
  content: "";
  position: absolute;
  left: 0; top: .45em;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--rouge);
}

.login-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--carte);
  padding: 2rem;
}

.login-card {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.login-card-logo { height: 52px; width: auto; margin: 0 auto; }

.login-card h1 { margin: 0; text-align: center; color: var(--navy); font-size: 1.5rem; }
.login-card .tagline { text-align: center; color: var(--texte-mute); font-size: .85rem; margin-top: -.6rem; }

.login-card .field { display: flex; flex-direction: column; gap: .35rem; }
.login-card .field label { font-size: .78rem; font-weight: 600; color: var(--texte-mute); }
.login-card input {
  padding: .7rem .85rem;
  border: 1.5px solid var(--bordure);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus {
  outline: none;
  border-color: var(--bleu);
  box-shadow: 0 0 0 3px rgba(0,119,179,.15);
}

#login-error { color: var(--rouge); font-size: .82rem; min-height: 1.1em; text-align: center; }

@media (max-width: 860px) {
  #login-screen { grid-template-columns: 1fr; }
  .login-panel { display: none; }
  .login-form-side { min-height: 100vh; }
}

/* ---------------------------------------------------------------------- */
/* App shell                                                               */
/* ---------------------------------------------------------------------- */

.app-shell {
  display: grid;
  grid-template-columns: 256px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 1.4rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .4rem .5rem 1.4rem;
  border-bottom: 1px solid rgba(255,255,255,.10);
  margin-bottom: 1rem;
}

.sidebar-brand .logo-icon { height: 34px; }

.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.sidebar-brand-text strong { font-size: .95rem; }
.sidebar-brand-text span { font-size: .74rem; color: rgba(255,255,255,.6); }

.side-nav {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .65rem .8rem;
  border: none;
  background: none;
  color: rgba(255,255,255,.72);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  position: relative;
  transition: background .15s, color .15s;
}

.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; }

.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }

.nav-item.active {
  background: rgba(24,99,220,.22);
  color: #fff;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: -1rem;
  top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--rouge);
}

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.10);
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: .7rem;
}

.user-chip { display: flex; align-items: center; gap: .65rem; }

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bleu-vif), var(--bleu));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700;
  flex-shrink: 0;
}

.user-chip-text { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.user-chip-text #user-nom {
  font-size: .85rem; font-weight: 600; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.user-chip-text .link-btn {
  background: none; border: none; padding: 0;
  color: rgba(255,255,255,.55);
  font-size: .74rem; text-align: left; cursor: pointer;
  text-decoration: underline;
}
.user-chip-text .link-btn:hover { color: #fff; }

.logout-btn {
  display: flex; align-items: center; gap: .5rem;
  background: rgba(226,0,60,.14);
  color: #ffd4dd;
  border: 1px solid rgba(226,0,60,.3);
  padding: .55rem .8rem;
  border-radius: var(--radius-sm);
  font-size: .82rem; font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.logout-btn svg { width: 16px; height: 16px; }
.logout-btn:hover { background: rgba(226,0,60,.26); }

.content-area {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: .8rem;
  }
  .sidebar-brand { border: none; margin: 0 .6rem 0 0; padding: 0; }
  .sidebar-brand-text { display: none; }
  .side-nav { flex-direction: row; flex: none; }
  .nav-item span { display: none; }
  .nav-item.active::before { display: none; }
  .sidebar-footer { flex-direction: row; margin-left: auto; border: none; padding: 0; }
  .user-chip-text { display: none; }
}

/* ---------------------------------------------------------------------- */
/* Bandeau RGPD                                                            */
/* ---------------------------------------------------------------------- */

.rgpd-note {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  background: var(--orange-fond);
  color: #6b4b06;
  border-bottom: 1px solid #f0ddb0;
  padding: .65rem 1.6rem;
  font-size: .78rem;
  line-height: 1.45;
}
.rgpd-note svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; color: var(--orange); }

/* ---------------------------------------------------------------------- */
/* Contenu principal                                                       */
/* ---------------------------------------------------------------------- */

main {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 1.8rem 1.6rem 4rem;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}

.page-head h2 { margin: 0 0 .2rem; font-size: 1.35rem; color: var(--navy); }
.page-head .page-sub { margin: 0; color: var(--texte-mute); font-size: .88rem; }

.card {
  background: var(--carte);
  border: 1px solid var(--bordure);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.3rem 1.4rem;
  margin-bottom: 1.2rem;
}

.card h2 { margin-top: 0; color: var(--navy); font-size: 1.05rem; }
.card h3 { margin: 0 0 .8rem; font-size: .92rem; color: var(--navy); }

.table-card { padding: 0; overflow: hidden; }
.table-card table { margin: 0; }
.table-card thead th { background: #FAFBFD; }

/* Dossiers regroupés par bénéficiaire (registre des orientations) */
.dossier-list { display: flex; flex-direction: column; gap: 14px; }

.dossier-card { padding: 0; overflow: hidden; }

.dossier-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.3rem;
  background: #FAFBFD;
  border-bottom: 1px solid var(--bordure);
  flex-wrap: wrap;
}

.dossier-id { display: flex; align-items: center; gap: .7rem; }
.dossier-id strong { color: var(--navy); font-size: .95rem; display: block; }
.dossier-id .note { margin: 0; }

.avatar-sm { width: 30px; height: 30px; font-size: .7rem; }

.dossier-table { margin: 0; }
.dossier-table th { font-size: .66rem; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .87rem;
}

th, td {
  text-align: left;
  padding: .75rem 1.1rem;
  border-bottom: 1px solid var(--bordure);
}

th {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--texte-mute);
  font-weight: 700;
}

tbody tr { transition: background .1s; }
tbody tr:hover td { background: #F8FAFD; }
tbody tr:last-child td { border-bottom: none; }

.btn {
  background: var(--bleu);
  color: #fff;
  border: none;
  padding: .62rem 1.05rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .87rem;
  font-weight: 600;
  transition: background .15s, transform .1s;
  box-shadow: 0 1px 2px rgba(0,86,167,.25);
}
.btn:hover { background: var(--bleu-fonce); }
.btn:active { transform: translateY(1px); }

.btn.secondary {
  background: #fff;
  color: var(--bleu);
  border: 1.5px solid var(--bordure);
  box-shadow: none;
}
.btn.secondary:hover { border-color: var(--bleu); background: #F5FAFD; }

.btn.danger { background: var(--rouge); box-shadow: 0 1px 2px rgba(226,0,60,.25); }
.btn.danger:hover { background: #b8002f; }

.btn.small { padding: .4rem .75rem; font-size: .78rem; }

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

.chip-row { display: flex; gap: .5rem; }
.chip {
  background: #F1F5FA;
  border: 1px solid var(--bordure);
  color: var(--bleu-fonce);
  padding: .4rem .85rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.chip:hover { background: #E4EFF8; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.form-grid.two-col { grid-template-columns: 1fr 1fr; align-items: start; }
.form-grid.full { grid-template-columns: 1fr; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: .78rem; font-weight: 600; color: var(--texte-mute); }

.field input, .field select, .field textarea {
  padding: .6rem .7rem;
  border: 1.5px solid var(--bordure);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--bleu);
  box-shadow: 0 0 0 3px rgba(0,119,179,.13);
}

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

fieldset {
  border: 1.5px solid var(--bordure);
  border-radius: var(--radius);
  margin: 0 0 14px;
  padding: 14px 16px;
}

fieldset legend {
  color: var(--bleu-fonce);
  font-weight: 700;
  padding: 0 6px;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 700;
}
.badge.oui { background: var(--vert-fond); color: var(--vert); }
.badge.non { background: #F0F2F5; color: #7A8699; }
.badge.alerte { background: var(--rouge-fond); color: var(--rouge); }

.statut-en_attente { color: var(--texte-mute); }
.statut-prise_contact { color: var(--bleu); font-weight: 600; }
.statut-admis { color: var(--vert); font-weight: 700; }
.statut-refuse { color: var(--rouge); }
.statut-bloque { color: var(--rouge); font-weight: 700; }

.statut-en_attente select, .statut-prise_contact select, .statut-admis select, .statut-refuse select, .statut-bloque select {
  border: 1.5px solid var(--bordure);
  border-radius: var(--radius-sm);
  padding: .3rem .5rem;
  font-size: .82rem;
  font-weight: inherit;
  color: inherit;
  background: #fff;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-tile {
  background: var(--carte);
  border: 1px solid var(--bordure);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem;
  display: flex;
  align-items: center;
  gap: .9rem;
}

.stat-icon {
  width: 42px; height: 42px;
  border-radius: 11px;
  background: #EAF3FB;
  color: var(--bleu);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 21px; height: 21px; }

.stat-tile.alerte .stat-icon { background: var(--rouge-fond); color: var(--rouge); }
.stat-tile .value { font-size: 1.5rem; font-weight: 800; color: var(--navy); line-height: 1.1; }
.stat-tile.alerte .value { color: var(--rouge); }
.stat-tile .label { font-size: .76rem; color: var(--texte-mute); margin-top: 2px; }

.bar-list { display: flex; flex-direction: column; gap: .65rem; }
.bar-row { display: grid; grid-template-columns: 9rem 1fr 2.2rem; align-items: center; gap: .7rem; }
.bar-label { font-size: .82rem; color: var(--texte); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; border-radius: 999px; background: #EEF2F7; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--bleu), var(--bleu-vif)); transition: width .4s ease; }
.bar-value { font-size: .82rem; font-weight: 700; color: var(--navy); text-align: right; }

.note { font-size: .8rem; color: var(--texte-mute); margin-top: 4px; }

/* ---------------------------------------------------------------------- */
/* Modales                                                                 */
/* ---------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11,37,69,0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 40px 16px;
  z-index: 200;
}

.modal {
  background: var(--carte);
  border-radius: 18px;
  padding: 1.7rem 1.8rem;
  width: 100%;
  max-width: 660px;
  box-shadow: var(--shadow-lg);
  animation: modal-in .18s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(.99); }
  to { opacity: 1; transform: none; }
}

.modal h2 { margin-top: 0; color: var(--navy); font-size: 1.15rem; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--bordure);
}

.hidden { display: none !important; }
