:root {
  --bg: #0e1216; --surface: #171e26; --surface2: #1f2833; --line: #2a333d;
  --text: #e8edf2; --muted: #8b98a5; --accent: #e5484d; --blue: #4c8dff;
  --ok: #46a758; --warn: #f5a524; --cold: #7b8794; --radius: 10px;
}
* { box-sizing: border-box; margin: 0; font-family: "Segoe UI", sans-serif; }
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--text); height: 100vh; overflow: hidden; }
.view { height: 100vh; }
.error { color: var(--accent); font-size: 13px; min-height: 18px; }
button { cursor: pointer; }

/* Login */
.login { display: grid; place-items: center; }
.login-card { background: var(--surface); padding: 36px; border-radius: 16px;
  border: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px;
  width: 340px; }
.login-card h1 { font-size: 22px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.login-card input { background: var(--surface2); border: 1px solid var(--line);
  color: var(--text); border-radius: var(--radius); padding: 10px 12px; }
.login-card button { background: var(--accent); border: none; color: #fff;
  border-radius: var(--radius); padding: 11px; font-weight: 600; }

/* Layout app */
.app { display: flex; flex-direction: column; height: 100vh; }
.app-body { display: flex; flex: 1; min-height: 0; }
.sidebar { width: 210px; background: var(--surface); border-right: 1px solid var(--line);
  padding: 16px 10px; display: flex; flex-direction: column; gap: 4px; }
.sidebar .who { font-size: 13px; color: var(--muted); padding: 6px 10px 14px; }
.sidebar button { background: none; border: none; color: var(--text); text-align: left;
  padding: 9px 10px; border-radius: 8px; font-size: 13.5px; }
.sidebar button:hover { background: var(--surface2); }
.sidebar button.active { background: var(--surface2); font-weight: 600; }
.sidebar .spacer { flex: 1; }
.sidebar .ghost { color: var(--muted); }
main { flex: 1; overflow-y: auto; padding: 22px 28px; }

/* Liste */
.conv-row { display: grid; grid-template-columns: 92px 1fr 130px 110px 110px;
  gap: 10px; align-items: center; padding: 11px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); margin-bottom: 8px;
  cursor: pointer; font-size: 13.5px; }
.conv-row:hover { border-color: var(--blue); }
.badge { padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  justify-self: start; }
.badge.satisfait { background: rgba(70,167,88,.18); color: var(--ok); }
.badge.interesse { background: rgba(76,141,255,.18); color: var(--blue); }
.badge.hesitant { background: rgba(245,165,36,.18); color: var(--warn); }
.badge.froid { background: rgba(123,135,148,.2); color: var(--cold); }
.badge.status { background: var(--surface2); color: var(--muted); }
.badge.error { background: rgba(229,72,77,.18); color: var(--accent); }
.muted { color: var(--muted); }

/* Fiche */
.fiche h2 { margin-bottom: 4px; }
.fiche .meta { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px; font-size: 13.5px; line-height: 1.5; }
.card.wide { grid-column: 1 / -1; }
.card h3 { font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 10px; }
.card ul { padding-left: 18px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 10px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.proba { height: 8px; background: var(--surface2); border-radius: 4px; margin: 8px 0; }
.proba > div { height: 100%; border-radius: 4px; background: var(--blue); }
.obj { border-left: 3px solid var(--line); padding: 6px 10px; margin-bottom: 8px; }
.obj.bien { border-color: var(--ok); } .obj.mal { border-color: var(--accent); }
.obj.non_traitee { border-color: var(--warn); }
.feedback { display: flex; align-items: center; gap: 6px; }
.fb { background: none; border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 3px 10px; font-size: 14px; }
.fb:hover { border-color: var(--blue); }
.fb.active { border-color: var(--accent); background: rgba(229, 72, 77, .14); }
.transcript { white-space: pre-wrap; font-size: 12.5px; color: var(--muted);
  max-height: 260px; overflow-y: auto; }
.back { background: none; border: none; color: var(--blue); font-size: 13px;
  padding: 0 0 14px; }

/* Chat */
.chat { margin-top: 18px; }
.chat .msg { max-width: 78%; padding: 10px 14px; border-radius: 12px; margin-bottom: 8px;
  font-size: 13.5px; white-space: pre-wrap; line-height: 1.5; position: relative; }
.chat .msg.user { background: var(--surface2); margin-left: auto; }
.chat .msg.assistant { background: var(--surface); border: 1px solid var(--line); }
.chat .copy { position: absolute; top: 6px; right: 8px; background: none; border: none;
  color: var(--muted); font-size: 12px; }
.chat .copy:hover { color: var(--text); }
.chat form { display: flex; gap: 8px; margin-top: 12px; }
.chat input { flex: 1; background: var(--surface2); border: 1px solid var(--line);
  color: var(--text); border-radius: var(--radius); padding: 11px 14px; }
.chat button[type=submit] { background: var(--blue); color: #fff; border: none;
  border-radius: var(--radius); padding: 0 18px; font-weight: 600; }
.chat button[type=submit]:disabled { opacity: .6; cursor: not-allowed; }
#attachBtn { background: var(--surface2); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--radius); padding: 0 12px; font-size: 16px; flex: none; }
#attachBtn:hover { border-color: var(--blue); }
#attachBtn:disabled { opacity: .5; cursor: not-allowed; }
#attachName { display: flex; align-items: center; gap: 6px; margin-top: 8px;
  font-size: 12.5px; min-height: 16px; }
