:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1c2230;
  --ink-2: #3d4556;
  --muted: #6b7386;
  --faint: #9aa1b1;
  --line: #e7e9ee;
  --line-2: #f0f1f4;
  --accent: #4361d8;
  --accent-soft: #eef1fd;
  --accent-ink: #2f47b0;
  --ok: #1f9d6b;
  --ok-soft: #e7f6ef;
  --warn: #c98a1b;
  --warn-soft: #fdf4e3;
  --bad: #c9474b;
  --bad-soft: #fcecec;
  --grey-bar: #cfd4de;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 28, 45, .04), 0 2px 8px rgba(20, 28, 45, .04);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1, "cv11" 1;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }

/* ── Boutons et champs ─────────────────────────────────────────── */
.btn {
  font: inherit; font-weight: 550; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  height: 36px; padding: 0 14px; border-radius: 10px; cursor: pointer; display: inline-flex; align-items: center;
  gap: 8px; transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { border-color: #d5d9e2; background: #fafbfc; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid rgba(67, 97, 216, .25); outline-offset: 1px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--line-2); color: var(--ink); }
.btn.small { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.block { width: 100%; justify-content: center; height: 42px; }
.btn[disabled] { opacity: .5; cursor: default; }

input, select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 11px; width: 100%; transition: border-color .15s;
}
input:hover, select:hover, textarea:hover { border-color: #d5d9e2; }
textarea { resize: vertical; min-height: 80px; line-height: 1.55; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 550; color: var(--ink-2); }
.field .help { font-size: 12px; color: var(--muted); }

.switch { position: relative; width: 40px; height: 23px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; z-index: 1; margin: 0; }
.switch span { position: absolute; inset: 0; background: #d6dae3; border-radius: 99px; transition: background .2s; }
.switch span::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 17px; height: 17px; background: #fff;
  border-radius: 50%; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .2s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(17px); }
.switch input:focus-visible + span { outline: 3px solid rgba(67, 97, 216, .25); }

/* ── Connexion ─────────────────────────────────────────────────── */
.login {
  min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 500px at 50% -10%, #e9edfb 0%, var(--bg) 60%);
}
.login>form {
  width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  padding: 36px 32px 30px; box-shadow: 0 10px 40px rgba(30, 45, 90, .08); display: grid; gap: 14px; text-align: center;
}
.login>form .field { text-align: left; margin-top: 8px; }
.lock {
  width: 60px; height: 60px; border-radius: 18px; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; margin: 0 auto 4px;
}
.login>form p.muted { margin: -6px 0 0; }
.error { color: var(--bad); min-height: 20px; margin: 0; font-size: 13px; }

/* ── Structure ─────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100%; }
.side {
  position: sticky; top: 0; height: 100vh; background: var(--card); border-right: 1px solid var(--line);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 22px;
}
.brand { display: flex; gap: 11px; align-items: center; padding: 2px 8px; }
.brand strong { display: block; font-size: 14.5px; }
.brand small { color: var(--muted); font-size: 12px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px; color: var(--ink-2);
  font-weight: 500; transition: background .15s, color .15s;
}
.nav a svg { width: 18px; height: 18px; fill: currentColor; stroke: currentColor; opacity: .75; }
.nav a:hover { background: var(--line-2); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent-ink); }
.nav a.active svg { opacity: 1; }
.live-count {
  margin-left: auto; background: var(--ok); color: #fff; font-size: 11px; font-weight: 600; border-radius: 99px;
  padding: 1px 7px;
}
.side-status { margin-top: auto; display: grid; gap: 8px; padding: 12px; background: var(--bg); border-radius: 12px; font-size: 12.5px; }
.side-status .row { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.logout { align-self: flex-start; }

.main { padding: 28px 32px 56px; max-width: 1320px; width: 100%; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: 2fr 1fr; }
.mt { margin-top: 16px; }

/* ── Sélecteur de période ──────────────────────────────────────── */
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button {
  font: inherit; font-size: 13px; font-weight: 500; border: 0; background: transparent; color: var(--muted);
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--accent-soft); color: var(--accent-ink); }

/* ── Indicateurs ───────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 7px; }
.kpi .value { font-size: 27px; font-weight: 650; letter-spacing: -.02em; margin-top: 6px; line-height: 1.1; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
.dot.warn { background: var(--warn); }
.dot.idle { background: var(--faint); }
.dot.accent { background: var(--accent); }
.dot.grey { background: var(--grey-bar); }
.dot.pulse { box-shadow: 0 0 0 0 rgba(31, 157, 107, .5); animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(31, 157, 107, 0); } 100% { box-shadow: 0 0 0 0 rgba(31, 157, 107, 0); } }

.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 210px; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Carte de chaleur jour × heure */
.heat { display: grid; grid-template-columns: 34px repeat(24, minmax(0, 1fr)); gap: 3px; font-size: 11px; color: var(--muted); }
.heat .c { aspect-ratio: 1.25; border-radius: 4px; background: var(--line-2); }
.heat .h { text-align: center; }
.heat .d { display: flex; align-items: center; }

/* Barres horizontales simples */
.bars { display: grid; gap: 11px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; font-size: 13px; }
.bar-row .track { grid-column: 1 / -1; height: 7px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width .5s ease; }
.bar-row .fill.grey { background: var(--grey-bar); }
.bar-row b { font-weight: 600; }

.list { display: grid; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-2); font-size: 13px; }
.list-row:first-child { border-top: 0; }
.list-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Badges ────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 550; padding: 2px 9px;
  border-radius: 99px; background: var(--line-2); color: var(--ink-2); white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: #17734f; }
.badge.accent { background: var(--accent-soft); color: var(--accent-ink); }
.badge.warn { background: var(--warn-soft); color: #94650f; }
.badge.bad { background: var(--bad-soft); color: #a3373b; }

/* ── En direct ─────────────────────────────────────────────────── */
.status-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.status-strip .card { padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.status-strip .t { font-size: 12px; color: var(--muted); }
.status-strip .v { font-weight: 600; }

.live-call { padding: 0; overflow: hidden; }
.live-call .lc-head { display: flex; align-items: center; gap: 14px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 650; flex: none;
}
.timer { margin-left: auto; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chat { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px; max-height: 440px; overflow-y: auto; scroll-behavior: smooth; }
.bubble { max-width: 78%; padding: 9px 13px; border-radius: 14px; line-height: 1.5; font-size: 13.5px; animation: fadein .25s ease; }
.bubble small { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; font-weight: 550; }
.bubble.claire { background: var(--accent-soft); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.appelant { background: var(--line-2); align-self: flex-end; border-bottom-right-radius: 4px; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.typing { display: inline-flex; gap: 4px; padding: 12px 14px; align-self: flex-start; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty .ring {
  width: 58px; height: 58px; border-radius: 50%; margin: 0 auto 14px; display: grid; place-items: center;
  background: var(--ok-soft); color: var(--ok);
}
.empty strong { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 550; color: var(--muted); font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fbfbfc; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; transition: background .12s; }
tr.click:hover { background: #fafbfd; }
.table-wrap { overflow-x: auto; }

/* ── Dossiers ──────────────────────────────────────────────────── */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.search { position: relative; flex: 1; min-width: 220px; max-width: 380px; }
.search input { padding-left: 36px; height: 38px; }
.search svg { position: absolute; left: 12px; top: 11px; width: 16px; height: 16px; stroke: var(--faint); fill: none; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font: inherit; font-size: 12.5px; font-weight: 500; border: 1px solid var(--line); background: var(--card);
  color: var(--ink-2); padding: 5px 11px; border-radius: 99px; cursor: pointer;
}
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.snippet { color: var(--muted); max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dossier-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
.dossier-side { position: sticky; top: 20px; display: grid; gap: 14px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; margin-bottom: 12px; }
.back:hover { color: var(--ink); }
.save-state { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.timeline { display: grid; gap: 14px; }
.call-card .cc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.summary { white-space: pre-wrap; line-height: 1.6; color: var(--ink-2); }
.transcript { margin-top: 14px; border-top: 1px solid var(--line-2); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

/* ── Réglages ──────────────────────────────────────────────────── */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line-2); }
.set-row:first-of-type { border-top: 0; }
.set-row .l { min-width: 0; }
.set-row .l b { font-weight: 550; display: block; }
.set-row .l small { color: var(--muted); font-size: 12px; }
.set-row input, .set-row select { width: 170px; flex: none; }
.set-row input[type=range] { padding: 0; border: 0; accent-color: var(--accent); }
.set-row .rv { display: flex; align-items: center; gap: 10px; }
.set-row .rv output { min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 550; }
.pause-card { display: flex; align-items: center; gap: 16px; padding: 18px 20px; margin-bottom: 16px; }
.pause-card .grow { flex: 1; }
.sticky-save {
  position: sticky; bottom: 16px; margin-top: 16px; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px; background: var(--ink); color: #fff; border-radius: 14px; box-shadow: 0 10px 30px rgba(20, 28, 45, .2);
  animation: fadein .2s ease;
}
.sticky-save .btn { border-color: transparent; }
.contact { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 10px; }
.contact .row2 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 500; font-size: 13px;
  transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); }

.skeleton { background: linear-gradient(90deg, var(--line-2), #f7f8fa, var(--line-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }

/* ── Adaptation écrans ─────────────────────────────────────────── */
@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
  .g-2, .g-3, .settings-grid, .dossier-grid { grid-template-columns: 1fr; }
  .dossier-side { position: static; }
  .status-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; align-items: center;
    padding: 10px 16px; gap: 10px; overflow-x: auto;
  }
  .brand div, .side-status, .logout { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav a { white-space: nowrap; padding: 8px 10px; }
  .main { padding: 20px 16px 48px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .contact .row2 { grid-template-columns: 1fr; }
  .set-row { flex-wrap: wrap; }
  .set-row input, .set-row select { width: 100%; }
  .bubble { max-width: 92%; }
  .heat { font-size: 9px; gap: 2px; }
}
