:root{
  --navy:#1B3A63;
  --navy-dark:#132C4C;
  --green:#1E7A5C;
  --green-dark:#176249;
  --light-navy-bg:#EEF2F8;
  --light-green-bg:#E7F3EE;
  --amber-bg:#FDF3E3;
  --gray:#6B7280;
  --line:#E3E7EE;
  --danger:#B3261E;
  --radius:14px;
  --radius-sm:8px;
  --shadow:0 2px 10px rgba(27,58,99,0.06);
  --shadow-hover:0 8px 24px rgba(27,58,99,0.12);
}
*{box-sizing:border-box;}
body{
  margin:0;
  font-family:"Segoe UI", Calibri, Arial, sans-serif;
  background:#F4F6F9;
  color:#262626;
  -webkit-font-smoothing:antialiased;
}

/* ===== Topbar ===== */
.topbar{
  background:linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%);
  color:#fff;
  padding:16px 28px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  box-shadow:0 2px 12px rgba(19,44,76,0.25);
  position:sticky;
  top:0;
  z-index:20;
}
.topbar .brand{
  font-weight:700;
  font-size:19px;
  letter-spacing:0.3px;
}
.topbar .brand small{
  display:block;
  font-weight:400;
  font-size:10.5px;
  color:#A9C0E0;
  letter-spacing:1.5px;
}
.topbar nav{ display:flex; align-items:center; gap:6px; }
.topbar nav a{
  color:#E7EDF5;
  text-decoration:none;
  padding:8px 14px;
  border-radius:20px;
  font-size:13.5px;
  font-weight:500;
  transition:background 0.15s ease;
}
.topbar nav a:hover{ background:rgba(255,255,255,0.12); }
.topbar nav a.current{ background:rgba(255,255,255,0.16); font-weight:600; }

/* ===== Layout ===== */
.container{
  max-width:760px;
  margin:32px auto;
  padding:0 20px 60px;
}
.container.wide{ max-width:1180px; }

.card{
  background:#fff;
  border:1px solid var(--line);
  border-radius:var(--radius);
  padding:30px 32px;
  box-shadow:var(--shadow);
}

h1{
  color:var(--navy);
  font-size:26px;
  font-weight:700;
  margin:0 0 6px;
  letter-spacing:-0.3px;
}
h2.section-title{
  color:var(--green);
  font-size:17px;
  font-weight:700;
  border-bottom:2px solid var(--light-green-bg);
  padding-bottom:10px;
  margin:30px 0 18px;
}
h3.sub-title{
  color:var(--navy);
  font-size:14.5px;
  font-weight:700;
  margin:22px 0 10px;
}
p.lead{ color:var(--gray); margin-top:0; font-size:14.5px; }

.info-box{
  background:var(--light-green-bg);
  border:1px solid #BFE0D2;
  border-radius:var(--radius-sm);
  padding:14px 18px;
  font-size:13.5px;
  color:#25523F;
  margin:18px 0;
  line-height:1.55;
}
.banner{
  background:var(--amber-bg);
  border:1px solid #EDD09B;
  border-radius:var(--radius-sm);
  padding:11px 16px;
  font-size:13px;
  font-weight:600;
  color:#7A5A10;
  margin:16px 0;
}

label{
  display:block;
  font-weight:600;
  color:var(--navy);
  font-size:13.5px;
  margin:16px 0 6px;
}
label .required{ color:var(--danger); }
label .hint{ font-weight:400; color:var(--gray); font-size:12px; display:block; }

input[type=text], input[type=number], input[type=date], input[type=email],
select, textarea{
  width:100%;
  padding:10px 13px;
  border:1.5px solid var(--line);
  border-radius:var(--radius-sm);
  font-size:14px;
  font-family:inherit;
  background:#fff;
  transition:border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea{ min-height:80px; resize:vertical; }
input:focus, select:focus, textarea:focus{
  outline:none;
  border-color:var(--green);
  box-shadow:0 0 0 3px rgba(30,122,92,0.12);
}

.checkbox-grid, .radio-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(220px,1fr));
  gap:8px 16px;
  margin-top:8px;
}
.checkbox-grid label, .radio-grid label{
  display:flex;
  align-items:center;
  gap:8px;
  font-weight:400;
  color:#262626;
  margin:0;
  font-size:13.5px;
}
.checkbox-grid input, .radio-grid input{ width:auto; accent-color:var(--green); }

.score-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:11px 0;
  border-bottom:1px solid var(--line);
}
.score-row:last-child{ border-bottom:none; }
.score-row label{ margin:0; flex:1; font-size:14px; }
.score-row input{ width:90px; text-align:center; }

.btn-row{
  display:flex;
  justify-content:space-between;
  margin-top:30px;
}
button{
  font-family:inherit;
  font-size:14px;
  font-weight:600;
  padding:11px 22px;
  border-radius:var(--radius-sm);
  border:none;
  cursor:pointer;
  transition:background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}
