/* CRM — calme, dense, lisible. Clair + sombre (système ou choix manuel). */
:root {
  color-scheme: light;
  --bg: #f6f6f8;
  --surface: #ffffff;
  --surface-2: #f1f1f4;
  --surface-3: #e9e9ee;
  --hover: #f0f0f4;
  --border: #e3e3e8;
  --border-strong: #d0d0d8;
  --text: #17171c;
  --text-2: #4d4d57;
  --text-3: #6b6b76;
  --accent: #4f46e5;
  --accent-text: #4338ca;
  --accent-weak: #eef0ff;
  --on-accent: #ffffff;
  --focus: #6366f1;
  --danger: #c0262d;
  --danger-weak: #fdecec;
  --ok: #15803d;
  --ok-weak: #e7f6ec;
  --warn: #a15c07;
  --warn-weak: #fdf3e2;
  --s-new: #1d5fd6; --s-new-bg: #e8f0fe;
  --s-qualified: #6d3fd8; --s-qualified-bg: #f1ebfe;
  --s-handoff: #9a5a00; --s-handoff-bg: #fdf1dc;
  --s-closed: #5f5f6a; --s-closed-bg: #eeeef2;
  --c-whatsapp: #128043; --c-instagram: #b42e72; --c-sms: #1d5fd6; --c-email: #9a5a00;
  --bubble-in: #ffffff;
  --bubble-out: #e3f5e8;
  --bubble-out-text: #12301d;
  --thread-bg: #f3f2ef;
  --shadow-sm: 0 1px 2px rgba(16, 16, 24, .06);
  --shadow-md: 0 4px 16px rgba(16, 16, 24, .08), 0 1px 3px rgba(16, 16, 24, .06);
  --shadow-lg: 0 18px 48px rgba(16, 16, 24, .18);
  --radius: 8px;
  --radius-lg: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar: 236px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d10; --surface: #141418; --surface-2: #1b1b20; --surface-3: #24242b; --hover: #1e1e24;
    --border: #26262d; --border-strong: #34343d;
    --text: #ececf1; --text-2: #b0b0bb; --text-3: #8e8e9a;
    --accent: #7c83f6; --accent-text: #a5abff; --accent-weak: #1f2040; --on-accent: #0d0d10; --focus: #8b91ff;
    --danger: #f06d72; --danger-weak: #3a1618; --ok: #4ade80; --ok-weak: #11281a; --warn: #f5b84a; --warn-weak: #33240b;
    --s-new: #7fb0ff; --s-new-bg: #172440; --s-qualified: #b9a1ff; --s-qualified-bg: #261d42;
    --s-handoff: #f5bd57; --s-handoff-bg: #33250d; --s-closed: #a2a2ad; --s-closed-bg: #232329;
    --c-whatsapp: #4cd486; --c-instagram: #f07ab4; --c-sms: #7fb0ff; --c-email: #f5bd57;
    --bubble-in: #1e1e24; --bubble-out: #173a29; --bubble-out-text: #dff5e7; --thread-bg: #101013;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 6px 20px rgba(0, 0, 0, .45); --shadow-lg: 0 18px 48px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d10; --surface: #141418; --surface-2: #1b1b20; --surface-3: #24242b; --hover: #1e1e24;
  --border: #26262d; --border-strong: #34343d;
  --text: #ececf1; --text-2: #b0b0bb; --text-3: #8e8e9a;
  --accent: #7c83f6; --accent-text: #a5abff; --accent-weak: #1f2040; --on-accent: #0d0d10; --focus: #8b91ff;
  --danger: #f06d72; --danger-weak: #3a1618; --ok: #4ade80; --ok-weak: #11281a; --warn: #f5b84a; --warn-weak: #33240b;
  --s-new: #7fb0ff; --s-new-bg: #172440; --s-qualified: #b9a1ff; --s-qualified-bg: #261d42;
  --s-handoff: #f5bd57; --s-handoff-bg: #33250d; --s-closed: #a2a2ad; --s-closed-bg: #232329;
  --c-whatsapp: #4cd486; --c-instagram: #f07ab4; --c-sms: #7fb0ff; --c-email: #f5bd57;
  --bubble-in: #1e1e24; --bubble-out: #173a29; --bubble-out-text: #dff5e7; --thread-bg: #101013;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 6px 20px rgba(0, 0, 0, .45); --shadow-lg: 0 18px 48px rgba(0, 0, 0, .6);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body, .root { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: 8px; top: -40px; z-index: 100; background: var(--accent); color: var(--on-accent); padding: 8px 12px; border-radius: 6px; }
.skip:focus { top: 8px; }
.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.grow-flex { flex: 1; min-width: 0; }
.grid-gap { display: grid; gap: 8px; justify-items: start; }
.pad { padding: 14px 16px; color: var(--text-2); }

/* ---------- boutons & champs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 500; font-size: 13px; white-space: nowrap; box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.07); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-weak); border-color: var(--danger); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: var(--on-accent); }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-icon { width: 32px; padding: 0; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-block { width: 100%; height: 38px; font-size: 14px; }
.input, .select, .textarea {
  width: 100%; height: 34px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; min-height: 72px; padding: 8px 10px; resize: vertical; line-height: 1.45; }
.select {
  appearance: none; padding-right: 28px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 10px) 50%; background-size: 4px 4px; background-repeat: no-repeat;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.search { position: relative; }
.search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 32px; }
.kbd { font: 11px var(--mono); color: var(--text-3); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; }

/* ---------- pastilles */
.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--surface-2); color: var(--text-2);
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-new { background: var(--s-new-bg); color: var(--s-new); }
.pill-qualified { background: var(--s-qualified-bg); color: var(--s-qualified); }
.pill-handoff { background: var(--s-handoff-bg); color: var(--s-handoff); }
.pill-closed { background: var(--s-closed-bg); color: var(--s-closed); }
.pill-stop { background: var(--danger-weak); color: var(--danger); font-weight: 600; letter-spacing: .02em; }
.pill-ok { background: var(--ok-weak); color: var(--ok); }
.pill-warn { background: var(--warn-weak); color: var(--warn); }
.pill-down { background: var(--danger-weak); color: var(--danger); }
.pill-idle, .pill-test { background: var(--surface-2); color: var(--text-2); }
.chan { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px 0 6px; border-radius: 5px; font-size: 11.5px; font-weight: 500; border: 1px solid var(--border); color: var(--text-2); background: var(--surface); white-space: nowrap; }
.chan .icon { width: 12px; height: 12px; }
.chan-whatsapp .icon { color: var(--c-whatsapp); }
.chan-instagram .icon { color: var(--c-instagram); }
.chan-sms .icon { color: var(--c-sms); }
.chan-email .icon { color: var(--c-email); }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--surface-3); color: var(--text-2); font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.count-accent { background: var(--accent); color: var(--on-accent); }

