/* CRUZ CRM — style « Nuit » (défaut) + mode « Jour » (html[data-mode="jour"]).
   Toutes les couleurs passent par ces variables : un composant n'utilise jamais
   une couleur en dur qui ne marcherait que dans un des deux modes. */
:root {
  color-scheme: dark;
  --bg: #0d0f14;
  --side: #0b0d11;
  --surface: #151922;
  --surface-2: #1d2230;
  --input: #10131a;
  --ink: #e9ecf2;
  --ink-2: #c3c8d4;
  --muted: #8a92a6;
  --line: #232836;
  --line-2: #1b2030;
  --accent: #ff4f7a;
  --accent-ink: #ff7d9b;
  --accent-soft: #2a1820;
  --on-accent: #0d0f14;
  --visits: #3a4256;
  --ok: #2fbf71;
  --ok-soft: #13261c;
  --danger: #ff6b5e;
  --warn-bg: #2b2412; --warn-fg: #f0c060;
  --bad-bg: #2d1515; --bad-fg: #ff8a80;
  --pop-bg: #e9ecf2; --pop-fg: #0d0f14;
  --ring: rgba(255, 79, 122, .28);
  --shadow: 0 30px 80px -20px rgba(0, 0, 0, .6);
  --radius: 16px;
  --font: "IBM Plex Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Archivo", "IBM Plex Sans", -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}
:root[data-mode="jour"] {
  color-scheme: light;
  --bg: #f4f5f8;
  --side: #ffffff;
  --surface: #ffffff;
  --surface-2: #eceef4;
  --input: #ffffff;
  --ink: #12141b;
  --ink-2: #3b4050;
  --muted: #687085;
  --line: #e1e4ec;
  --line-2: #eef0f5;
  --accent: #e3335f;
  --accent-ink: #c41d48;
  --accent-soft: #ffe5ec;
  --on-accent: #ffffff;
  --visits: #cdd2de;
  --ok: #17924f;
  --ok-soft: #e6f6ec;
  --danger: #d63a2f;
  --warn-bg: #fff1d6; --warn-fg: #8a5a00;
  --bad-bg: #fde3e0; --bad-fg: #a3271d;
  --pop-bg: #12141b; --pop-fg: #ffffff;
  --ring: rgba(227, 51, 95, .2);
  --shadow: 0 30px 80px -20px rgba(18, 20, 27, .35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; }
code { font-family: var(--mono); font-size: .9em; }
.muted { color: var(--muted); }
.sm { font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Marque ── */
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark { display: none; }
.brand-name { font-family: var(--display); font-stretch: 112%; font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.brand-sub { font: 500 11px var(--mono); letter-spacing: .16em; color: var(--accent); }
.brand-lg .brand-name { font-size: 34px; }
.brand-lg .brand-sub { font-size: 13px; }

/* ── Boutons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 18px; border-radius: 10px;
  font-weight: 600; white-space: nowrap;
  transition: background .15s, color .15s, transform .1s, border-color .15s, filter .15s;
}
.btn:active { transform: scale(.97); }
a.btn { text-decoration: none; }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border: 1px solid var(--line); background: var(--surface); }
.btn.ghost:hover { border-color: var(--muted); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.sm { height: 34px; padding: 0 13px; font-size: 13px; }
.btn.block { width: 100%; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  color: var(--ink-2); transition: background .15s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 17px; height: 17px; }

/* ── Formulaires ── */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field > span em { font-style: normal; font-weight: 400; color: var(--muted); }
.field input, .field select, .field textarea, .slug-input {
  width: 100%; min-height: 44px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--input);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 80px; }
.field input:focus, .field select:focus, .field textarea:focus, .slug-input:focus-within {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring);
}
.slug-input { display: flex; align-items: center; padding: 0 0 0 14px; font-family: var(--mono); font-size: 13px; }
.slug-input input { border: 0; box-shadow: none !important; padding-left: 0; font-family: var(--mono); font-size: 13px; min-height: 42px; background: transparent; }
.slug-input input:disabled { color: var(--muted); }
.slug-prefix { color: var(--muted); white-space: nowrap; }
.hint { display: block; color: var(--muted); font-size: 12px; margin-top: 6px; }
.form-error { color: var(--danger); font-size: 13px; margin: -4px 0 14px; }
select { appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a92a6' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px !important; }
option { background: var(--surface); color: var(--ink); }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: 13px; margin-bottom: 18px; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: var(--line); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--ring); }
.switch.inline { margin: 0; }

