/* ------------------------------------------------------------------ */
/* Base                                                                */
/* ------------------------------------------------------------------ */
:root {
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --bg: #f1f5f9;
  --card: #ffffff;
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-soft: #eef2ff;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px -12px rgba(15, 23, 42, .18);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

body { overscroll-behavior-y: none; }

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.015em; }
p { margin: 0 0 .75rem; }
a { color: var(--brand); }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .8125rem; }
.center { text-align: center; }
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .75rem;
  word-break: break-all;
}

/* ------------------------------------------------------------------ */
/* Boutons / champs                                                    */
/* ------------------------------------------------------------------ */
.btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border: 1px solid transparent;
  border-radius: 11px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: .9375rem;
  padding: .8125rem 1.125rem;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, opacity .15s, transform .05s;
  touch-action: manipulation;
  min-height: 46px;
}
.btn:active { transform: translateY(1px); }
.btn:hover { background: var(--brand-dark); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn[disabled]:hover { background: var(--brand); }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--ink-2); border-color: var(--line-2); }
.btn.ghost:hover { background: #f8fafc; }
.btn.subtle { background: var(--brand-soft); color: var(--brand-dark); }
.btn.subtle:hover { background: #e0e7ff; }
.btn.danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: .5rem .75rem; font-size: .8125rem; min-height: 36px; border-radius: 9px; }

label.field { display: block; margin-bottom: .875rem; }
label.field > span {
  display: block;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: .375rem;
}
input[type=text], input[type=password], select {
  width: 100%;
  font: inherit;
  font-size: 1rem; /* >=16px : evite le zoom auto iOS */
  padding: .6875rem .8125rem;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, .btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-color: var(--brand);
}

.check {
  display: flex;
  gap: .625rem;
  align-items: flex-start;
  padding: .75rem;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: #f8fafc;
  cursor: pointer;
  font-size: .875rem;
  line-height: 1.4;
}
.check input { width: 20px; height: 20px; margin: 1px 0 0; flex: 0 0 auto; accent-color: var(--brand); }

/* ------------------------------------------------------------------ */
/* Structure                                                           */
/* ------------------------------------------------------------------ */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .02em;
  padding: .25rem .5rem;
  border-radius: 999px;
  text-transform: uppercase;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.wait { background: var(--warn-soft); color: var(--warn); }

.note {
  border-radius: 10px;
  padding: .75rem .875rem;
  font-size: .875rem;
  line-height: 1.45;
}
.note.info { background: var(--brand-soft); color: #3730a3; }
.note.ok { background: var(--ok-soft); color: #065f46; }
.note.warn { background: var(--warn-soft); color: #92400e; }
.note.err { background: var(--danger-soft); color: #991b1b; }

/* ------------------------------------------------------------------ */
/* Visionneuse PDF                                                     */
/* ------------------------------------------------------------------ */
.pdf-viewer { padding: .75rem .625rem 1rem; }
.pdf-page {
  position: relative;
  margin: 0 auto .75rem;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .12), 0 6px 16px -10px rgba(15, 23, 42, .3);
  border-radius: 4px;
  overflow: hidden;

}
.pdf-page canvas { display: block; width: 100%; height: auto; }
.pdf-page .pnum {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(15, 23, 42, .62);
  color: #fff;
  font-size: .6875rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  pointer-events: none;
}
.pdf-skeleton {
  background: linear-gradient(100deg, #f8fafc 30%, #eef2f7 50%, #f8fafc 70%);
  background-size: 300% 100%;
  animation: sk 1.4s ease-in-out infinite;
}
@keyframes sk { 0% { background-position: 130% 0; } 100% { background-position: -30% 0; } }

.spinner {
  width: 22px; height: 22px;
  border: 2.5px solid var(--line-2);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