/* ---------- avatar */
.avatar { position: relative; width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 12.5px; font-weight: 600; letter-spacing: .02em; }
.avatar-lg { width: 52px; height: 52px; font-size: 17px; }
.avatar .ch { position: absolute; right: -3px; bottom: -3px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; box-shadow: 0 0 0 1.5px var(--surface); }
.avatar .ch .icon { width: 11px; height: 11px; stroke-width: 2.2; }
.hue-0 { background: #e6ecfd; color: #2c4fb8; } .hue-1 { background: #e9f6ee; color: #1d6b3f; }
.hue-2 { background: #fbeee6; color: #9a4313; } .hue-3 { background: #f3eafd; color: #6532b8; }
.hue-4 { background: #fde9f1; color: #a52a5e; } .hue-5 { background: #e6f5f7; color: #146673; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hue-0 { background: #1c2848; color: #a9c0ff; } :root:not([data-theme="light"]) .hue-1 { background: #153222; color: #8ee0ae; }
  :root:not([data-theme="light"]) .hue-2 { background: #3a2316; color: #f6b48a; } :root:not([data-theme="light"]) .hue-3 { background: #2a1d44; color: #c9aefc; }
  :root:not([data-theme="light"]) .hue-4 { background: #3d1828; color: #f7a3c7; } :root:not([data-theme="light"]) .hue-5 { background: #13313a; color: #8ed8e3; }
}
:root[data-theme="dark"] .hue-0 { background: #1c2848; color: #a9c0ff; } :root[data-theme="dark"] .hue-1 { background: #153222; color: #8ee0ae; }
:root[data-theme="dark"] .hue-2 { background: #3a2316; color: #f6b48a; } :root[data-theme="dark"] .hue-3 { background: #2a1d44; color: #c9aefc; }
:root[data-theme="dark"] .hue-4 { background: #3d1828; color: #f7a3c7; } :root[data-theme="dark"] .hue-5 { background: #13313a; color: #8ed8e3; }

/* ---------- connexion */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(1200px 500px at 50% -10%, var(--accent-weak), transparent 70%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: var(--shadow-md); }
.login-card h1 { font-size: 20px; letter-spacing: -.01em; margin-top: 18px; }
.login-card p.intro { color: var(--text-3); margin: 6px 0 22px; }
.login-card form { display: grid; gap: 14px; }
.login-foot { margin-top: 18px; font-size: 12.5px; color: var(--text-3); display: flex; gap: 6px; align-items: center; }
.alert { display: flex; gap: 8px; align-items: flex-start; padding: 9px 11px; border-radius: 8px; background: var(--danger-weak); color: var(--danger); font-size: 13px; }
.alert[hidden], .notice[hidden], .login-card form[hidden] { display: none; }
.notice { display: flex; gap: 8px; align-items: flex-start; padding: 9px 11px; border-radius: 8px; background: var(--accent-weak); color: var(--accent-text); font-size: 13px; margin-bottom: 14px; }
.notice .icon, .alert .icon { flex: none; margin-top: 1px; }
.login-card .alert { margin-bottom: 14px; }
.input-code { font-size: 22px; letter-spacing: .45em; text-align: center; font-variant-numeric: tabular-nums; padding-left: .45em; }
.login-actions { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.login-card .small { font-size: 12.5px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -.01em; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #8b5cf6); color: #fff; display: grid; place-items: center; }
.brand-mark .icon { width: 16px; height: 16px; stroke-width: 2.2; }

/* ---------- coquille */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); height: 100%; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.sidebar-head { height: 52px; padding: 0 14px; display: flex; align-items: center; border-bottom: 1px solid var(--border); }
.sidebar-body { flex: 1; overflow-y: auto; padding: 10px 8px; display: grid; align-content: start; gap: 2px; }
.nav-label { font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; padding: 14px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 9px; height: 32px; padding: 0 10px; border-radius: 7px; color: var(--text-2); font-weight: 500; }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item[aria-current="page"], .nav-item.active { background: var(--accent-weak); color: var(--accent-text); }
.nav-item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hdot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--text-3); }
.hdot-ok { background: var(--ok); } .hdot-warn { background: var(--warn); } .hdot-down { background: var(--danger); }
.hdot-idle, .hdot-test { background: var(--border-strong); }
.sidebar-foot { border-top: 1px solid var(--border); padding: 10px; display: flex; align-items: center; gap: 8px; }
.sidebar-foot .who { flex: 1; min-width: 0; font-size: 12.5px; }
.sidebar-foot .who strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.page-head { padding: 18px 24px 0; background: var(--bg); }
.page-head .row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 34px; }
.page-head h1 { font-size: 18px; font-weight: 650; letter-spacing: -.015em; }
.page-head .sub { color: var(--text-3); margin-top: 2px; font-size: 13px; }
.page-head .spacer { flex: 1; }
.page-head.inbox-head:not(:has(.tabs)) { padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-3); margin-bottom: 6px; }
.crumbs a:hover { color: var(--text); }
.tabs { display: flex; gap: 2px; margin-top: 14px; border-bottom: 1px solid var(--border); }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 8px 10px 10px; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.content { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 24px 32px; }
.content.flush { padding: 0; overflow: hidden; display: flex; }
.bottomnav { display: none; }

/* ---------- vue d'ensemble */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.kpi .label { font-size: 12.5px; color: var(--text-3); font-weight: 500; display: flex; gap: 6px; align-items: center; }
.kpi .value { font-size: 24px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 14px; font-weight: 600; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--text-3); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th.r, .table td.r { text-align: right; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; transition: background .1s; }
.table tbody tr:hover { background: var(--hover); }
.table .client-name { font-weight: 600; display: block; }
.table .client-name:focus-visible { outline-offset: 4px; }
.table .client-sector { font-size: 12px; color: var(--text-3); }
.health { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.health .detail { font-size: 12px; color: var(--text-3); }
.client-cards { display: none; }

/* ---------- demandes */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .search { width: 260px; }
.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.seg button { height: 26px; padding: 0 10px; border: 0; background: transparent; border-radius: 6px; color: var(--text-2); font-size: 12.5px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 12.5px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { background: var(--hover); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip[aria-pressed="true"] .count { background: color-mix(in srgb, var(--surface) 22%, transparent); color: var(--surface); }
.board { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 12px; align-items: start; }
.column { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 8px; min-height: 120px; }
.column-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; font-weight: 600; font-size: 13px; }
.column-head .pill { height: 20px; }
.column-list { display: grid; gap: 8px; }
.column-empty { padding: 18px 8px; text-align: center; color: var(--text-3); font-size: 12.5px; border: 1px dashed var(--border-strong); border-radius: 8px; }
.lead { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; box-shadow: var(--shadow-sm); display: grid; gap: 8px; transition: border-color .12s, box-shadow .12s; }
.lead:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.lead-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.lead-who { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.lead-link::after { content: ""; position: absolute; inset: 0; border-radius: 10px; }
.lead-link:focus-visible { outline: none; }
.lead-link:focus-visible::after { outline: 2px solid var(--focus); outline-offset: 2px; }
.lead-service { font-size: 13px; color: var(--text); font-weight: 500; }
.slots { display: flex; flex-wrap: wrap; gap: 4px; }
.slot { font-size: 12px; padding: 2px 7px; border-radius: 5px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot b { font-weight: 500; color: var(--text-3); }
.lead-foot { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.lead-foot .time { font-size: 12px; color: var(--text-3); }
.lead-foot .select { position: relative; z-index: 1; width: auto; height: 26px; font-size: 12px; padding: 0 24px 0 8px; background-position: calc(100% - 12px) 50%, calc(100% - 8px) 50%; }
.lead-list { display: grid; }
.lead-list .lead { border-radius: 0; box-shadow: none; border-width: 0 0 1px; grid-template-columns: minmax(160px, 1.2fr) minmax(140px, 1fr) minmax(0, 2fr) auto auto; align-items: center; gap: 14px; padding: 10px 16px; }
.lead-list .lead:hover { box-shadow: none; background: var(--hover); }
.lead-list .lead:last-child { border-bottom: 0; }
.lead-list .lead-link::after { border-radius: 0; }

/* ---------- boîte de réception */
.inbox { display: grid; grid-template-columns: 340px minmax(0, 1fr); flex: 1; min-height: 0; width: 100%; }
.inbox.with-panel { grid-template-columns: 340px minmax(0, 1fr) 320px; }
.convlist { border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.convlist-head { padding: 12px; display: grid; gap: 8px; border-bottom: 1px solid var(--border); }
.convlist-head .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.convlist-head .select { height: 30px; font-size: 12.5px; }
.convlist-meta { font-size: 12px; color: var(--text-3); padding: 0 2px; display: flex; justify-content: space-between; }
.convs { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: 4px 0; }
.conv { display: flex; gap: 10px; padding: 10px 12px; margin: 0 6px; border-radius: 8px; cursor: pointer; align-items: flex-start; }
.conv:hover { background: var(--hover); }
.conv[aria-selected="true"] { background: var(--accent-weak); }
.conv:focus-visible { outline-offset: -2px; }
.conv-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.conv-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.conv-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.conv-preview { color: var(--text-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.conv-preview .from { color: var(--text-2); }
.conv .pill { height: 19px; font-size: 11px; padding: 0 6px; }
.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--thread-bg); }
.thread-head { height: 60px; flex: none; padding: 0 16px; display: flex; align-items: center; gap: 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.thread-head .who { flex: 1; min-width: 0; }
.thread-head .who strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-head .who span { font-size: 12.5px; color: var(--text-3); display: flex; gap: 6px; align-items: center; }
.thread-head .back { display: none; }
.bubbles { flex: 1; overflow-y: auto; padding: 18px clamp(12px, 4%, 48px) 24px; display: flex; flex-direction: column; gap: 4px; }
.day { align-self: center; margin: 14px 0 8px; font-size: 11.5px; font-weight: 600; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); padding: 3px 10px; border-radius: 999px; box-shadow: var(--shadow-sm); }
.msg { display: flex; flex-direction: column; max-width: min(560px, 78%); }
.msg-in { align-self: flex-start; align-items: flex-start; }
.msg-out { align-self: flex-end; align-items: flex-end; }
.msg + .msg-out.cont, .msg + .msg-in.cont { margin-top: -1px; }
.bubble { padding: 7px 10px 6px; border-radius: 10px; box-shadow: var(--shadow-sm); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.42; }
.msg-in .bubble { background: var(--bubble-in); border: 1px solid var(--border); border-top-left-radius: 3px; }
.msg-out .bubble { background: var(--bubble-out); color: var(--bubble-out-text); border-top-right-radius: 3px; }
.msg.cont.msg-in .bubble { border-top-left-radius: 10px; }
.msg.cont.msg-out .bubble { border-top-right-radius: 10px; }
.bubble-meta { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 3px; font-size: 11px; color: var(--text-3); float: right; margin-left: 12px; position: relative; top: 4px; }
.msg-out .bubble-meta { color: color-mix(in srgb, var(--bubble-out-text) 62%, transparent); }
.bubble-meta .icon { width: 14px; height: 14px; }
.bubble-meta .st-sent { color: var(--ok); }
.bubble-meta .st-failed, .bubble-meta .st-uncertain { color: var(--danger); }
.msg-under { display: flex; gap: 6px; align-items: center; margin: 4px 2px 6px; font-size: 11.5px; color: var(--text-3); }
.intent { font-size: 11px; height: 19px; padding: 0 7px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text-2); display: inline-flex; align-items: center; gap: 4px; }
.sender-tag { font-weight: 600; font-size: 11px; color: var(--text-3); margin: 8px 4px 3px; }
.event { align-self: center; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 5px 10px; border-radius: 8px; margin: 6px 0; background: var(--warn-weak); color: var(--warn); }
.event-blocked, .event-stop { background: var(--danger-weak); color: var(--danger); }
.readonly { flex: none; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 16px; font-size: 12.5px; color: var(--text-3); background: var(--surface); border-top: 1px solid var(--border); text-align: center; }
.readonly.stop { color: var(--danger); background: var(--danger-weak); }
.panel { border-left: 1px solid var(--border); background: var(--surface); overflow-y: auto; min-height: 0; }
.panel-head { position: sticky; top: 0; background: var(--surface); z-index: 1; height: 60px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px 0 16px; border-bottom: 1px solid var(--border); font-weight: 600; }
.panel-section { padding: 16px; border-bottom: 1px solid var(--border); display: grid; gap: 10px; }
.panel-section:last-child { border-bottom: 0; }
.panel-section h3 { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; justify-content: space-between; }
.identity { display: flex; gap: 12px; align-items: center; }
.identity strong { font-size: 15px; display: block; }
.address .btn { font-family: var(--font); }
.address { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; margin: 0; }
.facts dt { color: var(--text-3); }
.facts dd { margin: 0; text-align: right; }
.mini-lead { border: 1px solid var(--border); border-radius: 9px; padding: 10px; display: grid; gap: 8px; }
.mini-lead .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mini-lead .select { width: auto; height: 28px; font-size: 12.5px; }
.notes { display: grid; gap: 8px; }
.note { background: var(--warn-weak); border-radius: 8px; padding: 8px 10px; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.note .meta { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.note-form { display: grid; gap: 8px; }
.note-form .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-3); }

/* ---------- fiche robot */
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stack { display: grid; gap: 16px; }
.services { list-style: none; margin: 0; padding: 0; }
.services li { padding: 12px 16px; border-bottom: 1px solid var(--border); display: grid; gap: 6px; }
.services li:last-child { border-bottom: 0; }
.services .row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.services .name { font-weight: 600; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 9px 16px; padding: 14px 16px; margin: 0; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; text-align: right; }
.log { list-style: none; margin: 0; padding: 4px 0; font-size: 12.5px; }
.log li { display: flex; gap: 10px; padding: 7px 16px; align-items: baseline; }
.log li .what { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log li time { color: var(--text-3); white-space: nowrap; }

/* ---------- états */
.empty { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 48px 24px; color: var(--text-3); margin: auto; max-width: 420px; }
.empty .ico { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; color: var(--text-2); margin-bottom: 4px; }
.empty .ico .icon { width: 20px; height: 20px; }
.empty strong { color: var(--text); font-size: 15px; font-weight: 600; }
.sk { background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: sk 1.3s ease-in-out infinite; border-radius: 6px; }
@keyframes sk { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.sk-line { height: 12px; margin: 6px 0; }
.sk-row { display: flex; gap: 10px; padding: 12px; align-items: center; }
.sk-circle { width: 34px; height: 34px; border-radius: 50%; flex: none; }
.sk-card { height: 104px; border-radius: 10px; }
.sk-kpi { height: 84px; border-radius: 12px; }
.w-40 { width: 40%; } .w-60 { width: 60%; } .w-80 { width: 80%; } .w-30 { width: 30%; }
.toast-zone { position: fixed; bottom: 64px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; pointer-events: none; }
.toast { background: var(--text); color: var(--surface); padding: 9px 14px; border-radius: 9px; box-shadow: var(--shadow-lg); font-size: 13px; display: flex; align-items: center; gap: 8px; animation: pop .18s ease-out; }
.toast-error { background: var(--danger); color: var(--on-accent); }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
dialog { border: 1px solid var(--border); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(420px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(10, 10, 16, .45); }
.dialog-body { padding: 20px; display: grid; gap: 8px; }
.dialog-body h2 { font-size: 16px; }
.dialog-body p { color: var(--text-2); }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 14px 14px; }
.hide-wide { display: none !important; }
.scrim, .scrim-menu { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- écrans moyens */
@media (max-width: 1280px) {
  .inbox.with-panel { grid-template-columns: 300px minmax(0, 1fr) 300px; }
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1060px) {
  .inbox.with-panel { grid-template-columns: 300px minmax(0, 1fr); }
  .inbox.with-panel .panel { position: fixed; right: 0; top: 0; bottom: 0; width: min(360px, 100vw); z-index: 40; box-shadow: var(--shadow-lg); }
  .inbox.with-panel .scrim { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(10, 10, 16, .35); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .lead-list .lead { grid-template-columns: minmax(0, 1fr) auto; }
  .lead-list .lead .slots, .lead-list .lead .lead-service { grid-column: 1 / -1; }
}

/* ---------- téléphone */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr) auto; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 50; transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .app.menu-open .sidebar { transform: none; }
  .app.menu-open .scrim-menu { display: block; position: fixed; inset: 0; z-index: 49; background: rgba(10, 10, 16, .4); }
  .topbar { display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 8px 0 4px; background: var(--surface); border-bottom: 1px solid var(--border); }
  .topbar .title { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottomnav { display: flex; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
  .bottomnav a { flex: 1; display: grid; justify-items: center; gap: 2px; padding: 7px 4px 8px; font-size: 11px; font-weight: 500; color: var(--text-3); }
  .bottomnav a .icon { width: 20px; height: 20px; }
  .bottomnav a[aria-current="page"] { color: var(--accent-text); }
  .page-head { padding: 14px 16px 0; }
  .page-head .crumbs, .page-head h1.dup { display: none; }
  .tabs { overflow-x: auto; margin-top: 10px; }
  .content { padding: 14px 16px 24px; }
  .kpis { gap: 8px; }
  .kpi { padding: 12px; }
  .kpi .value { font-size: 20px; }
  .clients-table { display: none; }
  .client-cards { display: grid; gap: 8px; }
  .client-card { display: grid; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; box-shadow: var(--shadow-sm); }
  .client-card .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .client-card .nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; font-size: 12px; color: var(--text-3); }
  .client-card .nums b { display: block; font-size: 16px; color: var(--text); font-weight: 650; }
  .toolbar .search { width: 100%; order: -1; }
  .board { grid-template-columns: 1fr; }
  .column { background: transparent; border: 0; padding: 0; min-height: 0; }
  .column-head { padding: 6px 2px 8px; }
  .hide-narrow { display: none !important; }
  .hide-wide { display: initial !important; }
  .page-head.inbox-head { display: none; }
  .inbox, .inbox.with-panel { grid-template-columns: 1fr; }
  .inbox .thread { display: none; }
  .inbox.open .convlist { display: none; }
  .inbox.open .thread { display: flex; }
  .thread-head { padding: 0 8px; gap: 8px; }
  .thread-head .back { display: inline-flex; }
  .msg { max-width: 86%; }
  .inbox.with-panel .panel { width: 100vw; }
  .lead-list .lead { padding: 12px; }
  .input, .textarea, .convlist-head .select { font-size: 16px; } /* évite le zoom iOS */
}
.lead > .muted { font-size: 12.5px; }