/* ── Connexion ── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 34px 28px 28px; }
.login-card .brand { margin-bottom: 10px; }
.login-hint { color: var(--muted); margin-bottom: 24px; }

/* ── Coque : menu latéral + contenu ── */
.shell { display: flex; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; width: 240px; flex: none;
  display: flex; flex-direction: column; gap: 26px;
  padding: 22px 14px; background: var(--side); border-right: 1px solid var(--line);
  overflow-y: auto;
}
.side .brand { padding: 0 10px; }
.tabs { display: flex; flex-direction: column; gap: 2px; }
.tabs a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  text-decoration: none; color: var(--muted); font-weight: 500; transition: background .15s, color .15s;
}
.tabs a svg { width: 17px; height: 17px; flex: none; }
.tabs a:hover { color: var(--ink); background: var(--surface); }
.tabs a.on { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.tabs .count { margin-left: auto; font: 500 11px var(--mono); font-style: normal; color: var(--muted); }
.side-models { display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.side-label { padding: 0 12px 4px; font: 500 10.5px var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.side-model {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 12px; border-radius: 10px;
  text-align: left; transition: background .15s;
}
.side-model:hover { background: var(--surface); }
.side-model.on { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }
.side-model .av { width: 32px; height: 32px; border-radius: 50%; flex: none; object-fit: cover; display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #0d0f14; }
.side-model .nm { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.side-model .nm b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-model .nm small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-empty { padding: 4px 12px; font-size: 12.5px; color: var(--muted); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.mode-switch button { display: flex; align-items: center; justify-content: center; gap: 6px; height: 32px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--muted); }
.mode-switch button svg { width: 15px; height: 15px; }
.mode-switch button.on { background: var(--surface-2); color: var(--ink); font-weight: 600; }

.content { flex: 1; min-width: 0; }
.demo-banner { background: var(--accent-soft); color: var(--ink); text-align: center; font-size: 12.5px; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.demo-banner code { color: var(--accent-ink); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 26px 28px 80px; }
.tab { position: relative; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-family: var(--display); font-stretch: 112%; font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.eyebrow { font: 500 11px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.range-label { color: var(--muted); margin-top: 8px; }
.head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* ── Barre d'outils ── */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 18px; }
.chips { display: flex; flex-wrap: wrap; padding: 3px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.chips button {
  height: 30px; padding: 0 12px; border-radius: 7px;
  font-size: 13px; color: var(--muted); transition: background .15s, color .15s;
}
.chips button:hover { color: var(--ink); }
.chips button.on { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.custom-range { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.custom-range input { height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--input); }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.filters select { height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background-color: var(--surface); font-size: 13px; font-weight: 500; max-width: 210px; }
.filters select.set { border-color: var(--accent); color: var(--ink); font-weight: 600; }

/* ── Chiffres clés : une seule barre ── */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; min-width: 0; border-right: 1px solid var(--line); }
.kpi:last-child { border-right: 0; }
.kpi-label { font: 500 10.5px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.kpi-value { font-family: var(--display); font-stretch: 112%; font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12.5px; color: var(--muted); min-height: 1em; }
.kpi.accent .kpi-value { color: var(--accent); }

/* ── Panneaux ── */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { font-size: 15px; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.grid-2 .panel { margin-bottom: 0; }
.grid-2 + .grid-2 { margin-top: 18px; }

.legend { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.lg { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.lg-visits { background: var(--visits); }
.lg-clicks { background: var(--accent); margin-left: 8px; }

/* ── Graphique ── */
.chart-wrap { position: relative; }
#chart svg { display: block; width: 100%; }
#chart .grid line { stroke: var(--line); }
#chart .axis text { fill: var(--muted); font-size: 11px; font-family: var(--mono); }
#chart .b-visits { fill: var(--visits); }
#chart .b-clicks { fill: var(--accent); }
#chart .hit { fill: transparent; }
#chart .hit:hover { fill: var(--line-2); fill-opacity: .5; }
.tip {
  position: absolute; z-index: 5; pointer-events: none;
  background: var(--pop-bg); color: var(--pop-fg); border-radius: 10px; padding: 8px 11px;
  font-size: 12.5px; line-height: 1.5; white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); transform: translate(-50%, -100%);
}
.tip b { font-weight: 600; display: block; margin-bottom: 2px; }
.tip .dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

/* ── Tableaux ── */
.table-scroll { max-height: 420px; overflow: auto; margin: 0 -6px; }
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th { position: sticky; top: 0; background: var(--surface); text-align: right; font: 500 10.5px var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .1em; padding: 0 6px 9px; border-bottom: 1px solid var(--line); }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl td { text-align: right; padding: 10px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { cursor: pointer; transition: background .1s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr.sel { background: var(--accent-soft); }
.tbl .name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tbl .name span { overflow: hidden; text-overflow: ellipsis; }
.tbl .share { position: relative; height: 6px; border-radius: 3px; background: var(--line); margin-top: 6px; overflow: hidden; }
.tbl .share i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 3px; }
.tbl .strong { font-weight: 600; }
.tbl .ctr { color: var(--accent-ink); font-weight: 600; }
.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: 12px; font-weight: 600; }
.flag { position: relative; width: 24px; height: 17px; border-radius: 3px; flex: none; overflow: hidden; background: var(--surface-2); box-shadow: 0 0 0 1px var(--line); display: inline-grid; place-items: center; }
.flag img { width: 100%; height: 100%; object-fit: cover; display: block; }
.flag b { font: 500 9px var(--mono); color: var(--muted); }
.flag.nf img { display: none; }
.flag:not(.nf) b { display: none; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.empty { text-align: center; color: var(--muted); padding: 34px 10px; }

/* ── Listes à barres ── */
.bars { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 120px minmax(0, 1fr) 70px; align-items: center; gap: 12px; font-size: 13px; }
.bar-row .lbl { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .trk { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar-row .trk i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar-row .val { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-row .val b { color: var(--ink); font-weight: 600; }

/* ── Chargement ── */
.loading-veil { position: absolute; inset: 140px 0 auto; display: flex; justify-content: center; align-items: center; gap: 10px; color: var(--muted); font-weight: 600; }
.stats-body.dim { opacity: .45; pointer-events: none; transition: opacity .2s; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--accent); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Liste des liens ── */
.list { display: grid; gap: 10px; }
.link-row {
  display: grid; grid-template-columns: 52px minmax(0, 1.4fr) minmax(0, 1fr) auto; align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
}
.link-row.off { opacity: .55; }
.thumb { width: 52px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--surface-2); display: block; }
.link-main { min-width: 0; }
.link-url { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 13.5px; font-weight: 500; }
.link-url a { text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-url a:hover { text-decoration: underline; }
.link-url .host { color: var(--muted); }
.link-meta { color: var(--muted); font-size: 12.5px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-meta b { color: var(--ink-2); font-weight: 600; }
.link-dest { min-width: 0; font-size: 12.5px; color: var(--muted); }
.link-dest span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.link-ctrl { display: flex; align-items: center; gap: 14px; }
.link-actions { display: flex; gap: 2px; }
.tags { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: 6px; vertical-align: 1px; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.tag.warn { background: var(--warn-bg); color: var(--warn-fg); }
.tag.bad { background: var(--bad-bg); color: var(--bad-fg); }
.tag.dark { background: var(--ink); color: var(--bg); }
.tag.ab { background: var(--accent-soft); color: var(--accent-ink); }

/* ── Rôles / équipe ── */
body:not([data-full]) .need-full, body:not([data-team]) .need-team { display: none !important; }
.me-chip { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 10px; text-align: left; border: 1px solid var(--line); background: var(--surface); }
.me-chip:hover { border-color: var(--muted); }
.me-chip .av { width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 12px; background: var(--accent); color: var(--on-accent); }
.me-chip .nm { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.me-chip .nm b { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-chip .nm small { font-size: 11.5px; color: var(--muted); }
.role-tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; letter-spacing: .02em; }
.r-admin { background: var(--accent); color: var(--on-accent); }
.r-manager { background: var(--accent-soft); color: var(--accent-ink); }
.r-responsable { background: color-mix(in srgb, var(--visits) 22%, transparent); color: var(--ink); }
.r-clipper { background: var(--surface-2); color: var(--ink-2); }
.roles-help { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.roles-help > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.roles-help p { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.user-row { display: grid; grid-template-columns: 40px minmax(0, 1.2fr) minmax(0, 1.5fr) auto; align-items: center; gap: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.user-row.off { opacity: .55; }
.user-row .av { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #0d0f14; }
.user-row .who b { display: block; font-weight: 600; }
.user-row .who small { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.user-row .scope { font-size: 12.5px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row .scope b { color: var(--ink-2); font-weight: 600; }
.user-row .ctrl { display: flex; align-items: center; gap: 10px; }
.role-pick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.role-pick label { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; background: var(--input); }
.role-pick label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.role-pick input { flex: none; width: 16px; height: 16px; min-height: 0; margin: 2px 0 0; padding: 0; accent-color: var(--accent); box-shadow: none; }
.role-pick b { display: block; font-size: 13px; font-weight: 600; }
.role-pick small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.model-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.model-checks label { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border: 1.5px solid var(--line); border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 500; background: var(--input); }
.model-checks label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.model-checks input { position: absolute; opacity: 0; pointer-events: none; }
.model-checks .av { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #0d0f14; }
.owner { color: var(--muted); }
.model-card[disabled] { cursor: default; }
.model-card[disabled]:hover { transform: none; border-color: var(--line); }

/* ── Modèles ── */
.model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.model-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-align: left; transition: transform .15s, border-color .15s; }
.model-card:hover { transform: translateY(-2px); border-color: var(--muted); }
.model-card img, .model-card .ph { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; display: block; background: var(--surface-2); }
.model-card .ph { display: grid; place-items: center; font-family: var(--display); font-size: 54px; font-weight: 800; color: var(--muted); }
.model-card .body { padding: 12px 14px 14px; }
.model-card h3 { font-size: 16px; font-weight: 600; }
.model-card p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.empty-card { grid-column: 1 / -1; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 48px 20px; text-align: center; color: var(--muted); }
.empty-card .btn { margin-top: 14px; }

/* ── Fenêtres ── */
.dlg { margin: auto; border: 1px solid var(--line); border-radius: 20px; padding: 0; width: min(520px, calc(100vw - 24px)); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.dlg::backdrop { background: rgba(5, 6, 10, .55); backdrop-filter: blur(3px); }
.dlg form { padding: 22px 24px 20px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.dlg-head h2 { font-family: var(--display); font-stretch: 112%; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.x { width: 34px; height: 34px; border-radius: 50%; font-size: 22px; line-height: 1; color: var(--muted); }
.x:hover { background: var(--surface-2); color: var(--ink); }
.dlg-foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.spacer { flex: 1; }
.model-form-row { display: flex; gap: 18px; }
.grow { flex: 1; min-width: 0; }
.photo-pick { flex: none; width: 128px; aspect-ratio: 4 / 5; border-radius: 14px; border: 1.5px dashed var(--line); background: var(--input); display: grid; place-items: center; overflow: hidden; cursor: pointer; position: relative; transition: border-color .15s; }
.photo-pick:hover { border-color: var(--accent); }
.photo-pick img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.photo-pick-empty { font-weight: 600; color: var(--muted); font-size: 13px; }

/* ── Éditeur de lien ── */
.dlg-wide { width: min(1060px, calc(100vw - 24px)); }
.dlg-sm { width: min(400px, calc(100vw - 24px)); }
.dlg-wide form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 316px; gap: 28px; min-height: 0; flex: 1; }
.editor-form { overflow-y: auto; min-height: 0; padding-right: 8px; margin-right: -8px; }
.sec { padding: 4px 0 18px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.sec:last-child { border-bottom: 0; margin-bottom: 0; }
.sec h3 { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.sec h3 .muted { font-weight: 400; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.sub-opts { padding: 2px 0 2px 48px; }
.sec .switch { display: flex; margin-bottom: 14px; }
.link-btn { display: block; margin-top: 8px; font-size: 12px; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: var(--ink); }
.photo-col { flex: none; }
.photo-pick-sm { width: 112px; }
.photo-pick-sm .photo-pick-empty { text-align: center; padding: 0 10px; font-size: 12px; line-height: 1.3; }
.center { text-align: center; }

.btn-list { display: grid; gap: 10px; margin-bottom: 12px; }
.btn-item { display: grid; grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 8px; align-items: center; }
.btn-item .num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--ink-2); }
.btn-item:first-child .num { background: var(--accent); color: var(--on-accent); }
.btn-item input { width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--input); outline: none; }
.btn-item input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.btn-item .ops { display: flex; }
.btn-item .ops .icon-btn { width: 30px; height: 30px; }
.btn-item .ops .icon-btn:disabled { opacity: .3; pointer-events: none; }

.themes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.theme { cursor: pointer; display: block; }
.theme input { position: absolute; opacity: 0; pointer-events: none; }
.theme i { display: block; height: 54px; border-radius: 12px; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(127,127,127,.25); position: relative; transition: border-color .15s; }
.theme i::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 9px; height: 12px; border-radius: 999px; }
.theme b { display: block; font-size: 12px; font-weight: 600; margin-top: 5px; text-align: center; color: var(--ink-2); }
.theme input:checked + i { border-color: var(--accent); }
.theme input:focus-visible + i { box-shadow: 0 0 0 3px var(--ring); }
.t-nuit i { background: #0f0e0c; } .t-nuit i::after { background: #f5f2ea; }
.t-creme i { background: #f3ede2; } .t-creme i::after { background: #1b1813; }
.t-rose i { background: #2a0f1b; } .t-rose i::after { background: #ffd3e1; }
.t-ocean i { background: #0a1a2a; } .t-ocean i::after { background: #e8f3ff; }

.accents { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.accents button { width: 30px; height: 30px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px var(--surface), 0 0 0 2px transparent; transition: box-shadow .15s; }
.accents button.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.accent-custom { width: 30px; height: 30px; border-radius: 50%; overflow: hidden; position: relative; cursor: pointer;
  background: conic-gradient(#ff5a1f, #e8b100, #14b87a, #2f7bff, #8b5cf6, #ff2e74, #ff5a1f); box-shadow: 0 0 0 2px var(--surface), 0 0 0 2px transparent; }
.accent-custom.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.accent-custom input { position: absolute; inset: -6px; width: 44px; height: 44px; opacity: 0; cursor: pointer; }

.editor-preview { position: sticky; top: 0; align-self: start; }
.phone { width: 300px; height: 600px; margin: 0 auto; border-radius: 40px; border: 8px solid #05060a; overflow: hidden; background: #0f0e0c; box-shadow: 0 0 0 1px var(--line), 0 24px 50px -24px rgba(0,0,0,.6); }
.phone iframe { width: 355px; border: 0; display: block; transform: scale(.8); transform-origin: 0 0; height: 730px; }

.tpls { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.tpl { cursor: pointer; display: block; text-align: center; border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 6px 10px; transition: border-color .15s, background .15s; }
.tpl:hover { border-color: var(--muted); }
.tpl input { position: absolute; opacity: 0; pointer-events: none; }
.tpl i { display: block; width: 34px; height: 48px; margin: 0 auto 8px; color: var(--muted); }
.tpl i svg { width: 100%; height: 100%; display: block; }
.tpl b { display: block; font-size: 13px; font-weight: 700; }
.tpl small { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
.tpl:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.tpl:has(input:checked) i { color: var(--accent); }
.tpl:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--ring); }
#lf-tpl-hint { margin-top: 10px; }

.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.img-item { position: relative; aspect-ratio: 4 / 5; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.img-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-item .rm { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; background: rgba(5,6,10,.75); color: #fff; font-size: 14px; line-height: 1; display: grid; place-items: center; }
.img-item .ord { position: absolute; left: 4px; bottom: 4px; font-size: 10px; font-weight: 700; background: rgba(255,255,255,.9); color: #12141b; border-radius: 6px; padding: 1px 5px; }
.img-add { aspect-ratio: 4 / 5; border-radius: 10px; border: 1.5px dashed var(--line); display: grid; place-items: center; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 12px; text-align: center; background: var(--input); }
.img-add:hover { border-color: var(--accent); color: var(--ink); }

/* Test A/B */
.ab-explain { display: grid; gap: 8px; margin-bottom: 16px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.ab-step { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; align-items: start; font-size: 13px; color: var(--ink-2); line-height: 1.45; }
.ab-step b { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800; background: var(--accent); color: var(--on-accent); }
.ab-step strong { color: var(--ink); font-weight: 600; }
.ab-opts { padding-left: 48px; display: grid; gap: 4px; }
.ab-choice { display: grid; gap: 8px; }
.ab-radio { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; background: var(--input); }
.ab-radio:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.ab-radio[hidden] { display: none; }
.ab-radio input { flex: none; width: 16px; height: 16px; min-height: 0; margin: 2px 0 0; padding: 0; accent-color: var(--accent); box-shadow: none; }
.ab-radio > span { flex: 1; min-width: 0; text-align: left; }
.ab-radio b { display: block; font-size: 13px; font-weight: 600; color: var(--ink); }
.ab-radio small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
#lf-ab-link { margin-top: 8px; }
.ab-current { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.ab-current b { font-family: var(--mono); font-weight: 500; }
.ab-bar { display: flex; height: 30px; border-radius: 10px; overflow: hidden; gap: 2px; margin-bottom: 6px; }
.ab-bar i { font-style: normal; display: grid; place-items: center; font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; transition: flex-grow .15s; }
.ab-bar-a { background: var(--surface-2); color: var(--ink); }
.ab-bar-b { background: var(--accent); color: var(--on-accent); }
#lf-ab-split { width: 100%; accent-color: var(--accent); }
.ab-sentence { font-size: 13px; color: var(--ink-2); margin: 2px 0 0; }
.ab-banner { margin-bottom: 18px; padding: 12px 14px; border-radius: 12px; font-size: 13px; line-height: 1.5; background: var(--accent-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.ab-banner[hidden] { display: none; }
.tag.ab-b { background: var(--surface-2); color: var(--ink-2); }
button.tag { border: 0; cursor: pointer; font: inherit; font-size: 11px; font-weight: 600; }
button.tag:hover { text-decoration: underline; }

#panel-ab { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.ab-test + .ab-test { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.ab-test-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.ab-test-head b { font-family: var(--mono); font-weight: 500; }
.ab-cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ab-card { border: 1.5px solid var(--line); border-radius: 14px; padding: 14px 16px; display: grid; gap: 8px; background: var(--bg); align-content: start; }
.ab-card.win { border-color: var(--accent); }
.ab-card .ab-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ab-card .ab-name { font-size: 13px; font-weight: 500; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.ab-card .ab-letter { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; background: var(--surface-2); color: var(--ink); flex: none; }
.ab-card.win .ab-letter { background: var(--accent); color: var(--on-accent); }
.ab-crown { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: var(--on-accent); flex: none; }
.ab-card .ab-ctr { font-family: var(--display); font-stretch: 112%; font-size: 34px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.ab-explain-sm { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.ab-explain-sm b { color: var(--ink); font-weight: 600; }
.ab-card .btn { margin-top: 4px; }
.ab-verdict { margin: 12px 0 0; font-size: 14px; color: var(--ink-2); padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.ab-verdict.win { background: var(--accent-soft); color: var(--ink); }

.qr-box { display: grid; place-items: center; padding: 18px; background: #fff; border: 1px solid var(--line); border-radius: 16px; min-height: 260px; }
.qr-box img, .qr-box canvas { width: 240px !important; height: 240px !important; image-rendering: pixelated; }
.qr-url { text-align: center; margin: 12px 0 16px; word-break: break-all; color: var(--ink-2); }
.panel-gap { margin-top: 18px; }

/* ── Notification ── */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; background: var(--pop-bg); color: var(--pop-fg); padding: 11px 18px; border-radius: 12px; font-weight: 500; box-shadow: 0 12px 30px rgba(0,0,0,.3); max-width: calc(100vw - 32px); animation: toastIn .2s ease; }
.toast.err { background: var(--danger); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ── Écrans plus étroits ── */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(2) { border-right: 0; }
  .kpi:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 960px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .filters { margin-left: 0; }
  .link-row { grid-template-columns: 52px minmax(0, 1fr) auto; }
  .link-dest { display: none; }
}
@media (max-width: 900px) {
  .editor { grid-template-columns: 1fr; }
  .editor-preview { display: none; }
  /* Le menu latéral passe en barre en haut */
  .shell { flex-direction: column; }
  .side { position: static; height: auto; width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .tabs { flex-direction: row; order: 3; width: 100%; }
  .tabs a { flex: 1; justify-content: center; padding: 9px 8px; }
  .tabs .count { display: none; }
  .side-models { display: none; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  .side-foot .btn { width: auto; height: 34px; font-size: 13px; }
  .me-chip { width: auto; padding: 4px 10px 4px 4px; }
  .me-chip .nm small { display: none; }
  .roles-help { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .user-row { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .user-row .scope { grid-column: 2 / 4; grid-row: 2; white-space: normal; }
  .wrap { padding: 22px 16px 64px; }
}
@media (max-width: 560px) {
  .row-2 { grid-template-columns: 1fr; }
  .role-pick, .roles-help { grid-template-columns: 1fr; }
  .sub-opts, .ab-opts { padding-left: 0; }
  .btn-item { grid-template-columns: 26px minmax(0, 1fr) auto; }
  .btn-item .b-url { grid-column: 2 / 4; }
  .themes { grid-template-columns: repeat(2, 1fr); }
  .tpls { grid-template-columns: repeat(3, 1fr); }
  .ab-cmp { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 28px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 26px; }
  .filters select { flex: 1 1 140px; max-width: none; }
  .link-row { grid-template-columns: 44px minmax(0, 1fr); gap: 4px 12px; }
  .link-row .thumb { width: 44px; height: 54px; grid-row: span 2; }
  .link-ctrl { grid-column: 2; justify-content: space-between; }
  .model-form-row { flex-direction: column; }
  .photo-pick { width: 110px; }
  .bar-row { grid-template-columns: 84px minmax(0, 1fr) 60px; }
  .mode-switch button { padding: 0 8px; }
}
