:root {
  --bg: #f3f5f9; --card: #fff; --text: #16202e; --muted: #6b7280; --line: #e3e7ee;
  --primary: #1d4ed8; --primary-d: #1e40af; --green: #15803d; --red: #b91c1c; --orange: #c2410c; --blue: #1d4ed8; --gray: #4b5563;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 6px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 16px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
h2 + h2, .card-form h2:not(:first-child) { margin-top: 20px; }
p { margin: 0 0 10px; }
code { background: #eef1f6; padding: 2px 6px; border-radius: 4px; font-size: 13px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.inline { display: inline; }
.nowrap { white-space: nowrap; }
.ok { color: var(--green); font-weight: 600; }
.err { color: var(--red); font-weight: 600; }
.warn { color: var(--orange); font-weight: 600; }
.lock { font-size: 12px; opacity: .7; }

/* ----- Barre du haut ----- */
.topbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 0 20px; height: 58px; display: flex; align-items: center; gap: 24px; }
.brand { font-weight: 700; font-size: 17px; color: var(--text); display: inline-flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand-lg { font-size: 22px; margin-bottom: 4px; }
.brand-dot { width: 12px; height: 12px; border-radius: 4px; background: linear-gradient(135deg, #1d4ed8, #22c55e); display: inline-block; }
.menu { display: flex; gap: 4px; flex: 1; }
.menu a { padding: 8px 12px; border-radius: 8px; color: var(--gray); font-weight: 500; }
.menu a:hover { background: #f1f4f9; text-decoration: none; }
.menu a.active { background: #e8eefc; color: var(--primary); }
.topbar-right { display: flex; gap: 8px; align-items: center; }

/* ----- Conteneurs ----- */
.container { max-width: 1200px; margin: 0 auto; padding: 24px 20px 60px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card-sm { width: 100%; max-width: 380px; margin: 0 auto; }
body.centered { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin-bottom: 2px; }

/* ----- Stats ----- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; color: var(--text); box-shadow: var(--shadow); border-left: 4px solid #cbd5e1; }
.stat:hover { text-decoration: none; border-color: var(--primary); }
.stat-n { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-l { color: var(--muted); font-size: 13px; }
.stat-blue { border-left-color: var(--blue); } .stat-orange { border-left-color: var(--orange); } .stat-green { border-left-color: var(--green); } .stat-red { border-left-color: var(--red); } .stat-gray { border-left-color: #94a3b8; }

/* ----- Badges ----- */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; line-height: 1.5; vertical-align: middle; }
.badge-gray { background: #eef1f6; color: var(--gray); }
.badge-blue { background: #e0e9ff; color: var(--blue); }
.badge-orange { background: #ffedd5; color: var(--orange); }
.badge-green { background: #dcfce7; color: var(--green); }
.badge-red { background: #fee2e2; color: var(--red); }

/* ----- Tables ----- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.inactive td { opacity: .6; }
.table-kv th { text-transform: none; font-size: 14px; width: 45%; }

/* ----- Formulaires ----- */
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 12px; }
label input, label select, label textarea, .filters input, .filters select {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px; border: 1px solid #cfd6e1; border-radius: 8px; font: inherit; font-weight: 400; background: #fff; color: var(--text);
}
label input:focus, label select:focus, label textarea:focus { outline: 2px solid #bfd0ff; border-color: var(--primary); }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
label.check input { width: auto; margin: 0; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 4px; }
.hint-inline { font-weight: 400; color: var(--muted); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
details.more { margin-bottom: 14px; }
details.more summary, details.refus summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; margin-bottom: 10px; }
details.refus { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 12px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px; }
.filters input, .filters select { margin: 0; width: auto; min-width: 180px; }
.filters input[type=search] { flex: 1; }

/* ----- Boutons ----- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid #cfd6e1; background: #fff; color: var(--text); font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f6f8fb; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #166534; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-danger-text { color: var(--red); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--gray); }
.btn-ghost:hover { background: #f1f4f9; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-lg { padding: 14px 20px; font-size: 16px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }

/* ----- Flash ----- */
.flash { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.flash-success { background: #dcfce7; color: #14532d; }
.flash-error { background: #fee2e2; color: #7f1d1d; }

/* ----- Fiche client ----- */
.step h2 .step-n { width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.copybox { display: flex; gap: 8px; margin: 10px 0 12px; }
.copybox input { flex: 1; padding: 10px 12px; border: 1px solid #cfd6e1; border-radius: 8px; font: inherit; font-size: 13px; background: #f8fafc; }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 14px; }
.doc { margin: 0; }
.doc img, .doc-pdf { width: 100%; aspect-ratio: 3/2; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #f8fafc; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); }
.doc img:hover { outline: 2px solid var(--primary); }
.doc figcaption { font-size: 13px; margin-top: 6px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .small { display: inline-block; min-width: 110px; }
.steps-list { padding-left: 20px; font-size: 14px; }
.steps-list li { margin-bottom: 6px; }

/* ----- Pages publiques (client) ----- */
body.public { background: linear-gradient(180deg, #eef2ff 0%, var(--bg) 40%); }
.pub { max-width: 520px; margin: 0 auto; padding: 40px 16px 60px; }
.pub-brand { font-weight: 700; font-size: 20px; text-align: center; margin-bottom: 20px; display: flex; justify-content: center; align-items: center; gap: 8px; }
.pub-card { padding: 28px; text-align: center; }
.pub-card h1 { justify-content: center; font-size: 22px; margin-bottom: 10px; }
.pub-card form { text-align: left; margin-top: 18px; }
.pub-foot { text-align: center; margin-top: 16px; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.choice-opt { display: flex; gap: 10px; align-items: center; padding: 12px; border: 2px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 500; margin: 0; }
.choice-opt input { width: auto; margin: 0; }
.choice-opt:has(input:checked) { border-color: var(--primary); background: #eef3ff; }
.file { display: block; padding: 14px; border: 2px dashed #cfd6e1; border-radius: 10px; margin-bottom: 12px; cursor: pointer; background: #fff; }
.file.has-file { border-color: var(--green); border-style: solid; background: #f0fdf4; }
.file-label { display: block; margin-bottom: 6px; }
.file input { margin-top: 0; padding: 6px 0; border: 0; }
.spinner { width: 44px; height: 44px; border: 4px solid #dbe4ff; border-top-color: var(--primary); border-radius: 50%; margin: 6px auto 16px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bigcheck, .bigcross { width: 64px; height: 64px; border-radius: 50%; margin: 4px auto 14px; display: flex; align-items: center; justify-content: center; font-size: 34px; font-weight: 700; color: #fff; }
.bigcheck { background: var(--green); }
.bigcross { background: var(--red); }

@media (max-width: 860px) {
  .grid-2, .row-2 { grid-template-columns: 1fr; }
  .menu { overflow-x: auto; }
  .topbar-inner { gap: 12px; padding: 0 12px; }
  .topbar-right .btn-primary { display: none; }
  .table { display: block; overflow-x: auto; }
  .choice { grid-template-columns: 1fr; }
}

/* ----- Lien du service / compte à rebours ----- */
.card-redirect { border-left: 4px solid var(--primary); background: #f8faff; }
.redirect-form { display: flex; gap: 10px; align-items: flex-end; }
.redirect-form label { flex: 1; margin-bottom: 0; }
.redirect-form .btn { margin-bottom: 1px; }
.card-redirect .hint { margin-top: 8px; }
.countdown { font-size: 22px; font-weight: 700; color: var(--primary); margin: 6px 0 14px; }
@media (max-width: 860px) { .redirect-form { flex-direction: column; align-items: stretch; } }

/* ----- Choix photo / galerie (page client) ----- */
.file-btns { display: flex; gap: 8px; margin: 6px 0 8px; }
.file-btns .btn { flex: 1; padding: 11px 8px; font-size: 14px; }
.file.has-file .file-name { color: var(--green); font-weight: 600; }

/* ----- Logo ----- */
.brand-logo { height: 44px; width: auto; display: block; }
.login-logo { text-align: center; margin-bottom: 6px; }
.login-logo img { height: 110px; width: auto; }
.center { text-align: center; }
.pub-brand img { height: 120px; width: auto; }
@media (max-width: 860px) { .brand-logo { height: 36px; } .pub-brand img { height: 96px; } }
