:root {
  --bg: #0a0f1c;
  --bg2: #101729;
  --card: #141c31;
  --line: #222c47;
  --text: #e8ecf6;
  --muted: #8a94b0;
  --primary: #6d5efc;
  --primary2: #22d3ee;
  --ok: #22c55e;
  --err: #f43f5e;
  --info: #38bdf8;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(109, 94, 252, .18), transparent 60%),
              radial-gradient(900px 500px at -10% 10%, rgba(34, 211, 238, .10), transparent 60%), var(--bg);
  color: var(--text); line-height: 1.55;
}
a { color: #a5b4fc; text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); line-height: 1.2; margin: .2em 0 .4em; letter-spacing: -.02em; }
h2, h3 { letter-spacing: -.01em; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }
main.wrap { flex: 1; padding-top: 28px; padding-bottom: 48px; }
.narrow { max-width: 720px; margin: 0 auto; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.inline { display: inline; margin: 0; }
.grad { background: linear-gradient(90deg, var(--primary), var(--primary2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Barre du haut */
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(10, 15, 28, .8); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand b { font-weight: 800; }
.nav { display: flex; align-items: center; gap: 16px; font-size: .95rem; }
.nav a { color: var(--text); }
.pill { background: linear-gradient(90deg, rgba(109,94,252,.25), rgba(34,211,238,.2)); border: 1px solid rgba(109,94,252,.5); padding: 4px 12px; border-radius: 999px; font-weight: 700; }
.pill:hover { text-decoration: none; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6); color: #fff; border: 0; border-radius: 10px;
  padding: 11px 20px; font: inherit; font-weight: 600; cursor: pointer; transition: transform .12s, box-shadow .12s, opacity .12s;
  box-shadow: 0 6px 20px rgba(109, 94, 252, .3);
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 8px 26px rgba(109, 94, 252, .45); }
.btn:active { transform: none; }
.btn-sm { padding: 6px 14px; font-size: .9rem; }
.btn-full { width: 100%; }
.btn-ghost { background: transparent; border: 1px solid var(--line); box-shadow: none; color: var(--text); }
.btn-ghost:hover { border-color: var(--primary); box-shadow: none; }
.btn-danger { background: var(--err); box-shadow: none; }
button.link { background: none; border: 0; color: #a5b4fc; font: inherit; cursor: pointer; padding: 0; }
button.link:hover { text-decoration: underline; }

/* Messages */
.flash { padding: 12px 16px; border-radius: 10px; margin: 0 0 18px; border: 1px solid; }
.flash ul { margin: 0; padding-left: 18px; }
.flash-success { background: rgba(34,197,94,.1); border-color: rgba(34,197,94,.4); color: #bbf7d0; }
.flash-error { background: rgba(244,63,94,.1); border-color: rgba(244,63,94,.4); color: #fecdd3; }
.flash-info { background: rgba(56,189,248,.1); border-color: rgba(56,189,248,.4); color: #bae6fd; }

/* Accueil */
.hero { text-align: center; padding: 40px 0 28px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 800; }
.lead { font-size: 1.08rem; color: #c3cae0; max-width: 620px; margin: 0 auto 1em; }
.cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.section-title { font-size: 1.2rem; margin: 32px 0 14px; display: flex; align-items: center; gap: 10px; }
.count { background: var(--primary); color: #fff; font-size: .8rem; border-radius: 999px; padding: 1px 9px; }
.empty { color: var(--muted); padding: 24px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; }
.stat-n { font-size: 1.8rem; font-weight: 800; }
.stat-l { color: var(--muted); font-size: .9rem; }

/* Cartes sondage */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.survey-card { color: var(--text); display: flex; flex-direction: column; gap: 6px; transition: border-color .15s, transform .15s; }
.survey-card:hover { text-decoration: none; border-color: var(--primary); transform: translateY(-2px); }
.survey-card h3 { margin: 4px 0 0; font-size: 1.08rem; }
.survey-card.done { opacity: .7; }
.card-top, .card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-foot { margin-top: auto; padding-top: 8px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 0; font-size: .93rem; }
.reward { background: rgba(34,197,94,.14); color: #86efac; font-weight: 700; font-size: .85rem; padding: 3px 10px; border-radius: 999px; }
.reward.big { font-size: 1rem; padding: 5px 14px; }
.tag { font-size: .82rem; font-weight: 600; color: #c7d2fe; background: rgba(109,94,252,.15); padding: 3px 10px; border-radius: 999px; }
.tag-ok { color: #86efac; background: rgba(34,197,94,.14); }

/* Formulaires */
.auth { max-width: 420px; margin: 30px auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: .93rem; }
input, textarea, select {
  font: inherit; color: var(--text); background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(109,94,252,.25); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--primary); }
.hint { font-weight: 400; font-size: .8rem; color: var(--muted); }

/* Page sondage */
.back { display: inline-block; margin-bottom: 14px; color: var(--muted); }
.survey-head { margin-bottom: 18px; }
.survey-head .lead, .done-box .lead { margin-left: 0; margin-right: 0; max-width: none; }
.survey-form { display: flex; flex-direction: column; gap: 16px; }
.progress { position: sticky; top: 60px; z-index: 5; height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), var(--primary2)); transition: width .25s; }
.question { border: 1px solid var(--line); background: var(--card); border-radius: var(--radius); padding: 18px; margin: 0; }
.question.answered { border-color: rgba(109,94,252,.55); }
.question legend { font-weight: 600; padding: 0; display: flex; gap: 10px; align-items: baseline; float: left; width: 100%; margin-bottom: 12px; }
.question legend + * { clear: both; }
.qnum { flex: none; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: rgba(109,94,252,.2); color: #c7d2fe; font-size: .85rem; font-weight: 700; margin-right: 8px; }
.question legend .qnum { margin-right: 0; }
.req { color: var(--err); }
.choices { display: flex; flex-direction: column; gap: 8px; clear: both; }
.choice { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; transition: border-color .12s, background .12s; }
.choice:hover { border-color: #3a4670; }
.choice:has(input:checked) { border-color: var(--primary); background: rgba(109,94,252,.12); }
.rating { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; clear: both; }
.rating label { position: relative; }
.rating input { position: absolute; opacity: 0; }
.rating span { display: grid; place-items: center; height: 48px; border: 1px solid var(--line); border-radius: 10px; font-weight: 700; cursor: pointer; transition: all .12s; }
.rating label:hover span { border-color: #3a4670; }
.rating input:checked + span { background: linear-gradient(135deg, var(--primary), #8b5cf6); border-color: transparent; color: #fff; }
.rating input:focus-visible + span { box-shadow: 0 0 0 3px rgba(109,94,252,.4); }
.rating-legend { grid-column: 1 / -1; display: flex; justify-content: space-between; }
.question textarea { clear: both; }

.done-box { text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px 20px; }
.done-box .btn { margin: 6px; }
.done-icon { width: 64px; height: 64px; margin: 0 auto 8px; border-radius: 50%; display: grid; place-items: center; font-size: 2rem; color: #fff; background: linear-gradient(135deg, var(--ok), #10b981); }

/* Résultats */
.result-q { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.result-q h3 { margin: 0; font-size: 1.02rem; display: flex; align-items: baseline; }
.result-q > p.small { margin: 4px 0 12px; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 34%) 1fr 92px; align-items: center; gap: 10px; font-size: .92rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 10px; background: var(--bg2); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary2)); border-radius: 6px; }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; }
.avg { margin: 0 0 10px; }
.texts { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow: auto; }

/* Admin */
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.admin-head > div { display: flex; gap: 8px; }
.table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: .93rem; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.table tr:last-child td { border-bottom: 0; }
.actions { white-space: nowrap; display: flex; gap: 14px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.span2 { grid-column: span 2; }
label.check { flex-direction: row !important; align-items: center; gap: 10px !important; }
.qedit { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.qedit-head { display: flex; gap: 8px; align-items: center; }
.qedit-head select { width: auto; }
.qedit-head .grow { flex: 1; }
.icon-btn { background: var(--bg2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; flex: none; }
.icon-btn:hover { border-color: var(--primary); }
.icon-btn.del:hover { border-color: var(--err); color: var(--err); }
.opt-row { display: flex; gap: 8px; }
.form-actions { position: sticky; bottom: 0; padding: 14px 0; background: linear-gradient(transparent, var(--bg) 40%); }
.danger-zone { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; }

/* Sondages partenaires (CPX) */
.partner-banner { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; color: var(--text);
  background: linear-gradient(120deg, rgba(109,94,252,.22), rgba(34,211,238,.12)); border-color: rgba(109,94,252,.45); }
.partner-banner:hover { text-decoration: none; border-color: var(--primary); }
.partner-banner p { margin: 2px 0 0; }
.cpx-frame { background: #fff; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); margin-top: 12px; }
.cpx-frame iframe { display: block; width: 100%; height: 2000px; border: 0; }
.cpx-history { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.cpx-history summary { cursor: pointer; font-weight: 600; }
.cpx-history ul { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 6px; }
.tag-err { color: #fda4af; background: rgba(244,63,94,.14); }

.footer { padding: 24px 20px 32px; font-size: .85rem; text-align: center; border-top: 1px solid var(--line); }

@media (max-width: 640px) {
  .hide-sm { display: none; }
  .nav { gap: 10px; font-size: .88rem; }
  .brand span { display: none; }
  .cols { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .bar-row { grid-template-columns: 1fr 70px; }
  .bar-row .bar { grid-column: 1 / -1; grid-row: 2; }
  .table { display: block; overflow-x: auto; }
}
