/* ==========================================================================
   Inscriptions – feuille de style unique (back-office, pages publiques, emails exclus)
   Mobile d'abord, aucune dépendance externe : fonctionne aussi hors-ligne.
   ========================================================================== */

:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --ink: #192744;
  --brand-navy: #192744;
  --brand-blue: #0f5884;
  --brand-orange: #f07e04;
  --ink-2: #52525b;
  --ink-3: #8a8a93;
  --line: #e4e2dc;
  --accent: #0f5884;
  --accent-ink: #ffffff;
  --ok: #157f3c;
  --ok-bg: #e5f5ea;
  --warn: #9a5b00;
  --warn-bg: #fff3dc;
  --danger: #c0262d;
  --danger-bg: #fde8e8;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(24, 24, 27, .05), 0 6px 24px rgba(24, 24, 27, .06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
small, .muted { color: var(--ink-2); }
.tiny { font-size: .82rem; color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Mise en page back-office ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 16px; height: 58px;
}
.brand { font-weight: 700; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 10px; }
.brand-dot { width: 26px; height: 26px; border-radius: 8px; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 14px; }
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav a, .nav button {
  color: var(--ink-2); text-decoration: none; font: inherit; font-size: .93rem;
  padding: 8px 12px; border-radius: 8px; background: none; border: 0; cursor: pointer;
}
.nav a:hover, .nav button:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { color: var(--ink); font-weight: 600; background: var(--surface-2); }
.nav-toggle { display: none; margin-left: auto; }

@media (max-width: 760px) {
  .nav-toggle { display: inline-flex; }
  .nav {
    display: none; position: absolute; top: 58px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 16px 16px;
  }
  .nav.open { display: flex; }
  .nav a, .nav button { padding: 13px 10px; text-align: left; font-size: 1rem; }
}

.impersonating {
  background: var(--warn-bg); color: var(--warn); font-size: .9rem;
  padding: 8px 16px; display: flex; gap: 12px; justify-content: center; align-items: center; flex-wrap: wrap;
}
.impersonating button { font: inherit; font-weight: 600; color: var(--warn); background: none; border: 0; text-decoration: underline; cursor: pointer; }

.container { max-width: 1080px; margin: 0 auto; padding: 24px 16px 80px; }
.container.narrow { max-width: 680px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); text-decoration: none; font-size: .92rem; margin-bottom: 10px; }
.back:hover { color: var(--ink); }