button:active{ transform:translateY(1px); }
button:disabled{ opacity:0.55; cursor:not-allowed; }
.btn-primary{ background:var(--green); color:#fff; box-shadow:0 2px 8px rgba(30,122,92,0.25); }
.btn-primary:hover:not(:disabled){ background:var(--green-dark); }
.btn-secondary{ background:#fff; color:var(--navy); border:1.5px solid #D5DDEA; }
.btn-secondary:hover{ background:var(--light-navy-bg); }
.btn-danger{ background:#fff; color:var(--danger); border:1.5px solid #F0C4C0; font-size:12px; padding:6px 12px; }
.btn-danger:hover{ background:#FDF0EF; }
.btn-ghost{ background:transparent; color:var(--gray); border:none; font-size:12.5px; padding:6px 10px; }
.btn-ghost:hover{ color:var(--navy); }

.step{ display:none; }
.step.active{ display:block; animation:fadeIn 0.25s ease; }
@keyframes fadeIn{ from{ opacity:0; transform:translateY(4px);} to{ opacity:1; transform:translateY(0);} }

.progress{
  display:flex;
  gap:6px;
  margin-bottom:26px;
}
.progress .dot{
  flex:1;
  height:5px;
  border-radius:3px;
  background:var(--line);
  transition:background 0.2s ease;
}
.progress .dot.done{ background:var(--green); }
.progress .dot.current{ background:var(--navy); }

/* ===== Accueil : sélection par cartes ===== */
.home-section{ margin-top:8px; }
.home-section-title{
  font-size:13px;
  font-weight:700;
  color:var(--navy);
  text-transform:uppercase;
  letter-spacing:0.5px;
  margin:26px 0 12px;
  display:flex;
  align-items:center;
  gap:8px;
}
.home-section-title .step-num{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:20px;height:20px;
  border-radius:50%;
  background:var(--navy);
  color:#fff;
  font-size:11px;
}

.option-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(150px,1fr));
  gap:12px;
}
.option-card{
  border:1.5px solid var(--line);
  border-radius:var(--radius-sm);
  padding:16px 14px;
  text-align:center;
  cursor:pointer;
  background:#fff;
  transition:all 0.15s ease;
  user-select:none;
}
.option-card:hover{ border-color:var(--green); box-shadow:var(--shadow-hover); transform:translateY(-1px); }
.option-card.selected{
  border-color:var(--green);
  background:var(--light-green-bg);
  box-shadow:0 0 0 3px rgba(30,122,92,0.12);
}
.option-card .avatar{
  width:40px;height:40px;
  border-radius:50%;
  background:var(--navy);
  color:#fff;
  display:flex;align-items:center;justify-content:center;
  font-weight:700;
  font-size:15px;
  margin:0 auto 8px;
}
.option-card.selected .avatar{ background:var(--green); }
.option-card .opt-name{ font-weight:600; font-size:13.5px; color:#262626; word-break:break-word; }
.option-card .opt-flag{ font-size:24px; margin-bottom:6px; }

.option-card.add-new{
  border-style:dashed;
  color:var(--gray);
  display:flex;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  gap:6px;
}
.option-card.add-new:hover{ color:var(--green); border-color:var(--green); }
.option-card.add-new .plus{ font-size:22px; line-height:1; }

.inline-add{
  display:none;
  gap:8px;
  margin-top:10px;
}
.inline-add.visible{ display:flex; }
.inline-add input{ flex:1; }
.inline-add button{ white-space:nowrap; padding:10px 16px; }

.selection-summary{
  background:var(--light-navy-bg);
  border-radius:var(--radius-sm);
  padding:14px 18px;
  margin-top:24px;
  font-size:13.5px;
  color:var(--navy);
  display:flex;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:10px;
}
.selection-summary strong{ font-weight:700; }
.selection-summary .find-link{
  font-size:12.5px;
  color:var(--green);
  text-decoration:none;
  font-weight:600;
}
.selection-summary .find-link:hover{ text-decoration:underline; }

/* ===== Tabs (admin) ===== */
.tabs{ display:flex; gap:6px; margin-bottom:20px; border-bottom:1px solid var(--line); }
.tab-btn{
  background:none; border:none; box-shadow:none;
  padding:10px 18px;
  font-size:14px; font-weight:600; color:var(--gray);
  border-bottom:2.5px solid transparent;
  border-radius:0;
  cursor:pointer;
}
.tab-btn:hover{ color:var(--navy); }
.tab-btn.active{ color:var(--green); border-bottom-color:var(--green); }
.tab-panel{ display:none; }
.tab-panel.active{ display:block; animation:fadeIn 0.2s ease; }

/* ===== Tables ===== */
table.data-table{
  width:100%;
  border-collapse:collapse;
  font-size:13px;
  background:#fff;
}
table.data-table th{
  background:var(--navy);
  color:#fff;
  text-align:left;
  padding:10px 12px;
  position:sticky;
  top:0;
  font-weight:600;
}
table.data-table td{
  padding:9px 12px;
  border-bottom:1px solid var(--line);
  vertical-align:middle;
}
table.data-table tr:hover td{ background:var(--light-navy-bg); }
table.data-table select.status-inline{
  width:auto;
  padding:5px 8px;
  font-size:12px;
  border-radius:6px;
}

.badge{
  display:inline-block;
  padding:3px 10px;
  border-radius:12px;
  font-size:11px;
  font-weight:700;
}
.badge.green{ background:var(--light-green-bg); color:var(--green); }
.badge.amber{ background:var(--amber-bg); color:#7A5A10; }
.badge.navy{ background:var(--light-navy-bg); color:var(--navy); }
.badge.red{ background:#FBE9E7; color:var(--danger); }
.badge.gray{ background:#EEF0F3; color:var(--gray); }

.stats-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(160px,1fr));
  gap:14px;
  margin-bottom:26px;
}
.stat-card{
  background:linear-gradient(135deg,#fff, #FAFBFD);
  border:1px solid var(--line);
  border-radius:var(--radius-sm);
  padding:18px;
  text-align:center;
}
.stat-card .num{ font-size:27px; font-weight:800; color:var(--navy); }
.stat-card .lbl{ font-size:11.5px; color:var(--gray); margin-top:4px; }

.toolbar{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
  margin-bottom:18px;
}
.toolbar select, .toolbar input{ width:auto; padding:9px 11px; font-size:13px; }

.table-wrap{ overflow-x:auto; border:1px solid var(--line); border-radius:var(--radius-sm); }

.center{ text-align:center; }
.muted{ color:var(--gray); font-size:13px; }

/* ===== Modal détail ===== */
.overlay{
  display:none;
  position:fixed; inset:0;
  background:rgba(19,44,76,0.5);
  z-index:50;
  padding:30px 16px;
  overflow-y:auto;
}
.overlay.visible{ display:block; }
.modal{
  background:#fff;
  max-width:760px;
  margin:0 auto;
  border-radius:var(--radius);
  padding:0;
  box-shadow:0 20px 60px rgba(0,0,0,0.25);
  overflow:hidden;
}
.modal-header{
  background:linear-gradient(135deg, var(--navy), var(--navy-dark));
  color:#fff;
  padding:22px 28px;
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
}
.modal-header h2{ margin:0; font-size:19px; }
.modal-header .sub{ font-size:12.5px; color:#B9CBE4; margin-top:4px; }
.modal-header button{ background:rgba(255,255,255,0.15); color:#fff; padding:7px 14px; font-size:12px; }
.modal-header button:hover{ background:rgba(255,255,255,0.25); }
.modal-body{ padding:24px 28px; max-height:70vh; overflow-y:auto; }

.detail-status-bar{
  display:flex; align-items:center; gap:12px;
  background:var(--light-green-bg);
  border-radius:var(--radius-sm);
  padding:14px 18px;
  margin-bottom:22px;
  flex-wrap:wrap;
}
.detail-status-bar label{ margin:0; white-space:nowrap; }
.detail-status-bar select{ max-width:220px; }
.detail-status-bar .save-msg{ font-size:12px; color:var(--green); font-weight:600; opacity:0; transition:opacity 0.2s; }
.detail-status-bar .save-msg.show{ opacity:1; }

.detail-section{ margin-bottom:22px; }
.detail-section-title{
  font-size:12.5px;
  font-weight:700;
  color:var(--green);
  text-transform:uppercase;
  letter-spacing:0.4px;
  border-bottom:1.5px solid var(--light-green-bg);
  padding-bottom:7px;
  margin-bottom:10px;
}
.detail-grid{
  display:grid;
  grid-template-columns:200px 1fr;
  gap:6px 14px;
  font-size:13.5px;
}
.detail-grid .k{ color:var(--gray); font-weight:600; }
.detail-grid .v{ color:#262626; }

.trash-row td{ opacity:0.75; }

/* ===== Éditeur du questionnaire ===== */
.editor-field-row{
  display:flex;
  align-items:center;
  gap:14px;
  padding:11px 4px;
  border-bottom:1px solid var(--line);
}
.editor-field-row:last-child{ border-bottom:none; }
.editor-field-reorder{ display:flex; flex-direction:column; gap:2px; }
.editor-field-reorder button{ padding:2px 8px; font-size:10px; line-height:1; box-shadow:none; }
.editor-field-main{ flex:1; min-width:0; }
.editor-field-label{ font-weight:600; font-size:14px; color:#262626; }
.editor-field-meta{ margin-top:5px; display:flex; gap:6px; flex-wrap:wrap; }
.editor-field-actions{ display:flex; gap:8px; flex-shrink:0; }

#fieldEditorOverlay .modal{ overflow:visible; }
#fieldEditorOverlay .modal-body{ max-height:80vh; }
.hint{ font-weight:400; color:var(--gray); font-size:12px; }

@media (max-width:600px){
  .detail-grid{ grid-template-columns:1fr; }
  .detail-grid .k{ margin-top:6px; }
  .container{ margin:16px auto; padding:0 12px 40px; }
  .card{ padding:20px 18px; }
}
