:root {
  --green-deep: #053b22;
  --green: #0b8f4a;
  --green-soft: #eaf8ef;
  --red: #e0202a;
  --gold: #f4c542;
  --white: #ffffff;
  --ink: #102018;
  --muted: #66766c;
  --line: #d8e8de;
  --bg: #f5fbf7;
  --shadow: 0 24px 60px rgba(5, 59, 34, .12);
  --badge-w: 85.6mm;
  --badge-h: 54mm;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at 12% 6%, rgba(11, 143, 74, .18), transparent 30%),
    radial-gradient(circle at 90% 8%, rgba(224, 32, 42, .10), transparent 28%),
    linear-gradient(135deg, #fbfffc, #edf8f1);
  color: var(--ink);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

.topbar {
  background: linear-gradient(135deg, var(--green-deep), var(--green));
  color: var(--white);
  padding: 18px 18px;
  border-bottom: 5px solid var(--red);
}

.topbar-inner {
  width: min(1260px, 100%);
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  width: 92px;
  height: 70px;
  object-fit: contain;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 18px;
  padding: 8px;
}

.logo.small {
  width: 60px;
  height: 46px;
  padding: 5px;
  border-radius: 12px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; letter-spacing: -.04em; font-size: clamp(24px, 4vw, 42px); }
.subtitle { margin: 0; color: #d9f9e4; font-size: 14px; line-height: 1.45; }

.nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav a, .nav button, button, .file-btn {
  border: 0;
  border-radius: 14px;
  padding: 11px 14px;
  cursor: pointer;
  font-weight: 900;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: .2s ease;
}

.nav a {
  background: rgba(255,255,255,.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,.22);
}

.nav a:hover, button:hover, .file-btn:hover { transform: translateY(-1px); }

.container {
  width: min(1260px, 100%);
  margin: 26px auto 48px;
  padding: 0 16px;
}

.grid-main {
  display: grid;
  grid-template-columns: 390px 1fr;
  gap: 22px;
  align-items: start;
}

.card {
  background: rgba(255,255,255,.94);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 26px;
  padding: 22px;
}

.sticky { position: sticky; top: 16px; }

.card h2 {
  font-size: 20px;
  color: var(--green-deep);
  margin-bottom: 16px;
}

.hr { height: 1px; background: var(--line); margin: 18px 0; }

.form-row { margin-bottom: 13px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #315943;
}

input, select, textarea {
  width: 100%;
  border: 1px solid #cfe2d6;
  background: #fff;
  border-radius: 14px;
  padding: 12px 13px;
  color: var(--ink);
  font-size: 15px;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: #20b86b;
  box-shadow: 0 0 0 4px rgba(32,184,107,.14);
}

input[type="file"] { display: none; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.btn-primary { background: linear-gradient(135deg, var(--green-deep), var(--green)); color: white; box-shadow: 0 14px 26px rgba(11,143,74,.22); }
.btn-secondary, .file-btn { background: #effaf3; color: var(--green-deep); border: 1px solid #cfe8d8; }
.btn-red { background: #fff1f1; color: var(--red); border: 1px solid #ffd1d1; }
.btn-gold { background: linear-gradient(135deg, var(--gold), #ffdf75); color: #3c2d00; }
.btn-dark { background: #102018; color: white; }
button:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.note, .hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.48;
}

.camera-box {
  display: none;
  margin-top: 14px;
  background: #07180f;
  border-radius: 18px;
  padding: 12px;
}

video, #reader video {
  width: 100%;
  border-radius: 14px;
  display: block;
  background: #06120c;
}

.preview-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.preview-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.badge-stage {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 24px;
  justify-items: center;
  overflow-x: auto;
  padding: 12px 4px 30px;
}

.caption {
  text-align: center;
  font-size: 12px;
  font-weight: 950;
  color: var(--green-deep);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 10px;
}

.badge {
  width: var(--badge-w);
  height: var(--badge-h);
  position: relative;
  overflow: hidden;
  border-radius: 4mm;
  background: white;
  border: .35mm solid rgba(5,59,34,.18);
  box-shadow: 0 24px 45px rgba(5,59,34,.22);
  flex-shrink: 0;
}

.badge-front {
  color: #fff;
  background:
    radial-gradient(circle at 14% 0%, rgba(255,255,255,.20), transparent 34%),
    linear-gradient(135deg, #053b22 0%, #0b8f4a 55%, #11c96c 100%);
}

.badge-front:before {
  content: "";
  position: absolute;
  right: -32%; top: -18%;
  width: 78%; height: 136%;
  transform: rotate(17deg);
  background: rgba(255,255,255,.08);
  border-left: 1.4mm solid rgba(255,255,255,.13);
}

.vip-ribbon {
  display: none;
  position: absolute;
  z-index: 10;
  right: -10mm;
  top: 7mm;
  width: 45mm;
  transform: rotate(35deg);
  text-align: center;
  background: var(--red);
  color: #fff;
  padding: 1.6mm 0;
  font-weight: 950;
  letter-spacing: .12em;
  font-size: 4mm;
  box-shadow: 0 2mm 5mm rgba(0,0,0,.26);
}

.is-vip .vip-ribbon { display: block; }

.badge-inner {
  position: relative;
  z-index: 2;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.badge-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 4mm;
  padding: 3.4mm 4mm 2mm;
}

.badge-logo {
  width: 25mm;
  height: 14mm;
  object-fit: contain;
  filter: drop-shadow(0 1.8mm 2.5mm rgba(0,0,0,.18));
}

.edition {
  text-align: right;
  font-size: 2.25mm;
  font-weight: 950;
  line-height: 1.15;
  text-transform: uppercase;
  color: #e9fff0;
}

.edition span {
  display: inline-block;
  margin-top: 1mm;
  border-radius: 99px;
  background: var(--red);
  color: #fff;
  padding: .75mm 1.8mm;
}

.badge-body {
  display: grid;
  grid-template-columns: 25mm 1fr;
  gap: 3.5mm;
  align-items: center;
  padding: 0 4mm 2mm;
}

.photo-frame {
  width: 24mm;
  height: 28mm;
  border-radius: 3.2mm;
  overflow: hidden;
  background: rgba(255,255,255,.18);
  border: .55mm solid rgba(255,255,255,.80);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.86);
  font-size: 8mm;
  font-weight: 950;
  box-shadow: 0 3mm 8mm rgba(0,0,0,.22);
}

.photo-frame img { width: 100%; height: 100%; object-fit: cover; }

.person .pass-label {
  font-size: 2.6mm;
  font-weight: 950;
  color: var(--gold);
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 1.1mm;
}

.person .name {
  font-size: 5.6mm;
  line-height: .96;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: -.05em;
  text-shadow: 0 1mm 2mm rgba(0,0,0,.18);
  overflow-wrap: anywhere;
}

.person .role {
  margin-top: 1.3mm;
  font-size: 3mm;
  line-height: 1.15;
  font-weight: 850;
  color: #f3fff5;
  overflow-wrap: anywhere;
}

.badge-bottom {
  background: rgba(0,31,16,.44);
  border-top: .25mm solid rgba(255,255,255,.24);
  display: flex;
  justify-content: space-between;
  gap: 3mm;
  align-items: center;
  padding: 1.75mm 4mm;
  font-size: 2.18mm;
  font-weight: 850;
}

.badge-bottom b { color: var(--gold); }

.badge-back {
  background:
    radial-gradient(circle at 95% 10%, rgba(11,143,74,.16), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #effaf3 100%);
  padding: 4mm;
}

.back-inner {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 2.6mm;
}

.back-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: .35mm solid #d4e8db;
  padding-bottom: 2mm;
}

.back-top img { width: 28mm; height: 15mm; object-fit: contain; }
.back-title { text-align: right; font-size: 2.8mm; font-weight: 950; color: var(--green-deep); text-transform: uppercase; line-height: 1.1; }
.back-title span { color: var(--red); }

.back-body {
  display: grid;
  grid-template-columns: 1fr 22mm;
  gap: 3mm;
  align-items: center;
}

.rules {
  font-size: 2.25mm;
  line-height: 1.35;
  color: #294836;
  margin: 0;
  padding-left: 3mm;
}
.rules li { margin-bottom: 1mm; }

.qr-box {
  background: #fff;
  border: .35mm solid #b8d2c1;
  border-radius: 3mm;
  min-height: 23mm;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5mm;
}

#qrPreview, #qrPreviewBack { width: 18mm; height: 18mm; }
#qrPreview canvas, #qrPreview img, #qrPreviewBack canvas, #qrPreviewBack img { width: 100% !important; height: 100% !important; }

.qr-placeholder {
  font-size: 1.7mm;
  text-align: center;
  color: var(--muted);
  font-weight: 850;
  line-height: 1.15;
}

.back-footer {
  background: linear-gradient(135deg, var(--green-deep), var(--green));
  color: #fff;
  border-radius: 2.8mm;
  padding: 1.9mm 2.8mm;
  display: flex;
  justify-content: space-between;
  gap: 2mm;
  font-size: 2mm;
  font-weight: 850;
}
.back-footer span { color: #dff8e7; }

.badge.portrait .badge-logo { width: 35mm; height: 20mm; }
.badge.portrait .badge-top { padding: 5mm 5mm 2mm; }
.badge.portrait .badge-body { grid-template-columns: 1fr; text-align: center; justify-items: center; gap: 2.3mm; padding: 0 5mm 2mm; }
.badge.portrait .photo-frame { width: 31mm; height: 37mm; }
.badge.portrait .person .name { font-size: 7mm; }
.badge.portrait .person .role { font-size: 3.5mm; }
.badge.portrait .badge-bottom { padding: 2.4mm 5mm; font-size: 2.7mm; }
.badge-back.portrait { padding: 5mm; }
.badge-back.portrait .back-body { grid-template-columns: 1fr; justify-items: center; }
.badge-back.portrait .qr-box { width: 32mm; height: 32mm; }
.badge-back.portrait #qrPreviewBack { width: 26mm; height: 26mm; }

.toast {
  position: fixed;
  z-index: 9999;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: 16px;
  padding: 13px 15px;
  background: #102018;
  color: #fff;
  box-shadow: 0 16px 36px rgba(0,0,0,.20);
  transform: translateY(24px);
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
  font-weight: 850;
  font-size: 14px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.err { background: #921820; }
.toast.ok { background: #063f25; }

.status-card {
  border-radius: 24px;
  padding: 22px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
}
.status-card.valid { border-color: #80d7a0; background: #effbf3; }
.status-card.invalid { border-color: #ffb9b9; background: #fff3f3; }
.status-title { font-size: clamp(26px, 4vw, 44px); line-height: 1; font-weight: 950; margin-bottom: 12px; color: var(--green-deep); }
.status-card.invalid .status-title { color: var(--red); }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(160px,1fr)); gap: 12px; margin-top: 15px; }
.info-item { background: rgba(255,255,255,.75); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.info-item b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 5px; }
.info-item span { font-weight: 900; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--green-deep); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.badge-pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 950; background: #edf9f2; color: var(--green-deep); border: 1px solid #cde8d7; }
.badge-pill.red { background: #fff1f1; color: var(--red); border-color: #ffd2d2; }
.badge-pill.gold { background: #fff8df; color: #6e5300; border-color: #ffe68a; }
.photo-mini { width: 42px; height: 42px; object-fit: cover; border-radius: 12px; background: #eef7f1; border: 1px solid var(--line); }
.hidden { display: none !important; }

@media (max-width: 980px) {
  .grid-main { grid-template-columns: 1fr; }
  .sticky { position: static; }
}

@media (max-width: 720px) {
  .logo { width: 76px; height: 58px; }
  .badge-stage { grid-template-columns: 1fr; }
  .form-grid-2, .info-grid { grid-template-columns: 1fr; }
  .nav { width: 100%; }
  .nav a { flex: 1; }
  .badge { transform: scale(.92); transform-origin: top center; margin-bottom: -7mm; }
}

@media print {
  body { background: #fff; }
  .topbar, .card.sticky, .preview-head, .toast, .no-print { display: none !important; }
  .container, .grid-main, .card { margin: 0; padding: 0; width: 100%; box-shadow: none; border: 0; display: block; }
  .badge-stage { display: block; padding: 0; }
  .badge-item { page-break-after: always; display: flex; justify-content: center; align-items: center; min-height: 100vh; }
  .caption { display: none; }
  .badge { box-shadow: none; transform: none; }
}

.export-offscreen {
  position: fixed;
  left: -12000px;
  top: 0;
  width: max-content;
  background: #ffffff;
  padding: 20px;
  z-index: -1;
}
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 250px;
}
.admin-actions button {
  padding: 8px 9px;
  border-radius: 10px;
  font-size: 12px;
}
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0b8f4a;
  margin-right: 6px;
}
.status-dot.red { background: #d5202a; }
.print-page {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  page-break-after: always;
}
.print-page img { max-width: 96vw; max-height: 96vh; }
#adminQrPreview { width: 22mm; height: 22mm; }
#adminQrPreview canvas, #adminQrPreview img { width: 100% !important; height: 100% !important; }
#qrPreviewBack { width: 21mm; height: 21mm; }
.badge-back.portrait #qrPreviewBack { width: 28mm; height: 28mm; }

/* Authentification et administration avancée */
.auth-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 170px);
}
.auth-card {
  width: min(520px, 100%);
  margin: auto;
}
.auth-message {
  min-height: 18px;
  color: var(--red);
  font-weight: 800;
}
.auth-user-email {
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 900;
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #f4fbf6;
  border-radius: 18px;
  margin-bottom: 16px;
}
.bulk-bar button:disabled {
  opacity: .45;
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 20, 10, .62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.modal-card {
  width: min(760px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  background: #fff;
  border-radius: 26px;
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0,0,0,.28);
  padding: 22px;
}
.table-wrap input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}
a.btn-secondary, a.btn-primary, a.btn-red {
  border-radius: 14px;
  padding: 11px 14px;
  cursor: pointer;
  font-weight: 900;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: .2s ease;
}

/* v5 - Accueil public et administration */
.btn-primary, .btn-secondary, .btn-red, .btn-gold, .btn-dark {
  border: 0;
  border-radius: 14px;
  padding: 11px 14px;
  cursor: pointer;
  font-weight: 900;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: .2s ease;
}

.home-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 16% 10%, rgba(255,255,255,.18), transparent 24%),
    radial-gradient(circle at 80% 20%, rgba(224,32,42,.28), transparent 24%),
    linear-gradient(135deg, #022f1a, #0b8f4a 62%, #03c267);
  color: white;
  display: grid;
  place-items: center;
  padding: 24px;
}

.admin-corner-btn {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 5;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.28);
  color: #fff;
  border-radius: 999px;
  padding: 11px 16px;
  font-weight: 950;
  backdrop-filter: blur(10px);
}

.home-hero {
  width: min(680px, 100%);
  text-align: center;
  padding: 42px 24px;
  border-radius: 34px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.22);
  box-shadow: 0 26px 80px rgba(0,0,0,.24);
  backdrop-filter: blur(10px);
}

.home-logo {
  width: min(260px, 78vw);
  height: auto;
  object-fit: contain;
  margin-bottom: 18px;
  filter: drop-shadow(0 14px 22px rgba(0,0,0,.24));
}

.home-hero h1 {
  font-size: clamp(42px, 9vw, 82px);
  margin: 0 0 10px;
  line-height: .92;
}

.home-hero p {
  color: #e7fff0;
  font-size: 17px;
  line-height: 1.5;
  margin-bottom: 24px;
}

.home-scan-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: min(360px, 100%);
  min-height: 74px;
  border-radius: 24px;
  background: #fff;
  color: var(--green-deep);
  font-weight: 950;
  font-size: clamp(22px, 4vw, 34px);
  box-shadow: 0 18px 40px rgba(0,0,0,.20);
  border: 3px solid rgba(244,197,66,.85);
}

.home-scan-btn:hover,
.admin-corner-btn:hover {
  transform: translateY(-2px);
}

.home-note {
  margin-top: 18px !important;
  margin-bottom: 0 !important;
  font-size: 13px !important;
  color: rgba(255,255,255,.78) !important;
}

.admin-intro-card,
.admin-create-section {
  margin-bottom: 22px;
}

@media (max-width: 720px) {
  .admin-corner-btn { top: 12px; right: 12px; padding: 9px 12px; font-size: 13px; }
  .home-hero { padding: 34px 18px; }
}

/* ============================
   V6 - Accueil, thèmes, template et disposition libre
   ============================ */
.home-admin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 12px;
  padding: 12px 18px;
  border-radius: 16px;
  background: rgba(255,255,255,.14);
  color: #fff;
  border: 1px solid rgba(255,255,255,.30);
  font-weight: 950;
}
.admin-corner-btn { display: none !important; }

.layout-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
  gap: 10px 12px;
  margin-top: 14px;
  padding: 14px;
  border-radius: 18px;
  background: #f5fbf7;
  border: 1px solid var(--line);
}
.layout-editor.compact { grid-template-columns: repeat(4, minmax(90px, 1fr)); }
.layout-editor .form-row { margin-bottom: 0; }
.layout-editor input[type="range"] { padding: 0; }

/* La bannière VIP est volontairement désactivée. Le statut VIP reste affiché dans le texte et l'administration. */
.vip-ribbon, .is-vip .vip-ribbon { display: none !important; }

.badge-front.theme-green {
  background:
    var(--template-front, none),
    radial-gradient(circle at 14% 0%, rgba(255,255,255,.20), transparent 34%),
    linear-gradient(135deg, #053b22 0%, #0b8f4a 55%, #11c96c 100%);
  background-size: cover, auto, auto;
  background-position: center, center, center;
  color: var(--badge-text-color, #fff);
}
.badge-back.theme-green {
  background:
    var(--template-back, none),
    radial-gradient(circle at 95% 10%, rgba(11,143,74,.16), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #effaf3 100%);
  background-size: cover, auto, auto;
  background-position: center, center, center;
}
.badge-front.theme-red {
  background:
    var(--template-front, none),
    radial-gradient(circle at 12% 0%, rgba(255,255,255,.20), transparent 34%),
    linear-gradient(135deg, #4a0509 0%, #b3131b 55%, #e0202a 100%);
  background-size: cover, auto, auto; background-position: center, center, center;
  color: var(--badge-text-color, #fff);
}
.badge-back.theme-red {
  background:
    var(--template-back, none),
    radial-gradient(circle at 95% 10%, rgba(224,32,42,.16), transparent 34%),
    linear-gradient(180deg, #fff 0%, #fff0f1 100%);
  background-size: cover, auto, auto; background-position: center, center, center;
}
.badge-front.theme-black {
  background:
    var(--template-front, none),
    radial-gradient(circle at 12% 0%, rgba(255,255,255,.13), transparent 34%),
    linear-gradient(135deg, #050706 0%, #151c18 58%, #2f3a34 100%);
  background-size: cover, auto, auto; background-position: center, center, center;
  color: var(--badge-text-color, #fff);
}
.badge-back.theme-black {
  background:
    var(--template-back, none),
    radial-gradient(circle at 95% 10%, rgba(16,32,24,.14), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #e8ebe9 100%);
  background-size: cover, auto, auto; background-position: center, center, center;
}
.badge-front.theme-gold {
  background:
    var(--template-front, none),
    radial-gradient(circle at 12% 0%, rgba(255,255,255,.30), transparent 34%),
    linear-gradient(135deg, #6f4b00 0%, #c7951c 55%, #f4c542 100%);
  background-size: cover, auto, auto; background-position: center, center, center;
  color: var(--badge-text-color, #fff);
}
.badge-back.theme-gold {
  background:
    var(--template-back, none),
    radial-gradient(circle at 95% 10%, rgba(244,197,66,.26), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #fff7df 100%);
  background-size: cover, auto, auto; background-position: center, center, center;
}
.badge-front.theme-silver {
  background:
    var(--template-front, none),
    radial-gradient(circle at 12% 0%, rgba(255,255,255,.42), transparent 34%),
    linear-gradient(135deg, #4a5450 0%, #9aa4a0 56%, #e1e6e3 100%);
  background-size: cover, auto, auto; background-position: center, center, center;
  color: var(--badge-text-color, #fff);
}
.badge-back.theme-silver {
  background:
    var(--template-back, none),
    radial-gradient(circle at 95% 10%, rgba(160,170,165,.20), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #eef1ef 100%);
  background-size: cover, auto, auto; background-position: center, center, center;
}
.badge-front[class*="theme-"] .edition span,
.badge-front[class*="theme-"] .badge-bottom,
.back-footer { background: var(--badge-primary-color, var(--green)); }
.badge-front[class*="theme-"] .person .pass-label,
.badge-front[class*="theme-"] .badge-bottom b { color: #ffe680; }
.badge-front[class*="theme-"] .person .name,
.badge-front[class*="theme-"] .person .role { color: var(--badge-text-color, #fff); }

.badge.custom-layout .badge-inner,
.badge-back.custom-layout .back-inner { display: block; position: relative; height: 100%; }
.badge-front.custom-layout .badge-top {
  position: absolute; left: calc(var(--logo-x, 18) * 1%); top: calc(var(--logo-y, 16) * 1%);
  transform: translate(-50%, -50%); padding: 0; display: block; z-index: 4;
}
.badge-front.custom-layout .edition { display: none; }
.badge-front.custom-layout .badge-body { display: block; padding: 0; }
.badge-front.custom-layout .photo-frame {
  position: absolute; left: calc(var(--photo-x, 20) * 1%); top: calc(var(--photo-y, 55) * 1%);
  transform: translate(-50%, -50%); z-index: 4;
}
.badge-front.custom-layout .person {
  position: absolute; left: calc(var(--info-x, 62) * 1%); top: calc(var(--info-y, 55) * 1%);
  transform: translate(-50%, -50%); width: 55%; max-width: 58mm; z-index: 4;
}
.badge-front.custom-layout .badge-bottom { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; }
.badge-back.custom-layout .back-top { position: relative; z-index: 3; }
.badge-back.custom-layout .back-body { display: block; position: relative; height: calc(100% - 26mm); }
.badge-back.custom-layout .rules { max-width: 55%; }
.badge-back.custom-layout .qr-box {
  position: absolute; left: calc(var(--qr-x, 78) * 1%); top: calc(var(--qr-y, 55) * 1%);
  transform: translate(-50%, -50%); z-index: 4;
}
.badge-back.custom-layout .back-footer { position: absolute; left: 4mm; right: 4mm; bottom: 4mm; z-index: 4; }
.badge.has-template:before { opacity: .25; }

@media (max-width: 720px) {
  .layout-editor, .layout-editor.compact { grid-template-columns: 1fr; }
}

/* ============================
   V7 - Accueil, accordéons, thème bleu et finitions badge
   ============================ */
.home-actions-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 22px;
}
.home-action-btn,
.home-scan-btn,
.home-admin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: min(360px, 100%);
  min-height: 58px;
  border-radius: 20px;
  background: rgba(255,255,255,.14) !important;
  color: #fff !important;
  border: 1px solid rgba(255,255,255,.32) !important;
  box-shadow: 0 16px 36px rgba(0,0,0,.18);
  backdrop-filter: blur(10px);
  font-weight: 950;
  font-size: clamp(18px, 3vw, 24px);
  margin: 0 !important;
}
.home-action-btn:hover,
.home-scan-btn:hover,
.home-admin-btn:hover {
  transform: translateY(-2px);
  background: rgba(255,255,255,.22) !important;
}
.home-scan-btn {
  min-height: 64px;
  font-size: clamp(22px, 4vw, 34px);
}

.accordion {
  display: grid;
  gap: 10px;
}
.accordion-section {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f7fcf8;
  overflow: hidden;
}
.accordion-toggle {
  width: 100%;
  border-radius: 0;
  padding: 13px 14px;
  background: #effaf3;
  color: var(--green-deep);
  border: 0;
  justify-content: space-between;
  text-align: left;
}
.accordion-toggle span {
  font-size: 13px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.accordion-toggle b {
  font-size: 20px;
  line-height: 1;
}
.accordion-body {
  display: none;
  padding: 14px;
}
.accordion-section.open .accordion-body {
  display: block;
}
.accordion-section.open .accordion-toggle {
  background: linear-gradient(135deg, rgba(5,59,34,.96), rgba(11,143,74,.90));
  color: white;
}

.badge-front.theme-blue {
  background:
    var(--template-front, none),
    radial-gradient(circle at 12% 0%, rgba(255,255,255,.22), transparent 34%),
    linear-gradient(135deg, #062c67 0%, #0b5ed7 55%, #23a8ff 100%);
  background-size: cover, auto, auto;
  background-position: center, center, center;
  color: var(--badge-text-color, #fff);
}
.badge-back.theme-blue {
  background:
    var(--template-back, none),
    radial-gradient(circle at 95% 10%, rgba(11,94,215,.18), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #eaf3ff 100%);
  background-size: cover, auto, auto;
  background-position: center, center, center;
}
.badge-front.theme-green, .badge-back.theme-green { --theme-primary: #0b8f4a; }
.badge-front.theme-red, .badge-back.theme-red { --theme-primary: #b3131b; }
.badge-front.theme-black, .badge-back.theme-black { --theme-primary: #151c18; }
.badge-front.theme-gold, .badge-back.theme-gold { --theme-primary: #c7951c; }
.badge-front.theme-silver, .badge-back.theme-silver { --theme-primary: #7b8581; }
.badge-front.theme-blue, .badge-back.theme-blue { --theme-primary: #0b5ed7; }
.badge-front[class*="theme-"] .edition span,
.badge-front[class*="theme-"] .badge-bottom,
.badge-back[class*="theme-"] .back-footer {
  background: var(--badge-primary-color, var(--theme-primary, var(--green))) !important;
}
.badge-front[class*="theme-"] .badge-bottom b { white-space: nowrap; }

@media (max-width: 720px) {
  .home-actions-stack { gap: 12px; }
  .home-action-btn, .home-scan-btn, .home-admin-btn { width: 100%; }
}


/* ============================
   V8 - Correction export PDF/PNG avec fond/template
   ============================ */
.badge-template-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
  z-index: 0;
  pointer-events: none;
  user-select: none;
}
.badge.has-template > .badge-template-layer {
  display: block;
}
.badge.has-template .badge-inner,
.badge.has-template .back-inner {
  position: relative;
  z-index: 2;
}
.badge-front.has-template:before {
  z-index: 1;
  opacity: .16;
}
.badge-front:before {
  z-index: 1;
}

/* ============================
   V9 - Dashboard, import CSV, planche A4, rôles et scanner amélioré
   ============================ */
.form-grid-3 { display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 12px; }
.dashboard-card { margin-bottom: 22px; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat-card {
  background: linear-gradient(135deg, #f5fbf7, #ffffff);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 12px 28px rgba(5,59,34,.06);
}
.stat-card b {
  display: block;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  font-size: 11px;
  margin-bottom: 8px;
}
.stat-card span { display: block; font-size: 34px; line-height: 1; font-weight: 950; color: var(--green-deep); }
.stats-split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.stats-split h3 { font-size: 15px; color: var(--green-deep); margin-bottom: 10px; }
.mini-stat-list { display: grid; gap: 8px; }
.mini-stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.mini-stat-row span { color: #2e4d3b; font-weight: 750; }
.mini-stat-row b { color: var(--green-deep); font-weight: 950; }
.mini-stat-row small { color: var(--muted); font-weight: 700; }
.badge-pill.gold { background: #fff8df; color: #7d5a00; border-color: #ffdf75; }
.status-dot.gold { background: #e0a700; }
.ok-text { color: #047a3e !important; }
.bad-text { color: var(--red) !important; }
.manage-only:disabled { opacity: .45; cursor: not-allowed; }
@media (max-width: 980px) {
  .form-grid-3, .stats-split { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
}
@media (max-width: 520px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ============================
   V10 - Impression badge, templates image automatiques et interface nettoyée
   ============================ */
.design-card {
  margin-bottom: 22px;
}
.compact-table table input[type="color"],
.compact-table table select {
  min-width: 120px;
  padding: 7px 8px;
}
.muted-note {
  display: none !important;
}
.badge.has-template {
  background: #ffffff !important;
}
.badge.has-template > .badge-template-layer {
  display: block !important;
  z-index: 0;
}
.badge.has-template .badge-inner,
.badge.has-template .back-inner {
  z-index: 3;
}
.badge.has-template.badge-front:before {
  opacity: .12 !important;
}
.export-offscreen {
  left: -10000px;
  top: 0;
  z-index: 0;
  opacity: 1;
  pointer-events: none;
}
@media print {
  body[data-page="admin"] .topbar,
  body[data-page="admin"] #authGate,
  body[data-page="admin"] #accessDenied,
  body[data-page="admin"] #protectedApp > section:not(.print-only-badge),
  body[data-page="admin"] .toast,
  body[data-page="admin"] .modal {
    display: none !important;
  }
}

/* ============================
   V11 - Administration épurée + template dans création
   ============================ */
body[data-page="admin"] .admin-intro-card { padding: 16px 20px; }
body[data-page="admin"] .admin-intro-card p { margin: 0; color: var(--muted); }
body[data-page="admin"] .dashboard-card,
body[data-page="admin"] #protectedApp > section.card:nth-of-type(3) {
  padding: 16px 18px;
}
body[data-page="admin"] .dashboard-card .preview-head,
body[data-page="admin"] #protectedApp > section.card:nth-of-type(3) .preview-head {
  margin-bottom: 8px;
}
body[data-page="admin"] .admin-create-section .grid-main {
  grid-template-columns: minmax(360px, 460px) minmax(420px, 1fr);
  align-items: start;
}
body[data-page="admin"] .admin-create-section .grid-main > .card.sticky {
  grid-column: 1;
  grid-row: 1 / span 2;
}
body[data-page="admin"] .admin-create-section .grid-main > .card:not(.sticky):not(.design-card) {
  grid-column: 2;
  grid-row: 1;
}
body[data-page="admin"] .admin-create-section .grid-main > .design-card {
  grid-column: 1 / -1;
  grid-row: 3;
}
.template-save-box {
  margin-top: 14px;
  padding: 14px;
  border: 1px dashed #bdd9c7;
  border-radius: 18px;
  background: #fbfffc;
}
.template-save-box .actions { margin-top: 8px; }
body[data-page="admin"] .card h2 { margin-bottom: 10px; }
body[data-page="admin"] .preview-head p.note,
body[data-page="admin"] .muted-note { display: none !important; }
body[data-page="admin"] .admin-actions button { padding: 8px 10px; font-size: 12px; border-radius: 10px; }
body[data-page="admin"] table th,
body[data-page="admin"] table td { padding: 9px 10px; }
body[data-page="admin"] .accordion-body { padding: 12px; }
body[data-page="admin"] .form-row { margin-bottom: 10px; }
body[data-page="admin"] .layout-editor { max-height: 260px; overflow: auto; }
@media (max-width: 980px) {
  body[data-page="admin"] .admin-create-section .grid-main { grid-template-columns: 1fr; }
  body[data-page="admin"] .admin-create-section .grid-main > .card.sticky,
  body[data-page="admin"] .admin-create-section .grid-main > .card:not(.sticky):not(.design-card),
  body[data-page="admin"] .admin-create-section .grid-main > .design-card {
    grid-column: auto;
    grid-row: auto;
  }
}

/* ===============================
   V12 - Administration corporate structurée
   =============================== */
body.admin-v12 {
  background:
    radial-gradient(circle at 10% 0%, rgba(11,143,74,.12), transparent 30%),
    radial-gradient(circle at 90% 4%, rgba(1,69,128,.10), transparent 30%),
    linear-gradient(135deg,#f5faf7,#eef5f1 55%,#f8fbff);
}
.corporate-topbar {
  background: linear-gradient(135deg,#062817,#075331 54%,#0b8f4a);
  border-bottom: 4px solid #d8ad35;
}
.admin-shell { max-width: 1480px; }
.admin-hero {
  background: linear-gradient(135deg, rgba(5,59,34,.98), rgba(11,143,74,.94));
  color: #fff;
  border-radius: 28px;
  padding: 26px;
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  box-shadow: 0 24px 70px rgba(5,59,34,.18);
  overflow: hidden;
  position: relative;
}
.admin-hero:after {
  content: "";
  position: absolute;
  right: -60px;
  top: -80px;
  width: 230px;
  height: 230px;
  border-radius: 50%;
  border: 34px solid rgba(255,255,255,.08);
}
.admin-hero h2 { color: #fff; margin: 2px 0 6px; font-size: clamp(26px,3vw,42px); }
.admin-hero p { color: rgba(255,255,255,.86); margin: 0; max-width: 720px; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 950; color: #d8ad35 !important; margin: 0 0 4px !important; }
.hero-actions { display:flex; gap:10px; flex-wrap:wrap; position:relative; z-index:1; }
.admin-menu {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
  margin: 18px 0 22px;
}
.admin-menu-btn {
  text-decoration: none;
  border: 1px solid #dbe8df;
  background: rgba(255,255,255,.92);
  color: #12241a;
  border-radius: 22px;
  padding: 16px;
  min-height: 96px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto 1fr;
  gap: 5px 12px;
  text-align: left;
  align-items: start;
  box-shadow: 0 12px 34px rgba(5,59,34,.08);
  cursor: pointer;
  transition: .2s ease;
}
.admin-menu-btn:hover, .admin-menu-btn.active {
  transform: translateY(-2px);
  border-color: rgba(11,143,74,.45);
  box-shadow: 0 18px 48px rgba(5,59,34,.14);
  background: linear-gradient(180deg,#ffffff,#f2fff6);
}
.admin-menu-btn span {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: #eaf8ef;
  color: #053b22;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 950;
  grid-row: 1 / 3;
}
.admin-menu-btn.active span { background: #053b22; color:#fff; }
.admin-menu-btn b { font-size: 16px; color: #053b22; }
.admin-menu-btn small { color: #66756d; line-height: 1.25; }
.corporate-card { border-radius: 24px; border: 1px solid #dfeadf; box-shadow: 0 18px 50px rgba(5,59,34,.08); }
.admin-tab-panel { display: none; }
.admin-tab-panel.active { display: block; }
.badge-work-area {
  display: grid;
  grid-template-columns: minmax(360px, 520px) 1fr;
  gap: 20px;
  align-items: start;
}
.badge-work-area.hidden { display: none !important; }
#badgePreviewPanel { position: sticky; top: 18px; }
.section-title-row {
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  margin-bottom: 16px;
}
.section-title-row h2 { margin: 0; }
.form-step-card {
  background: linear-gradient(180deg,#ffffff,#f8fcf9);
  border: 1px solid #e1ece5;
  border-radius: 20px;
  padding: 16px;
  margin-bottom: 14px;
}
.form-step-card.slim { padding-bottom: 12px; }
.form-step-card h3 {
  margin: 0 0 12px;
  color: #053b22;
  font-size: 16px;
}
.align-end { justify-content: end; }
.align-end button { margin-top: auto; }
.novice-form .form-row { margin-bottom: 12px; }
.form-final-actions { margin-top: 14px; padding-top: 10px; border-top: 1px solid #e1ece5; }
.professional-actions {
  background: #f8fcf9;
  border: 1px solid #e1ece5;
  border-radius: 18px;
  padding: 10px;
  margin-bottom: 14px;
}
.filters-row { margin-bottom: 14px; }
.clean-table table { font-size: 13px; }
.clean-table th { background: #f4faf6; color:#053b22; }
.discreet-tools { margin-top: 16px; }
.discreet-tools summary { cursor: pointer; font-weight: 900; color:#053b22; }
.import-box { margin-top: 16px; }
.model-editor-grid {
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.preview-card .badge-stage { grid-template-columns: repeat(2, minmax(250px,1fr)); }
.admin-v12 .note.muted-note,
.admin-v12 .muted-note { display:none !important; }
.admin-v12 .accordion { display:block; }
.admin-v12 .layout-editor.compact { grid-template-columns: repeat(4, minmax(110px,1fr)); }
@media (max-width: 1180px) {
  .badge-work-area { grid-template-columns: 1fr; }
  #badgePreviewPanel { position: static; }
  .admin-menu { grid-template-columns: repeat(2,minmax(180px,1fr)); }
}
@media (max-width: 760px) {
  .admin-hero { align-items: flex-start; flex-direction: column; border-radius: 20px; }
  .admin-menu { grid-template-columns: 1fr; }
  .model-editor-grid { grid-template-columns: 1fr; }
  .preview-card .badge-stage { grid-template-columns: 1fr; }
}

/* ===============================
   V13 - Modèles MIABE verticaux + éditeur par glisser-déposer
   =============================== */
.admin-v13 .admin-hero {
  background: linear-gradient(135deg,#052817,#075331 52%,#0fa33d);
}
.admin-v13 .designer-panel {
  border: 1px solid rgba(16,161,61,.22);
  background: linear-gradient(180deg,#ffffff,#f7fff9);
}
.template-palette-picker {
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed #cfe4d4;
  border-radius: 16px;
  background: #fbfffc;
}
.designer-toolbar {
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-bottom: 10px;
}
.designer-help {
  margin: 0 0 12px;
  color:#53645a;
  font-size: 13px;
  line-height: 1.45;
}
.designer-drag-on .badge [data-drag-element] {
  cursor: move;
  outline: 1.5px dashed rgba(216,173,53,.85);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(216,173,53,.10);
}
.designer-drag-on .badge [data-drag-element]::after {
  content: attr(data-drag-element);
  position:absolute;
  left:0;
  top:-18px;
  font-size:10px;
  background:#053b22;
  color:#fff;
  padding:2px 5px;
  border-radius:6px;
  pointer-events:none;
  opacity:.9;
}
.designer-drag-on .badge [data-drag-element].dragging {
  outline-color:#e31b23;
  box-shadow:0 0 0 6px rgba(227,27,35,.15);
}
.badge-front.theme-purple,
.badge-back.theme-purple { --badge-primary-color:#831bb7; }
.badge-front.theme-orange,
.badge-back.theme-orange { --badge-primary-color:#f06a22; }
.badge-front.theme-yellow,
.badge-back.theme-yellow { --badge-primary-color:#f6b800; }
.badge-front.theme-teal,
.badge-back.theme-teal { --badge-primary-color:#2bb7a9; }
.badge-front.theme-purple { background: var(--template-front, none), linear-gradient(135deg,#831bb7,#a235d9); background-size: cover; background-position:center; }
.badge-front.theme-orange { background: var(--template-front, none), linear-gradient(135deg,#f06a22,#ff8b3d); background-size: cover; background-position:center; }
.badge-front.theme-yellow { background: var(--template-front, none), linear-gradient(135deg,#f6b800,#ffd84a); background-size: cover; background-position:center; }
.badge-front.theme-teal { background: var(--template-front, none), linear-gradient(135deg,#2bb7a9,#4bd0c5); background-size: cover; background-position:center; }
.badge-back.theme-purple { background: var(--template-back, none), linear-gradient(180deg,#fff,#f6eaff); background-size: cover; background-position:center; }
.badge-back.theme-orange { background: var(--template-back, none), linear-gradient(180deg,#fff,#fff1e8); background-size: cover; background-position:center; }
.badge-back.theme-yellow { background: var(--template-back, none), linear-gradient(180deg,#fff,#fff7dc); background-size: cover; background-position:center; }
.badge-back.theme-teal { background: var(--template-back, none), linear-gradient(180deg,#fff,#e6fffc); background-size: cover; background-position:center; }

/* La disposition libre V13 permet de déplacer chaque élément séparément. */
.badge-front.custom-layout,
.badge-back.custom-layout { position: relative; }
.badge-front.custom-layout .badge-inner,
.badge-back.custom-layout .back-inner { display:block !important; position:relative !important; height:100% !important; padding:0 !important; }
.badge-front.custom-layout .badge-top,
.badge-front.custom-layout .badge-body,
.badge-back.custom-layout .back-top,
.badge-back.custom-layout .back-body { display:contents !important; padding:0 !important; border:0 !important; height:auto !important; }
.badge-front.custom-layout .badge-logo {
  position:absolute !important; left:calc(var(--logo-x,50) * 1%) !important; top:calc(var(--logo-y,11) * 1%) !important;
  transform:translate(-50%,-50%) !important; width:36mm !important; height:18mm !important; object-fit:contain !important; z-index:5;
}
.badge-front.custom-layout .edition {
  display:block !important; position:absolute !important; left:calc(var(--edition-x,82) * 1%) !important; top:calc(var(--edition-y,10) * 1%) !important;
  transform:translate(-50%,-50%) !important; z-index:5; width:34mm; text-align:center; font-size:3.1mm; font-weight:950; color:#fff;
}
.badge-front.custom-layout .edition span { background:rgba(0,0,0,.22); color:#fff; }
.badge-front.custom-layout .photo-frame {
  position:absolute !important; left:calc(var(--photo-x,50) * 1%) !important; top:calc(var(--photo-y,37) * 1%) !important;
  transform:translate(-50%,-50%) !important; width:31mm !important; height:38mm !important; z-index:6; border-radius:2.8mm;
}
.badge-front.custom-layout .person { position:static !important; width:auto !important; max-width:none !important; transform:none !important; }
.badge-front.custom-layout .pass-label {
  position:absolute !important; left:calc(var(--pass-label-x,50) * 1%) !important; top:calc(var(--pass-label-y,59) * 1%) !important;
  transform:translate(-50%,-50%) !important; z-index:5; width:80%; text-align:center; font-size:4mm; letter-spacing:.08em; color:rgba(255,255,255,.9) !important;
}
.badge-front.custom-layout .person .name {
  position:absolute !important; left:calc(var(--name-x,50) * 1%) !important; top:calc(var(--name-y,66) * 1%) !important;
  transform:translate(-50%,-50%) !important; z-index:5; width:82%; text-align:center; font-size:5.8mm !important; color:#fff !important; text-shadow:0 1.8mm 3mm rgba(0,0,0,.25);
}
.badge-front.custom-layout .person .role {
  position:absolute !important; left:calc(var(--role-x,50) * 1%) !important; top:calc(var(--role-y,79) * 1%) !important;
  transform:translate(-50%,-50%) !important; z-index:5; width:86%; text-align:center; font-size:10.5mm !important; line-height:.9; font-weight:950; text-transform:uppercase; color:#fff !important; text-shadow:0 2mm 3mm rgba(0,0,0,.18);
}
.badge-front.custom-layout .badge-bottom {
  position:absolute !important; left:calc(var(--bottom-x,50) * 1%) !important; top:calc(var(--bottom-y,94) * 1%) !important;
  right:auto !important; bottom:auto !important; transform:translate(-50%,-50%) !important; z-index:5; width:94%; border-radius:2.5mm; justify-content:space-between; background:rgba(0,0,0,.42) !important;
}
.badge-front.custom-layout .badge-bottom b { color:#fff !important; }
.badge-back.custom-layout .back-top img {
  position:absolute !important; left:calc(var(--back-logo-x,28) * 1%) !important; top:calc(var(--back-logo-y,11) * 1%) !important;
  transform:translate(-50%,-50%) !important; width:36mm !important; height:18mm !important; object-fit:contain; z-index:5;
}
.badge-back.custom-layout .back-title {
  position:absolute !important; left:calc(var(--back-title-x,72) * 1%) !important; top:calc(var(--back-title-y,16) * 1%) !important;
  transform:translate(-50%,-50%) !important; width:44mm; text-align:center; z-index:5; color:#fff !important; text-shadow:0 1mm 2mm rgba(0,0,0,.2);
}
.badge-back.custom-layout .back-title span { color:#fff !important; }
.badge-back.custom-layout .rules {
  position:absolute !important; left:calc(var(--rules-x,32) * 1%) !important; top:calc(var(--rules-y,49) * 1%) !important;
  transform:translate(-50%,-50%) !important; width:54%; max-width:none !important; z-index:5; color:#fff !important; text-shadow:0 1mm 2mm rgba(0,0,0,.18); font-size:2.8mm;
}
.badge-back.custom-layout .qr-box {
  position:absolute !important; left:calc(var(--qr-x,76) * 1%) !important; top:calc(var(--qr-y,55) * 1%) !important;
  transform:translate(-50%,-50%) !important; z-index:5; width:30mm; height:30mm; background:#fff; border-color:rgba(255,255,255,.9);
}
.badge-back.custom-layout .back-footer {
  position:absolute !important; left:calc(var(--footer-x,50) * 1%) !important; top:calc(var(--footer-y,93) * 1%) !important;
  right:auto !important; bottom:auto !important; transform:translate(-50%,-50%) !important; width:92%; z-index:5; background:rgba(0,0,0,.42) !important;
}
.badge-front.has-template:before,
.badge-back.has-template:before { opacity:0 !important; }
.badge-template-layer { object-fit: fill !important; }

@media print {
  body[data-page="admin"] .topbar,
  body[data-page="admin"] .admin-hero,
  body[data-page="admin"] .admin-menu,
  body[data-page="admin"] #adminHome,
  body[data-page="admin"] #adminCreate,
  body[data-page="admin"] #adminModel,
  body[data-page="admin"] .preview-head .actions,
  body[data-page="admin"] .caption { display:none !important; }
  body[data-page="admin"] #badgePreviewPanel { display:block !important; box-shadow:none !important; border:0 !important; }
  body[data-page="admin"] #badgeExportArea { display:block !important; }
  body[data-page="admin"] .badge-item { page-break-after:always; break-after:page; display:flex; align-items:center; justify-content:center; min-height:100vh; }
}


/* ===============================
   V14 - Aperçu recto/verso distinct et sans chevauchement
   =============================== */
body.admin-v14 #badgePreviewPanel {
  overflow: hidden;
}

body.admin-v14 #badgePreviewPanel .preview-head {
  border-bottom: 1px solid #e3eee7;
  padding-bottom: 14px;
}

body.admin-v14 #badgeExportArea.badge-stage,
body.admin-v14 .preview-card .badge-stage {
  display: flex !important;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: 32px;
  padding: 18px 10px 32px;
  overflow-x: auto;
  overflow-y: visible;
}

body.admin-v14 #badgeExportArea .badge-item {
  flex: 0 0 auto;
  width: max-content;
  max-width: 100%;
  padding: 16px;
  border: 1px solid #d8e7de;
  border-radius: 22px;
  background: linear-gradient(180deg, #fbfffc, #f2f8f4);
  box-shadow: 0 14px 35px rgba(5, 59, 34, .10);
  overflow: auto;
}

body.admin-v14 #badgeExportArea .badge-item:nth-child(2) {
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}

body.admin-v14 #badgeExportArea .caption {
  position: sticky;
  top: 0;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #053b22;
  color: #ffffff;
  box-shadow: 0 8px 16px rgba(5, 59, 34, .16);
}

body.admin-v14 #badgeExportArea .caption::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f2c94c;
}

body.admin-v14 #badgeExportArea .badge {
  display: block;
  margin: 0 auto;
  flex-shrink: 0;
}

body.admin-v14 #badgePreviewPanel::after {
  content: "Astuce : si le badge est très grand, chaque face dispose de sa propre zone de défilement pour éviter le chevauchement.";
  display: block;
  margin: -14px 10px 6px;
  color: #64736a;
  font-size: 12px;
  text-align: center;
}

@media (max-width: 760px) {
  body.admin-v14 #badgeExportArea.badge-stage,
  body.admin-v14 .preview-card .badge-stage {
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 18px;
    padding-left: 4px;
    padding-right: 4px;
  }

  body.admin-v14 #badgeExportArea .badge-item {
    padding: 12px;
  }
}

@media print {
  body.admin-v14 #badgePreviewPanel::after { display: none !important; }
  body.admin-v14 #badgeExportArea .badge-item {
    padding: 0 !important;
    border: 0 !important;
    background: none !important;
    box-shadow: none !important;
    overflow: visible !important;
  }
}

/* ============================
   V15 - Éditeur complet des éléments et bibliothèque visuelle de templates
   ============================ */
body.admin-v15 .designer-panel {
  border: 1px solid #d9e8df;
  background: linear-gradient(180deg, #ffffff, #f7fbf8);
}

.design-field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.field-toggle,
.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #dbe8df;
  border-radius: 14px;
  background: #ffffff;
  color: #173a28;
  font-weight: 850;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
}

.field-toggle input,
.inline-check input { width: auto; }

.element-editor-card {
  padding: 16px;
  border: 1px solid #dbe8df;
  border-radius: 18px;
  background: #f8fcfa;
  margin: 14px 0;
}

.compact-actions { margin: 8px 0 14px; }
.advanced-position-details {
  margin-top: 14px;
  border: 1px dashed #bfd5c8;
  border-radius: 16px;
  padding: 12px;
  background: #ffffff;
}
.advanced-position-details summary {
  cursor: pointer;
  color: #064326;
  font-weight: 950;
}

.template-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.template-thumb {
  display: grid;
  gap: 8px;
  padding: 8px;
  border-radius: 15px;
  border: 1px solid #dbe8df;
  background: #ffffff;
  color: #173a28;
  box-shadow: 0 8px 18px rgba(5,59,34,.08);
}
.template-thumb img {
  width: 100%;
  aspect-ratio: 5 / 7;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,.08);
}
.template-thumb span { font-size: 12px; font-weight: 950; }
.template-thumb:hover { transform: translateY(-2px); border-color: #10a13d; }

.hidden-field { display: none !important; }

.badge.custom-layout .badge-inner,
.badge-back.custom-layout .back-inner {
  display: block !important;
  position: relative !important;
  height: 100% !important;
  z-index: 2;
}

.badge-front.custom-layout .badge-top,
.badge-front.custom-layout .badge-body,
.badge-back.custom-layout .back-top,
.badge-back.custom-layout .back-body {
  position: static !important;
  display: block !important;
  padding: 0 !important;
  height: auto !important;
}

.badge-front.custom-layout .person {
  position: static !important;
  width: auto !important;
  max-width: none !important;
}

.badge-front.custom-layout .badge-logo,
.badge-front.custom-layout [data-drag-element="edition"],
.badge-front.custom-layout [data-drag-element="photo"],
.badge-front.custom-layout [data-drag-element="passLabel"],
.badge-front.custom-layout [data-drag-element="name"],
.badge-front.custom-layout [data-drag-element="role"],
.badge-front.custom-layout [data-drag-element="bottom"],
.badge-front.custom-layout [data-drag-element="customText"],
.badge-back.custom-layout [data-drag-element="backLogo"],
.badge-back.custom-layout [data-drag-element="backTitle"],
.badge-back.custom-layout [data-drag-element="rules"],
.badge-back.custom-layout [data-drag-element="qr"],
.badge-back.custom-layout [data-drag-element="footer"],
.badge-back.custom-layout [data-drag-element="customBackText"] {
  position: absolute !important;
  z-index: 5;
  transform: translate(-50%, -50%);
}

.badge-front.custom-layout .badge-logo {
  left: calc(var(--logo-x, 50) * 1%);
  top: calc(var(--logo-y, 11) * 1%);
  width: calc(28mm * var(--logo-scale, 1));
  height: calc(16mm * var(--logo-scale, 1));
}
.badge-front.custom-layout [data-drag-element="edition"] {
  display: block !important;
  left: calc(var(--edition-x, 82) * 1%);
  top: calc(var(--edition-y, 10) * 1%);
  font-size: calc(2.7mm * var(--edition-scale, 1));
  min-width: 28mm;
}
.badge-front.custom-layout [data-drag-element="photo"] {
  left: calc(var(--photo-x, 50) * 1%);
  top: calc(var(--photo-y, 37) * 1%);
  width: calc(28mm * var(--photo-scale, 1));
  height: calc(34mm * var(--photo-scale, 1));
}
.badge-front.custom-layout [data-drag-element="passLabel"] {
  left: calc(var(--pass-label-x, 50) * 1%);
  top: calc(var(--pass-label-y, 59) * 1%);
  font-size: calc(3.5mm * var(--pass-label-scale, 1));
  width: 90%;
  text-align: center;
}
.badge-front.custom-layout [data-drag-element="name"] {
  left: calc(var(--name-x, 50) * 1%);
  top: calc(var(--name-y, 66) * 1%);
  font-size: calc(6.5mm * var(--name-scale, 1));
  width: 90%;
  max-width: 90%;
  text-align: center;
}
.badge-front.custom-layout [data-drag-element="role"] {
  left: calc(var(--role-x, 50) * 1%);
  top: calc(var(--role-y, 79) * 1%);
  font-size: calc(3.4mm * var(--role-scale, 1));
  width: 90%;
  max-width: 90%;
  text-align: center;
}
.badge-front.custom-layout [data-drag-element="bottom"] {
  left: calc(var(--bottom-x, 50) * 1%);
  top: calc(var(--bottom-y, 94) * 1%);
  bottom: auto !important;
  right: auto !important;
  width: 92%;
  font-size: calc(2.6mm * var(--bottom-scale, 1));
}

.custom-text {
  padding: 1.5mm 3mm;
  border-radius: 99px;
  background: rgba(0,0,0,.32);
  color: var(--badge-text-color, #ffffff);
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .04em;
  text-align: center;
  white-space: pre-line;
  max-width: 85%;
  line-height: 1.1;
}
.badge-front.custom-layout [data-drag-element="customText"] {
  left: calc(var(--custom-text-x, 50) * 1%);
  top: calc(var(--custom-text-y, 87) * 1%);
  font-size: calc(3.2mm * var(--custom-text-scale, 1));
}

.badge-back.custom-layout [data-drag-element="backLogo"] {
  left: calc(var(--back-logo-x, 28) * 1%);
  top: calc(var(--back-logo-y, 11) * 1%);
  width: calc(30mm * var(--back-logo-scale, 1));
  height: calc(17mm * var(--back-logo-scale, 1));
  object-fit: contain;
}
.badge-back.custom-layout [data-drag-element="backTitle"] {
  left: calc(var(--back-title-x, 72) * 1%);
  top: calc(var(--back-title-y, 16) * 1%);
  font-size: calc(4mm * var(--back-title-scale, 1));
  min-width: 30mm;
}
.badge-back.custom-layout [data-drag-element="rules"] {
  left: calc(var(--rules-x, 32) * 1%);
  top: calc(var(--rules-y, 49) * 1%);
  font-size: calc(2.5mm * var(--rules-scale, 1));
  width: 55%;
  max-width: 60%;
}
.badge-back.custom-layout [data-drag-element="qr"] {
  left: calc(var(--qr-x, 76) * 1%);
  top: calc(var(--qr-y, 55) * 1%);
  width: calc(28mm * var(--qr-scale, 1));
  height: calc(28mm * var(--qr-scale, 1));
}
.badge-back.custom-layout [data-drag-element="qr"] canvas,
.badge-back.custom-layout [data-drag-element="qr"] img {
  max-width: 100% !important;
  max-height: 100% !important;
}
.badge-back.custom-layout [data-drag-element="footer"] {
  left: calc(var(--footer-x, 50) * 1%);
  top: calc(var(--footer-y, 93) * 1%);
  bottom: auto !important;
  right: auto !important;
  width: 92%;
  font-size: calc(2.3mm * var(--footer-scale, 1));
}
.badge-back.custom-layout [data-drag-element="customBackText"] {
  left: calc(var(--custom-back-text-x, 50) * 1%);
  top: calc(var(--custom-back-text-y, 78) * 1%);
  font-size: calc(3mm * var(--custom-back-text-scale, 1));
}

.designer-drag-on [data-drag-element] {
  outline: 2px dashed rgba(242, 201, 76, .92);
  outline-offset: 2px;
  cursor: grab;
}
.designer-drag-on [data-drag-element].dragging {
  cursor: grabbing;
  outline-color: #e52c21;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,.22));
}

body.admin-v15 #badgePreviewPanel::after {
  content: "" !important;
  display: none !important;
}

/* ===============================
   V16 - Administration compacte et navigation haute
   =============================== */
body.admin-v16 .corporate-topbar,
body.admin-v16 .admin-compact-topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 3px solid #d8ad35;
  box-shadow: 0 10px 28px rgba(5,59,34,.16);
}
body.admin-v16 .topbar-inner {
  min-height: 68px;
  gap: 14px;
}
body.admin-v16 .compact-brand .logo {
  width: 92px;
  max-height: 52px;
  object-fit: contain;
}
body.admin-v16 .admin-top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  width: auto;
}
body.admin-v16 .top-nav-btn {
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(255,255,255,.12);
  color: #fff;
  text-decoration: none;
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13px;
  line-height: 1;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  box-shadow: none;
}
body.admin-v16 .top-nav-btn:hover,
body.admin-v16 .top-nav-btn.active {
  background: #ffffff;
  color: #053b22;
  transform: translateY(-1px);
}
body.admin-v16 .top-nav-btn.danger {
  background: rgba(227,27,35,.95);
  border-color: rgba(255,255,255,.2);
  color: #fff;
}
body.admin-v16 .top-nav-btn.danger:hover { background:#fff; color:#b51018; }
body.admin-v16 .account-chip {
  color: #e9fff0;
  background: rgba(0,0,0,.22);
  border: 1px solid rgba(255,255,255,.14);
  padding: 8px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.admin-v16 .admin-menu,
body.admin-v16 .admin-hero,
body.admin-v16 .brand-block h1,
body.admin-v16 .brand-block .subtitle,
body.admin-v16 .preview-helper,
body.admin-v16 .designer-help:not(.compact-hint) {
  display: none !important;
}
body.admin-v16 .container.admin-shell {
  max-width: 1500px;
  padding-top: 18px;
}
body.admin-v16 .card,
body.admin-v16 .corporate-card {
  border-radius: 18px;
  box-shadow: 0 12px 34px rgba(5,59,34,.07);
}
body.admin-v16 .card { padding: 16px; }
body.admin-v16 .preview-head {
  gap: 10px;
  margin-bottom: 12px;
}
body.admin-v16 h2 { font-size: 20px; margin-bottom: 6px !important; }
body.admin-v16 h3 { font-size: 14px !important; margin-bottom: 8px !important; }
body.admin-v16 .form-step-card {
  padding: 12px;
  margin-bottom: 10px;
  border-radius: 16px;
}
body.admin-v16 .form-row { margin-bottom: 8px !important; }
body.admin-v16 label { font-size: 11px; margin-bottom: 5px; }
body.admin-v16 input,
body.admin-v16 select,
body.admin-v16 textarea {
  padding: 9px 10px;
  border-radius: 11px;
  font-size: 13px;
}
body.admin-v16 .actions,
body.admin-v16 .compact-actions {
  gap: 7px;
  margin-top: 8px;
}
body.admin-v16 button,
body.admin-v16 .file-btn,
body.admin-v16 .btn-primary,
body.admin-v16 .btn-secondary,
body.admin-v16 .btn-red,
body.admin-v16 .btn-gold {
  padding: 9px 11px;
  border-radius: 11px;
  font-size: 12px;
  min-height: 34px;
}
body.admin-v16 .badge-work-area {
  grid-template-columns: minmax(330px, 480px) minmax(520px, 1fr);
  gap: 14px;
}
body.admin-v16 #badgePreviewPanel {
  top: 84px;
  max-height: calc(100vh - 96px);
  overflow: auto;
}
body.admin-v16 .model-editor-grid {
  grid-template-columns: 1fr;
  gap: 10px;
}
body.admin-v16 .template-palette-picker,
body.admin-v16 .element-editor-card,
body.admin-v16 .designer-panel {
  padding: 10px;
  border-radius: 14px;
}
body.admin-v16 .template-library-grid {
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 8px;
}
body.admin-v16 .template-thumb { padding: 6px; border-radius: 12px; }
body.admin-v16 .template-thumb span { font-size: 11px; }
body.admin-v16 .design-field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 6px;
}
body.admin-v16 .field-toggle {
  padding: 7px 8px;
  border-radius: 10px;
  background: #f7fbf8;
  border: 1px solid #dfeadf;
  font-size: 12px;
}
body.admin-v16 .designer-toolbar { gap: 7px; margin-bottom: 8px; }
body.admin-v16 .compact-hint {
  display: block !important;
  font-size: 12px;
  margin: 0 0 8px !important;
  color: #54645c;
}
body.admin-v16 .badge-stage {
  gap: 22px;
  align-items: start;
}
body.admin-v16 .badge-item {
  background: #f8faf9;
  border: 1px solid #dfeadf;
  border-radius: 18px;
  padding: 14px;
  overflow: auto;
}
body.admin-v16 .caption {
  font-size: 12px;
  margin-bottom: 8px;
}
body.admin-v16 .bulk-bar { padding: 8px; gap: 6px; }
body.admin-v16 table th,
body.admin-v16 table td { padding: 7px 8px !important; font-size: 12px; }
body.admin-v16 .layout-editor.compact { max-height: 190px; }

/* Meilleur contrôle des éléments du modèle */
body.admin-v16 .badge [data-drag-element] {
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
}
body.admin-v16 .badge img[data-drag-element],
body.admin-v16 .badge-logo[data-drag-element] {
  pointer-events: auto !important;
  object-fit: contain;
}
body.admin-v16 .designer-drag-on .badge [data-drag-element] {
  outline: 2px dashed rgba(216,173,53,.95) !important;
  outline-offset: 2px;
}
body.admin-v16 .designer-drag-on .badge [data-drag-element]:hover {
  box-shadow: 0 0 0 5px rgba(216,173,53,.12);
}
body.admin-v16 .designer-drag-on .badge [data-drag-element].dragging {
  opacity: .92;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,.28));
}

@media (max-width: 1180px) {
  body.admin-v16 .badge-work-area { grid-template-columns: 1fr; }
  body.admin-v16 #badgePreviewPanel { position: static; max-height: none; }
}
@media (max-width: 820px) {
  body.admin-v16 .topbar-inner { align-items: flex-start; }
  body.admin-v16 .admin-top-actions { justify-content: flex-start; }
  body.admin-v16 .top-nav-btn { padding: 8px 10px; font-size: 12px; }
  body.admin-v16 .account-chip { width: 100%; max-width: none; }
}

/* ============================
   V17 - Intégration fonds/logos officiels, menu haut et interface compacte
   ============================ */
body.admin-v17 .topbar.auth-only.hidden { display: none !important; }
body.admin-v17 .corporate-topbar {
  padding: 9px 14px;
  border-bottom: 3px solid rgba(255,255,255,.18);
  box-shadow: 0 14px 30px rgba(5,59,34,.16);
}
body.admin-v17 .topbar-inner { gap: 10px; align-items: center; }
body.admin-v17 .compact-brand .logo,
body.admin-v17 .logo {
  width: 74px;
  height: 38px;
  padding: 4px 6px;
  border-radius: 10px;
  background: rgba(0,0,0,.18);
  border-color: rgba(255,255,255,.18);
}
body.admin-v17 .admin-top-actions { gap: 6px; align-items: center; }
body.admin-v17 .top-nav-btn,
body.admin-v17 .account-chip {
  min-height: 34px;
  padding: 8px 11px !important;
  border-radius: 999px !important;
  font-size: 12px !important;
  white-space: nowrap;
}
body.admin-v17 .top-nav-btn.active {
  background: #fff !important;
  color: var(--green-deep) !important;
  border-color: #fff !important;
}
body.admin-v17 .account-chip {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.22);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.admin-v17 .container { margin-top: 14px; margin-bottom: 26px; }
body.admin-v17 .card { border-radius: 18px; padding: 14px; }
body.admin-v17 .preview-head { margin-bottom: 10px; }
body.admin-v17 h2 { font-size: 18px; margin-bottom: 8px; }
body.admin-v17 h3 { font-size: 15px; margin-bottom: 8px; }
body.admin-v17 .note, body.admin-v17 .hint { font-size: 11px; }
body.admin-v17 input, body.admin-v17 select, body.admin-v17 textarea { padding: 9px 10px; border-radius: 10px; font-size: 13px; }
body.admin-v17 label { font-size: 11px; margin-bottom: 4px; }
body.admin-v17 .actions { gap: 6px; margin-top: 8px; }
body.admin-v17 button, body.admin-v17 .file-btn { padding: 8px 10px; border-radius: 10px; font-size: 12px; }
body.admin-v17 .form-row { margin-bottom: 9px; }
body.admin-v17 .form-step-card { padding: 12px; border-radius: 15px; margin-bottom: 10px; }
body.admin-v17 .model-editor-grid { gap: 10px; }
body.admin-v17 .designer-panel { padding: 12px; }
body.admin-v17 .designer-toolbar { gap: 6px; }
body.admin-v17 .element-editor-card { padding: 10px; border-radius: 14px; }
body.admin-v17 .badge-work-area { gap: 14px; }
body.admin-v17 #badgePreviewPanel { top: 74px; }
body.admin-v17 .badge-stage { gap: 16px; padding: 8px 0 14px; }
body.admin-v17 .badge-item { padding: 10px; border-radius: 14px; }
body.admin-v17 .home-list-card { margin-top: 0; }
body.admin-v17.home-view #adminHome .dashboard-card { display: none !important; }
body.admin-v17.dashboard-view #adminHome .home-list-card,
body.admin-v17.dashboard-view #adminHome .discreet-tools { display: none !important; }
body.admin-v17.dashboard-view #adminHome .dashboard-card { display: block !important; }
body.admin-v17 .template-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px;
}
body.admin-v17 .template-thumb {
  border: 2px solid #d8e8de;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  padding: 4px;
}
body.admin-v17 .template-thumb img { height: 132px; object-fit: cover; border-radius: 10px; }
body.admin-v17 .template-thumb.selected,
body.admin-v17 .template-thumb:focus-visible {
  border-color: #f4c542;
  box-shadow: 0 0 0 4px rgba(244,197,66,.20);
}
body.admin-v17 .template-thumb span { display:block; padding: 5px 0 2px; font-size: 11px; }
body.admin-v17 .badge-template-layer {
  object-fit: fill !important;
  width: 100% !important;
  height: 100% !important;
}
body.admin-v17 .badge-front.has-template,
body.admin-v17 .badge-back.has-template { background: #fff !important; }
body.admin-v17 .badge.has-template::before,
body.admin-v17 .badge.has-template::after { display: none !important; }
body.admin-v17 .badge-logo,
body.admin-v17 .back-top img,
body.admin-v17 [data-drag-element="backLogo"] { object-fit: contain !important; }
body.admin-v17 .badge-front.custom-layout .badge-logo {
  width: calc(38mm * var(--logo-scale, 1)) !important;
  height: calc(18mm * var(--logo-scale, 1)) !important;
  max-width: 95% !important;
  transform: translate(-50%, -50%) !important;
}
body.admin-v17 .badge-back.custom-layout [data-drag-element="backLogo"] {
  width: calc(36mm * var(--back-logo-scale, 1)) !important;
  height: calc(17mm * var(--back-logo-scale, 1)) !important;
}
body.admin-v17 .designer-drag-on .badge [data-drag-element] {
  outline: 2px dashed #ffd24d !important;
  background-color: rgba(255,210,77,.05);
}
body.admin-v17 .designer-drag-on .badge [data-drag-element]::after {
  content: "" !important;
  position: absolute;
  inset: -6px;
}
body.admin-v17 .badge [data-drag-element].dragging { opacity: .9; }
body.admin-v17 .clean-table { max-height: calc(100vh - 310px); }
body.admin-v17 table th, body.admin-v17 table td { padding: 6px 7px !important; }

@media (max-width: 980px) {
  body.admin-v17 .topbar-inner { align-items: flex-start; }
  body.admin-v17 .admin-top-actions { width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  body.admin-v17 .account-chip { display: none !important; }
}

/* ============================
   V18 - Connexion directement sur index.html
   ============================ */
.login-page {
  min-height: 100vh;
  padding: 18px;
}
.login-hero {
  width: min(620px, 100%);
  padding: 28px 22px;
}
.login-logo {
  width: min(230px, 74vw);
  margin-bottom: 12px;
}
.home-login-card {
  width: min(440px, 100%);
  margin: 0 auto;
  background: rgba(255,255,255,.94);
  color: var(--green-deep);
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 24px;
  padding: 20px;
  text-align: left;
  box-shadow: 0 22px 46px rgba(0,0,0,.18);
}
.home-login-card h1 {
  margin: 0 0 6px;
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1;
  color: var(--green-deep);
  text-align: center;
}
.login-subtitle {
  margin: 0 0 16px !important;
  color: #52645a !important;
  font-size: 13px !important;
  text-align: center;
  line-height: 1.45 !important;
}
.home-login-form {
  display: grid;
  gap: 12px;
}
.home-login-form .form-row {
  margin: 0;
}
.home-login-form label {
  color: #244c33;
}
.home-login-form input {
  min-height: 46px;
  border-radius: 14px;
  font-size: 15px;
}
.login-submit-btn {
  width: 100%;
  min-width: 0 !important;
  min-height: 50px !important;
  background: linear-gradient(135deg, #064225, #11a452) !important;
  border: 0 !important;
  color: #fff !important;
  font-size: 17px !important;
}
.login-submit-btn:disabled {
  opacity: .7;
  cursor: wait;
}
.home-auth-message {
  margin: 0 !important;
  min-height: 20px;
  font-size: 13px !important;
  text-align: center;
  color: var(--red) !important;
}
.home-auth-message.ok {
  color: #06783e !important;
}
.home-auth-message.err {
  color: var(--red) !important;
}
.compact-home-actions {
  margin-top: 16px;
  gap: 10px;
}
.compact-home-actions .home-scan-btn {
  width: min(440px, 100%);
  min-width: 0 !important;
  min-height: 52px;
  font-size: clamp(18px, 4vw, 24px);
}
@media (max-width: 560px) {
  .login-page { padding: 12px; }
  .login-hero { padding: 20px 14px; border-radius: 24px; }
  .home-login-card { padding: 16px; border-radius: 20px; }
}
