:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --line: #e5e7eb;
  --line-2: #eef0f3;
  --text: #111827;
  --muted: #6b7280;
  --faint: #9ca3af;
  --accent: #15803d;
  --accent-2: #16a34a;
  --accent-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --info: #2563eb;
  --info-soft: #dbeafe;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --thread-bg: #efeae2;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, .25);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f14; --panel: #12171e; --panel-2: #161c24; --line: #232b36; --line-2: #1b222b;
    --text: #e5e7eb; --muted: #9aa4b2; --faint: #6b7584;
    --accent: #22c55e; --accent-2: #16a34a; --accent-soft: #11301d;
    --danger: #f87171; --danger-soft: #3a1414; --warn: #fbbf24; --warn-soft: #3a2a0a; --info: #60a5fa; --info-soft: #102544;
    --bubble-in: #1f2731; --bubble-out: #144d37; --thread-bg: #0e1319;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 20px 40px -12px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--info); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 20px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 76px 1fr; height: 100vh; height: 100dvh; }
.nav {
  background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  align-items: center; padding: 14px 0; gap: 4px;
}
.nav .logo {
  width: 38px; height: 38px; border-radius: 11px; background: var(--accent-2); display: grid; place-items: center;
  margin-bottom: 14px; color: #fff;
}
.nav a {
  position: relative; width: 64px; padding: 8px 0 6px; border-radius: 10px; display: flex; flex-direction: column;
  align-items: center; gap: 3px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 550;
}
.nav a svg { width: 22px; height: 22px; }
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav .badge { position: absolute; top: 3px; right: 9px; }
.nav .bottom { margin-top: auto; }
.main { min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.page { flex: 1; overflow: auto; padding: 24px 28px 40px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.demo-banner {
  background: var(--warn-soft); color: var(--warn); font-size: 12px; font-weight: 600; padding: 6px 14px; text-align: center;
  border-bottom: 1px solid var(--line);
}

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 550;
  white-space: nowrap; transition: background .12s, border-color .12s;
}
a.btn { color: inherit; text-decoration: none; }
.btn:hover { background: var(--panel-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn.primary:hover { background: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 34px; padding: 0; }
.input, select.input, textarea.input {
  width: 100%; height: 36px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
  outline: none; transition: border-color .12s, box-shadow .12s;
}
textarea.input { height: auto; padding: 9px 11px; resize: vertical; min-height: 80px; line-height: 1.45; }
.input:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 18%, transparent); }
.input.sm { height: 30px; font-size: 13px; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 550; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent-2); margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--accent-2); color: #fff; font-size: 11px; font-weight: 700;
}
.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 11px; font-size: 12px;
  font-weight: 600; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap;
}
.pill.green { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.red { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill.amber { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.blue { background: var(--info-soft); color: var(--info); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 1px 7px 1px 6px;
  border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
  max-width: 160px; overflow: hidden; text-overflow: ellipsis;
}
.empty { text-align: center; color: var(--muted); padding: 48px 20px; }
.empty h2 { color: var(--text); margin-bottom: 6px; }
.empty p { max-width: 420px; margin: 0 auto 16px; }

/* ---------- Inbox ---------- */
.inbox { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px 1fr 290px; }
.inbox.no-details { grid-template-columns: 340px 1fr; }
.conv-list { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.conv-list .head { padding: 14px 14px 10px; border-bottom: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 9px; }
.conv-list .items { flex: 1; overflow-y: auto; }
.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--faint); }
.search .input { padding-left: 32px; }
.filters { display: flex; gap: 6px; }
.filters select { flex: 1; min-width: 0; }
.tabs { display: flex; gap: 4px; background: var(--panel-2); border-radius: 8px; padding: 3px; }
.tabs button { flex: 1; border: 0; background: transparent; border-radius: 6px; padding: 4px 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.conv {
  display: flex; gap: 11px; padding: 11px 14px; cursor: pointer; border-bottom: 1px solid var(--line-2); text-decoration: none; color: inherit;
}
.conv:hover { background: var(--panel-2); }
.conv.active { background: var(--accent-soft); }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 14px;
  color: #fff; position: relative;
}
.avatar .acc { position: absolute; right: -2px; bottom: -2px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--panel); }
.avatar.lg { width: 40px; height: 40px; }
.conv .body { flex: 1; min-width: 0; }
.conv .top { display: flex; align-items: baseline; gap: 6px; }
.conv .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.conv .time { font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.conv.unread .time { color: var(--accent-2); font-weight: 700; }
.conv .preview { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.conv .preview span.txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; }
.conv.unread .preview span.txt { color: var(--text); font-weight: 550; }
.conv .meta { display: flex; gap: 5px; margin-top: 5px; flex-wrap: wrap; }

.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--thread-bg); }
.thread-head { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 62px; }
.thread-head .who { flex: 1; min-width: 0; }
.thread-head .who .n { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-head .back { display: none; }
.messages { flex: 1; overflow-y: auto; padding: 18px 6% 10px; display: flex; flex-direction: column; gap: 3px; }
.day-sep {
  align-self: center; margin: 14px 0 8px; font-size: 12.5px; font-weight: 650; color: var(--text); background: var(--panel);
  padding: 4px 12px; border-radius: 8px; box-shadow: var(--shadow); text-align: center; min-width: min(280px, 90%);
  position: sticky; top: 4px; z-index: 2; /* le jour reste visible en haut quand on remonte la conversation */
}
.msg { max-width: min(560px, 78%); padding: 6px 9px 4px 10px; border-radius: 9px; background: var(--bubble-in); box-shadow: var(--shadow); align-self: flex-start; position: relative; }
.msg.me { align-self: flex-end; background: var(--bubble-out); }
.msg + .msg.me, .msg.me + .msg:not(.me) { margin-top: 6px; }
.msg .txt { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.msg .kind { color: var(--muted); font-style: italic; }
.msg .foot { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); margin-top: 1px; margin-left: 24px; float: right; position: relative; top: 4px; }
.msg .foot .ts { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.msg::after { content: ""; display: block; clear: both; }
.msg .camp { font-size: 11px; font-weight: 650; color: var(--accent); margin-bottom: 2px; display: flex; align-items: center; gap: 4px; }
.msg.failed { outline: 1px solid var(--danger); }
.tick { width: 16px; height: 11px; }
.tick.read { color: #53bdeb; }
.tick.failed { color: var(--danger); }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 14px; background: var(--panel); border-top: 1px solid var(--line); }
.composer textarea { flex: 1; resize: none; min-height: 40px; max-height: 180px; height: 40px; border-radius: 20px; padding: 9px 15px; }
.composer .btn { height: 40px; width: 40px; border-radius: 50%; padding: 0; }
.composer-note { padding: 10px 16px; background: var(--warn-soft); color: var(--warn); font-size: 13px; font-weight: 550; border-top: 1px solid var(--line); }
.thread-empty { flex: 1; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 20px; }
.thread-empty svg { width: 54px; height: 54px; opacity: .35; margin-bottom: 8px; }

.details { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 18px; }
.details .sec { display: flex; flex-direction: column; gap: 8px; }
.details dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; font-size: 13px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; overflow-wrap: anywhere; }
.stage-grid { display: flex; flex-wrap: wrap; gap: 5px; }
.stage-grid button { border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 3px 10px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.stage-grid button.on { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }

/* ---------- Tables ---------- */
.table-wrap { overflow: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--panel-2); }
table.t td.w { width: 1%; white-space: nowrap; }

/* ---------- Campaigns ---------- */
.camp-list { display: grid; gap: 12px; }
.camp-card { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 16px 18px; cursor: pointer; }
.camp-card:hover { border-color: color-mix(in srgb, var(--accent-2) 45%, var(--line)); }
.camp-card .name { font-weight: 650; font-size: 15px; }
.progress { height: 7px; border-radius: 4px; background: var(--line-2); overflow: hidden; display: flex; }
.progress span { display: block; height: 100%; }
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.kpi { padding: 12px 14px; }
.kpi .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12px; color: var(--muted); font-weight: 550; }
.activity { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.activity.ok { background: var(--accent-soft); color: var(--accent); }
.activity.idle { background: var(--info-soft); color: var(--info); }
.activity.warn { background: var(--warn-soft); color: var(--warn); }
.camp-layout { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 16px; align-items: start; }
.var-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.var-chips button { border: 1px dashed var(--line); background: var(--panel-2); border-radius: 6px; padding: 2px 8px; font-size: 12px; cursor: pointer; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.var-chips button:hover { border-color: var(--accent-2); color: var(--accent); }
.preview-box { background: var(--thread-bg); border-radius: 10px; padding: 14px; }
.preview-box .msg { max-width: 92%; }
.days { display: flex; gap: 4px; }
.days label { flex: 1; }
.days input { display: none; }
.days span { display: block; text-align: center; border: 1px solid var(--line); border-radius: 7px; padding: 5px 0; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--muted); }
.days input:checked + span { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.tag-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-pick label { display: inline-flex; }
.tag-pick input { display: none; }
.tag-pick span { border: 1px solid var(--line); border-radius: 14px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; }
.tag-pick input:checked + span { background: var(--accent-soft); border-color: var(--accent-2); color: var(--accent); font-weight: 600; }
.estimate { font-size: 12.5px; color: var(--muted); background: var(--panel-2); border-radius: 8px; padding: 8px 10px; }

/* ---------- Dashboard ---------- */
:root { --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --grid: #eef0f3; }
@media (prefers-color-scheme: dark) { :root { --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --grid: #1f2731; } }
.dash-kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.dash-kpis .kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; overflow: visible; }
.chart-wrap .axis { font-size: 11px; fill: var(--muted); }
.chart-tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  border-radius: 8px; padding: 8px 10px; font-size: 12.5px; min-width: 190px; z-index: 5; }
.chart-tip .r { display: flex; align-items: center; gap: 12px; justify-content: space-between; white-space: nowrap; }
.chart-tip .r i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.rate { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.rate .bar { height: 6px; width: 70px; background: var(--line-2); border-radius: 3px; overflow: hidden; flex: none; }
.rate .bar span { display: block; height: 100%; background: var(--series-1); border-radius: 0 3px 3px 0; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 1180px) { .dash-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 820px) { .dash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Numbers ---------- */
.acc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.acc-card { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.acc-card .top { display: flex; align-items: center; gap: 10px; }
.acc-card .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.acc-card .stats div { background: var(--panel-2); border-radius: 8px; padding: 7px 9px; }
.acc-card .stats b { display: block; font-size: 16px; }
.acc-card .stats span { font-size: 11.5px; color: var(--muted); }
.qr-box { display: grid; place-items: center; padding: 12px; }
.qr-box img { width: 264px; height: 264px; border-radius: 10px; background: #fff; padding: 8px; }
.qr-placeholder { width: 264px; height: 264px; border-radius: 10px; border: 1px dashed var(--line); display: grid; place-items: center; color: var(--muted); }
ol.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; }

/* ---------- Modal / toasts ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .12s; }
.modal { background: var(--panel); border-radius: 14px; box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; animation: pop .14s; }
.modal.wide { width: min(760px, 100%); }
.modal .mh { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.modal .mb { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal .mf { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line-2); }
@keyframes fade { from { opacity: 0 } }
@keyframes pop { from { transform: translateY(6px) scale(.98); opacity: 0 } }
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; align-items: center; }
.toast { background: #111827; color: #fff; padding: 9px 16px; border-radius: 9px; box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 550; animation: pop .15s; max-width: 90vw; }
.toast.err { background: var(--danger); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(360px, 100%); padding: 28px; display: flex; flex-direction: column; gap: 14px; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .inbox { grid-template-columns: 320px 1fr; }
  .details { display: none; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .camp-layout { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .nav { flex-direction: row; justify-content: space-around; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); order: 2; }
  .nav .logo, .nav .bottom { display: none; }
  .nav a { width: auto; flex: 1; }
  .page { padding: 16px 14px 30px; }
  .inbox, .inbox.no-details { grid-template-columns: minmax(0, 1fr); }
  .conv-list, .thread { min-width: 0; }
  .thread-head { padding: 8px 10px; gap: 8px; }
  .thread-head .who .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
  .thread-head .who .via { display: none; }
  #stage-select { max-width: 128px; }
  .inbox.has-thread .conv-list { display: none; }
  .inbox:not(.has-thread) .thread { display: none; }
  .thread-head .back { display: inline-flex; }
  .messages { padding: 14px 10px; }
  .camp-card { grid-template-columns: 1fr; gap: 10px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2, .grid3 { grid-template-columns: 1fr; }
}
.acc-switches { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line, rgba(0,0,0,.08)); }
.acc-switches .check { align-items: flex-start; }
.acc-switches .check input { margin-top: 1px; flex: none; }

/* ---------- Chauffe ---------- */
.wu-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.wu-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.wu-thread { display: flex; flex-direction: column; height: min(640px, calc(100vh - 260px)); min-height: 380px; overflow: hidden; }
.wu-thread .messages { background: var(--panel-2); }
.wu-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.wu-pair { display: flex; align-items: center; gap: 7px; font-size: 14px; }
.wu-sep { align-self: center; margin: 10px 0 6px; font-size: 11px; font-weight: 600; color: var(--faint); }
.wu-who { font-size: 11.5px; font-weight: 700; margin-bottom: 1px; }
.wu-typing .dots { display: inline-flex; gap: 3px; padding: 4px 2px; }
.wu-typing .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: wu-blink 1.2s infinite ease-in-out; }
.wu-typing .dots i:nth-child(2) { animation-delay: .2s; }
.wu-typing .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes wu-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.wu-num { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; padding: 6px 0; border-top: 1px solid var(--line-2); }
.wu-num input { width: 16px; height: 16px; accent-color: var(--accent-2); margin: 2px 0 0; flex: none; }
.wu-num .dot { margin-top: 5px; flex: none; }
.wu-num .grow, .wu-daylist .grow { flex: 1; min-width: 0; }
.wu-daylist { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.wu-daylist .row { gap: 6px; }
@media (max-width: 900px) {
  .wu-grid { grid-template-columns: 1fr; }
  .wu-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wu-thread { height: 520px; }
}

/* ---------- File d'attente ---------- */
.q-list { display: flex; flex-direction: column; }
.q-item { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(0, 2.2fr) minmax(170px, 1fr); gap: 14px; padding: 14px 16px; border-top: 1px solid var(--line-2); align-items: start; }
.q-item .q-msg .msg { max-width: 100%; align-self: auto; display: inline-block; }
.q-item .q-when { text-align: right; }
@media (max-width: 820px) {
  .q-item { grid-template-columns: 1fr; }
  .q-item .q-when { text-align: left; }
  .q-item .q-when .row { justify-content: flex-start !important; }
}

/* ---------- Setting IA ---------- */
.chip.ai { background: var(--accent-soft); color: var(--accent); }
.chip.warn { color: var(--warn); }
.ai-card { margin: 0 12px 8px; padding: 10px 12px; border: 1px solid var(--accent-2); border-radius: 10px; background: var(--panel); display: flex; flex-direction: column; gap: 7px; box-shadow: var(--shadow); }
.ai-card.subtle { border-color: var(--line); box-shadow: none; padding: 6px 10px; }
.ai-card.paused { border-color: var(--warn); }
.ai-card.error { border-color: var(--danger); }
.ai-card .ai-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ai-card .ai-top svg { width: 16px; height: 16px; color: var(--accent); flex: none; }
.ai-card .ai-edit { resize: vertical; min-height: 38px; font-size: 13.5px; }
.ai-card .ai-bubble { background: var(--bubble-out); border-radius: 8px; padding: 6px 9px; font-size: 13.5px; align-self: flex-end; max-width: 90%; }
.s-mode { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.s-mode.on { border-color: var(--accent-2); background: var(--accent-soft); }
.s-mode input { margin-top: 3px; accent-color: var(--accent-2); }
.s-item { gap: 8px; padding: 7px 0; border-top: 1px solid var(--line-2); color: inherit; text-decoration: none; }
.s-item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Bandeau d'alerte : un numéro a sauté (même alerte que sur Telegram) */
.alert-banner {
  display: flex; align-items: flex-start; gap: 8px; background: var(--danger-soft); color: var(--danger);
  font-size: 13px; padding: 8px 14px; line-height: 1.45; border-bottom: 1px solid var(--danger);
}
.alert-banner.hidden { display: none; }
.alert-banner svg { flex: none; width: 16px; height: 16px; margin-top: 2px; }
.alert-banner a { color: inherit; text-decoration: underline; }

/* Photos dans les conversations */
.msg-photo { display: block; margin: 0 -5px 4px -6px; }
.msg-photo img { display: block; max-width: 100%; max-height: 340px; border-radius: 7px; background: var(--line); }
.msg-photo.sticker img { max-height: 150px; background: none; }

/* Supprimer un de nos messages pour tout le monde (au survol) */
.msg .msg-del {
  position: absolute; top: 50%; left: -32px; transform: translateY(-50%); width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; border: 0; background: var(--panel); color: var(--faint); box-shadow: var(--shadow);
  cursor: pointer; opacity: 0; transition: opacity .12s;
}
.msg:hover .msg-del { opacity: 1; }
.msg .msg-del:hover { color: var(--danger); }
@media (hover: none) { .msg .msg-del { opacity: .7; } }

/* Bouton rond « Nouveau message » sur téléphone (le bouton « Nouveau » du haut reste sur ordinateur) */
.conv-list { position: relative; }
.fab { display: none; }
@media (max-width: 820px) {
  .fab {
    display: grid; place-items: center; position: absolute; right: 16px; bottom: 16px; z-index: 5;
    width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
    background: var(--accent-2); color: #fff; box-shadow: var(--shadow-lg);
  }
  .fab:active { transform: scale(.96); }
  .conv-list .items { padding-bottom: 84px; } /* la dernière conversation ne passe pas sous le bouton */
}
@media (max-width: 820px) { .call-btn .lbl { display: none; } .call-btn { padding-left: 9px; padding-right: 9px; } }
