/* CRM — interface. Thème réglable dans Settings (⚙︎) : posé sur <html> par index.html / app.js via
   data-theme (light|dark), data-chat (tinted|plain), data-bubbles (solid) et la variable --accent-base. */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f6f7f9;
  --hover: #f1f3f6;
  --border: #e6e8ec;
  --border-2: #d3d7de;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --faint: #9aa1ad;
  --chat-bg: #edf0f4;
  --bubble-in: #ffffff;
  --meta: #8b95a3;
  --day-bg: rgba(255, 255, 255, .92);
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --good: #15803d;
  --good-soft: #e7f6ec;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 10px 28px rgba(16, 24, 40, .10);
  /* une seule couleur d'accent : tout le reste en découle */
  --accent-base: #2481cc;
  --accent: var(--accent-base);
  --accent-2: color-mix(in srgb, var(--accent) 86%, #000);
  --accent-soft: color-mix(in srgb, var(--accent) 11%, var(--panel));
  --active: color-mix(in srgb, var(--accent) 12%, var(--panel));
  --bubble-out: color-mix(in srgb, var(--accent) 17%, #fff);
  --bubble-out-text: var(--text);
  --meta-out: color-mix(in srgb, var(--accent) 62%, var(--muted));
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 24%, transparent);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e1014;
  --panel: #15181d;
  --panel-2: #1a1d23;
  --hover: #1d2128;
  --border: #252931;
  --border-2: #343a44;
  --text: #e8eaee;
  --text-2: #c5cad3;
  --muted: #9198a5;
  --faint: #6b7280;
  --chat-bg: #0b0d11;
  --bubble-in: #1b1f26;
  --meta: #7b8494;
  --day-bg: rgba(27, 31, 38, .94);
  --danger: #f87171;
  --danger-soft: #3a1a1a;
  --good: #4ade80;
  --good-soft: #12321d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .45);
  --accent: color-mix(in srgb, var(--accent-base) 80%, #fff);
  --accent-2: color-mix(in srgb, var(--accent) 85%, #fff);
  --accent-soft: color-mix(in srgb, var(--accent) 15%, var(--panel));
  --active: color-mix(in srgb, var(--accent) 17%, var(--panel));
  --bubble-out: color-mix(in srgb, var(--accent) 30%, var(--panel-2));
  --meta-out: color-mix(in srgb, var(--accent) 70%, var(--muted));
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
  color-scheme: dark;
}
/* fond des conversations */
:root[data-chat="tinted"] { --chat-bg: color-mix(in srgb, var(--accent) 10%, var(--bg)); }
:root[data-chat="plain"] { --chat-bg: var(--panel); --bubble-in: var(--hover); }
/* bulles envoyées pleines, texte blanc */
:root[data-bubbles="solid"] { --bubble-out: var(--accent); --bubble-out-text: #fff; --meta-out: rgba(255, 255, 255, .8); }

/* couleurs des tags (fond, texte, pastille) */
[data-c="blue"]   { --tb: #dbeafe; --tf: #1e40af; --sw: #3b82f6; }
[data-c="green"]  { --tb: #dcfce7; --tf: #166534; --sw: #22c55e; }
[data-c="amber"]  { --tb: #fef3c7; --tf: #92400e; --sw: #f59e0b; }
[data-c="red"]    { --tb: #fee2e2; --tf: #991b1b; --sw: #ef4444; }
[data-c="purple"] { --tb: #ede9fe; --tf: #5b21b6; --sw: #8b5cf6; }
[data-c="pink"]   { --tb: #fce7f3; --tf: #9d174d; --sw: #ec4899; }
[data-c="teal"]   { --tb: #ccfbf1; --tf: #115e59; --sw: #14b8a6; }
[data-c="slate"]  { --tb: #e5e7eb; --tf: #374151; --sw: #64748b; }
:root[data-theme="dark"] [data-c="blue"]   { --tb: #172f4d; --tf: #9cc8ff; }
:root[data-theme="dark"] [data-c="green"]  { --tb: #12321d; --tf: #86efac; }
:root[data-theme="dark"] [data-c="amber"]  { --tb: #3a2c0c; --tf: #fcd34d; }
:root[data-theme="dark"] [data-c="red"]    { --tb: #3b1618; --tf: #fca5a5; }
:root[data-theme="dark"] [data-c="purple"] { --tb: #2a2148; --tf: #c4b5fd; }
:root[data-theme="dark"] [data-c="pink"]   { --tb: #3a172d; --tf: #f9a8d4; }
:root[data-theme="dark"] [data-c="teal"]   { --tb: #0e322f; --tf: #5eead4; }
:root[data-theme="dark"] [data-c="slate"]  { --tb: #282d35; --tf: #cbd5e1; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
input, textarea { outline: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.logo { stroke: none; }
[hidden] { display: none !important; }
code { font: 12px var(--mono); background: var(--panel-2); border: 1px solid var(--border); padding: 0 5px; border-radius: 5px; }
kbd { font: 11px var(--mono); padding: 0 5px; border: 1px solid var(--border-2); border-bottom-width: 2px; border-radius: 5px; background: var(--panel); color: var(--text-2); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
:focus-visible { outline: none; box-shadow: var(--ring); }

.list, .msgs, .info, .sugg, .modal-card { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }

/* ── boutons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--text-2); font-weight: 550; white-space: nowrap; }
.btn:hover { background: var(--hover); text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.busy, .busy { opacity: .55; pointer-events: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.on { background: var(--accent-soft); color: var(--accent); }
.icon-btn.sm { width: 26px; height: 26px; }
.icon-btn.sm svg { width: 15px; height: 15px; }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.link { padding: 0; border: 0; background: none; color: var(--accent); font-size: 13px; }
.link:hover { text-decoration: underline; }

.spin { width: 22px; height: 22px; margin: 0 auto; border: 2.5px solid var(--border-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.spin.sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.boot { height: 100%; display: grid; place-items: center; }

/* ── marque ── */
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15.5px; letter-spacing: -.01em; }
.brand svg { width: 26px; height: 26px; }

/* ── connexion ── */
.auth { min-height: 100%; display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 420px; padding: 28px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }
.auth h1 { margin: 22px 0 6px; font-size: 20px; letter-spacing: -.015em; }
.auth .lead { margin: 0 0 16px; color: var(--text-2); }
.auth form { display: grid; gap: 12px; }
.auth label { display: grid; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.auth input { height: 42px; padding: 0 12px; border: 1px solid var(--border-2); border-radius: 9px; background: var(--panel); font-size: 15px; font-weight: 400; color: var(--text); }
.auth input:focus { border-color: var(--accent); box-shadow: var(--ring); }
.auth .btn { height: 42px; margin-top: 2px; font-size: 14.5px; }
.auth .wide { width: 100%; }
.or { display: flex; align-items: center; gap: 10px; margin: 18px 0 12px; font-size: 12px; color: var(--faint); }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.qr { display: grid; place-items: center; width: 236px; min-height: 236px; margin: 6px auto 18px; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: #fff; line-height: 0; }
.qr svg { width: 100%; height: auto; fill: #000; stroke: none; }
.auth .err { padding: 8px 11px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); font-size: 13px; }
.auth .hint { margin: -4px 0 0; font-size: 12.5px; color: var(--muted); }
.steps { margin: 0 0 18px; padding-left: 20px; color: var(--text-2); }
.steps li { margin: 5px 0; }
.links { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; }
.auth .center { display: grid; gap: 14px; justify-items: center; padding: 18px 0 6px; color: var(--muted); }
.auth .btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.fine { margin: 22px 0 0; padding-top: 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }

/* ── mise en page ── */
/* coquille : barre des modèles + vues */
.shell { display: grid; grid-template-columns: 68px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.views { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
.view-dash { height: 100%; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
.views > .auth { height: 100%; overflow-y: auto; }
.rail { display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 0; padding: 12px 0; background: var(--panel); border-right: 1px solid var(--border); }
.rail-logo { display: grid; place-items: center; margin-bottom: 8px; padding: 0; border: 0; border-radius: 10px; background: none; }
.rail-logo svg { width: 30px; height: 30px; transition: transform .15s; }
.rail-logo:hover svg { transform: scale(1.07); }
.rail-btn { position: relative; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 12px; background: transparent; color: var(--muted); }
.rail-btn:hover { background: var(--hover); color: var(--text); }
.rail-btn.on { background: var(--accent-soft); color: var(--accent); }
.rail-btn svg { width: 22px; height: 22px; }
.rail-btn[data-tip]:hover::after, .rail-btn[data-tip]:focus-visible::after { content: attr(data-tip); position: absolute; top: 50%; left: calc(100% + 10px); z-index: 70; padding: 5px 9px; transform: translateY(-50%); border-radius: 7px; background: var(--text); color: var(--panel); font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none; box-shadow: var(--shadow); }
.rail-sep { width: 28px; height: 1px; margin: 4px 0; background: var(--border); }
/* toute la largeur de la barre : la pastille de non-lus et l'anneau du modèle actif ne sont plus rognés */
.rail-models { display: flex; flex: 1; flex-direction: column; align-items: center; align-self: stretch; gap: 10px; min-height: 0; padding: 6px 0; overflow-y: auto; scrollbar-width: none; }
.rail-model { flex: none; display: grid; place-items: center; padding: 0; border: 0; background: none; }
.rail-av { position: relative; display: block; border-radius: 50%; box-shadow: 0 0 0 2px transparent; transition: box-shadow .15s; }
.rail-model:hover .rail-av { box-shadow: 0 0 0 2px var(--border-2); }
.rail-model.on .rail-av { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
.rail-badge { position: absolute; top: -3px; right: -5px; display: grid; place-items: center; min-width: 16px; height: 16px; padding: 0 4px; border: 2px solid var(--panel); border-radius: 999px; background: var(--accent); color: #fff; font-size: 9.5px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; box-sizing: content-box; }
.rail-off { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border: 2px solid var(--panel); border-radius: 50%; background: var(--faint); }
.rail-add { flex: none; display: grid; place-items: center; padding: 0; border: 0; background: none; color: var(--muted); }
.rail-add-ic { display: grid; flex: none; place-items: center; width: 40px; height: 40px; border: 1.5px dashed var(--border-2); border-radius: 50%; color: var(--muted); }
.rail-add:hover .rail-add-ic { border-color: var(--accent); color: var(--accent); }
.rail-bottom { display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 6px; }
.rail-me { display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: none; }
.rail-me:hover { opacity: .85; }
.rail-label, .rail-count { display: none; }

/* barre dépliée : le nom à côté de chaque icône et de chaque modèle */
.shell { transition: grid-template-columns .18s ease; }
.shell.rail-open { grid-template-columns: 232px minmax(0, 1fr); }
.rail-open .rail { align-items: stretch; padding: 12px 10px; }
.rail-open .rail-logo, .rail-open .rail-btn, .rail-open .rail-model, .rail-open .rail-add, .rail-open .rail-me { display: flex; align-items: center; justify-content: flex-start; gap: 12px; width: 100%; height: 42px; padding: 0 10px; border-radius: 10px; }
.rail-open .rail-logo { margin-bottom: 8px; padding: 0 6px; }
.rail-open .rail-label { display: block; flex: 1; min-width: 0; overflow: hidden; color: var(--text-2); font-size: 14px; font-weight: 600; text-align: left; white-space: nowrap; text-overflow: ellipsis; }
.rail-open .rail-logo .rail-label { color: var(--text); font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.rail-open .rail-btn.on .rail-label { color: var(--accent); }
.rail-open .rail-btn[data-tip]:hover::after, .rail-open .rail-btn[data-tip]:focus-visible::after { content: none; }
.rail-open .rail-model:hover, .rail-open .rail-add:hover, .rail-open .rail-me:hover { background: var(--hover); opacity: 1; }
.rail-open .rail-model.on { background: var(--accent-soft); }
.rail-open .rail-model.on .rail-label { color: var(--accent); }
.rail-open .rail-model .rail-av, .rail-open .rail-model:hover .rail-av, .rail-open .rail-model.on .rail-av { box-shadow: none; }
.rail-open .rail-model .av, .rail-open .rail-me .av { --s: 30px !important; }  /* la taille est posée en ligne sur l'avatar */
.rail-open .rail-add-ic { width: 30px; height: 30px; }
.rail-open .rail-add .rail-label { color: var(--muted); }
.rail-open .rail-badge { display: none; }
.rail-open .rail-count { display: inline-grid; flex: none; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rail-open .rail-sep { width: auto; margin: 6px 4px; }
.rail-open .rail-models { align-items: stretch; gap: 2px; padding: 2px 0; }
.rail-open .rail-bottom { align-items: stretch; gap: 2px; }

.app { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: 100%; }
.app.show-info { grid-template-columns: 340px minmax(0, 1fr) 320px; }
.info { display: none; }
.app.show-info .info { display: block; }

/* ── colonne de gauche ── */
.side { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-right: 1px solid var(--border); }
.side-head { display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 12px 14px 10px 16px; }
.side-model { display: grid; min-width: 0; line-height: 1.25; }
.side-model b { overflow: hidden; font-size: 15px; white-space: nowrap; text-overflow: ellipsis; }
.side-model span { overflow: hidden; font-size: 12px; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
.tabs { display: flex; gap: 3px; margin: 0 12px; padding: 3px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; }
.tab { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .1); }
.count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; }
.count:empty { display: none; }
.tab:not(.active) .count { background: var(--faint); }
.search { position: relative; margin: 10px 12px 8px; }
.search svg { position: absolute; left: 10px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--faint); }
.search input { width: 100%; height: 34px; padding: 0 10px 0 32px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel-2); }
.search input:focus { border-color: var(--accent); background: var(--panel); box-shadow: var(--ring); }
.tagbar { display: flex; align-items: center; gap: 6px; padding: 0 12px 10px; overflow-x: auto; scrollbar-width: none; }
.tagbar::-webkit-scrollbar { display: none; }
.tagbar .tag { flex: none; height: 24px; border: 0; cursor: pointer; }
.tagbar .tag:hover { filter: brightness(.97); }
.tagbar .tag.on { box-shadow: inset 0 0 0 1.5px var(--tf); }
.tagbar .tag .n { margin-left: 3px; font-size: 11px; opacity: .6; }
.tagbar .icon-btn { flex: none; }
.list { flex: 1; min-height: 0; overflow-y: auto; border-top: 1px solid var(--border); }
.loading-bar { display: flex; align-items: center; gap: 8px; padding: 9px 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.loading-bar .spin { margin: 0; }

.row { position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 14px 9px 14px; cursor: pointer; }
.row:hover { background: var(--hover); }
.row.active { background: var(--active); }
.row-main { flex: 1; min-width: 0; }
.row-top, .row-bottom { display: flex; align-items: center; gap: 8px; }
.row .nm { flex: 1; min-width: 0; overflow: hidden; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.row .time { flex: none; font-size: 12px; color: var(--faint); }
.row.unread .time { color: var(--accent); font-weight: 600; }
.row-bottom { margin-top: 1px; }
.row .prev { flex: 1; min-width: 0; overflow: hidden; font-size: 13.5px; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
.row.unread .prev { color: var(--text-2); }
.row .you { color: var(--text-2); }
.badge { display: inline-grid; place-items: center; flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 700; }
.badge.dot { min-width: 0; width: 10px; height: 10px; padding: 0; }
.row-tags { display: flex; gap: 4px; margin-top: 5px; overflow: hidden; }
.more-tags { align-self: center; font-size: 11px; font-weight: 600; color: var(--muted); }
.row-act { position: absolute; top: 50%; right: 10px; display: none; place-items: center; width: 30px; height: 30px; padding: 0; transform: translateY(-50%); border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--muted); box-shadow: 0 1px 3px rgba(16, 24, 40, .08); }
.row:hover .row-act { display: grid; }
.row-act:hover { border-color: var(--accent); color: var(--accent); }
.list-sep { padding: 16px 16px 6px; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); }
.list-empty { padding: 56px 24px; text-align: center; color: var(--muted); }
.list-empty b { display: block; margin-bottom: 4px; font-size: 15px; color: var(--text); }

/* ── avatars & tags ── */
.av { --s: 44px; position: relative; display: grid; place-items: center; flex: none; width: var(--s); height: var(--s); overflow: hidden; border-radius: 50%; background: var(--av); background: linear-gradient(150deg, color-mix(in srgb, var(--av) 72%, #fff), var(--av)); color: #fff; font-size: calc(var(--s) * .37); font-weight: 600; user-select: none; }
.av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 9px; border-radius: 999px; background: var(--tb, #e5e7eb); color: var(--tf, #374151); font-size: 12px; font-weight: 600; line-height: 1; white-space: nowrap; }
.tag.sm { height: 18px; padding: 0 7px; font-size: 11px; }
.tag-x { display: inline-grid; place-items: center; width: 16px; height: 16px; margin-right: -5px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: inherit; opacity: .55; }
.tag-x:hover { opacity: 1; background: rgba(0, 0, 0, .08); }
.tag-x svg { width: 11px; height: 11px; stroke-width: 2.4; }

/* ── conversation ── */
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--chat-bg); }
.chat-empty { display: grid; gap: 6px; justify-items: center; margin: auto; padding: 24px; text-align: center; color: var(--muted); }
.chat-empty svg { width: 44px; height: 44px; margin-bottom: 8px; opacity: .9; }
.chat-empty p { margin: 0; }
.chat-head { display: flex; flex: none; align-items: center; gap: 12px; height: 60px; padding: 0 12px 0 16px; background: var(--panel); border-bottom: 1px solid var(--border); }
.chat-head .who { flex: 1; min-width: 0; }
.chat-head .nm, .chat-head .sub { cursor: pointer; }
.nm-row { display: flex; align-items: center; gap: 3px; min-width: 0; }
.nm-row .nm { min-width: 0; }
.pen { display: inline-grid; place-items: center; flex: none; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--faint); }
.pen:hover { background: var(--hover); color: var(--accent); }
.pen svg { width: 14px; height: 14px; }
.rename-input { width: 100%; min-width: 0; max-width: 340px; height: 30px; padding: 0 9px; border: 1px solid var(--accent); border-radius: 7px; background: var(--panel); color: var(--text); font-size: 15px; font-weight: 650; box-shadow: var(--ring); }
.chat-head .av { cursor: pointer; }
.chat-head .nm { overflow: hidden; font-size: 15px; font-weight: 650; white-space: nowrap; text-overflow: ellipsis; }
.chat-head .sub { overflow: hidden; font-size: 12.5px; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
.chat-head .sub:empty::before { content: '\00a0'; }
.head-actions { display: flex; align-items: center; gap: 6px; }
.back { display: none; }

.msgs { flex: 1; min-height: 0; overflow-y: auto; overflow-anchor: none; padding: 6px 20px 18px; }
.msgs-top { padding: 14px 0 6px; font-size: 12px; text-align: center; color: var(--faint); }
.msgs-state { display: grid; place-items: center; height: 100%; color: var(--muted); text-align: center; }
.day { position: sticky; top: 8px; z-index: 2; display: flex; justify-content: center; margin-top: 10px; margin-bottom: 6px; pointer-events: none; }
.day span { padding: 3px 10px; border-radius: 999px; background: var(--day-bg); color: var(--text-2); font-size: 12px; font-weight: 600; box-shadow: 0 1px 2px rgba(16, 24, 40, .08); }
.svc { display: flex; justify-content: center; margin: 6px auto; }
.svc span { padding: 3px 10px; border-radius: 999px; background: var(--day-bg); color: var(--muted); font-size: 12.5px; }
.msg { display: flex; padding: 1.5px 0; }
.msg.out { justify-content: flex-end; }
.bubble { position: relative; max-width: min(560px, 78%); padding: 6px 10px 6px 11px; border-radius: 16px; background: var(--bubble-in); box-shadow: 0 1px 1px rgba(16, 24, 40, .07); }
.msg.in .bubble { border-bottom-left-radius: 6px; }
.msg.out .bubble { border-bottom-right-radius: 6px; background: var(--bubble-out); color: var(--bubble-out-text); }
:root[data-bubbles="solid"] .msg.out .bubble a { color: inherit; text-decoration: underline; }
:root[data-bubbles="solid"] .msg.out .quote { border-left-color: rgba(255, 255, 255, .75); background: rgba(255, 255, 255, .16); color: inherit; }
:root[data-bubbles="solid"] .msg.out .fwd, :root[data-bubbles="solid"] .msg.out .att { color: inherit; }
.tx { white-space: pre-wrap; overflow-wrap: anywhere; }
.ghost, .meta { font-size: 11px; line-height: 1; white-space: nowrap; }
.ghost { display: inline-block; margin-left: 10px; visibility: hidden; }
.meta { position: absolute; right: 9px; bottom: 6px; color: var(--meta); user-select: none; }
.msg.out .meta { color: var(--meta-out); }
.tick { font-style: normal; }
.tick::after { content: '✓'; margin-left: 3px; }
.msg.out.read .tick::after { content: '✓✓'; letter-spacing: -3px; margin-right: 3px; }
.fwd { margin-bottom: 2px; font-size: 12px; font-weight: 600; color: var(--accent); }
.quote { max-width: 100%; margin: 2px 0 5px; padding: 3px 8px; overflow: hidden; border-left: 3px solid var(--accent); border-radius: 4px; background: color-mix(in srgb, var(--accent) 9%, transparent); color: var(--text-2); font-size: 13px; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; }
.bubble.has-ph { width: 340px; }
.ph { position: relative; display: block; margin: -3px -7px 5px -8px; overflow: hidden; border-radius: 12px; background: var(--panel-2); line-height: 0; }
.ph img { display: block; width: 100%; height: auto; max-height: 440px; object-fit: cover; }
.ph:hover { text-decoration: none; }
.ph-badge { position: absolute; left: 8px; bottom: 8px; padding: 4px 8px; border-radius: 999px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 11.5px; line-height: 1.2; }
.ph.ph-err { padding: 14px; line-height: 1.4; }
.ph.ph-err img { display: none; }
.ph.ph-err::before { content: attr(data-label); color: var(--muted); }
.ph.round { width: 220px; margin: 0 auto 5px; border-radius: 50%; }
.ph.round img { aspect-ratio: 1 !important; }
.bubble.media-only { padding: 3px; }
.bubble.media-only .ph { margin: 0; border-radius: 13px; }
.bubble.media-only .meta, .bubble.sticker-only .meta { right: 10px; bottom: 10px; padding: 3px 7px; border-radius: 999px; background: rgba(0, 0, 0, .5); color: #fff; }
.bubble.sticker-only { background: transparent !important; box-shadow: none; }
.sticker { padding: 0 4px 22px; font-size: 64px; line-height: 1.1; }
.att { display: flex; align-items: center; gap: 6px; padding: 2px 0; color: var(--text-2); font-weight: 550; }
.msg.flash .bubble { animation: flash 1.4s ease-out; }
@keyframes flash { 0%, 35% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 1px 1px rgba(16, 24, 40, .07); } }

.composer { position: relative; display: flex; flex: none; align-items: flex-end; gap: 8px; padding: 10px 16px 14px; background: var(--panel); border-top: 1px solid var(--border); }
.composer textarea { flex: 1; min-height: 40px; max-height: 200px; padding: 9px 14px; resize: none; border: 1px solid var(--border-2); border-radius: 20px; background: var(--panel-2); line-height: 1.45; }
.composer textarea:focus { border-color: var(--accent); background: var(--panel); box-shadow: var(--ring); }
.ppv-btn { display: inline-flex; flex: none; align-items: center; gap: 5px; height: 40px; padding: 0 13px; border: 1px solid var(--border-2); border-radius: 20px; background: var(--panel); color: var(--text-2); font-size: 12.5px; font-weight: 700; letter-spacing: .02em; }
.ppv-btn:hover { border-color: var(--accent); color: var(--accent); }
.ppv-btn svg { width: 16px; height: 16px; }
.send { display: grid; place-items: center; flex: none; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: var(--accent); color: #fff; }
.send:hover { background: var(--accent-2); }
.send svg { width: 18px; height: 18px; margin-left: -2px; }

/* ── fiche contact ── */
.info { min-height: 0; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--border); }
.info-close { position: absolute; top: 8px; right: 8px; display: none; }
.info-top { display: flex; flex-direction: column; align-items: center; padding: 28px 20px 22px; text-align: center; border-bottom: 1px solid var(--border); }
.info-name { position: relative; max-width: calc(100% - 64px); margin-top: 14px; }
.info-name h2 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -.015em; line-height: 1.25; overflow-wrap: anywhere; }
.info-name .pen { position: absolute; top: 50%; left: 100%; margin-left: 4px; transform: translateY(-50%); }
.rename-input.big { max-width: 250px; height: 38px; margin-top: 14px; font-size: 19px; font-weight: 700; text-align: center; }
.tg-name { margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.info-sec { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.info-sec:last-child { border-bottom: 0; }
.info-sec h3 { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.info-sec h3 svg { width: 14px; height: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chips:empty { display: none; }
.tag-add { position: relative; }
.tag-add input { width: 100%; height: 32px; padding: 0 10px; border: 1px dashed var(--border-2); border-radius: 8px; background: transparent; font-size: 13px; }
.tag-add input:focus { border-style: solid; border-color: var(--accent); background: var(--panel); box-shadow: var(--ring); }
.sugg { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 10; max-height: 240px; padding: 4px; overflow-y: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.sg { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; font-size: 13px; cursor: pointer; }
.sg.on { background: var(--hover); }
.sg .plus { color: var(--muted); }
.note { display: block; width: 100%; min-height: 104px; padding: 10px 12px; resize: vertical; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2); font-size: 13.5px; line-height: 1.5; }
.note:focus { border-color: var(--accent); background: var(--panel); box-shadow: var(--ring); }
.save-state { margin-left: auto; font-size: 11.5px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--faint); }
.fields { display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 8px 10px; }
.fields label { font-size: 13px; color: var(--muted); }
.fields input { width: 100%; height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); font-size: 13.5px; }
.fields input:focus { border-color: var(--accent); background: var(--panel); box-shadow: var(--ring); }
.fields #f-age { width: 72px; }

/* ── modale, toast ── */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(15, 23, 42, .38); }
.modal-card { width: 100%; max-width: 460px; max-height: 82vh; padding: 18px 20px 20px; overflow-y: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-card p { margin: 6px 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.tm-list { display: grid; gap: 2px; margin-top: 12px; }
.tm-row { display: flex; align-items: center; gap: 8px; padding: 3px 4px 3px 8px; border-radius: 8px; }
.tm-row:hover { background: var(--hover); }
.swatch { flex: none; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; background: var(--sw); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); }
.tm-name { flex: 1; min-width: 0; height: 30px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px; background: transparent; font-weight: 600; }
.tm-name:hover { border-color: var(--border); }
.tm-name:focus { border-color: var(--accent); background: var(--panel); box-shadow: var(--ring); }
.tm-n { min-width: 70px; font-size: 12px; text-align: right; color: var(--muted); }
.acct { display: flex; align-items: center; gap: 12px; margin: 14px 0; }

/* ── Settings ── */
.set { display: grid; gap: 20px; margin-top: 18px; }
.set-row { display: grid; gap: 9px; }
.set-label { font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.seg { display: inline-flex; justify-self: start; gap: 3px; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2); }
.seg button { height: 30px; padding: 0 15px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .12); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.sw { position: relative; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; background: var(--sw); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); cursor: pointer; }
.sw.on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--sw); }
.sw.custom { background: conic-gradient(#ef4444, #f59e0b, #22c55e, #06b6d4, #3b82f6, #a855f7, #ef4444); }
.sw.custom.on { background: var(--sw); }
.sw input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }

/* ── PPV ── */
.modal-card.wide { max-width: 780px; }
.modal-head h2 .muted { font-weight: 500; }
.ppv { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 24px; margin-top: 16px; }
.ppv-label { display: flex; align-items: baseline; gap: 6px; margin: 16px 0 7px; font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.ppv > div > .ppv-label:first-child { margin-top: 0; }
.ppv-label span { font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--faint); }
.ppv-drop { padding: 8px; border: 1.5px dashed var(--border-2); border-radius: 12px; transition: background .15s, border-color .15s; }
.ppv-drop.drag { border-color: var(--accent); background: var(--accent-soft); }
.ppv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.ppv-grid:not(:empty) { margin-bottom: 8px; }
.ppv-item { position: relative; aspect-ratio: 1; overflow: hidden; border-radius: 9px; background: var(--panel-2); }
.ppv-item img, .ppv-item video { display: block; width: 100%; height: 100%; object-fit: cover; }
.ppv-x { position: absolute; top: 4px; right: 4px; display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; }
.ppv-x:hover { background: rgba(0, 0, 0, .8); }
.ppv-x svg { width: 12px; height: 12px; stroke-width: 2.4; }
.ppv-tag { position: absolute; left: 4px; bottom: 4px; padding: 1px 6px; border-radius: 999px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 10.5px; }
.ppv-add { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 16px 12px; border-radius: 9px; color: var(--accent); font-weight: 600; text-align: center; cursor: pointer; }
.ppv-add:hover { background: var(--hover); }
.ppv-add svg { width: 22px; height: 22px; }
.ppv-add small { font-size: 12px; font-weight: 400; color: var(--muted); }
.ppv-price { position: relative; }
.ppv-cur { position: absolute; top: 50%; left: 12px; transform: translateY(-50%); font-size: 16px; font-weight: 650; color: var(--muted); pointer-events: none; }
.ppv-price input, .ppv textarea { border: 1px solid var(--border-2); border-radius: 9px; background: var(--panel); color: var(--text); }
.ppv-price input { width: 100%; height: 40px; padding: 0 12px 0 27px; font-size: 16px; font-weight: 650; }
.ppv textarea { display: block; width: 100%; padding: 9px 11px; resize: vertical; font-size: 14px; line-height: 1.45; }
.ppv-price input:focus, .ppv textarea:focus { border-color: var(--accent); box-shadow: var(--ring); }
.ppv-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ppv-presets button { height: 28px; padding: 0 11px; border: 1px solid var(--border); border-radius: 999px; background: var(--panel); color: var(--text-2); font-size: 12.5px; font-weight: 600; }
.ppv-presets button:hover { border-color: var(--accent); }
.ppv-presets button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.ppv-preview { display: flex; justify-content: flex-end; padding: 16px 14px; border-radius: 12px; background: var(--chat-bg); }
.ppv-bubble { width: 100%; max-width: 220px; padding: 3px; border-radius: 16px 16px 6px 16px; background: var(--bubble-out); box-shadow: 0 1px 1px rgba(16, 24, 40, .07); }
.ppv-lock { position: relative; aspect-ratio: 4 / 5; overflow: hidden; border-radius: 13px; background: linear-gradient(150deg, #64748b, #1e293b); }
.ppv-cover { position: absolute; inset: 0; }
.ppv-cover img, .ppv-cover video { width: 100%; height: 100%; object-fit: cover; filter: blur(18px) brightness(.75); transform: scale(1.2); }
.ppv-veil { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; color: #fff; }
.ppv-veil svg { width: 30px; height: 30px; stroke-width: 2; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .35)); }
.ppv-pill { padding: 7px 13px; border-radius: 999px; background: rgba(255, 255, 255, .94); color: #111827; font-size: 13px; font-weight: 700; box-shadow: 0 2px 8px rgba(0, 0, 0, .2); }
.ppv-meta { position: absolute; left: 8px; bottom: 8px; padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, .45); color: #fff; font-size: 11.5px; }
.ppv-meta:empty { display: none; }
.ppv-cap { padding: 6px 8px 4px; color: var(--bubble-out-text); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ppv-cap:empty { display: none; }
.ppv-foot { align-items: center; }
.ppv-foot > span { margin-right: auto; }
.toast { position: fixed; bottom: 24px; left: 50%; z-index: 60; display: flex; align-items: center; gap: 16px; max-width: calc(100vw - 32px); padding: 10px 14px 10px 16px; transform: translateX(-50%); border-radius: 10px; background: #111827; color: #fff; font-size: 13.5px; box-shadow: var(--shadow); }
.toast-btn { padding: 0; border: 0; background: none; color: #8ec5ff; font-weight: 700; }
.conn { position: fixed; top: 10px; left: 50%; z-index: 60; padding: 5px 12px; transform: translateX(-50%); border-radius: 999px; background: #b45309; color: #fff; font-size: 12.5px; }

/* ── petits éléments partagés ── */
.grow { flex: 1; }
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border: 1px solid var(--border); border-radius: 999px; color: var(--text-2); font-size: 12px; font-weight: 600; white-space: nowrap; }
.link.danger { color: var(--danger); }
.seg.sm button { height: 26px; padding: 0 10px; font-size: 12px; }
.pill { display: inline-flex; align-items: center; height: 18px; padding: 0 7px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); font-size: 10.5px; font-weight: 600; letter-spacing: 0; text-transform: none; vertical-align: 2px; }
.sp-badge { display: inline-flex; align-items: center; flex: none; height: 19px; padding: 0 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: 10.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.sp-badge[data-t="ppv"] { background: color-mix(in srgb, #f59e0b 16%, var(--panel)); color: #b45309; }
:root[data-theme="dark"] .sp-badge[data-t="ppv"] { color: #fcd34d; }
.sp-price { flex: none; font-weight: 700; color: var(--text); }

/* ── panneau des scripts (dans la zone de saisie) ── */
.scripts-pop { position: absolute; bottom: calc(100% + 8px); left: 12px; z-index: 25; display: flex; flex-direction: column; width: min(540px, calc(100% - 24px)); max-height: min(420px, 60vh); overflow: hidden; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.sp-head { display: flex; align-items: center; gap: 8px; padding: 10px; border-bottom: 1px solid var(--border); }
.sp-head input { flex: 1; min-width: 0; height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); }
.sp-head input:focus { border-color: var(--accent); background: var(--panel); box-shadow: var(--ring); }
.sp-list { overflow-y: auto; padding: 6px; scrollbar-width: thin; }
.sp-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.sp-item.on, .sp-item:hover { background: var(--hover); }
.sp-thumb { flex: none; width: 40px; height: 40px; overflow: hidden; border-radius: 8px; background: var(--panel-2); }
.sp-thumb img, .sp-thumb video { width: 100%; height: 100%; object-fit: cover; filter: blur(3px); }
.sp-main { flex: 1; min-width: 0; }
.sp-top { display: flex; align-items: center; gap: 8px; }
.sp-top b { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sp-text { overflow: hidden; margin-top: 2px; font-size: 13px; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
.sp-empty { padding: 22px 12px; text-align: center; color: var(--muted); font-size: 13px; }

/* ── tableau de bord ── */
.dash { max-width: 1080px; margin: 0 auto; padding: 28px 28px 48px; }
.dash-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 24px; margin-bottom: 22px; }
.dash-title h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.dash-title p { max-width: 620px; margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.dash-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.dash-bar p { margin: 0; font-size: 13px; }
.dash-h2 { margin: 26px 0 10px; font-size: 13px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.dash-empty { display: grid; gap: 4px; justify-items: center; padding: 48px 20px; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--border-2); border-radius: 14px; }
.dash-empty > svg { width: 28px; height: 28px; margin-bottom: 6px; color: var(--accent); }
.dash-empty p { margin: 0; }
.dash-empty b { color: var(--text); font-size: 15px; }
.dash-empty .btn { margin-top: 12px; }

/* filtres : une ligne au-dessus des graphiques (période d'abord, puis modèle) */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.dd { position: relative; }
.dd-btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 10px 0 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); color: var(--text); font-size: 13.5px; font-weight: 600; box-shadow: 0 1px 2px rgba(16, 24, 40, .05); transition: border-color .15s, box-shadow .15s; }
.dd-btn:hover { border-color: var(--border-2); }
.dd-btn.open, .dd-btn:focus-visible { border-color: var(--accent); box-shadow: var(--ring); outline: none; }
.dd-ico { display: grid; place-items: center; color: var(--accent); }
.dd-ico svg, .stack-empty svg { width: 17px; height: 17px; }
.dd-meta { color: var(--muted); font-weight: 500; }
.dd-chev { display: grid; place-items: center; color: var(--faint); transition: transform .15s; }
.dd-chev svg { width: 16px; height: 16px; }
.dd-btn.open .dd-chev { transform: rotate(180deg); }
.stack { display: inline-flex; }
.stack > .av { box-shadow: 0 0 0 2px var(--panel); }
.stack > .av + .av { margin-left: -8px; }
.stack-empty { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.pop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; min-width: 260px; padding: 6px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); animation: pop-in .12s ease-out; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } }
.pop-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 6px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--text); text-align: left; font-size: 13.5px; }
.pop-row:hover, .pop-row:focus-visible { background: var(--hover); outline: none; }
.pop-main { display: grid; flex: 1; min-width: 0; }
.pop-main b { overflow: hidden; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.pop-main small { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.pop-check { display: grid; flex: none; place-items: center; width: 18px; color: var(--accent); }
.pop-check svg { width: 16px; height: 16px; stroke-width: 2.6; }
.pop-row:not(.on) .pop-check { color: var(--faint); }
.pop-sep { height: 1px; margin: 6px 4px; background: var(--border); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.dot.on { background: var(--good); }
.pop-cal { width: 300px; padding: 10px 12px 12px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal-head b { font-size: 14px; }
.cal-head .icon-btn:disabled { opacity: .35; pointer-events: none; }
.cal-dow, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dow span { padding: 4px 0; text-align: center; color: var(--faint); font-size: 11px; font-weight: 600; }
.cal-grid { row-gap: 3px; }
.cal-d { height: 36px; padding: 0; border: 0; border-radius: 9px; background: transparent; color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; }
.cal-d:not(:disabled):hover { background: var(--hover); }
.cal-d:disabled { color: var(--faint); opacity: .5; cursor: default; }
.cal-d.today { color: var(--accent); font-weight: 700; }
.cal-d.in, .cal-d.in:hover { border-radius: 0; background: var(--accent-soft); }
.cal-d.lo, .cal-d.hi, .cal-d.lo:hover, .cal-d.hi:hover { background: var(--accent); color: #fff; font-weight: 600; }
.cal-d.lo { border-radius: 9px 0 0 9px; }
.cal-d.hi { border-radius: 0 9px 9px 0; }
.cal-d.lo.hi { border-radius: 9px; }
.cal-foot { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.cal-sel { flex: 1; min-width: 0; color: var(--muted); font-size: 12.5px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-back { display: inline-flex; align-items: center; gap: 2px; height: 28px; padding: 0 8px 0 4px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.cal-back:hover { background: var(--hover); color: var(--text); }
.cal-back svg { width: 16px; height: 16px; }

/* cartes : revenus en tête (chiffre principal), nouvelles conversations dessous, toute la largeur */
.cards { display: grid; gap: 16px; transition: opacity .2s; }
.cards.loading { opacity: .55; pointer-events: none; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.kpi { padding: 20px 22px 16px; }
.kpi > .spin { margin: 60px auto; }
.kpi-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13.5px; font-weight: 600; }
.kpi-value { margin-top: 6px; font-size: 32px; font-weight: 650; letter-spacing: -.02em; line-height: 1.1; }
.kpi.hero .kpi-value { font-size: 48px; letter-spacing: -.03em; }
.kpi-delta { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 650; }
.kpi-delta span { color: var(--muted); font-weight: 500; }
.kpi-delta[data-dir="up"] { background: var(--good-soft); color: var(--good); }
.kpi-delta[data-dir="down"] { background: var(--danger-soft); color: var(--danger); }
.kpi-delta[data-dir="flat"] { background: var(--panel-2); color: var(--muted); }
.stats-note { margin: 14px 2px 0; color: var(--faint); font-size: 12.5px; }
.chart { position: relative; margin-top: 20px; }
.chart-plot { position: relative; height: 150px; margin-left: 48px; }
.kpi.hero .chart-plot { height: 210px; }
.gl { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border); }
.gl span { position: absolute; top: -8px; right: calc(100% + 8px); font-size: 11px; color: var(--faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chart-bars { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 2px; }
.chart-bars.dense { gap: 1px; }
.col { display: flex; flex: 1; align-items: flex-end; justify-content: center; min-width: 0; height: 100%; outline: none; }
.col.empty { pointer-events: none; }
.bar { width: 100%; max-width: 24px; border-radius: 4px 4px 0 0; background: var(--accent); transition: background .12s; }
.col:hover .bar, .col:focus-visible .bar { background: var(--accent-2); }
.col:focus-visible .bar { outline: 2px solid var(--accent); outline-offset: 2px; }
.chart-x { position: relative; height: 16px; margin: 8px 0 0 48px; color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-x span { position: absolute; top: 0; white-space: nowrap; }
.chart-tip { position: absolute; z-index: 5; display: grid; gap: 1px; padding: 6px 10px; transform: translate(-50%, -100%); pointer-events: none; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); font-size: 12px; color: var(--muted); white-space: nowrap; }
.chart-tip b { font-size: 13px; color: var(--text); }
/* publications des canaux : à gauche, nombre de vues dans l'heure */
.msg-views { display: inline-flex; align-items: center; gap: 3px; margin-right: 6px; }
.msg-views svg { width: 13px; height: 13px; }
.msgs.channel .bubble { max-width: min(560px, 82%); }
/* temps réel : « en train d'écrire… », en ligne */
.prev.typing { color: var(--accent); font-style: italic; }
.chat-head .sub.live { color: var(--accent); }
/* message en cours d'envoi : affiché tout de suite, petite horloge jusqu'à la confirmation de Telegram */
.msg.pending .bubble { opacity: .82; }
.meta .sending { display: inline-grid; margin-left: 3px; vertical-align: -2px; }
.meta .sending svg { width: 12px; height: 12px; stroke-width: 2.2; }
/* économie de données : image téléchargée seulement quand on la touche */
.ph.ph-lazy { display: grid; place-items: center; align-content: center; gap: 4px; width: calc(100% + 15px); min-height: 120px; max-height: 300px; padding: 12px; border: 0; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; line-height: 1.3; cursor: pointer; }
.ph.ph-lazy svg { width: 26px; height: 26px; }
.ph.ph-lazy small { color: var(--faint); font-size: 11.5px; font-weight: 500; }
.ph.ph-lazy:hover { color: var(--accent); }
.ph.ph-lazy.round { width: 220px; border-radius: 50%; }
/* mode SFW : images floutées, « See image » pour en afficher une */
.ph.blur img { filter: blur(26px) saturate(.7); transform: scale(1.15); }
.ph-reveal { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 7px; width: max-content; height: 34px; margin: auto; padding: 0 14px; border-radius: 999px; background: rgba(15, 23, 42, .62); color: #fff; font-size: 13px; font-weight: 600; line-height: 1; backdrop-filter: blur(4px); }
.ph-reveal svg { width: 16px; height: 16px; }
.ph.blur:hover .ph-reveal { background: rgba(15, 23, 42, .78); }
:root[data-sfw] :is(.sc-thumb, .sp-thumb, .ppv-item) :is(img, video) { filter: blur(12px); transform: scale(1.12); transition: filter .15s, transform .15s; }
:root[data-sfw] :is(.sc-thumb, .sp-thumb, .ppv-item):hover :is(img, video) { filter: none; transform: none; }
:root[data-sfw] .ppv-preview :is(img, video) { filter: blur(18px); }
.sc-thumb > svg, .sp-thumb > svg { width: 20px; height: 20px; color: var(--muted); }
.set-hint { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
/* longues listes : les lignes hors de l'écran ne sont pas dessinées */
.row { content-visibility: auto; contain-intrinsic-size: auto 68px; }
.sc-list { display: grid; gap: 10px; }
.sc-card { padding: 14px 16px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.sc-card header { display: flex; align-items: center; gap: 8px; }
.sc-card h3 { margin: 0; overflow: hidden; font-size: 14.5px; white-space: nowrap; text-overflow: ellipsis; }
.sc-text { display: -webkit-box; margin: 8px 0 0; overflow: hidden; color: var(--text-2); font-size: 13.5px; white-space: pre-wrap; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.sc-media { display: flex; gap: 6px; margin-top: 10px; }
.sc-thumb { position: relative; display: grid; place-items: center; width: 56px; height: 56px; overflow: hidden; border-radius: 8px; background: var(--panel-2); color: var(--muted); font-size: 12px; font-weight: 700; }
.sc-thumb img, .sc-thumb video { width: 100%; height: 100%; object-fit: cover; }
.sc-thumb i { position: absolute; color: #fff; font-style: normal; text-shadow: 0 1px 3px rgba(0, 0, 0, .5); }
.se { display: grid; gap: 14px; margin-top: 16px; }
.se label { display: grid; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.se label small { font-weight: 400; }
.se input:not([type]), .se input[name], .se select, .se textarea { height: 38px; padding: 0 11px; border: 1px solid var(--border-2); border-radius: 9px; background: var(--panel); color: var(--text); font-size: 14px; font-weight: 400; }
.se textarea { height: auto; padding: 9px 11px; resize: vertical; line-height: 1.45; }
.se input:focus, .se select:focus, .se textarea:focus { border-color: var(--accent); box-shadow: var(--ring); }
.se .ppv-price input { padding-left: 27px; font-size: 16px; font-weight: 650; }
.se-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 12px; }
.se .err { padding: 8px 11px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); font-size: 13px; }
.se .modal-foot { margin-top: 4px; }
.members { display: grid; gap: 12px; }
.member { padding: 14px 16px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.member header { display: flex; align-items: center; gap: 10px; }
.member-id { display: grid; flex: 1; min-width: 0; line-height: 1.3; }
.member p { margin: 10px 0 0; }
.role { height: 22px; padding: 0 9px; border-radius: 999px; background: var(--panel-2); color: var(--text-2); font-size: 12px; font-weight: 600; line-height: 22px; }
.role[data-r="admin"] { background: var(--accent-soft); color: var(--accent); }
.perm-wrap { margin-top: 12px; overflow-x: auto; }
.perms { width: 100%; border-collapse: collapse; font-size: 13px; }
.perms th, .perms td { padding: 7px 8px; border-bottom: 1px solid var(--border); text-align: center; white-space: nowrap; }
.perms thead th { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.perms tbody th { text-align: left; font-weight: 600; }
.perms tbody th .av { display: inline-grid; margin-right: 8px; vertical-align: middle; }
.perms thead th:first-child { text-align: left; }
.perms tr:last-child th, .perms tr:last-child td { border-bottom: 0; }
.perms input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.perms input:disabled { cursor: not-allowed; opacity: .35; }
/* canaux d'un modèle, sous sa ligne : un bouton par canal, ouvert ou non au chatteur */
.perms tr.has-ch th, .perms tr.has-ch td { border-bottom: 0; }
.perms .perm-ch td { padding: 0 8px 10px; text-align: left; white-space: normal; }
.ch-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-left: 32px; }
.ch-label { display: inline-flex; align-items: center; gap: 5px; margin-right: 2px; color: var(--muted); font-size: 12px; font-weight: 600; }
.ch-label svg { width: 15px; height: 15px; }
.ch-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px 0 4px; border: 1px solid var(--border); border-radius: 999px; background: var(--panel); color: var(--text-2); font-size: 12.5px; font-weight: 600; transition: background .15s, border-color .15s, color .15s; }
.ch-chip:hover:not(:disabled) { border-color: var(--border-2); background: var(--hover); }
.ch-chip.on { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent-soft); color: var(--accent); }
.ch-chip:disabled { opacity: .45; cursor: not-allowed; }
.ch-chip i { display: grid; place-items: center; color: var(--faint); font-style: normal; }
.ch-chip.on i { color: var(--accent); }
.ch-chip i svg { width: 14px; height: 14px; stroke-width: 2.4; }
.inv-list { display: grid; gap: 8px; }
.inv { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
.inv code { flex: 1; min-width: 0; overflow: hidden; padding: 4px 8px; white-space: nowrap; text-overflow: ellipsis; }
.invite-new { margin-top: 12px; }
.mcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.mcard { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.mcard-main { flex: 1; min-width: 0; }
.mcard-name { display: flex; align-items: center; gap: 2px; }
.mcard-name b { overflow: hidden; font-size: 15px; white-space: nowrap; text-overflow: ellipsis; }
.mcard-actions { display: grid; gap: 6px; }
.st { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.st::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.st[data-s="on"]::before { background: #16a34a; }
.st[data-s="load"]::before { background: #f59e0b; }

/* ── PPV envoyé : son état dans la bulle (pas ouvert, ouvert, au paiement, payé…) ── */
.ppv-state { display: flex; align-items: center; gap: 6px; margin: 6px 4px 2px; padding: 5px 9px; border-radius: 9px; background: color-mix(in srgb, var(--text) 6%, transparent); color: var(--text-2); font-size: 12.5px; line-height: 1.3; }
.ppv-state svg { flex: none; width: 14px; height: 14px; stroke-width: 2.2; }
.ppv-state span { color: var(--muted); }
.ppv-state[data-s="opened"] svg, .ppv-state[data-s="checkout"] svg { color: var(--accent); }
.ppv-state[data-s="paid"] { background: var(--good-soft); color: var(--good); }
.ppv-state[data-s="paid"] span { color: var(--good); }
.ppv-state:is([data-s="underpaid"], [data-s="refunded"]) { background: var(--danger-soft); color: var(--danger); }
:root[data-bubbles="solid"] .msg.out .ppv-state:not([data-s="paid"]) { background: rgba(255, 255, 255, .18); color: #fff; }
:root[data-bubbles="solid"] .msg.out .ppv-state:not([data-s="paid"]) :is(span, svg) { color: rgba(255, 255, 255, .85); }
.ppv-foot .warn { color: var(--danger); }

/* ── écran Payments ── */
.pay-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 16px; align-items: start; }
.pay-card { padding: 18px 20px 20px; }
.pay-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.pay-card h3 { margin: 0; font-size: 16px; }
.pay-card header p { margin: 3px 0 0; }
.pay-card header .st { flex: none; margin-top: 3px; }
.pay-steps { display: grid; gap: 14px; margin: 18px 0 0; padding: 0; list-style: none; }
.pay-step { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 11px; color: var(--text-2); font-size: 13.5px; line-height: 1.5; }
.pay-n { display: grid; place-items: center; width: 24px; height: 24px; border: 1.5px solid var(--border-2); border-radius: 50%; color: var(--muted); font-size: 12px; font-weight: 700; }
.pay-n svg { width: 14px; height: 14px; stroke-width: 2.6; }
.pay-step.done .pay-n { border-color: var(--good); background: var(--good); color: #fff; }
.pay-step code { padding: 1px 5px; border-radius: 5px; background: var(--panel-2); font-size: 12.5px; }
.pay-copy { display: flex; align-items: center; gap: 8px; margin-top: 7px; }
.pay-copy code { flex: 1; min-width: 0; overflow: hidden; padding: 6px 9px; border: 1px solid var(--border); background: var(--panel-2); border-radius: 8px; white-space: nowrap; text-overflow: ellipsis; }
.pay-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 7px; }
.pay-form input { flex: 1 1 200px; min-width: 0; height: 34px; padding: 0 10px; border: 1px solid var(--border-2); border-radius: 8px; background: var(--panel); color: var(--text); font-size: 13.5px; }
.pay-form input:focus { border-color: var(--accent); box-shadow: var(--ring); }
.pay-form .btn { height: 34px; }
.pay-warn { margin: 7px 0 0; color: var(--danger); font-size: 12.5px; }
.pay-mode { display: grid; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.pay-sum { margin: 0 0 10px; color: var(--muted); font-size: 13.5px; }
.pay-sum b { color: var(--text); }
.sales-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.sales { width: 100%; border-collapse: collapse; font-size: 13px; }
.sales th, .sales td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.sales thead th { color: var(--muted); font-size: 11.5px; font-weight: 700; }
.sales tr:last-child td { border-bottom: 0; }
.sales td .av { display: inline-grid; margin-right: 7px; vertical-align: middle; }
.sale-st { display: inline-flex; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); font-size: 12px; font-weight: 650; }
.sale-st:is([data-s="opened"], [data-s="checkout"]) { background: var(--accent-soft); color: var(--accent); }
.sale-st[data-s="paid"] { background: var(--good-soft); color: var(--good); }
.sale-st:is([data-s="underpaid"], [data-s="refunded"]) { background: var(--danger-soft); color: var(--danger); }

/* ── écrans étroits ── */
@media (max-width: 1080px) {
  .app.show-info { grid-template-columns: 320px minmax(0, 1fr); }
  .app.show-info .info { position: fixed; top: 0; right: 0; bottom: 0; z-index: 30; width: min(340px, 100vw); box-shadow: -12px 0 32px rgba(16, 24, 40, .18); }
  .info-close { display: inline-grid; }
}
@media (max-width: 720px) {
  .app, .app.show-info { grid-template-columns: minmax(0, 1fr); }
  .app.chat-open .side { display: none; }
  .app:not(.chat-open) .chat { display: none; }
  .back { display: inline-grid; }
  .head-actions .btn span { display: none; }
  .ppv { grid-template-columns: minmax(0, 1fr); }
  .ppv-btn span { display: none; }
  .ppv-foot > span { display: none; }
  .ppv-foot { flex-wrap: wrap; }
  .ppv-foot > span.warn { display: block; flex-basis: 100%; }
  .pay-card { padding: 16px 14px; }
  .msgs { padding: 6px 10px 14px; }
  .bubble { max-width: 86%; }
  .shell { grid-template-columns: 56px minmax(0, 1fr); }
  .rail-btn { width: 40px; height: 40px; }
  .shell.rail-open { grid-template-columns: 56px minmax(0, 1fr); }
  .rail-open .rail { position: fixed; top: 0; bottom: 0; left: 0; z-index: 45; width: 232px; box-shadow: 12px 0 32px rgba(16, 24, 40, .18); }
  .rail-open .rail-btn { width: 100%; height: 42px; }
  .dash { padding: 18px 14px 36px; }
  .mcards { grid-template-columns: minmax(0, 1fr); }
  .dash-title h1 { font-size: 22px; }
  .kpi { padding: 16px 14px 12px; }
  .kpi.hero .kpi-value { font-size: 40px; }
  .chart-plot, .chart-x { margin-left: 40px; }
  .kpi.hero .chart-plot { height: 170px; }
  .dd-meta { display: none; }
  .filters { position: relative; }
  .dd { position: static; }
  .pop, .pop-cal { right: 0; width: auto; min-width: 0; }
  .se-row { grid-template-columns: minmax(0, 1fr); }
  .mcard { flex-wrap: wrap; }
}
