:root {
  --rouge: #e30613;
  --rouge-fonce: #c00510;
  --rouge-pale: #fff1f1;
  --noir: #18181b;
  --gris-900: #232326;
  --gris-700: #4a4a50;
  --gris-500: #76767d;
  --gris-300: #d6d6d9;
  --gris-200: #e7e7e9;
  --gris-100: #f0f0f0;
  --fond: #f4f4f2;
  --blanc: #ffffff;
  --vert: #17803d;
  --rayon: 16px;
  --rayon-sm: 9px;
  --ombre: 0 1px 2px rgba(0, 0, 0, 0.04);
  font-family: "Lexend", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--noir);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--fond); min-height: 100vh; }
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

/* ── Barre du haut ─────────────────────────────── */
.topbar { background: var(--noir); color: var(--blanc); }
.topbar__inner {
  max-width: 1200px; margin: 0 auto; padding: 10px 32px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
/* Logo fourni sur fond blanc carré : on recadre sur le disque (≈ 78 % de l'image). */
.brand__logo {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: url("../img/logo-sport2000.webp") center / 129% no-repeat;
}
.brand__text { display: flex; flex-direction: column; line-height: 1.15; }
.brand__text strong { font-weight: 700; font-size: 15px; letter-spacing: 0.01em; }
.brand__text span { font-size: 12px; font-weight: 300; opacity: 0.92; }

.nav { display: flex; align-items: center; gap: 4px; }
.nav__link {
  text-decoration: none; font-weight: 600; font-size: 13.5px;
  padding: 8px 16px; border-radius: 999px; white-space: nowrap;
}
.nav__link:hover { background: rgba(255, 255, 255, 0.08); }
.nav__link.is-active { background: var(--rouge); }
.nav__link.is-parent { background: #3a3a3e; }
.nav__logout {
  background: none; border: 0; color: rgba(255, 255, 255, 0.6); cursor: pointer;
  font-size: 12px; padding: 6px 8px; margin-left: 4px;
}
.nav__logout:hover { color: var(--blanc); }

.demo-banner {
  background: #fff7d6; color: #6b4e00; text-align: center; font-size: 12px; padding: 6px 16px;
}
.demo-banner code { background: rgba(0, 0, 0, 0.06); padding: 1px 5px; border-radius: 4px; }

/* ── Mise en page ──────────────────────────────── */
.page { max-width: 1200px; margin: 0 auto; padding: 32px 32px 60px; }
.page-title { font-size: 28px; font-weight: 700; letter-spacing: -0.01em; margin: 0; line-height: 1.15; }
.page-lead { color: var(--gris-700); font-size: 14.5px; font-weight: 300; margin: 8px 0 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; margin-top: 24px; }
.layout__aside { position: sticky; top: 18px; display: grid; gap: 16px; }

.card { background: var(--blanc); border-radius: var(--rayon); padding: 20px 22px; box-shadow: var(--ombre); }
#form .card + .card { margin-top: 16px; }
.card__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card__title { font-size: 16px; font-weight: 600; margin: 0; }
.card__hint { color: var(--gris-700); font-size: 12px; font-weight: 300; }

/* ── Boutons ───────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--rayon-sm); border: 1px solid var(--gris-300); background: var(--blanc);
  padding: 8px 14px; font-size: 13.5px; font-weight: 400; cursor: pointer; text-decoration: none;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:hover { background: var(--gris-100); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--primary { background: var(--rouge); border-color: var(--rouge); color: var(--blanc); font-weight: 600; }
.btn--primary:hover { background: var(--rouge-fonce); border-color: var(--rouge-fonce); }
.btn--dark { background: var(--noir); border-color: var(--noir); color: var(--blanc); font-weight: 600; }
.btn--dark:hover { background: #000; }
.btn--lg { font-size: 14.5px; padding: 11px 18px; border-radius: 10px; width: 100%; }
.btn--block { width: 100%; }

/* ── Formulaire ────────────────────────────────── */
.label { display: block; font-weight: 500; font-size: 13px; margin: 14px 0 6px; }
.input, .textarea {
  width: 100%; border: 1px solid var(--gris-300); border-radius: var(--rayon-sm); background: var(--blanc);
  padding: 9px 12px; font-size: 14px; outline: none;
}
.input:focus, .textarea:focus { border-color: var(--noir); box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.08); }
.input::placeholder, .textarea::placeholder { color: var(--gris-500); }
.input--mid { max-width: 480px; }
.textarea { min-height: 90px; resize: vertical; line-height: 1.45; }
.error-text { color: var(--rouge); font-size: 12.5px; margin: 8px 0 0; }

.drop {
  border: 1.5px dashed var(--gris-300); border-radius: 12px; padding: 22px 16px; text-align: center;
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.drop:hover, .drop.is-over { border-color: var(--rouge); background: var(--rouge-pale); }
.drop__icon { width: 22px; height: 22px; margin: 0 auto 8px; color: var(--gris-700); }
.drop__title { font-weight: 500; font-size: 14px; margin: 0 0 4px; }
.drop__sub { color: var(--gris-700); font-size: 12px; font-weight: 300; margin: 0; }

/* ── Formulaire cadré : fichiers, formats, aperçu de la demande ── */
.layout--wide-aside { grid-template-columns: minmax(0, 1fr) 380px; }
.files-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr); gap: 18px; }
.field-title { font-weight: 600; font-size: 13.5px; margin: 0 0 8px; }
.req { color: var(--gris-700); font-weight: 300; font-size: 12px; margin-left: 4px; }
.drop--compact { padding: 16px 12px; }
.drop--ref { aspect-ratio: 3 / 4; display: grid; align-content: center; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-top: 10px; }
.thumbs:empty { display: none; }
.thumb { position: relative; border: 1px solid var(--gris-200); border-radius: 9px; padding: 5px; background: var(--blanc); }
.thumb img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--gris-100); border-radius: 6px; }
.thumb--ref { border: 1.5px solid var(--rouge); background: var(--rouge-pale); }
.thumb--ref img { aspect-ratio: 3 / 4; }
.thumb__name { font-size: 11px; margin: 5px 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb__x {
  position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, 0.95); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); font-size: 14px; line-height: 1;
}
.thumb__x:hover { background: var(--noir); color: var(--blanc); }

