/* ==========================================================================
   Galaxie Cartes — design system (mobile d'abord)
   ========================================================================== */
:root {
  --night-1: #070d2b;
  --night-2: #0f1d57;
  --night-3: #1c3494;
  --brand: #2f55e4;
  --brand-2: #5b8cff;
  --brand-soft: #e8eeff;
  --star: #ffd84d;
  --bg: #f3f5fb;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --text: #121833;
  --muted: #5d6685;
  --border: #e2e6f1;
  --ok: #12925b; --ok-soft: #e3f6ec;
  --wait: #b86e00; --wait-soft: #fff3dc;
  --rej: #d33a2c; --rej-soft: #fde8e6;
  --print: #3651d4; --print-soft: #e7ebff;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 64, .06), 0 1px 3px rgba(16, 24, 64, .06);
  --shadow: 0 10px 30px -12px rgba(16, 24, 64, .25);
  --shadow-lg: 0 30px 60px -20px rgba(7, 13, 43, .45);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --sidebar: 264px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; font: 15px/1.55 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
img { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: clamp(22px, 4vw, 28px); font-weight: 800; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.mt { margin-top: 16px; } .mt-lg { margin-top: 28px; } .mb { margin-bottom: 16px; } .mb-0 { margin-bottom: 0; }

.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 28px; height: 28px; }

/* ---------- Fond étoilé (pages publiques) ---------- */
.space {
  min-height: 100vh; min-height: 100dvh; color: #fff; position: relative; overflow-x: hidden;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(91, 140, 255, .35), transparent 60%),
              radial-gradient(900px 500px at -10% 110%, rgba(255, 216, 77, .12), transparent 60%),
              linear-gradient(160deg, var(--night-1), var(--night-2) 55%, var(--night-3));
}
.space::before, .space::after {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 20px 30px, #fff, transparent),
    radial-gradient(1px 1px at 90px 120px, #fff, transparent),
    radial-gradient(1.2px 1.2px at 160px 60px, #cfe0ff, transparent),
    radial-gradient(1px 1px at 230px 160px, #fff, transparent),
    radial-gradient(1.6px 1.6px at 300px 40px, #ffe9a1, transparent),
    radial-gradient(1px 1px at 350px 210px, #fff, transparent);
  background-size: 380px 260px; opacity: .55; animation: twinkle 6s ease-in-out infinite alternate;
}
.space::after { background-size: 520px 340px; background-position: 130px 90px; opacity: .35; animation-delay: -3s; }
@keyframes twinkle { from { opacity: .2; } to { opacity: .65; } }
.space > * { position: relative; z-index: 1; }
.space a:not(.btn) { color: #cfe0ff; }
.space .btn-star { color: var(--night-1); }

.orbit { position: absolute; border: 1px solid rgba(255,255,255,.08); border-radius: 50%; pointer-events: none; }

/* ---------- Boutons ---------- */
.btn {
  --b: var(--brand); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 12px; border: 1px solid transparent;
  font: 600 15px/1.2 var(--font); cursor: pointer; text-decoration: none !important; white-space: nowrap;
  transition: transform .15s var(--ease), box-shadow .2s var(--ease), background .2s, opacity .2s; position: relative;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: 3px solid rgba(47, 85, 228, .35); outline-offset: 2px; }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--brand), #4b3fe0); box-shadow: 0 8px 20px -8px rgba(47, 85, 228, .7); }
.btn-primary:hover { box-shadow: 0 12px 26px -8px rgba(47, 85, 228, .8); }
.btn-star { color: var(--night-1); background: linear-gradient(135deg, #ffe37a, var(--star)); box-shadow: 0 10px 30px -10px rgba(255, 216, 77, .8); }
.btn-success { color: #fff; background: linear-gradient(135deg, #16a567, #0e8a54); box-shadow: 0 8px 20px -8px rgba(18, 146, 91, .7); }
.btn-danger { color: #fff; background: linear-gradient(135deg, #e5483a, #c22d20); box-shadow: 0 8px 20px -8px rgba(211, 58, 44, .6); }
.btn-ghost { color: var(--text); background: var(--surface); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-glass { color: #fff; background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.22); backdrop-filter: blur(8px); }
.btn-glass:hover { background: rgba(255,255,255,.18); }
.btn-link { background: none; color: var(--brand); padding: 6px 8px; min-height: 0; }
.btn-sm { min-height: 36px; padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn-lg { min-height: 54px; padding: 14px 26px; font-size: 16px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; min-height: 40px; padding: 0; }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; box-shadow: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .7s linear infinite;
}
.btn-ghost.is-loading::after { border-color: rgba(18,24,51,.2); border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Formulaires ---------- */
.field { display: block; margin-bottom: 16px; }
.field > label, .label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field .req { color: var(--rej); }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 12px 14px; font: 16px/1.3 var(--font); color: var(--text);
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px;
  transition: border-color .2s, box-shadow .2s; -webkit-appearance: none; appearance: none;
}
.select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%235d6685' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px; }
.textarea { min-height: 110px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(47, 85, 228, .12); }
.input.upper { text-transform: uppercase; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--rej); background: #fffafa; }
.field.is-valid .input { border-color: #9fdcbf; }
.error { color: var(--rej); font-size: 13px; margin-top: 6px; display: flex; gap: 6px; align-items: flex-start; }
.error:empty { display: none; }
.hint { color: var(--muted); font-size: 13px; margin-top: 6px; }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 48px; }
.input-wrap .suffix { position: absolute; right: 4px; top: 4px; bottom: 4px; width: 40px; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 10px; display: grid; place-items: center; }
.input-wrap .suffix:hover { background: var(--surface-2); color: var(--text); }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon .input { padding-left: 44px; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; padding: 5px; background: var(--surface-2); border: 1.5px solid var(--border); border-radius: 14px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label { margin: 0; min-height: 40px; display: flex; align-items: center; justify-content: center; gap: 8px; border-radius: 10px; cursor: pointer; font-weight: 600; color: var(--muted); transition: all .2s var(--ease); }
.segmented input:checked + label { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + label { outline: 2px solid var(--brand); }

.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; font-size: 14px; }
.check input { width: 22px; height: 22px; accent-color: var(--brand); flex: none; margin: 1px 0 0; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 48px; height: 28px; border-radius: 99px; background: #cfd5e6; position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .25s var(--ease); }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(20px); }

/* ---------- Cartes / surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card.flush { padding: 0; overflow: hidden; }
.glass { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.16); border-radius: 22px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.panel { background: var(--surface); color: var(--text); border-radius: 24px; box-shadow: var(--shadow-lg); padding: 24px; }
@media (min-width: 640px) { .panel { padding: 32px; } }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 99px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge-wait { color: var(--wait); background: var(--wait-soft); }
.badge-ok { color: var(--ok); background: var(--ok-soft); }
.badge-rej { color: var(--rej); background: var(--rej-soft); }
.badge-print { color: var(--print); background: var(--print-soft); }
.badge-muted { color: var(--muted); background: var(--surface-2); }
.badge-wait::before { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; transform: scale(.7); } }

/* ---------- Alertes ---------- */
.alert { display: flex; gap: 12px; padding: 14px 16px; border-radius: 14px; border: 1px solid; font-size: 14.5px; align-items: flex-start; }
.alert .icon { margin-top: 1px; }
.alert-info { background: var(--brand-soft); border-color: #cdd8ff; color: #23398f; }
.alert-warn { background: var(--wait-soft); border-color: #f5d9a5; color: #7a4a00; }
.alert-err { background: var(--rej-soft); border-color: #f6c3bd; color: #8e2118; }
.alert-ok { background: var(--ok-soft); border-color: #b6e6cd; color: #0b5e3a; }

/* ---------- Coquille de l'application (authentifié) ---------- */
.shell { min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 40; display: none; flex-direction: column;
  color: #dfe6ff; padding: 22px 16px; overflow-y: auto;
  background: radial-gradient(500px 300px at 0 0, rgba(91,140,255,.25), transparent 70%), linear-gradient(180deg, var(--night-1), var(--night-2));
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; font-weight: 800; font-size: 17px; letter-spacing: -.01em; padding: 0 8px 20px; text-decoration: none !important; }
.brand img { width: 40px; height: 47px; filter: drop-shadow(0 4px 10px rgba(0,0,0,.35)); }
.brand small { display: block; font-weight: 500; font-size: 12px; color: #9fb0e6; letter-spacing: .02em; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: #7f8fc6; margin: 18px 12px 6px; font-weight: 700; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; color: #c9d3f5; font-weight: 600; text-decoration: none; transition: background .2s, color .2s; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: linear-gradient(135deg, rgba(91,140,255,.35), rgba(91,140,255,.12)); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.1); }
.nav a .count { margin-left: auto; background: var(--star); color: var(--night-1); font-size: 12px; font-weight: 800; padding: 1px 8px; border-radius: 99px; }
.sidebar .me { margin-top: auto; display: flex; gap: 10px; align-items: center; padding: 14px 10px 0; border-top: 1px solid rgba(255,255,255,.1); }
.avatar { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 14px; color: var(--night-1); background: linear-gradient(135deg, #ffe37a, #ffc93d); flex: none; }
.me .who { flex: 1; min-width: 0; font-size: 13px; line-height: 1.3; }
.me .who b { display: block; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me .who span { color: #8d9bd0; }
.me button { background: rgba(255,255,255,.08); border: 0; color: #dfe6ff; width: 38px; height: 38px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.me button:hover { background: rgba(255,255,255,.16); }

.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: linear-gradient(135deg, var(--night-1), var(--night-2)); color: #fff;
}
.topbar .brand { padding: 0; font-size: 15px; }
.topbar .brand img { width: 30px; height: 35px; }
.topbar .spacer { flex: 1; }
.topbar .avatar { width: 34px; height: 34px; font-size: 13px; }

.main { padding: 18px 16px 110px; max-width: 1240px; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin: 4px 0 0; }
.crumb { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; font-size: 14px; margin-bottom: 8px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: rgba(255,255,255,.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border); padding: 6px 6px max(6px, env(safe-area-inset-bottom));
}
.tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px; color: var(--muted); font-size: 11.5px; font-weight: 700; text-decoration: none; border-radius: 12px; position: relative; background: none; border: 0; font-family: var(--font); cursor: pointer; }
.tabbar a.active { color: var(--brand); }
.tabbar a.active .icon { transform: translateY(-1px); }
.tabbar a.active::before { content: ""; position: absolute; top: -7px; width: 28px; height: 3px; border-radius: 0 0 4px 4px; background: var(--brand); }
.tabbar .dot { position: absolute; top: 3px; right: calc(50% - 20px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--rej); color: #fff; font-size: 10.5px; display: grid; place-items: center; }

@media (min-width: 1024px) {
  .sidebar { display: flex; }
  .topbar, .tabbar { display: none; }
  .shell { padding-left: var(--sidebar); }
  .main { padding: 32px 36px 60px; }
}

/* ---------- KPI ---------- */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; position: relative; overflow: hidden; box-shadow: var(--shadow-sm); }
.kpi .k-label { color: var(--muted); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.kpi .k-value { font-size: clamp(24px, 4vw, 30px); font-weight: 800; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 12.5px; color: var(--muted); }
.kpi .k-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.kpi.wait .k-ico { background: var(--wait-soft); color: var(--wait); }
.kpi.ok .k-ico { background: var(--ok-soft); color: var(--ok); }
.kpi.rej .k-ico { background: var(--rej-soft); color: var(--rej); }
.kpi.print .k-ico { background: var(--print-soft); color: var(--print); }
.kpi.hero { color: #fff; border: 0; background: radial-gradient(300px 200px at 100% 0, rgba(255,216,77,.25), transparent 70%), linear-gradient(135deg, var(--night-2), var(--brand)); }
.kpi.hero .k-label, .kpi.hero .k-sub { color: #c8d4ff; }
.kpi.hero .k-ico { background: rgba(255,255,255,.14); color: var(--star); }

/* ---------- Filtres / chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 99px; border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font-weight: 700; font-size: 14px; cursor: pointer; white-space: nowrap; transition: all .2s var(--ease); font-family: var(--font); }
.chip .n { font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.active { background: var(--night-2); border-color: var(--night-2); color: #fff; }
.chip.active .n { background: rgba(255,255,255,.18); color: #fff; }
.chip:hover:not(.active) { border-color: #c7cee3; }
.motif-chip { font-weight: 600; font-size: 13px; padding: 7px 12px; }
.motif-chip.active { background: var(--rej); border-color: var(--rej); }

.toolbar { display: grid; gap: 10px; grid-template-columns: 1fr; margin-bottom: 14px; }
@media (min-width: 760px) { .toolbar { grid-template-columns: 1fr 220px 220px; } }

/* ---------- Liste des demandes ---------- */
.list { display: grid; gap: 10px; }
.item {
  display: grid; grid-template-columns: auto 52px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; color: var(--text); text-decoration: none !important;
  transition: transform .15s var(--ease), box-shadow .2s var(--ease), border-color .2s; animation: rise .35s var(--ease) both;
}
.item:hover { box-shadow: var(--shadow); border-color: #cfd6ea; transform: translateY(-1px); }
.item .thumb { width: 52px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--surface-2); }
.item .title { font-weight: 700; line-height: 1.25; }
.item .meta { color: var(--muted); font-size: 13px; display: flex; gap: 6px 12px; flex-wrap: wrap; margin-top: 3px; }
.item .meta span { display: inline-flex; align-items: center; gap: 4px; }
.item .end { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.item .sel { width: 22px; height: 22px; accent-color: var(--brand); }
.item.no-sel { grid-template-columns: 52px 1fr auto; }
.item.locked { background: repeating-linear-gradient(135deg, #fff, #fff 10px, #fafbff 10px, #fafbff 20px); }
.lock-tag { font-size: 12px; color: var(--muted); display: inline-flex; gap: 4px; align-items: center; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.list .item:nth-child(2) { animation-delay: .03s; } .list .item:nth-child(3) { animation-delay: .06s; }
.list .item:nth-child(4) { animation-delay: .09s; } .list .item:nth-child(5) { animation-delay: .12s; }
@media (max-width: 480px) { .item .end .badge { font-size: 11.5px; padding: 3px 8px; } }

.skeleton { background: linear-gradient(90deg, #eceff7 25%, #f6f7fb 37%, #eceff7 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 14px; height: 88px; }
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ill { width: 84px; height: 84px; margin: 0 auto 14px; border-radius: 26px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.empty h3 { color: var(--text); }

.pager { display: flex; gap: 6px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.pager a, .pager span { min-width: 40px; height: 40px; display: grid; place-items: center; padding: 0 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 700; text-decoration: none; }
.pager .cur { background: var(--night-2); color: #fff; border-color: var(--night-2); }
.pager .off { opacity: .4; }

.selbar {
  position: fixed; left: 50%; transform: translate(-50%, 140%); bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 36;
  display: flex; gap: 10px; align-items: center; padding: 10px 10px 10px 18px; border-radius: 18px; color: #fff;
  background: var(--night-1); box-shadow: var(--shadow-lg); transition: transform .35s var(--ease); width: min(560px, calc(100% - 24px));
}
.selbar.show { transform: translate(-50%, 0); }
.selbar .txt { flex: 1; font-weight: 700; }
@media (min-width: 1024px) { .selbar { bottom: 24px; left: calc(50% + var(--sidebar) / 2); } }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 12px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: #fafbff; }
@media (max-width: 760px) {
  .table.stack-sm thead { display: none; }
  .table.stack-sm, .table.stack-sm tbody, .table.stack-sm tr, .table.stack-sm td { display: block; width: 100%; }
  .table.stack-sm tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .table.stack-sm td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; }
  .table.stack-sm td[data-l]::before { content: attr(data-l); color: var(--muted); font-size: 12.5px; font-weight: 600; }
  .table.stack-sm td.full { display: block; }
}

/* ---------- Définitions (fiche demande) ---------- */
.dl { display: grid; grid-template-columns: 1fr; gap: 0; }
.dl > div { display: grid; grid-template-columns: 130px 1fr; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--border); }
.dl > div:last-child { border-bottom: 0; }
.dl dt { color: var(--muted); font-size: 13.5px; font-weight: 600; }
.dl dd { margin: 0; font-weight: 700; word-break: break-word; }
@media (min-width: 760px) { .dl.cols { grid-template-columns: 1fr 1fr; column-gap: 28px; } }

.photo-xl { width: 100%; max-width: 320px; aspect-ratio: 35.5 / 43.7; object-fit: cover; border-radius: 18px; background: var(--surface-2); box-shadow: var(--shadow); cursor: zoom-in; margin: 0 auto; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 18px 30px; }
.timeline li::before { content: ""; position: absolute; left: 9px; top: 20px; bottom: -2px; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .dot { position: absolute; left: 0; top: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border); display: grid; place-items: center; }
.timeline .dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #c9cfe0; }
.timeline li.done .dot { border-color: var(--ok); } .timeline li.done .dot::after { background: var(--ok); }
.timeline li.now .dot { border-color: var(--brand); box-shadow: 0 0 0 5px rgba(47,85,228,.12); } .timeline li.now .dot::after { background: var(--brand); animation: pulse 1.6s infinite; }
.timeline li.bad .dot { border-color: var(--rej); } .timeline li.bad .dot::after { background: var(--rej); }
.timeline b { display: block; }
.timeline .when { font-size: 12.5px; color: var(--muted); }

/* ---------- Modal (dialog) ---------- */
dialog.modal { border: 0; padding: 0; border-radius: 22px; width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 32px); box-shadow: var(--shadow-lg); color: var(--text); background: var(--surface); }
dialog.modal::backdrop { background: rgba(7, 13, 43, .55); backdrop-filter: blur(4px); }
dialog.modal[open] { animation: pop .3s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(16px) scale(.97); } }
.modal-head { padding: 20px 22px 0; display: flex; gap: 14px; align-items: flex-start; }
.modal-head .ico { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: none; background: var(--brand-soft); color: var(--brand); }
.modal-head .ico.danger { background: var(--rej-soft); color: var(--rej); }
.modal-head .ico.ok { background: var(--ok-soft); color: var(--ok); }
.modal-head h2 { margin: 2px 0 4px; }
.modal-head p { margin: 0; color: var(--muted); font-size: 14px; }
.modal-body { padding: 18px 22px; }
.modal-foot { padding: 0 22px 22px; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.modal-foot .btn { flex: 1 1 auto; }
@media (min-width: 560px) { .modal-foot .btn { flex: 0 0 auto; } }
.modal-x { margin-left: auto; background: none; border: 0; width: 36px; height: 36px; border-radius: 10px; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.modal-x:hover { background: var(--surface-2); }

.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(7,13,43,.9); display: grid; place-items: center; padding: 20px; animation: fade .2s; cursor: zoom-out; }
.lightbox img { max-height: 90dvh; max-width: 100%; border-radius: 12px; box-shadow: var(--shadow-lg); }
@keyframes fade { from { opacity: 0; } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 120; top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: grid; gap: 10px; width: min(440px, calc(100% - 24px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; color: #fff; background: var(--night-1); box-shadow: var(--shadow-lg); animation: toastIn .45s var(--ease); font-weight: 600; font-size: 14.5px; }
.toast .ti { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.toast.success .ti { background: var(--ok); } .toast.error .ti { background: var(--rej); } .toast.info .ti { background: var(--brand); }
.toast.out { animation: toastOut .3s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-16px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-12px) scale(.96); } }

/* ---------- Assistant d'inscription ---------- */
.wizard-wrap { max-width: 1120px; margin: 0 auto; padding: 18px 16px 40px; display: grid; gap: 24px; }
@media (min-width: 1000px) { .wizard-wrap { grid-template-columns: minmax(0, 1fr) 440px; align-items: start; padding-top: 28px; } }
.wizard-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 0; max-width: 1120px; margin: 0 auto; }
.progress { height: 8px; border-radius: 99px; background: #eef1f8; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--brand), var(--brand-2), var(--star)); transition: width .5s var(--ease); }
.steps { display: flex; justify-content: space-between; margin: 14px 0 22px; gap: 4px; }
.steps button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; background: none; border: 0; color: var(--muted); font: 600 11.5px/1.2 var(--font); cursor: pointer; padding: 0; }
.steps .n { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--border); background: var(--surface); font-size: 13px; font-weight: 800; transition: all .3s var(--ease); }
.steps button.done .n { background: var(--ok); border-color: var(--ok); color: #fff; }
.steps button.current { color: var(--brand); }
.steps button.current .n { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 5px rgba(47,85,228,.12); }
.steps button:disabled { cursor: default; }
@media (max-width: 520px) { .steps .lbl { display: none; } .steps button.current .lbl { display: block; position: absolute; } .steps { margin-bottom: 26px; } .steps button { position: relative; } .steps button.current .lbl { top: 38px; white-space: nowrap; } }
.step { display: none; }
.step.active { display: block; animation: stepIn .45s var(--ease); }
.step.back { animation-name: stepBack; }
@keyframes stepIn { from { opacity: 0; transform: translateX(22px); } }
@keyframes stepBack { from { opacity: 0; transform: translateX(-22px); } }
.step-title { display: flex; gap: 14px; align-items: center; margin-bottom: 20px; }
.step-title .ico { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.step-title h2 { margin: 0; font-size: 20px; }
.step-title p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.wizard-nav { display: flex; gap: 10px; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--border); }
.wizard-nav .btn-primary, .wizard-nav .btn-success { flex: 1; }
@media (min-width: 640px) { .wizard-nav { justify-content: space-between; } .wizard-nav .btn-primary, .wizard-nav .btn-success { flex: 0 0 auto; min-width: 200px; } }
.fields-2 { display: grid; gap: 0 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .fields-2 { grid-template-columns: 1fr 1fr; } }

.dropzone {
  border: 2px dashed #c7d1ee; border-radius: 20px; padding: 26px 18px; text-align: center; background: linear-gradient(180deg, #fbfcff, #f3f6ff);
  transition: all .2s var(--ease); cursor: pointer; display: block;
}
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone .ill { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 12px; background: #fff; box-shadow: var(--shadow); display: grid; place-items: center; color: var(--brand); }
.dropzone b { display: block; font-size: 16px; }
.photo-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.rules { display: grid; gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; font-size: 13.5px; color: var(--muted); }
.rules li { display: flex; gap: 8px; align-items: center; }
.rules li .icon { color: var(--ok); }
.cropper-box { max-height: 60vh; border-radius: 16px; overflow: hidden; background: #0b1133; }
.cropper-box img { max-width: 100%; display: block; }
.crop-tools { display: flex; gap: 8px; justify-content: center; margin: 12px 0; flex-wrap: wrap; }
.photo-done { display: flex; gap: 16px; align-items: center; padding: 14px; border-radius: 18px; background: var(--ok-soft); border: 1px solid #b6e6cd; }
.photo-done img { width: 86px; height: 106px; object-fit: cover; border-radius: 12px; box-shadow: var(--shadow); }

.strength { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.strength i { height: 6px; border-radius: 99px; background: #e5e8f2; transition: background .3s; }
.strength[data-s="1"] i:nth-child(-n+1) { background: var(--rej); }
.strength[data-s="2"] i:nth-child(-n+2) { background: #f0a020; }
.strength[data-s="3"] i:nth-child(-n+3) { background: #7cc24a; }
.strength[data-s="4"] i { background: var(--ok); }
.pw-rules { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.pw-rules li { display: flex; gap: 8px; align-items: center; transition: color .2s; }
.pw-rules li::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #cdd3e4; transition: all .2s; flex: none; }
.pw-rules li.ok { color: var(--ok); }
.pw-rules li.ok::before { border-color: var(--ok); background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E") center/10px no-repeat; }

.recap { display: grid; gap: 0; }
.recap .grp { padding: 12px 0; border-bottom: 1px dashed var(--border); }
.recap .grp:last-child { border-bottom: 0; }
.recap .grp-h { display: flex; justify-content: space-between; align-items: center; font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.recap .kv { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 14.5px; }
.recap .kv span:first-child { color: var(--muted); }
.recap .kv span:last-child { font-weight: 700; text-align: right; }

.upload-progress { position: fixed; inset: 0; z-index: 110; background: rgba(7,13,43,.75); backdrop-filter: blur(6px); display: grid; place-items: center; color: #fff; text-align: center; padding: 24px; }
.upload-progress .ring { width: 120px; height: 120px; margin: 0 auto 18px; }
.upload-progress .ring circle { fill: none; stroke-width: 8; }
.upload-progress .ring .bg { stroke: rgba(255,255,255,.15); }
.upload-progress .ring .fg { stroke: var(--star); stroke-linecap: round; transition: stroke-dashoffset .3s; transform: rotate(-90deg); transform-origin: 50% 50%; }

/* ---------- Aperçu de la carte (HTML) ---------- */
.preview-side { position: relative; }
@media (min-width: 1000px) { .preview-side { position: sticky; top: 24px; } }
.preview-card { background: linear-gradient(160deg, var(--night-1), var(--night-2) 60%, var(--night-3)); border-radius: 24px; padding: 18px; color: #fff; box-shadow: var(--shadow-lg); position: relative; overflow: hidden; }
.preview-card::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(1px 1px at 30px 40px, #fff, transparent), radial-gradient(1.3px 1.3px at 120px 90px, #ffe9a1, transparent), radial-gradient(1px 1px at 200px 20px, #fff, transparent); background-size: 240px 140px; opacity: .45; }
.preview-card > * { position: relative; }
.preview-card .ph { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; }
.preview-card .ph b { font-size: 15px; }
.face-switch { display: inline-flex; background: rgba(255,255,255,.1); border-radius: 12px; padding: 4px; }
.face-switch button { border: 0; background: none; color: #c8d4ff; font: 700 12.5px var(--font); padding: 7px 12px; border-radius: 9px; cursor: pointer; }
.face-switch button.on { background: #fff; color: var(--night-1); }

.gx-scaler { width: 100%; aspect-ratio: 146.4 / 97.5; position: relative; }
.gx-flip { position: absolute; inset: 0; perspective: 1400px; }
.gx-flip-inner { position: absolute; inset: 0; transition: transform .8s var(--ease); transform-style: preserve-3d; }
.gx-flip.flipped .gx-flip-inner { transform: rotateY(180deg); }
.gx-side { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.gx-side.out { transform: rotateY(180deg); }
.gx-face {
  position: absolute; left: 0; top: 0; width: 146.4mm; height: 97.5mm; background: #fff; color: #000; transform-origin: 0 0;
  box-shadow: 0 18px 40px -12px rgba(0,0,0,.5); border-radius: 3px; overflow: hidden;
  font-family: "Arial Narrow", "Roboto Condensed", "Liberation Sans Narrow", "Helvetica Neue", Arial, sans-serif;
}
.gx-face .cf { position: absolute; white-space: nowrap; line-height: 1; }
.gx-face .cf.c { text-align: center; }
.gx-face .cf.b { font-weight: 700; }
.gx-face .f-el { font-family: Elephant, "Bodoni MT Black", "Abril Fatface", Georgia, serif; font-weight: 900; }
.gx-face .f-co { font-family: Constantia, Georgia, serif; }
.gx-face .f-tb { font-family: "Times New Roman", Times, serif; }
.gx-face .f-dj { font-family: "Segoe UI Symbol", "DejaVu Sans", sans-serif; }
.gx-face .cf-frame { position: absolute; width: 146.4mm; height: 97.5mm; border: .53mm solid #0C445E; }
.gx-face .cf-cover { position: absolute; width: 67.8mm; height: 93.9mm; border: .53mm solid #156082; border-radius: 2mm; }
.gx-face .cf-hr { position: absolute; border-top: .35mm solid #000; }
.gx-face .cf-hr.thick { border-top-width: .53mm; }
.gx-face .cf-photo { position: absolute; width: 35.5mm; height: 43.7mm; border: .53mm solid #000; background: #f1f3f8; overflow: hidden; }
.gx-face .cf-photo img { width: 100%; height: 100%; object-fit: cover; }
.gx-face .cf-logo { position: absolute; width: 16.9mm; height: 19.9mm; }
.gx-face .hl { outline: 2px solid rgba(47,85,228,.5); outline-offset: 1px; border-radius: 2px; background: rgba(47,85,228,.08); transition: all .3s; }
.specimen::after {
  content: "SPÉCIMEN — NON VALABLE"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-18deg);
  font: 900 14mm/1 var(--font); color: rgba(211, 58, 44, .22); white-space: nowrap; letter-spacing: 2mm; pointer-events: none; z-index: 5;
}
.preview-note { font-size: 12.5px; color: #b9c6f3; margin-top: 12px; display: flex; gap: 8px; align-items: flex-start; }

/* ---------- Page d'accueil ---------- */
.hero { max-width: 1120px; margin: 0 auto; padding: 18px 20px 60px; }
.hero-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0 30px; }
.hero-grid { display: grid; gap: 40px; align-items: center; }
@media (min-width: 960px) { .hero-grid { grid-template-columns: 1.05fr .95fr; padding-top: 30px; } }
.hero h1 { font-size: clamp(34px, 7vw, 58px); line-height: 1.04; letter-spacing: -.03em; font-weight: 800; margin-bottom: 18px; }
.hero h1 .shine { background: linear-gradient(90deg, var(--star), #fff3b8, var(--brand-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .lead { font-size: clamp(16px, 2.2vw, 19px); color: #c9d4f7; max-width: 540px; margin-bottom: 28px; }
.hero .ctas { display: flex; gap: 12px; flex-wrap: wrap; }
.pill { display: inline-flex; gap: 8px; align-items: center; padding: 6px 14px 6px 8px; border-radius: 99px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); color: #dbe4ff; font-size: 13.5px; font-weight: 600; margin-bottom: 20px; }
.pill i { width: 22px; height: 22px; border-radius: 50%; background: var(--star); display: grid; place-items: center; color: var(--night-1); font-style: normal; font-size: 12px; }
.how { display: grid; gap: 14px; margin-top: 56px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.how .glass { padding: 20px; }
.how .num { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: rgba(255,216,77,.15); color: var(--star); font-weight: 800; margin-bottom: 12px; }
.how h3 { color: #fff; margin-bottom: 4px; }
.how p { color: #b9c6f3; margin: 0; font-size: 14px; }
.floaty { animation: floaty 7s ease-in-out infinite; }
@keyframes floaty { 50% { transform: translateY(-10px) rotate(-1deg); } }
.hero-card { transform: rotate(-4deg); }
.hero-card .gx-face { box-shadow: 0 40px 80px -20px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.2); }

/* ---------- Authentification ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-box { width: min(440px, 100%); }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; text-align: center; }
.auth-logo img { width: 74px; filter: drop-shadow(0 12px 24px rgba(0,0,0,.4)); }
.auth-logo b { font-size: 20px; }
.auth-logo span { color: #b9c6f3; font-size: 14px; }

/* ---------- Statut élève ---------- */
.status-hero { border-radius: 24px; padding: 22px; color: #fff; position: relative; overflow: hidden; box-shadow: var(--shadow); }
.status-hero.wait { background: linear-gradient(135deg, #f09a1a, #d9730b); }
.status-hero.ok { background: linear-gradient(135deg, #17a868, #0c7d4b); }
.status-hero.rej { background: linear-gradient(135deg, #e5483a, #b3261e); }
.status-hero.print { background: linear-gradient(135deg, var(--brand), #3b2fc4); }
.status-hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: rgba(255,255,255,.12); }
.status-hero .big { font-size: 24px; font-weight: 800; margin: 6px 0; }
.status-hero .ico { width: 52px; height: 52px; border-radius: 16px; background: rgba(255,255,255,.2); display: grid; place-items: center; }
.motif-box { background: #fff; color: var(--text); border-radius: 16px; padding: 14px 16px; margin-top: 14px; position: relative; }
.motif-box small { color: var(--rej); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-size: 11.5px; }

/* ---------- Graphiques ---------- */
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 240px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.bar-list { display: grid; gap: 10px; }
.bar-list .bl { display: grid; gap: 4px; }
.bar-list .bl-top { display: flex; justify-content: space-between; font-size: 13.5px; gap: 12px; }
.bar-list .bl-top b { font-variant-numeric: tabular-nums; }
.bar-list .track { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar-list .track i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--rej), #f07a6e); width: 0; transition: width .9s var(--ease); }

.secret { font-family: ui-monospace, Consolas, monospace; font-size: 22px; font-weight: 800; letter-spacing: .06em; padding: 14px; text-align: center; border-radius: 14px; background: var(--night-1); color: var(--star); user-select: all; }

.fab-print { box-shadow: 0 12px 30px -10px rgba(47,85,228,.8); }

@media print { .sidebar, .topbar, .tabbar, .toasts { display: none !important; } .shell { padding: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
.hide-xs{} @media (max-width:480px){.hide-xs{display:none}}
/* Barre de navigation de l'assistant : tient toujours dans la largeur du téléphone */
.wizard-nav .btn { min-width: 0; white-space: normal; text-align: center; line-height: 1.2; }
.wizard-nav #wz-prev { flex: 0 0 auto; }
@media (max-width: 420px) { .wizard-nav #wz-prev .lbl { display: none; } .wizard-nav #wz-prev { width: 52px; padding: 0; } }
.dl.cols > div { grid-template-columns: 92px 1fr; } .dl dd.mono { word-break: break-all; }
.space .panel a:not(.btn) { color: var(--brand); }
.field > label.switch { display: inline-flex; } .switch .track { display: inline-block; }
