:root{
  --rouge:#d61f4e; --bleu:#1478c4; --vert:#5bb91d; --orange:#f26522; --jaune:#ffcc00;
  --ink:#1e2733; --ink-2:#5a6675; --line:#e6eaf0; --bg:#f4f6fa; --white:#fff;
  --ok:#2e9c47; --warn:#e08a00; --danger:#d61f4e;
  --radius:14px; --radius-sm:9px; --shadow:0 10px 30px rgba(20,40,80,.08);
  --shadow-sm:0 3px 10px rgba(20,40,80,.06);
  --font:'Segoe UI',system-ui,-apple-system,Roboto,Helvetica,Arial,sans-serif;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{font-family:var(--font);color:var(--ink);background:var(--bg);line-height:1.5;-webkit-font-smoothing:antialiased}
a{color:var(--bleu);text-decoration:none}
a:hover{text-decoration:underline}
h1,h2,h3{margin:0 0 .6rem}
img{max-width:100%}
.muted{color:var(--ink-2);font-style:normal;font-size:.86rem}

/* ---------- Auth ---------- */
.auth-bg{min-height:100vh;display:flex;align-items:center;justify-content:center;
  background:linear-gradient(135deg,#eef3fb,#f7f9fc);padding:28px}
.auth-card{background:var(--white);border-radius:var(--radius);box-shadow:var(--shadow);
  width:100%;max-width:400px;padding:34px 30px}
.auth-card--wide{max-width:720px}
.auth-logo{text-align:center;margin-bottom:12px}
.auth-logo img{height:78px;width:auto}
.auth-card h1{text-align:center;font-size:1.5rem}
.auth-sub{text-align:center;color:var(--ink-2);margin:0 0 20px}
.auth-foot{text-align:center;margin-top:18px;color:var(--ink-2)}

/* ---------- Forms ---------- */
label{display:block;margin-bottom:14px;font-weight:600;font-size:.9rem}
input,select{width:100%;margin-top:6px;padding:11px 12px;border:1px solid var(--line);
  border-radius:var(--radius-sm);font-size:.95rem;font-family:inherit;background:#fbfcfe;font-weight:400}
input:focus,select:focus{outline:none;border-color:var(--bleu);box-shadow:0 0 0 3px rgba(20,120,196,.12);background:#fff}
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 18px}
.form-grid .span-2,.form-grid .form-section,.form-grid .form-actions{grid-column:1/-1}
.form-section{margin:14px 0 4px;font-size:1rem;color:var(--bleu);border-bottom:2px solid var(--line);padding-bottom:6px}
.form-actions{display:flex;gap:10px;justify-content:flex-end;margin-top:8px}
.checkbox-inline{display:flex;align-items:center;gap:8px;font-weight:600}
.checkbox-inline input{width:auto;margin:0}
.file-label{display:inline-block;cursor:pointer;background:#eef4fb;color:var(--bleu);
  padding:8px 14px;border-radius:var(--radius-sm);font-size:.85rem}
.file-label input{display:none}

/* ---------- Buttons ---------- */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;cursor:pointer;
  border:none;border-radius:var(--radius-sm);padding:11px 18px;font-size:.92rem;font-weight:600;
  font-family:inherit;transition:.15s;text-decoration:none}
.btn:hover{text-decoration:none;transform:translateY(-1px)}
.btn-block{width:100%}
.btn-primary{background:var(--bleu);color:#fff}
.btn-primary:hover{background:#1069ac}
.btn-secondary{background:#eef4fb;color:var(--bleu)}
.btn-ghost{background:transparent;color:var(--ink-2);border:1px solid var(--line)}
.btn-ghost:hover{background:#f2f5f9}
.btn-ok{background:var(--ok);color:#fff}
.btn-warn{background:var(--warn);color:#fff}
.btn-danger{background:var(--danger);color:#fff}
.btn-sm{padding:7px 12px;font-size:.82rem}

/* ---------- Alerts ---------- */
.alert{border-radius:var(--radius-sm);padding:12px 15px;margin-bottom:16px;font-size:.9rem}
.alert ul{margin:0;padding-left:18px}
.alert-error{background:#fdecef;color:#a01235;border:1px solid #f6c4d0}
.alert-success{background:#e9f8ee;color:#1c7a34;border:1px solid #bce6c9}

/* ---------- Topbar ---------- */
.app{background:var(--bg)}
.topbar{display:flex;align-items:center;gap:24px;background:#fff;border-bottom:1px solid var(--line);
  padding:0 26px;height:64px;position:sticky;top:0;z-index:50}
.topbar-brand{display:flex;align-items:center;gap:10px;font-weight:800;font-size:1.15rem;letter-spacing:.5px}
.topbar-brand img{height:40px}
.topbar-nav{display:flex;gap:4px;margin-left:10px}
.topbar-nav a{padding:8px 14px;border-radius:var(--radius-sm);color:var(--ink-2);font-weight:600;font-size:.9rem}
.topbar-nav a:hover{background:#f2f5f9;text-decoration:none}
.topbar-nav a.active{background:#eef4fb;color:var(--bleu)}
.topbar-user{margin-left:auto;display:flex;align-items:center;gap:14px}
.user-chip{display:flex;flex-direction:column;line-height:1.15;text-align:right}
.user-chip em{font-style:normal;font-size:.75rem;color:var(--ink-2)}
.app-main{max-width:1180px;margin:26px auto;padding:0 26px 60px}
.page-title{font-size:1.55rem}
.page-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:18px;flex-wrap:wrap;gap:12px}

/* ---------- Stats ---------- */
.stat-grid{display:grid;grid-template-columns:repeat(5,1fr);gap:16px;margin-bottom:22px}
.stat-card{background:#fff;border-radius:var(--radius);box-shadow:var(--shadow-sm);padding:20px;
  display:flex;flex-direction:column;gap:4px;border-left:4px solid var(--bleu)}
.stat-card.stat-ok{border-left-color:var(--ok)}
.stat-card.stat-warn{border-left-color:var(--warn)}
.stat-num{font-size:2rem;font-weight:800;line-height:1}
.stat-lbl{color:var(--ink-2);font-size:.85rem;font-weight:600}

/* ---------- Panels & grid ---------- */
.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:20px;margin-bottom:20px}
.panel{background:#fff;border-radius:var(--radius);box-shadow:var(--shadow-sm);padding:22px}
.panel h2{font-size:1.05rem;margin-bottom:16px}

/* Bar chart (vertical) */
.bars{display:flex;align-items:flex-end;gap:10px;height:180px;padding-top:20px}
.bar-col{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;height:100%;position:relative}
.bar{width:60%;min-height:4px;background:linear-gradient(180deg,var(--bleu),#4aa3e0);border-radius:6px 6px 0 0;transition:height .4s}
.bar-x{font-size:.72rem;color:var(--ink-2);margin-top:6px}
.bar-v{position:absolute;top:-18px;font-size:.72rem;font-weight:700;color:var(--ink)}

/* Horizontal bars */
.hbars{display:flex;flex-direction:column;gap:9px;max-height:260px;overflow:auto}
.hbar-row{display:grid;grid-template-columns:130px 1fr 34px;align-items:center;gap:10px}
.hbar-lbl{font-size:.82rem;color:var(--ink-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.hbar-track{background:#eef1f6;border-radius:6px;height:12px;overflow:hidden}
.hbar-fill{height:100%;background:linear-gradient(90deg,var(--vert),#7cd23e);border-radius:6px}
.hbar-v{font-size:.8rem;font-weight:700;text-align:right}

/* Feed */
.feed{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:12px}
.feed li{display:flex;gap:10px;font-size:.88rem}
.feed-dot{width:9px;height:9px;border-radius:50%;background:var(--orange);margin-top:6px;flex:none}
.feed-time{display:block;color:var(--ink-2);font-size:.75rem}

/* ---------- Tables ---------- */
.table-wrap{overflow:auto;background:#fff;border-radius:var(--radius);box-shadow:var(--shadow-sm)}
.table{width:100%;border-collapse:collapse;font-size:.88rem}
.table-sm{font-size:.84rem}
.table th{text-align:left;padding:12px 14px;background:#f7f9fc;color:var(--ink-2);
  font-weight:700;border-bottom:1px solid var(--line);white-space:nowrap}
.table td{padding:11px 14px;border-bottom:1px solid var(--line);vertical-align:middle}
.table tr:hover td{background:#fafbfd}
.cell-user{display:flex;align-items:center;gap:10px}
.cell-user strong{display:block}
.cell-actions{white-space:nowrap;display:flex;gap:4px}
.avatar-sm{width:36px;height:36px;border-radius:50%;object-fit:cover;flex:none}
.avatar-lg{width:96px;height:96px;border-radius:50%;object-fit:cover}
.avatar-ph{display:inline-flex;align-items:center;justify-content:center;background:var(--bleu);color:#fff;font-weight:700}
.avatar-lg.avatar-ph{font-size:1.8rem}
.avatar-edit{display:flex;align-items:center;gap:16px;margin-bottom:14px}

.badge{padding:4px 10px;border-radius:20px;font-size:.75rem;font-weight:700}
.badge-ok{background:#e6f6ec;color:var(--ok)}
.badge-warn{background:#fdf1de;color:var(--warn)}
.tag{padding:3px 9px;border-radius:6px;font-size:.72rem;font-weight:700}
.tag-role-super_admin{background:#fdecef;color:var(--rouge)}
.tag-role-admin{background:#fff2e6;color:var(--orange)}
.tag-role-user{background:#eef4fb;color:var(--bleu)}

.icon-btn{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;
  border:1px solid var(--line);background:#fff;border-radius:8px;cursor:pointer;font-size:.95rem;color:var(--ink-2)}
.icon-btn:hover{background:#f2f5f9;text-decoration:none}
.icon-danger:hover{background:#fdecef;color:var(--danger);border-color:#f6c4d0}
.link{font-weight:600}

/* Filters & bulk */
.filters{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:16px;background:#fff;
  padding:14px;border-radius:var(--radius);box-shadow:var(--shadow-sm)}
.filters input,.filters select{margin:0;width:auto;flex:1;min-width:150px}
.filters .btn{flex:none}
.bulkbar{display:flex;align-items:center;gap:16px;background:#eef4fb;padding:10px 16px;
  border-radius:var(--radius-sm);margin-bottom:12px;flex-wrap:wrap}
.bulk-count{color:var(--ink-2);font-size:.85rem;font-weight:600}
.bulkbar-actions{margin-left:auto;display:flex;gap:8px}

/* ---------- Modales ---------- */
.modal{position:fixed;inset:0;background:rgba(22,34,54,.55);display:none;
  align-items:center;justify-content:center;z-index:100;padding:20px}
.modal.is-open{display:flex}
.modal-box{background:#fff;border-radius:var(--radius);box-shadow:var(--shadow);
  width:100%;max-width:440px;padding:30px;position:relative;text-align:center;animation:pop .18s ease}
.modal-lg{max-width:720px;text-align:left}
@keyframes pop{from{transform:scale(.95);opacity:0}to{transform:scale(1);opacity:1}}
.modal-box h2{font-size:1.3rem}
.modal-close{position:absolute;top:12px;right:16px;background:none;border:none;font-size:1.6rem;
  cursor:pointer;color:var(--ink-2);line-height:1}
.modal-icon{width:64px;height:64px;border-radius:50%;background:#e9f8ee;color:var(--ok);
  display:flex;align-items:center;justify-content:center;font-size:2rem;font-weight:800;margin:0 auto 14px}
.modal-icon-warn{background:#fdf1de;color:var(--warn)}
.modal-lg .form-actions{margin-top:10px}

/* ---------- Toast ---------- */
.toast{position:fixed;bottom:26px;left:50%;transform:translateX(-50%) translateY(20px);
  background:var(--ink);color:#fff;padding:13px 22px;border-radius:10px;font-size:.9rem;font-weight:600;
  box-shadow:var(--shadow);opacity:0;pointer-events:none;transition:.25s;z-index:200}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}
.toast.toast-error{background:var(--danger)}
.toast.toast-ok{background:var(--ok)}

.profile-meta{margin-top:18px;border-top:1px solid var(--line);padding-top:14px;font-size:.88rem}
.profile-meta p{margin:5px 0}

/* ---------- Responsive ---------- */
@media(max-width:900px){
  .stat-grid{grid-template-columns:repeat(2,1fr)}
  .grid-2{grid-template-columns:1fr}
  .form-grid{grid-template-columns:1fr}
  .topbar{flex-wrap:wrap;height:auto;padding:10px 16px;gap:12px}
  .topbar-nav{order:3;width:100%;overflow:auto}
  .topbar-user{margin-left:auto}
}

/* ---------- Éditeur de réponses ---------- */
.rep-row{display:flex;align-items:center;gap:10px;margin-bottom:8px}
.rep-row .rep-check{width:auto;margin:0;flex:none}
.rep-row input[type="text"]{margin:0}
.rep-row .rep-del{flex:none}
textarea:focus{outline:none;border-color:var(--bleu);box-shadow:0 0 0 3px rgba(20,120,196,.12);background:#fff}

/* ---------- Espace évaluation ---------- */
.comp-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:14px}
.comp-card{border:1px solid var(--line);border-radius:var(--radius-sm);padding:16px;background:#fbfcfe;display:flex;flex-direction:column;gap:8px}
.comp-card-head{display:flex;align-items:center;justify-content:space-between}
.comp-card-head strong{font-size:1.05rem}
.comp-title{font-size:.9rem;color:var(--ink);margin:0;min-height:2.4em}
.comp-card form{margin:0}

.progress-head{display:flex;align-items:center;gap:14px;margin-bottom:18px}
.progress-track{flex:1;height:10px;background:#eef1f6;border-radius:6px;overflow:hidden}
.progress-fill{height:100%;background:linear-gradient(90deg,var(--bleu),#4aa3e0);border-radius:6px;transition:width .4s}

.question-panel{max-width:720px;margin:0 auto}
.question-enonce{font-size:1.25rem;font-weight:600;line-height:1.4;margin-bottom:14px}
.choices{display:flex;flex-direction:column;gap:10px;margin:16px 0}
.choice{display:flex;align-items:center;gap:12px;border:1px solid var(--line);border-radius:var(--radius-sm);
  padding:13px 16px;cursor:pointer;background:#fff;font-weight:500;transition:.12s;margin:0}
.choice:hover{border-color:var(--bleu);background:#f5f9fd}
.choice input{width:auto;margin:0;flex:none}
.choice span{flex:1}

.result-hero{background:#fff;border-radius:var(--radius);box-shadow:var(--shadow-sm);padding:28px;text-align:center;margin-bottom:20px}
.result-hero h1{font-size:1.6rem;margin-bottom:4px}
.result-stats{display:flex;justify-content:center;gap:36px;flex-wrap:wrap;margin-top:18px}
.result-stats>div{display:flex;flex-direction:column}
.result-num{font-size:2rem;font-weight:800;line-height:1}
.result-stats span:last-child{color:var(--ink-2);font-size:.82rem}

.answer-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:10px}
.answer-item{display:flex;gap:12px;padding:12px 14px;border-radius:var(--radius-sm);background:#fbfcfe;border:1px solid var(--line)}
.answer-item p{margin:0 0 4px}
.answer-mark{flex:none;width:26px;height:26px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-weight:800;color:#fff}
.answer-item.is-ok .answer-mark{background:var(--ok)}
.answer-item.is-ko .answer-mark{background:var(--danger)}

/* ---------- Profil de compétences ---------- */
.svg-radar{width:100%;max-width:340px;display:block;margin:0 auto}
.svg-axis-lbl{font-size:11px;font-weight:700;fill:var(--ink-2);font-family:var(--font)}
.radar-legend{display:flex;flex-direction:column;gap:5px;margin-top:14px;font-size:.8rem;color:var(--ink-2)}
.radar-legend span{display:flex;align-items:center;gap:8px}
.radar-legend i{width:12px;height:12px;border-radius:3px;flex:none}

.svgbars{display:flex;flex-direction:column;gap:9px}
.svgbar-row{display:grid;grid-template-columns:1fr 2fr 42px;align-items:center;gap:12px}
.svgbar-lbl{font-size:.82rem;color:var(--ink);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.svgbar-track{background:#eef1f6;border-radius:6px;height:14px;overflow:hidden}
.svgbar-fill{height:100%;border-radius:6px;transition:width .4s}
.svgbar-v{font-size:.8rem;font-weight:700;text-align:right;color:var(--ink-2)}

.global-score{text-align:center;padding:10px 0}
.global-ring{--pct:0;width:150px;height:150px;border-radius:50%;margin:0 auto 12px;
  display:flex;align-items:center;justify-content:center;
  background:conic-gradient(var(--bleu) calc(var(--pct)*1%), #eef1f6 0);}
.global-ring span{width:112px;height:112px;border-radius:50%;background:#fff;
  display:flex;align-items:center;justify-content:center;font-size:1.9rem;font-weight:800;color:var(--ink)}

/* ============================================================
   RESPONSIVE — renforcement mobile-first / adaptatif
   ============================================================ */

/* Tablette */
@media(max-width:768px){
  .app-main{margin:18px auto;padding:0 16px 48px}
  .stat-grid{gap:12px}
  .panel{padding:18px}
  .filters{padding:12px}
  .result-stats{gap:22px}
  .page-title{font-size:1.35rem}
}

/* Mobile large */
@media(max-width:600px){
  body{font-size:15px}
  .auth-card{padding:26px 18px}
  .auth-card--wide{max-width:100%}
  .app-main{padding:0 12px 40px}

  /* Barre supérieure compacte */
  .topbar{padding:8px 12px;gap:8px}
  .topbar-brand span{display:none}          /* logo seul */
  .topbar-brand img{height:34px}
  .topbar-user{gap:8px}
  .user-chip{display:none}                   /* gain de place */
  .topbar-nav{gap:2px}
  .topbar-nav a{padding:7px 10px;font-size:.82rem;white-space:nowrap}

  /* Grilles en pile */
  .stat-grid{grid-template-columns:repeat(2,1fr)}
  .grid-2{grid-template-columns:1fr}
  .form-grid{grid-template-columns:1fr}
  .comp-grid{grid-template-columns:1fr 1fr}

  /* Filtres empilés, pleine largeur */
  .filters{flex-direction:column;align-items:stretch}
  .filters input,.filters select,.filters .btn{width:100%;flex:none}

  /* Barre d'actions groupées */
  .bulkbar{flex-direction:column;align-items:stretch;gap:10px}
  .bulkbar-actions{margin-left:0;justify-content:space-between}
  .bulkbar-actions .btn{flex:1}

  /* Boutons de page pleine largeur */
  .page-head{flex-direction:column;align-items:stretch}
  .page-head .btn{width:100%}
  .form-actions{flex-direction:column-reverse}
  .form-actions .btn{width:100%}

  /* Tables : conserver le défilement horizontal mais alléger */
  .table th,.table td{padding:9px 10px;font-size:.82rem}
  .cell-actions{gap:2px}
  .icon-btn{width:30px;height:30px}

  /* Graphiques */
  .svgbar-row{grid-template-columns:1fr 1.4fr 36px;gap:8px}
  .hbar-row{grid-template-columns:96px 1fr 30px}
  .result-stats{gap:16px}
  .result-num{font-size:1.6rem}
  .global-ring{width:130px;height:130px}
  .global-ring span{width:96px;height:96px;font-size:1.6rem}

  .question-enonce{font-size:1.1rem}
  .choice{padding:12px 14px}

  /* Cibles tactiles confortables */
  .btn{padding:12px 18px}
  input,select{padding:12px}
}

/* Mobile étroit */
@media(max-width:400px){
  .stat-grid{grid-template-columns:1fr}
  .comp-grid{grid-template-columns:1fr}
  .radar-legend{font-size:.74rem}
}