.fmt-head, .fmt-row { display: grid; grid-template-columns: 84px 12px 84px minmax(0, 1fr) 34px; gap: 8px; align-items: center; }
.fmt-head { color: var(--gris-700); font-size: 12px; margin-bottom: 6px; }
.fmt-row + .fmt-row { margin-top: 8px; }
.fmt-x { text-align: center; color: var(--gris-500); }
.fmt-suppr {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--gris-300); background: var(--blanc);
  cursor: pointer; font-size: 16px; line-height: 1; color: var(--gris-700);
}
.fmt-suppr:hover:not(:disabled) { border-color: var(--rouge); color: var(--rouge); }
.fmt-suppr:disabled { opacity: 0.35; cursor: not-allowed; }
.input.is-invalid { border-color: var(--rouge); }
.btn--add { margin-top: 12px; border-style: dashed; font-size: 13px; padding: 8px 14px; }
.textarea--tall { min-height: 130px; }

.brief {
  white-space: pre-wrap; overflow-wrap: anywhere; font: 11.5px/1.5 ui-monospace, Consolas, monospace;
  background: var(--gris-100); border-radius: 10px; padding: 12px; margin: 0 0 14px; max-height: 380px; overflow: auto;
}
.brief--job { margin: 10px 0 0; max-height: 300px; }
.brief__v {
  display: inline-block; background: var(--noir); color: var(--blanc); border-radius: 5px; font-size: 11.5px;
  padding: 2px 7px; margin-right: 8px; vertical-align: 1px;
}
.hist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.hist__item { border: 1px solid var(--gris-200); border-radius: 10px; padding: 8px 10px; }
.hist__item.is-active { border: 1.5px solid var(--rouge); background: var(--rouge-pale); padding: 7.5px 9.5px; }
.hist__head {
  display: flex; align-items: center; gap: 0; width: 100%; border: 0; background: none; padding: 0; cursor: pointer;
  font: inherit; text-align: left; color: inherit;
}
.hist__kind { font-weight: 600; font-size: 13px; }
.hist__date { margin-left: auto; color: var(--gris-700); font-size: 11.5px; font-weight: 300; }
.hist__texte {
  white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.45 Lexend, sans-serif; font-weight: 300; margin: 6px 0 0;
  color: var(--gris-700); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.hist__item.is-active .hist__texte {
  display: block; -webkit-line-clamp: none; color: var(--noir); font: 11.5px/1.5 ui-monospace, Consolas, monospace;
  max-height: 340px; overflow: auto;
}
.manque { color: var(--gris-700); font-size: 12px; font-weight: 300; margin: 10px 0 0; }
.manque:empty { display: none; }
.upload { height: 5px; border-radius: 999px; background: var(--gris-200); overflow: hidden; margin-top: 10px; }
.upload__bar { height: 100%; width: 0; background: var(--rouge); transition: width 0.2s; }

/* ── Récapitulatif ─────────────────────────────── */
.recap { display: grid; grid-template-columns: 1fr 1.3fr; gap: 9px 12px; margin: 2px 0 18px; font-size: 13px; }
.recap dt { color: var(--gris-700); font-weight: 300; }
.recap dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.note { color: var(--gris-700); font-size: 12px; font-weight: 300; margin: 12px 0 0; line-height: 1.45; }

/* ── Tableau des générations ───────────────────── */
.table-card { padding: 0; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-weight: 400; color: var(--gris-700); padding: 13px 18px; border-bottom: 1px solid var(--gris-200);
  font-size: 12.5px;
}
.table td { padding: 10px 18px; border-bottom: 1px solid var(--gris-200); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; transition: background 0.12s; }
.table tbody tr:hover { background: #fafafa; }
.table__thumb { width: 38px; height: 56px; object-fit: cover; border-radius: 5px; background: var(--gris-200); }
.table__link { font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.table__muted { color: var(--gris-700); }
.empty { text-align: center; padding: 44px 20px; color: var(--gris-700); }
.empty p { margin: 0 0 16px; }

/* ── Badges de statut ──────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 11px;
  font-weight: 500; font-size: 12.5px; white-space: nowrap;
}
.badge--depose { background: var(--gris-100); color: var(--gris-700); }
.badge--en_cours { background: #e4edfd; color: #1e3f96; }
.badge--a_valider { background: #fdf2c8; color: #7a4a00; }
.badge--valide { background: #dcf5e5; color: #17663a; }
.badge--erreur { background: #fde3e3; color: #a3111a; }
.badge--lg { font-size: 13px; padding: 6px 14px; }
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--en_cours .badge__dot { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

/* ── Page d'une génération ─────────────────────── */
.back { color: var(--rouge); text-decoration: none; font-size: 13.5px; font-weight: 400; }
.back:hover { text-decoration: underline; }
.job-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-top: 12px; }
.job-head .page-title { font-size: 26px; }
.job-meta { color: var(--gris-700); font-size: 13px; font-weight: 300; margin: 6px 0 0; }

.versions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 16px; }
.versions__label { color: var(--gris-700); margin-right: 4px; font-size: 13px; }
.pill {
  border: 1px solid var(--gris-300); background: var(--blanc); border-radius: 999px; padding: 5px 13px;
  font-weight: 500; cursor: pointer; font-size: 13px;
}
.pill:hover { border-color: var(--gris-500); }
.pill.is-active { background: var(--noir); border-color: var(--noir); color: var(--blanc); font-weight: 600; }

.livrables { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; align-items: start; }
.livrable { padding: 12px; }
.livrable__img { border-radius: 8px; background: var(--gris-100); overflow: hidden; min-height: 120px; display: grid; place-items: center; }
.livrable__img img { display: block; width: 100%; cursor: zoom-in; }
.livrable__img--loading { aspect-ratio: 1; background: linear-gradient(90deg, var(--gris-100) 30%, var(--gris-200) 50%, var(--gris-100) 70%) 0 0 / 300% 100%; animation: shimmer 1.4s linear infinite; }
.livrable__img--loading img { display: none; }
.livrable__img--none { aspect-ratio: 1; color: var(--gris-700); font-size: 12.5px; font-weight: 300; }
.livrable__img--error {
  aspect-ratio: 1; background: #fde3e3; color: #7c0d14; font-size: 12px; padding: 14px; text-align: center;
  align-content: center; gap: 4px; overflow-wrap: anywhere;
}
@keyframes shimmer { to { background-position: -150% 0; } }
.livrable__head { display: flex; justify-content: space-between; align-items: baseline; margin: 10px 0 9px; }
.livrable__format { font-weight: 600; font-size: 14px; }
.livrable__type { color: var(--gris-700); font-size: 12px; font-weight: 300; }
.livrable__nom { color: var(--gris-700); font-size: 11.5px; font-weight: 300; margin: -5px 0 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.livrable__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.livrable__html { display: grid; }
.livrable__html .btn:disabled { pointer-events: none; } /* l'info-bulle est portée par le span */
.livrable__actions .btn { padding: 8px 6px; font-size: 12.5px; white-space: nowrap; }

.progress-card { text-align: center; padding: 40px 24px; }
.spinner {
  width: 32px; height: 32px; margin: 0 auto 14px; border-radius: 50%;
  border: 3px solid var(--gris-200); border-top-color: var(--rouge); animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-card h2 { font-size: 16px; font-weight: 600; margin: 0 0 6px; }
.progress-card p { color: var(--gris-700); font-weight: 300; margin: 0; font-size: 13px; }

.alert { background: #fde3e3; color: #7c0d14; border-radius: 11px; padding: 12px 16px; margin-bottom: 16px; line-height: 1.45; font-size: 13px; }
.alert strong { display: block; margin-bottom: 3px; }

.side-title { font-size: 16px; font-weight: 600; margin: 0 0 6px; }
.side-lead { color: var(--gris-700); font-weight: 300; font-size: 13px; margin: 0 0 12px; line-height: 1.45; }

/* ── Connexion ─────────────────────────────────── */
.login { max-width: 360px; margin: 32px auto 0; }
.login .page-title { font-size: 24px; margin-bottom: 4px; }

/* ── Visionneuse, toast ────────────────────────── */
.lightbox {
  position: fixed; inset: 0; background: rgba(10, 10, 12, 0.88); display: grid; place-items: center;
  padding: 24px; z-index: 50; cursor: zoom-out;
}
.lightbox img { max-height: calc(100vh - 48px); max-width: 100%; border-radius: 8px; }
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--noir); color: var(--blanc);
  padding: 10px 18px; border-radius: 10px; font-size: 13px; z-index: 60; max-width: calc(100vw - 32px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
}
.toast.is-error { background: var(--rouge); }
.loading { color: var(--gris-700); padding: 30px 0; }

/* ── Responsive ────────────────────────────────── */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .layout__aside { position: static; }
}
@media (max-width: 640px) {
  .files-grid { grid-template-columns: 1fr; }
  .drop--ref { aspect-ratio: auto; }
  .fmt-head { display: none; }
  .fmt-row { grid-template-columns: 1fr 12px 1fr 34px; padding-bottom: 8px; border-bottom: 1px solid var(--gris-200); }
  .fmt-consignes { grid-column: 1 / 4; grid-row: 2; }
  .fmt-suppr { grid-column: 4; grid-row: 1; }
  .topbar__inner { padding: 10px 16px; }
  .page { padding: 22px 16px 48px; }
  .page-title, .job-head .page-title { font-size: 22px; }
  .page-head, .job-head { flex-direction: column; align-items: flex-start; }
  .card { padding: 16px; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 16px; border-bottom: 1px solid var(--gris-200); }
  .table td { padding: 0; border: 0; }
  .table td:first-child { flex-basis: 100%; }
  .livrables { grid-template-columns: 1fr; }
}