/* ---------- Cartes ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-title h2 { margin: 0; }
.stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: .95rem; line-height: 1;
  min-height: 44px; padding: 0 18px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: #cfccc4; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.06); border-color: var(--accent); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); border-color: #f3c2c2; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .88rem; border-radius: 9px; }
.btn-lg { min-height: 54px; padding: 0 24px; font-size: 1.05rem; border-radius: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.icon { width: 18px; height: 18px; flex: none; }

/* ---------- Formulaires ---------- */
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
label, .label { display: block; font-weight: 600; font-size: .93rem; margin-bottom: 6px; }
.req { color: var(--danger); margin-left: 2px; }
.hint { font-size: .84rem; color: var(--ink-3); margin-top: 6px; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number],
input[type=datetime-local], input[type=search], input[type=url], select, textarea {
  width: 100%; font: inherit; font-size: 16px; /* évite le zoom iOS */
  color: var(--ink); background: var(--surface);
  border: 1px solid #d6d3cb; border-radius: 11px;
  min-height: 48px; padding: 11px 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
  -webkit-appearance: none; appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2352525b' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
input[type=color] { width: 56px; height: 44px; padding: 3px; border: 1px solid #d6d3cb; border-radius: 10px; background: var(--surface); cursor: pointer; }
input[type=file] { font: inherit; font-size: .92rem; max-width: 100%; }
.is-invalid { border-color: var(--danger) !important; }
.error { color: var(--danger); font-size: .86rem; margin-top: 6px; }
.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 400; cursor: pointer; margin: 0; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.check span { font-size: .95rem; }
.row-2 { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .row-2 { grid-template-columns: 1fr; } }
.hp { position: absolute !important; left: -9999px !important; height: 0; overflow: hidden; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 700; font-size: 1.05rem; margin-bottom: 14px; padding: 0; }

/* ---------- Alertes, badges ---------- */
.alert { border-radius: 12px; padding: 12px 16px; margin-bottom: 18px; font-size: .95rem; border: 1px solid transparent; }
.alert-success { background: var(--ok-bg); color: var(--ok); border-color: #bfe6cc; }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: #f5c6c6; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: #f4dca8; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-muted { background: var(--surface-2); color: var(--ink-3); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }

/* ---------- Liste d'événements ---------- */
.event-list { display: grid; gap: 12px; }
.event-item {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 16px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; text-decoration: none; color: inherit; box-shadow: var(--shadow);
  transition: border-color .15s ease, transform .1s ease;
}
.event-item:hover { border-color: #cfccc4; }
.event-item:active { transform: scale(.995); }
.datebox { border-radius: 12px; background: var(--surface-2); text-align: center; padding: 8px 0; line-height: 1.1; border-top: 4px solid var(--c, var(--accent)); }
.datebox b { display: block; font-size: 1.45rem; }
.datebox span { font-size: .75rem; text-transform: uppercase; color: var(--ink-2); letter-spacing: .04em; }
.event-item h3 { margin: 0 0 4px; font-size: 1.04rem; }
.event-meta { display: flex; gap: 6px 14px; flex-wrap: wrap; font-size: .87rem; color: var(--ink-2); }
.event-count { text-align: right; font-size: .87rem; color: var(--ink-2); }
.event-count b { display: block; font-size: 1.25rem; color: var(--ink); }
@media (max-width: 560px) {
  .event-item { grid-template-columns: 54px 1fr; }
  .event-count { grid-column: 2; text-align: left; display: flex; gap: 6px; align-items: baseline; }
  .event-count b { display: inline; font-size: 1rem; }
}
.section-label { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 28px 0 10px; }
.empty { text-align: center; padding: 48px 20px; color: var(--ink-2); }
.empty h2 { color: var(--ink); }

/* ---------- Statistiques ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 1.7rem; letter-spacing: -.02em; line-height: 1.1; }
.stat span { font-size: .85rem; color: var(--ink-2); }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* ---------- Lien de partage ---------- */
.share { display: flex; gap: 8px; align-items: stretch; }
.share input { font-size: .92rem; min-height: 44px; background: var(--surface-2); }
@media (max-width: 560px) { .share { flex-direction: column; } }

/* ---------- Tableau / liste des inscrits ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar form { flex: 1; min-width: 200px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; overflow-x: auto; }
.tabs a { padding: 8px 12px; border-radius: 9px; text-decoration: none; color: var(--ink-2); font-size: .88rem; font-weight: 600; white-space: nowrap; }
.tabs a.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.table-wrap { overflow-x: auto; margin: 0 -20px; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; padding: 10px 20px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td .sub { display: block; font-size: .84rem; color: var(--ink-3); }
.attendee-list { list-style: none; margin: 0 -20px; padding: 0; }
.attendee-list li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line); }
.attendee-list .who { flex: 1; min-width: 0; }
.attendee-list .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attendee-list .who span { display: block; font-size: .85rem; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot-in { width: 10px; height: 10px; border-radius: 50%; background: var(--line); flex: none; }
.dot-in.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }

details.disclosure { border: 1px dashed #d6d3cb; border-radius: 12px; padding: 0 16px; background: var(--surface); }
details.disclosure[open] { padding-bottom: 16px; border-style: solid; }
details.disclosure summary { cursor: pointer; font-weight: 600; padding: 14px 0; list-style: none; display: flex; align-items: center; gap: 8px; }
details.disclosure summary::-webkit-details-marker { display: none; }
details.disclosure summary::before { content: "+"; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--surface-2); font-weight: 700; }
details.disclosure[open] summary::before { content: "–"; }

/* ---------- Constructeur de champs ---------- */
.fb-item { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--surface-2); margin-bottom: 10px; }
.fb-row { display: grid; grid-template-columns: 1fr 150px; gap: 10px; }
.fb-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 10px; flex-wrap: wrap; }
.fb-item textarea { min-height: 80px; margin-top: 10px; }
@media (max-width: 520px) { .fb-row { grid-template-columns: 1fr; } }

/* ---------- Écran de connexion ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 400px; padding: 28px; }

/* ---------- Pages publiques (inscription) ---------- */
.public { min-height: 100vh; min-height: 100dvh; padding-bottom: 48px; }
.hero { background: var(--accent); color: var(--accent-ink); position: relative; overflow: hidden; }
.hero-cover { aspect-ratio: 16 / 7; max-height: 360px; width: 100%; object-fit: cover; }
.hero-band { height: 120px; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 65%, #000)); }
.public-main { max-width: 640px; margin: -56px auto 0; padding: 0 16px; position: relative; }
.public-card { background: var(--surface); border-radius: 20px; box-shadow: 0 10px 40px rgba(24,24,27,.10); padding: 28px 24px; }
@media (min-width: 600px) { .public-card { padding: 36px 40px; } }
.org-logo { height: 44px; width: auto; max-width: 180px; object-fit: contain; margin-bottom: 18px; }
.org-name { font-size: .85rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.public-card h1 { font-size: 1.75rem; margin-bottom: 14px; }
.facts { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 10px; }
.facts li { display: flex; gap: 12px; align-items: flex-start; color: var(--ink-2); }
.facts svg { width: 20px; height: 20px; flex: none; margin-top: 2px; color: var(--accent); }
.description { white-space: pre-line; color: var(--ink-2); margin-bottom: 8px; }
.divider { height: 1px; background: var(--line); margin: 26px 0; border: 0; }
.public-footer { text-align: center; font-size: .8rem; color: var(--ink-3); margin-top: 24px; padding: 0 16px; }
.public-footer a { color: inherit; }
.preview-banner { background: var(--ink); color: #fff; text-align: center; font-size: .88rem; padding: 8px 16px; }
.success-mark { width: 64px; height: 64px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); display: grid; place-items: center; margin-bottom: 18px; }
.success-mark svg { width: 34px; height: 34px; }
.places { display: inline-block; font-size: .85rem; font-weight: 600; color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); padding: 4px 10px; border-radius: 99px; margin-bottom: 14px; }

/* ---------- Pages d'erreur ---------- */
.error-page { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: 24px; }
.error-page b { font-size: 4rem; letter-spacing: -.04em; color: var(--ink-3); display: block; }

/* ---------- Marque Quadrigital Events ---------- */
.brand-logo { height: 34px; width: auto; }
.auth-logo { height: auto; width: 210px; margin: 0 0 26px; }
.powered { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 18px 0 8px; font-size: .75rem; color: var(--ink-3); }
.powered img { height: 26px; width: auto; opacity: .9; }
.powered a { display: inline-flex; }
.powered a:hover img { opacity: 1; }

/* ---------- Tableaux de bord ---------- */
.grid > .card + .card, .grid-dash > .card + .card { margin-top: 0; }
.grid-dash { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.kpis { margin-bottom: 16px; }
.kpis .stat { display: flex; flex-direction: column; gap: 2px; }
.kpis .stat > span { order: -1; font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.kpis .stat small { font-size: .78rem; margin-top: 2px; }
.trend { color: var(--ink-2); font-weight: 600; }
.trend.up { color: var(--ok); }
.trend.down { color: var(--danger); }

.live-card {
  display: grid; grid-template-columns: 1fr auto auto; gap: 18px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--accent);
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.live-card h2 { margin: 4px 0 2px; }
.live-card p { margin: 0; color: var(--ink-2); font-size: .9rem; }
.live-tag { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--brand-orange); }
.live-count { min-width: 140px; }
.live-count b { font-size: 1.6rem; display: block; line-height: 1.1; }
.live-count span { font-size: .85rem; color: var(--ink-2); }
@media (max-width: 720px) { .live-card { grid-template-columns: 1fr; gap: 12px; } }

.mini-event { display: flex; gap: 14px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.mini-event:first-of-type { border-top: 0; padding-top: 0; }
.mini-event .datebox { width: 50px; flex: none; padding: 6px 0; }
.mini-event .datebox b { font-size: 1.15rem; }
.mini-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mini-main b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-main .progress { margin-top: 6px; height: 5px; }
.mini-event:hover b { color: var(--accent); }

/* Histogramme (une série, couleur de marque) */
.chart { margin: 0; }
.chart-plot { position: relative; height: 150px; border-bottom: 1px solid var(--line);
  background: linear-gradient(to bottom, var(--line) 1px, transparent 1px) 0 0 / 100% 50%; padding-top: 1px; }
.chart-max { position: absolute; top: -9px; left: 0; font-size: .7rem; color: var(--ink-3); background: var(--surface); padding-right: 6px; z-index: 1; }
.chart-bars { display: flex; align-items: stretch; height: 100%; gap: 2px; }
.chart-col { flex: 1; position: relative; display: flex; align-items: flex-end; outline: none; cursor: default; }
.chart-bar { display: block; width: 100%; max-width: 28px; margin: 0 auto; background: var(--brand-blue); border-radius: 4px 4px 0 0; transition: background .1s ease; }
.chart-col:hover .chart-bar, .chart-col:focus .chart-bar { background: var(--brand-navy); }
.chart-col:hover::after, .chart-col:focus::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--brand-navy); color: #fff; font-size: .76rem; font-weight: 600; white-space: nowrap;
  padding: 5px 9px; border-radius: 7px; pointer-events: none; z-index: 5;
}
.chart-col:first-child:hover::after, .chart-col:first-child:focus::after { left: 0; transform: none; }
.chart-col:last-child:hover::after, .chart-col:last-child:focus::after { left: auto; right: 0; transform: none; }
.chart-axis { position: relative; height: 22px; font-size: .72rem; color: var(--ink-3); }
.chart-axis span { position: absolute; top: 5px; transform: translateX(-50%); white-space: nowrap; }
.chart-axis span:first-child { transform: none; left: 0 !important; }
.chart-axis span:last-child:not(:first-child) { transform: none; left: auto !important; right: 0; }
.chart-note { font-size: .84rem; color: var(--ink-2); margin: 10px 0 0; }

/* Barres horizontales (répartitions) */
.hbars { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; gap: 10px 12px; align-items: center; font-size: .88rem; }
.hbar { display: contents; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.hbar-track { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.hbar-track i { display: block; height: 100%; background: var(--brand-blue); border-radius: 0 4px 4px 0; }
.hbar-value { font-size: .82rem; color: var(--ink-2); white-space: nowrap; }
.hbar-value b { color: var(--ink); }
.breakdown + .breakdown { margin-top: 20px; }
.breakdown h3 { font-size: .92rem; margin-bottom: 10px; }
