:root {
  --bg: #fff;
  --fg: #171717;
  --muted: #737373;
  --border: #e5e5e5;
  --hover: #f5f5f5;
  --field-bg: #fff;
  --accent: #2563eb;
  --good: #1a7f37; --good-bg: #e6f4ea;
  --bad: #c53030; --bad-bg: #fbe7e7;
  --warn: #b7791f; --warn-bg: #fbf0dd;
  --info: #1d4ed8; --info-bg: #dbeafe;
  --strong: #14532d; --strong-bg: #d1f2dd;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a; --fg: #ededed; --muted: #a3a3a3; --border: #262626; --hover: #171717; --field-bg: #171717;
    --accent: #60a5fa;
    --good: #4ade80; --good-bg: #113322;
    --bad: #f87171; --bad-bg: #3a1414;
    --warn: #fbbf24; --warn-bg: #3a2c0d;
    --info: #60a5fa; --info-bg: #12233f;
    --strong: #34d399; --strong-bg: #0d2c1f;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body.full { display: flex; flex-direction: column; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; border-bottom: 1px solid var(--border); }
.topbar .brand { font-weight: 600; color: var(--fg); }
.topbar nav { display: flex; gap: 16px; align-items: center; }
.topbar form { margin: 0; }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

.messages { list-style: none; margin: 8px 12px; padding: 0; }
.messages li { padding: 6px 10px; border-radius: 6px; background: var(--good-bg); color: var(--good); }
.messages .msg-error { background: var(--bad-bg); color: var(--bad); }
.error { color: var(--bad); background: var(--bad-bg); padding: 6px 10px; border-radius: 6px; margin: 6px 0; }
.error ul { margin: 0; padding-left: 16px; }

input, select, button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=color]), select {
  background: var(--field-bg); border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px;
}
.btn, button.primary { display: inline-block; border: 1px solid var(--border); border-radius: 6px; padding: 5px 12px; color: var(--fg); background: var(--field-bg); cursor: pointer; }
.btn.disabled { opacity: .4; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

.liste { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 10px 12px; }
.title-row { display: flex; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.filters { margin: 0 0 8px; }
.filter-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
:root { --tint-gray: color-mix(in srgb, var(--muted) 12%, var(--bg)); --tint-yellow: color-mix(in srgb, #eab308 15%, var(--bg)); --tint-blue: color-mix(in srgb, #3b82f6 13%, var(--bg)); --tint-orange: color-mix(in srgb, #f97316 13%, var(--bg)); }
.tint-gray, table.sites .tint-gray { background: var(--tint-gray); }
.tint-yellow, table.sites .tint-yellow { background: var(--tint-yellow); }
.tint-blue, table.sites .tint-blue { background: var(--tint-blue); }
.tint-orange, table.sites .tint-orange { background: var(--tint-orange); }
.filter-group { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 4px 8px; border-radius: 8px; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 12px; color: var(--muted); }
.field select, .field input { min-width: 70px; max-width: 180px; text-overflow: ellipsis; }
.check { display: inline-flex; align-items: center; gap: 4px; padding-bottom: 6px; white-space: nowrap; }
.check.disabled { opacity: .4; }
.icon-btn { border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; color: var(--fg); }
.columns-row { display: flex; flex-wrap: wrap; gap: 2px 14px; align-items: center; font-size: 12px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.columns-row .check { padding: 0; }
.col-group { display: flex; flex-wrap: wrap; gap: 2px 14px; align-items: center; padding: 1px 8px; border-radius: 6px; }
.pager-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-top: 8px; }
.saved-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 8px; font-size: 12px; }
.saved-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px 2px 10px; border: 1px solid var(--border); border-radius: 999px; }
.saved-chip a { color: var(--fg); }
.saved-chip.active { border-color: var(--accent); background: var(--info-bg); }
.saved-chip form { margin: 0; }
.saved-chip button.link { color: var(--muted); font-size: 14px; line-height: 1; }
.saved-new { display: inline-flex; gap: 6px; margin: 0 0 0 auto; }
.saved-new input { width: 160px; }
.pager, .sort { display: flex; align-items: center; gap: 10px; }
.sort { align-items: flex-end; }
.sort input { width: 80px; }

.table-wrap { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
table.sites { border-collapse: collapse; font-size: 13px; }
table.sites th { position: sticky; top: 0; background: var(--bg); text-align: left; color: var(--muted); font-weight: 700; white-space: nowrap; padding: 6px; border-bottom: 1px solid var(--border); }
table.sites th a { color: inherit; }
table.sites td { padding: 4px 6px; white-space: nowrap; border-bottom: 1px solid var(--border); }
table.sites tbody tr { cursor: pointer; }
table.sites tbody tr:hover td { background: color-mix(in srgb, var(--muted) 28%, var(--bg)); }
td.narrow { max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
td.right { text-align: right; font-variant-numeric: tabular-nums; }
td.empty { text-align: center; padding: 32px; color: var(--muted); }

.badge { display: inline-block; padding: 1px 6px; border-radius: 4px; font-weight: 600; }
.badge-good { color: var(--good); background: var(--good-bg); }
.badge-bad { color: var(--bad); background: var(--bad-bg); }
.badge-warn { color: var(--warn); background: var(--warn-bg); }
.badge-info { color: var(--info); background: var(--info-bg); }
.badge-strong { color: var(--strong); background: var(--strong-bg); }
/* Couleurs de marque, fixes quel que soit le thème */
.badge-divi { color: #fff; background: #8f42ec; }
.badge-elementor { color: #fff; background: #620856; }
.pill { display: inline-block; border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 600; }

.panel { position: fixed; inset: 0; z-index: 50; display: flex; justify-content: flex-end; background: rgba(0, 0, 0, .4); }
.panel[hidden] { display: none; }
.panel-body { position: relative; width: 100%; max-width: 560px; height: 100%; overflow-y: auto; background: var(--bg); border-left: 1px solid var(--border); padding: 20px 24px; }
.panel .close { position: absolute; top: 10px; right: 16px; background: none; border: 0; font-size: 24px; color: var(--muted); cursor: pointer; }

.fiche h2 { font-size: 20px; margin: 0 0 8px; }
.fiche h2 a { color: var(--fg); }
.fiche h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 20px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border); font-weight: 500; }
.fiche h3 a { text-transform: none; }
.fiche h4 { font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.fiche dl { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin: 0; font-size: 13px; }
.fiche dt { color: var(--muted); }
.fiche dd { margin: 0; word-break: break-word; }
.fiche .plugins { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.fiche .note { margin: 4px 0; font-size: 13px; }
.step-form { margin: 0 0 8px; }
.step-select { font-weight: 600; }

.narrow-page { max-width: 640px; margin: 0 auto; padding: 16px; }
.narrow-page.wide { max-width: 900px; }
.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.stack label { display: flex; flex-direction: column; gap: 4px; }
.email-config { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 12px 0; font-size: 13px; }
.email-config dt { color: var(--muted); }
.email-config dd { margin: 0; }
.template-list { list-style: none; padding: 0; }
.template-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.editor-field { display: flex; flex-direction: column; gap: 4px; }
.editor-field .ql-toolbar, .editor-field .ql-container { border-color: var(--border); background: var(--field-bg); }
.editor-field .ql-container { min-height: 260px; font-size: 14px; color: var(--fg); }
.editor-field .ql-snow .ql-stroke { stroke: var(--fg); }
.editor-field .ql-snow .ql-fill { fill: var(--fg); }
.editor-field .ql-snow .ql-picker { color: var(--fg); }

/* Page de connexion */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
.login-aside { position: relative; overflow: hidden; display: flex; align-items: center; padding: 56px; background: #0b1220; color: #e6edf7; }
.login-aside::before { content: ""; position: absolute; inset: 0; background: radial-gradient(520px 380px at 15% 5%, rgba(0, 229, 255, .16), transparent 65%), radial-gradient(520px 420px at 95% 100%, rgba(37, 99, 235, .28), transparent 65%); }
.login-aside::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px); background-size: 32px 32px; }
.login-aside-inner { position: relative; z-index: 1; max-width: 400px; }
.login-logo { width: 44px; height: 44px; filter: drop-shadow(0 0 14px rgba(0, 229, 255, .45)); }
.login-name { margin: 20px 0 8px; font-size: 28px; font-weight: 700; letter-spacing: -.01em; }
.login-tagline { margin: 0 0 36px; color: #9fb0c8; font-size: 15px; line-height: 1.55; }
.login-points { display: grid; gap: 18px; margin: 0; padding: 0; list-style: none; }
.login-points li { padding-left: 14px; border-left: 2px solid rgba(0, 229, 255, .55); color: #9fb0c8; line-height: 1.45; }
.login-points strong { display: block; margin-bottom: 2px; color: #e6edf7; font-weight: 600; }
.login-main { display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { font-size: 24px; letter-spacing: -.01em; }
.login-sub { margin: 6px 0 28px; color: var(--muted); }
.login-card form { display: flex; flex-direction: column; gap: 16px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; }
.login-card input:not([type=hidden]) { padding: 10px 12px; border-radius: 8px; font-size: 14px; transition: border-color .15s, box-shadow .15s; }
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.login-card button.primary { width: 100%; margin-top: 6px; padding: 10px 12px; border-radius: 8px; font-weight: 600; }
.login-card button.primary:hover { filter: brightness(1.08); }
.login-card .errorlist { margin: 0; padding: 8px 12px; border-radius: 8px; list-style: none; color: var(--bad); background: var(--bad-bg); }
@media (max-width: 800px) {
  .login { grid-template-columns: 1fr; }
  .login-aside { padding: 28px 24px; }
  .login-name { margin-top: 12px; font-size: 22px; }
  .login-tagline { margin: 0; }
  .login-points { display: none; }
}

.steps { list-style: none; padding: 0; margin: 16px 0; display: flex; flex-direction: column; gap: 4px; }
.step { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
.step.dragging { opacity: .4; }
.step.over-before { box-shadow: 0 -2px 0 var(--accent); }
.step.over-after { box-shadow: 0 2px 0 var(--accent); }
.step .handle { cursor: grab; color: var(--muted); padding: 0 4px; font-size: 18px; user-select: none; }
.step.new .handle { cursor: default; }
.step input[name$="-label"] { flex: 1; min-width: 160px; }
.step input[name$="-duration_days"] { width: 90px; }
.step .order { display: none; }
.step .check { padding: 0; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialog { padding: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--fg); width: min(900px, calc(100vw - 32px)); max-height: 80vh; }
.dialog::backdrop { background: rgba(0, 0, 0, .4); }
.dialog-body { padding: 16px 20px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.dialog-head h2 { margin: 0; font-size: 18px; }
.dialog .close { background: none; border: 0; font-size: 24px; color: var(--muted); cursor: pointer; }

.doc h2 { font-size: 16px; margin: 24px 0 8px; }
.doc p { max-width: 760px; }
.doc code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--hover); padding: 1px 4px; border-radius: 4px; white-space: nowrap; }
.schema-wrap { overflow-x: auto; }
table.doc { border-collapse: collapse; width: 100%; font-size: 13px; }
table.doc th { text-align: left; color: var(--muted); padding: 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.doc td { padding: 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.doc td.right { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }
td.nowrap { white-space: nowrap; }
button.copy { border: 1px solid var(--border); border-radius: 4px; background: var(--field-bg); color: var(--accent); font-size: 11px; padding: 1px 6px; cursor: pointer; }
button.copy:hover { background: var(--hover); }
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 6px 12px; border-radius: 6px; font-size: 13px; }