.attach-clear { background: none; border: none; color: var(--muted); font-size: 13px;
  padding: 0; }
.attach-clear:hover { color: var(--accent); }

/* Dashboard + admin */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
  margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; }
.stat .n { font-size: 30px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 12.5px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
.admin form.inline { display: flex; gap: 8px; margin: 10px 0 22px; flex-wrap: wrap; }
.admin input, .admin select { background: var(--surface2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 13px; }
.admin textarea { width: 100%; min-height: 180px; background: var(--surface2);
  color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 10px;
  font-family: Consolas, monospace; font-size: 12.5px; }
.btn { background: var(--blue); color: #fff; border: none; border-radius: 8px;
  padding: 8px 14px; font-weight: 600; }
.btn.danger { background: var(--accent); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.ghost:hover { border-color: var(--blue); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
#adminMsg.ok { color: var(--ok); }

/* Utilitaires remplaçant les style="" inline (bloqués par la CSP style-src 'self') */
.mt-8 { margin-top: 8px; }
.mt-14 { margin-top: 14px; }
.brand-name { margin: 10px 0 6px; }
.brand-save { margin: 6px 0 14px; }

/* Barre d'enregistrement (fusion du widget Electron dans la mise en page web) */
.record-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.record-bar select#brand { background: var(--surface2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 10px;
  font-size: 13px; width: 170px; }
.record-bar input#clientName { background: var(--surface2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 10px;
  font-size: 13px; flex: 1; min-width: 140px; }
#timer { font-variant-numeric: tabular-nums; font-size: 15px; min-width: 46px; }
.queue { font-size: 12px; color: var(--warn); }

/* Enregistrement (repris de widget.css) */
.record { width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 18px; flex: none;
  transition: transform .15s ease, box-shadow .15s ease; }
.record:hover { transform: scale(1.06); }
.record:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.record.recording { background: #fff; color: var(--accent);
  box-shadow: 0 0 0 4px rgba(229, 72, 77, .35); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 9px rgba(229, 72, 77, .12); } }
.legal { font-size: 11px; color: var(--muted); line-height: 1.35; padding: 6px 10px;
  background: var(--surface2); border-radius: var(--radius); opacity: 0;
  transition: opacity .2s ease; flex-basis: 100%; }
.legal.show { opacity: 1; color: #f5d90a; }
.legal.error { opacity: 1; color: var(--accent); }
.legal.ok { opacity: 1; color: var(--ok); }

/* Responsive */
@media (max-width: 768px) {
  body { overflow: auto; }
  .view { height: auto; min-height: 100vh; }
  .app { height: auto; min-height: 100vh; }
  .app-body { flex-direction: column; }
  .sidebar { width: auto; flex-direction: row; align-items: center;
    overflow-x: auto; padding: 8px 10px; gap: 6px; border-right: none;
    border-bottom: 1px solid var(--line); }
  .sidebar button { white-space: nowrap; }
  main { padding: 16px; }
  .record-bar { flex-wrap: wrap; }
  .cards { grid-template-columns: 1fr; }
  .conv-row { grid-template-columns: 1fr auto; }
  .hide-mobile { display: none; }
}
