/* ===== Back office ===== */
:root { --brand: #4a2d4f; --ink: #1f2328; --muted: #6a7078; --line: #e3e5e8; --bg: #f5f6f8; --ok: #18794e; --err: #b42318; }
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.nowrap { white-space: nowrap; }

/* En-tête */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 60px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); }
.brand .ic { color: var(--brand); }
.brand:hover { text-decoration: none; }
.nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav a, .nav button { color: var(--ink); padding: 8px 12px; border-radius: 8px; font: inherit; background: none; border: 0; cursor: pointer; }
.nav a:hover, .nav button:hover { background: var(--bg); text-decoration: none; }
.nav a.on { background: color-mix(in srgb, var(--brand) 10%, #fff); color: var(--brand); font-weight: 600; }
.nav form { margin: 0; }
.nav-t, .nav-b { display: none; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--brand); color: #fff; font-size: .72rem; line-height: 20px; text-align: center; font-weight: 700; }

.page { max-width: 1280px; margin: 0 auto; padding: 28px 24px 60px; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.head p { margin: 4px 0 0; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back { font-size: .88rem; display: inline-block; margin-bottom: 4px; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c9ccd1; text-decoration: none; background: #fafafa; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.sm { padding: 5px 11px; font-size: .85rem; border-radius: 8px; }
.danger-btn { color: var(--err); }
.danger-btn:hover { background: #fdeceb; border-color: #f3b8b2; }

/* Messages */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; background: #e8f6ee; color: var(--ok); border: 1px solid #bfe5cf; }
.flash.err { background: #fdeceb; color: var(--err); border-color: #f3c5c0; }

/* Statistiques */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.stats div { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.stats b { display: block; font-size: 1.7rem; line-height: 1.1; }
.stats span { color: var(--muted); font-size: .86rem; }
.search { display: flex; gap: 8px; margin-bottom: 16px; }
.search input { flex: 1; }

/* Tableaux */
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--line); background: #fafbfc; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions form { display: inline; }
.table tr.unread td { background: #fffaf0; }
.table .msg { max-width: 360px; color: #333; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: 1px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #eef0f3; color: #444; }
.pill.ok { background: #e3f5eb; color: var(--ok); }
.pill.off { background: #f1f1f1; color: #888; }
.pill.admin { background: color-mix(in srgb, var(--brand) 12%, #fff); color: var(--brand); }
.bulk { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.bulk .chk { margin-right: 8px; }
.empty { background: #fff; border: 1px dashed #cfd3d8; border-radius: 14px; padding: 48px 20px; text-align: center; }
.inline { display: inline; margin: 0; }

/* Formulaires */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label, .img-field .lbl { display: flex; flex-direction: column; gap: 5px; font-size: .85rem; font-weight: 600; color: #3b4148; }
input:not([type]), input[type=text], input[type=email], input[type=tel], input[type=password], input[type=search], select, textarea {
  font: inherit; font-weight: 400; color: var(--ink); background: #fff; border: 1px solid #d5d8dc; border-radius: 9px; padding: 9px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 30%, transparent); border-color: var(--brand); }
textarea { resize: vertical; }
.form .chk, .chk { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; display: flex; }
.chk input { width: 17px; height: 17px; accent-color: var(--brand); }
fieldset { border: 1px solid var(--line); background: #fff; border-radius: 14px; padding: 18px 20px 20px; margin: 0; display: flex; flex-direction: column; gap: 14px; }
legend { font-weight: 700; padding: 0 8px; margin-left: -8px; font-size: 1rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.prefix { display: flex; align-items: stretch; border: 1px solid #d5d8dc; border-radius: 9px; overflow: hidden; background: #f4f5f7; }
.prefix span { padding: 9px 4px 9px 12px; color: var(--muted); font-weight: 400; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; align-self: center; }
.prefix input { border: 0; border-radius: 0; }
.color span { display: flex; align-items: center; gap: 10px; }
.color input[type=color] { width: 54px; height: 40px; border: 1px solid #d5d8dc; border-radius: 9px; padding: 3px; background: #fff; cursor: pointer; }
.img-field { display: flex; flex-direction: column; gap: 6px; }
.img-field input[type=file] { font-size: .85rem; }
.img-prev { display: flex; align-items: center; gap: 12px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: repeating-conic-gradient(#f2f2f2 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.img-prev img { max-width: 120px; max-height: 60px; object-fit: contain; }
.img-prev .chk { font-weight: 500; font-size: .85rem; background: #fff; padding: 2px 8px; border-radius: 6px; }
.save-bar { display: flex; gap: 10px; align-items: center; }
.edit-form .save-bar { position: sticky; bottom: 0; background: color-mix(in srgb, var(--bg) 92%, transparent); padding: 12px 0; backdrop-filter: blur(4px); }
.panel-box { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 22px; margin-bottom: 20px; }
.narrow { max-width: 720px; }

/* Éditeur + aperçu */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 24px; align-items: start; }
.editor.no-preview { grid-template-columns: minmax(0, 860px); }
.preview { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 10px; }
.preview-head { display: flex; justify-content: space-between; align-items: center; }
.seg { display: flex; background: #e9ebee; border-radius: 9px; padding: 3px; }
.seg button { font: inherit; font-size: .82rem; font-weight: 600; border: 0; background: none; padding: 5px 12px; border-radius: 7px; cursor: pointer; color: #555; }
.seg button[aria-pressed=true] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.preview-frame { height: min(72vh, 760px); border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.08); }
.preview-frame iframe { border: 0; transform-origin: 0 0; display: block; }
.danger { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--line); }
.danger form { margin: 0; }

/* Connexion */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; margin: -28px -24px -60px; }
.auth-box { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 32px; box-shadow: 0 20px 50px rgba(0,0,0,.08); }
.auth-box h1 { font-size: 1.35rem; }
.auth-box p { margin: 4px 0 20px; }
.auth-ic { width: 60px; height: 60px; border-radius: 16px; background: var(--brand); color: #fff; display: grid; place-items: center; margin-bottom: 16px; }

/* ===== Mobile ===== */
@media (max-width: 1000px) {
  .editor { grid-template-columns: 1fr; }
  .preview { position: static; }
}
@media (max-width: 760px) {
  .top { padding: 0 16px; }
  .nav-b { display: grid; place-items: center; margin-left: auto; cursor: pointer; width: 40px; height: 40px; border-radius: 8px; }
  .nav { display: none; position: absolute; top: 60px; left: 0; right: 0; flex-direction: column; align-items: stretch; background: #fff; border-bottom: 1px solid var(--line); padding: 8px; }
  .nav-t:checked ~ .nav { display: flex; }
  .nav button { text-align: left; width: 100%; }
  .page { padding: 20px 14px 50px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  .table td { border: 0; padding: 4px 14px; text-align: left !important; }
  .table td[data-l]::before { content: attr(data-l); display: block; font-size: .72rem; text-transform: uppercase; color: var(--muted); font-weight: 600; }
  .auth { margin: -20px -14px -50px; }
}
.img-prev.dark { background: #2b2230; }
.img-prev video { max-width: 160px; max-height: 90px; border-radius: 6px; background: #000; }
.url-in { font-size: .85rem !important; }

/* Captcha & double authentification */
.captcha { display: flex; flex-direction: column; gap: 6px; }
.captcha .lbl { font-size: .85rem; font-weight: 600; color: #3b4148; }
.captcha-row { display: flex; align-items: center; gap: 10px; }
.captcha-img svg { display: block; border-radius: 8px; border: 1px solid var(--line); max-width: 100%; height: auto; }
.captcha-new { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; font-size: 1.2rem; color: var(--ink); }
.captcha-new:hover { background: var(--bg); text-decoration: none; }
.captcha input, .otp { letter-spacing: .35em; font-size: 1.15rem !important; text-align: center; font-variant-numeric: tabular-nums; }
.cf-turnstile { min-height: 65px; }
.steps { padding-left: 20px; margin: 0 0 10px; }
.steps li { margin-bottom: 6px; }
.totp-setup { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; margin: 6px 0 18px; }
.totp-qr { width: 180px; height: 180px; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.totp-qr svg { width: 100%; height: 100%; display: block; }
.secret { display: inline-block; font-family: ui-monospace, Consolas, monospace; font-size: .95rem; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; letter-spacing: .05em; word-break: break-all; }
details summary { cursor: pointer; }
