/* =========================================================================
   Tony SAV — panel équipe. Design : clair, pro, violet électrique.
   Public Sans (UI) + IBM Plex Mono (références / montants).
   ========================================================================= */

:root {
  --bg: #f5f5fb;
  --surface: #ffffff;
  --surface-2: #fbfaff;
  --ink: #2b2836;
  --ink-strong: #1a1824;
  --muted: #8c8899;
  --line: #ececf4;
  --line-strong: #dedbe9;

  --accent: #6a5cff;
  --accent-2: #8b7dff;
  --accent-soft: #edecff;

  --ok: #28c76f;      --ok-soft: #e4f8ee;
  --warn: #ff9f43;    --warn-soft: #fff2e3;
  --danger: #ea5455;  --danger-soft: #fdeaea;
  --info: #00cfe8;

  --radius: 12px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(26,24,36,.05), 0 10px 26px rgba(26,24,36,.06);
  --shadow-accent: 0 5px 16px rgba(106,92,255,.32);

  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #15161f;
    --surface: #20222e;
    --surface-2: #262835;
    --ink: #d5d4e2;
    --ink-strong: #f4f3fa;
    --muted: #8a889b;
    --line: #2e3040;
    --line-strong: #3a3d4f;
    --accent: #8b7dff;
    --accent-2: #a99dff;
    --accent-soft: #2a294a;
    --ok: #35d07f;      --ok-soft: #1c3a2c;
    --warn: #ffa863;    --warn-soft: #3d2f1c;
    --danger: #f2686a;  --danger-soft: #3d2222;
    --shadow: 0 1px 2px rgba(0,0,0,.35), 0 12px 32px rgba(0,0,0,.4);
    --shadow-accent: 0 5px 18px rgba(139,125,255,.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15161f;
  --surface: #20222e;
  --surface-2: #262835;
  --ink: #d5d4e2;
  --ink-strong: #f4f3fa;
  --muted: #8a889b;
  --line: #2e3040;
  --line-strong: #3a3d4f;
  --accent: #8b7dff;
  --accent-2: #a99dff;
  --accent-soft: #2a294a;
  --ok: #35d07f;      --ok-soft: #1c3a2c;
  --warn: #ffa863;    --warn-soft: #3d2f1c;
  --danger: #f2686a;  --danger-soft: #3d2222;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 12px 32px rgba(0,0,0,.4);
  --shadow-accent: 0 5px 18px rgba(139,125,255,.4);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
/* Sans ça, un `display:` posé par une classe (ex. .tc-panel, .amount-form)
   annule l'attribut [hidden] — piège CSS classique. Toggle-le en JS et ça
   reste invisible, quoi qu'il arrive. */
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { color: var(--ink-strong); margin: 0; font-weight: 600; text-wrap: balance; letter-spacing: -.01em; }
h1 { font-size: 21px; }
h2 { font-size: 15px; }
h3 { font-size: 13.5px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.muted { color: var(--muted); }
.sub { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.error {
  background: var(--danger-soft); color: var(--danger); font-weight: 600;
  border-radius: var(--radius-sm); padding: 9px 13px; font-size: 13px; margin: 0 0 14px;
}
.empty { color: var(--muted); padding: 22px 4px; text-align: center; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 20px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: var(--shadow-accent);
  display: grid; place-items: center; color: #fff;
}
.brand b { color: var(--ink-strong); font-size: 16px; letter-spacing: -.01em; }

.nav-group { display: flex; flex-direction: column; gap: 3px; }
.nav-label {
  font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); padding: 4px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500; text-decoration: none;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav-item svg { width: 19px; height: 19px; flex: none; }
.nav-item.active {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #fff; box-shadow: var(--shadow-accent);
}
.nav-item .count {
  margin-left: auto; font-size: 11px; font-weight: 700;
  background: var(--danger); color: #fff; border-radius: 999px;
  min-width: 18px; height: 18px; padding: 0 5px; display: grid; place-items: center;
}
.nav-item.active .count { background: rgba(255,255,255,.25); }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 13px 26px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.menu-btn { display: none; }
.top-search {
  position: relative;
  flex: 1; max-width: 380px;
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 14px; color: var(--muted); font-size: 13px;
}
.top-search svg { width: 15px; height: 15px; flex: none; }
.top-search input[type="search"] {
  flex: 1; width: auto; border: 0; border-radius: 0; background: none; padding: 0; margin: 0;
  color: var(--ink); font-size: 13px; font-family: var(--font);
}
.top-search input[type="search"]::placeholder { color: var(--muted); }
.top-search input[type="search"]:focus { outline: none; box-shadow: none; }
.top-search input[type="search"]::-webkit-search-cancel-button { display: none; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 0;
  background: none; color: var(--muted); display: grid; place-items: center;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.whoami { font-size: 13px; color: var(--muted); }
.whoami b { color: var(--ink-strong); }
.logout { display: flex; align-items: center; gap: 10px; margin: 0; }

.content { padding: 24px 26px 52px; max-width: 1240px; width: 100%; }
.content > h1:first-child, .page-title { margin-bottom: 18px; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

/* ---------- Card ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card.pad { padding: 18px 20px; }

/* ---------- Buttons ---------- */
button, .btn {
  font: inherit; cursor: pointer;
  border: 1px solid transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-radius: 9px; padding: 8px 15px; font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; gap: 7px;
  box-shadow: var(--shadow-accent);
  transition: filter .15s, background .15s, box-shadow .15s;
}
button:hover, .btn:hover { filter: brightness(1.05); }
button.ghost, .btn.ghost, button.linkish {
  background: var(--surface); color: var(--ink);
  border-color: var(--line-strong); box-shadow: none;
}
button.ghost:hover, .btn.ghost:hover { background: var(--surface-2); filter: none; }
button.danger, .btn.danger {
  background: none; color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); box-shadow: none;
}
button.danger:hover { background: var(--danger-soft); filter: none; }
button.sm, .btn.sm, .btn-sm { padding: 5px 11px; font-size: 12px; box-shadow: none; }
.btn-sm { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
button.linkish {
  border: 0; background: none; box-shadow: none; padding: 0;
  color: var(--accent); font-size: 12px; font-weight: 600; text-decoration: underline;
}

/* ---------- Form fields ---------- */
input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="number"], input[type="date"], select, textarea {
  font: inherit; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line-strong);
  border-radius: 9px; padding: 8px 11px; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: var(--surface); }
textarea { resize: vertical; }
input[type="color"] { padding: 2px; height: 34px; width: 44px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
label input, label select, label textarea { color: var(--ink); font-weight: 400; }

/* ---------- Login ---------- */
.login {
  width: 340px; max-width: 100%; padding: 30px 28px;
  display: flex; flex-direction: column; gap: 14px;
}
.login .brand-lockup { display: flex; align-items: center; gap: 11px; margin-bottom: 4px; }
.login h1 { font-size: 19px; }
.login button { margin-top: 4px; justify-content: center; }

/* ---------- KPI / stat tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px; margin: 4px 0 24px;
}
.kpi, .stat-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 15px 18px; display: flex; flex-direction: column; gap: 5px;
}
.kpi .label, .stat-l {
  font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted);
  order: 2;
}
.kpi .val, .stat-n {
  font-size: 23px; font-weight: 700; color: var(--ink-strong);
  font-variant-numeric: tabular-nums; letter-spacing: -.02em; order: 1;
}
.kpi .foot { order: 3; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.kpi.hero, .stat-card.highlight {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent; box-shadow: var(--shadow-accent);
}
.kpi.hero .label, .kpi.hero .val, .kpi.hero .foot,
.stat-card.highlight .stat-n, .stat-card.highlight .stat-l { color: #fff; }
.delta { font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.delta.up { color: var(--ok); background: var(--ok-soft); }
.delta.down { color: var(--danger); background: var(--danger-soft); }

/* ---------- Queue ---------- */
.queue-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.col .count {
  font-size: 11px; font-weight: 700; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 1px 8px; margin-left: 8px;
}
.col h2 { display: flex; align-items: center; margin-bottom: 12px; }
.ticket-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.ticket-row {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 13px 14px 13px 16px; position: relative; overflow: hidden;
  display: grid; grid-template-columns: 1fr auto; gap: 6px 12px;
  transition: border-color .15s, background .15s; cursor: pointer;
}
.ticket-row::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--line-strong); }
.queue-grid > section:first-child .ticket-row::before { background: var(--warn); }
.queue-grid > section:last-child .ticket-row::before { background: var(--accent); }
.ticket-row:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); background: var(--surface-2); }
.ticket-row form button { cursor: pointer; }
.ticket-main { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; text-decoration: none; }
.ticket-main:hover { text-decoration: none; }
.ticket-row .ref {
  font-family: var(--mono); font-size: 12px; color: var(--accent);
  background: var(--accent-soft); border-radius: 6px; padding: 1px 7px;
}
.ticket-row .shop { font-weight: 600; color: var(--ink-strong); }
.ticket-row .amount {
  font-weight: 700; color: var(--ink-strong); font-variant-numeric: tabular-nums;
  text-align: right; align-self: center;
}
.ticket-row .meta { color: var(--muted); font-size: 12.5px; }
.ticket-row .last-msg {
  grid-column: 1 / -1; min-width: 0;
  color: var(--muted); font-size: 12.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ticket-row .last-msg b { color: var(--ink); font-weight: 600; }
.ticket-row .row-tags { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 5px; }

.tag-filter { display: flex; flex-wrap: wrap; gap: 6px; margin: -2px 0 12px; }
.tf-chip {
  font-size: 11.5px; font-weight: 600; border-radius: 999px; padding: 4px 11px;
  border: 1px solid color-mix(in srgb, var(--chip, var(--line-strong)) 55%, transparent);
  color: var(--chip, var(--muted)); background: var(--surface); box-shadow: none;
}
.tf-chip:hover { filter: none; opacity: .8; }
.tf-chip.tf-active {
  background: var(--chip, var(--accent)); color: #fff; border-color: transparent;
}
.tf-chip.tf-all { --chip: var(--accent); }
.mine-empty-filtered { padding: 4px 2px; }
.ticket-row form { grid-column: 1 / -1; }
.ticket-row form button { padding: 5px 12px; font-size: 12px; }

/* ---------- Ticket detail ---------- */
main.ticket-page { display: flex; flex-direction: column; gap: 16px; }
.ticket-header {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px;
  display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; align-items: flex-start;
}
.ticket-id { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.back { font-size: 12px; color: var(--muted); font-weight: 600; }
.ticket-id h1 { font-size: 19px; }
.ticket-id .sub { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
.ticket-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ticket-actions form { margin: 0; }

.badge {
  font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}
.badge-open { color: var(--warn); background: var(--warn-soft); }
.badge-assigned { color: var(--accent); background: var(--accent-soft); }
.badge-closed { color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); }

.assigned-line, .close-note { color: var(--muted); font-size: 13px; margin: 0; }
.assigned-line strong, .close-note { color: var(--ink); }

.amount-wrap { display: inline-flex; align-items: baseline; gap: 7px; }
.amount-wrap strong { color: var(--accent); font-variant-numeric: tabular-nums; }
.amount-form { display: inline-flex; gap: 5px; align-items: center; }
.amount-form input { width: 6.5rem; padding: 4px 8px; }
.amount-form button { padding: 4px 9px; font-size: 12px; box-shadow: none; }

/* Résumé IA */
.summary-box {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px;
}
.summary-box.is-empty { border-left-color: var(--line-strong); }
.summary-head { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; }
.summary-title { font-weight: 700; font-size: 12px; color: var(--accent); letter-spacing: .04em; }
.summary-head .ghost { margin-left: auto; }
.summary-text { margin: 0; white-space: pre-wrap; }
.summary-meta { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.summary-spin { font-size: 12px; color: var(--muted); }

/* Tags */
.tags-block { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.tags-label { font-size: 12px; color: var(--muted); font-weight: 600; padding-top: 4px; }
.tags-edit { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.chip {
  font-size: 11.5px; font-weight: 600; border-radius: 999px; padding: 3px 10px;
  border: 1px solid color-mix(in srgb, var(--chip, var(--muted)) 45%, transparent);
  color: var(--chip, var(--muted)); background: transparent;
  display: inline-flex; align-items: center; gap: 5px; line-height: 1.35;
  font-family: var(--font);
}
button.chip { cursor: pointer; }
.chip-on, .chip.chip-on { background: var(--chip, var(--muted)); color: #fff; border-color: transparent; }
.chip-off { opacity: .72; }
.chip-off:hover { opacity: 1; }
.chip-sm { font-size: 11px; padding: 2px 8px; }

/* Chat thread */
.msg-list {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 12px;
  max-height: 460px; overflow-y: auto;
}
.msg { max-width: 76%; }
.msg-head { font-size: 11px; color: var(--muted); margin: 0 4px 3px; display: flex; gap: 8px; }
.msg-body { padding: 9px 13px; border-radius: 14px; font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.msg-client { align-self: flex-start; }
.msg-client .msg-body { background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg-agent { align-self: flex-end; }
.msg-agent .msg-head { justify-content: flex-end; }
.msg-agent .msg-body { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-bottom-right-radius: 5px; }
.msg-system { align-self: center; max-width: 90%; }
.msg-system .msg-body {
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 3px 13px; font-size: 12px;
}
.msg-photo { display: block; margin-top: 6px; }
.msg-photo img { max-width: 220px; border-radius: 10px; border: 1px solid var(--line); }
.msg-file { display: inline-block; margin-top: 6px; font-size: 12.5px; }

/* Quick replies + composer */
.quick-replies { display: flex; gap: 8px; flex-wrap: wrap; }
.qr-btn {
  font-size: 12.5px; font-weight: 600; border-radius: 999px; padding: 6px 13px;
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink); box-shadow: none;
}
.qr-btn:hover { border-color: var(--accent); color: var(--accent); filter: none; }
.reply-zone {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 18px;
}
.reply-closed { color: var(--muted); text-align: center; font-size: 13px; }
#reply-form { display: flex; flex-direction: column; gap: 10px; }
#reply-form textarea { min-height: 56px; }
.reply-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.reply-row-left { display: flex; align-items: center; gap: 6px; }
.file-btn {
  display: inline-flex; align-items: center; gap: 6px; margin: 0; cursor: pointer;
  font-size: 12.5px; color: var(--muted); font-weight: 500;
  border: 1px dashed var(--line-strong); border-radius: 8px; padding: 6px 11px;
}
.file-btn:hover { color: var(--ink); border-color: var(--accent); }
.file-btn input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-btn.icon-only {
  border-style: solid; padding: 0; width: 34px; height: 34px;
  justify-content: center; font-size: 15px; box-shadow: none;
}

/* ---------- Messages vocaux ---------- */
.voice-recorder { display: flex; flex-direction: column; }
.voice-recording, .voice-preview {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 8px 10px;
}
.rec-indicator {
  display: flex; align-items: center; gap: 8px; color: var(--danger);
  font-family: var(--mono); font-size: 13px; font-weight: 600; flex: 1;
}
.rec-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--danger); animation: rec-pulse 1.1s ease-in-out infinite; }
@keyframes rec-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.rec-actions { display: flex; gap: 6px; }
.stop-btn, .cancel-btn {
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
  flex: none; box-shadow: none; padding: 0;
}
.stop-btn { background: var(--danger); color: #fff; border: 0; }
.stop-btn:hover { filter: brightness(1.08); }
.cancel-btn { background: var(--surface); border: 1px solid var(--line-strong); color: var(--muted); }
.cancel-btn:hover { color: var(--ink); border-color: var(--accent); filter: none; }

.preview-play-btn {
  width: 30px; height: 30px; border-radius: 999px; background: var(--accent); border: 0;
  display: grid; place-items: center; flex: none; padding: 0; box-shadow: none;
}
.preview-play-btn svg { width: 12px; height: 12px; fill: #fff; }
.voice-wave {
  flex: 1; height: 10px; border-radius: 999px; background: var(--line-strong);
  position: relative; overflow: hidden;
}
.voice-wave-fill { display: block; height: 100%; width: 0%; background: var(--accent); border-radius: 999px; }
.voice-dur { font-family: var(--mono); font-size: 11.5px; color: var(--muted); flex: none; }

.voice-bubble {
  display: flex; align-items: center; gap: 10px; min-width: 180px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  border-radius: 14px; border-bottom-right-radius: 5px; padding: 9px 13px 9px 10px;
}
.msg-client .voice-bubble {
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
  border-bottom-right-radius: 14px; border-bottom-left-radius: 5px;
}
.voice-bubble .voice-play-btn {
  width: 28px; height: 28px; border-radius: 999px; background: rgba(255,255,255,.22); border: 0;
  display: grid; place-items: center; flex: none; padding: 0; box-shadow: none;
}
.msg-client .voice-bubble .voice-play-btn { background: var(--accent-soft); }
.voice-bubble .voice-play-btn svg { width: 11px; height: 11px; fill: #fff; }
.msg-client .voice-bubble .voice-play-btn svg { fill: var(--accent); }
.voice-bubble .voice-wave { background: rgba(255,255,255,.3); }
.voice-bubble .voice-wave-fill { background: #fff; }
.msg-client .voice-bubble .voice-wave { background: var(--line-strong); }
.msg-client .voice-bubble .voice-wave-fill { background: var(--accent); }
.voice-bubble .voice-dur { color: rgba(255,255,255,.9); }
.msg-client .voice-bubble .voice-dur { color: var(--muted); }

.close-dialog {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px;
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 420px; max-width: 92vw;
}
.close-dialog::backdrop { background: rgba(20,18,30,.5); backdrop-filter: blur(2px); }
.close-dialog h3 { margin-bottom: 12px; }
.close-dialog form { display: flex; flex-direction: column; gap: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.outcome-choice { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.close-dialog .radio { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-weight: 500; }
.close-dialog .radio input { width: auto; }
.close-dialog .hint { font-weight: 400; font-size: 12px; color: var(--muted); }

.outcome-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 13px; }
.outcome-line .sat { color: #eab308; letter-spacing: 1px; }

.encaisser-group { margin-bottom: 14px; }
.eg-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.eg-total { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.encaisser-group .table-wrap { box-shadow: none; margin: 6px 0 0; }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); margin: 12px 0 20px;
}
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th {
  text-align: left; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.grid td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover { background: var(--surface-2); }
table.grid td:nth-child(3) { font-variant-numeric: tabular-nums; }
.cell-tags { display: flex; flex-wrap: wrap; gap: 4px; max-width: 260px; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-blocked { opacity: .55; }
.pw-form { display: flex; gap: 6px; align-items: center; }
.pw-form input { width: 9rem; padding: 5px 9px; }

/* ---------- Forms : création / édition ---------- */
.search { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.search input[type="search"] { max-width: 280px; }
.search select { max-width: 200px; width: auto; }

.new-user, .new-tag, .new-shop, .qr-form, .shop-form {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 12px;
}
.new-user label, .new-shop label, .qr-form label, .shop-form label { flex: 1; min-width: 160px; }
.qr-form, .shop-form { flex-direction: column; align-items: stretch; }
.qr-form-top, .shop-form-top { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.qr-form-actions, .shop-form-actions { display: flex; gap: 8px; }
.qr-form .chk, .shop-form .chk {
  flex-direction: row; align-items: center; gap: 6px; color: var(--ink); font-weight: 500;
}
.qr-form .chk input, .shop-form .chk input { width: auto; }
.tag-edit-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.tag-edit-form input[type="text"] { width: 12rem; }
.tag-edit-form input[type="number"] { width: 5rem; }
.merge-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.merge-form select { width: auto; min-width: 160px; }

/* ---------- Stats ---------- */
.stat-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 8px 0 22px; }
.stat-2col h2 { margin-bottom: 12px; }
.bar-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.bar-list li { display: grid; grid-template-columns: 8rem 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; height: 9px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.bar-val { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Guide ---------- */
.guide { max-width: 840px; display: flex; flex-direction: column; gap: 16px; }
.guide-toc { display: flex; flex-wrap: wrap; gap: 8px; }
.guide-toc a {
  font-size: 12.5px; font-weight: 600; padding: 5px 11px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink); text-decoration: none;
}
.guide-toc a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.guide section { scroll-margin-top: 78px; }
.guide h2 { display: flex; align-items: baseline; gap: 9px; margin-bottom: 10px; font-size: 16px; }
.guide h2 .num {
  font-family: var(--mono); font-size: 12px; color: var(--accent); background: var(--accent-soft);
  border-radius: 6px; padding: 1px 7px; font-weight: 500;
}
.guide h3 { margin: 15px 0 6px; color: var(--ink-strong); }
.guide p { margin: 0 0 10px; }
.guide ul, .guide ol { margin: 0 0 10px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.guide li { line-height: 1.5; }
.guide .table-wrap { box-shadow: none; margin: 8px 0 12px; }
.guide .chips-inline { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.guide .callout {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  border-radius: 8px; padding: 10px 14px; margin: 10px 0 4px; font-size: 13px; color: var(--ink);
}
.guide code { white-space: nowrap; }

/* ---------- Account ---------- */
.ok-line { color: var(--ok); font-weight: 500; }
.link-code {
  font-family: var(--mono); font-size: 16px; color: var(--ink-strong);
  background: var(--surface-2); border: 1px dashed var(--accent); border-radius: 9px;
  padding: 10px 14px; display: inline-block; user-select: all; letter-spacing: .04em;
}
#link-code-zone { margin-top: 8px; }

/* ---------- Realtime offline hint ---------- */
.ws-offline .msg-list { border-color: var(--warn); }

/* ---------- Chat d'équipe (widget flottant, toutes pages) ---------- */
.tc-widget { position: fixed; right: 22px; bottom: 22px; z-index: 60; }
.tc-fab {
  width: 54px; height: 54px; border-radius: 50%; padding: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; box-shadow: var(--shadow-accent);
  display: grid; place-items: center; position: relative; border: 0;
}
.tc-fab:hover { filter: brightness(1.06); }
.tc-badge {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px;
  padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg);
}

.tc-panel {
  position: absolute; right: 0; bottom: 66px; width: 350px; max-width: calc(100vw - 32px);
  height: 480px; max-height: 70vh;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.28);
  display: flex; flex-direction: column; overflow: hidden;
}
.tc-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  font-weight: 700; font-size: 13.5px; color: var(--ink-strong);
}
.tc-close {
  background: none; border: 0; box-shadow: none; color: var(--muted);
  padding: 2px 6px; font-size: 14px; box-shadow: none;
}
.tc-close:hover { color: var(--ink); filter: none; }

.tc-msgs { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.tc-empty { text-align: center; margin: auto; font-size: 13px; }
.tc-msg { max-width: 84%; align-self: flex-start; }
.tc-msg-head { font-size: 10.5px; color: var(--muted); margin: 0 3px 3px; }
.tc-msg-body {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; border-bottom-left-radius: 4px;
  padding: 7px 11px; font-size: 13px; white-space: pre-wrap; word-break: break-word;
}
.tc-msg.tc-mine { align-self: flex-end; }
.tc-msg.tc-mine .tc-msg-head { text-align: right; }
.tc-msg.tc-mine .tc-msg-body {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  border-color: transparent; border-bottom-left-radius: 12px; border-bottom-right-radius: 4px;
}

.tc-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.tc-form textarea {
  flex: 1; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 8px 10px; font: inherit; font-size: 13px; resize: none; min-height: 36px; max-height: 100px; color: var(--ink);
}
.tc-form button {
  width: 36px; height: 36px; padding: 0; border-radius: 9px; flex: none; box-shadow: none;
  display: grid; place-items: center;
}

@media (max-width: 560px) {
  .tc-widget { right: 14px; bottom: 14px; }
  .tc-panel { width: calc(100vw - 28px); height: 66vh; bottom: 62px; }
}

/* ---------- Recherche globale ---------- */
.gs-results { position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 50; }
.gs-dropdown {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; max-height: 340px; overflow-y: auto;
}
.gs-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 13px;
  border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); font-size: 13px;
}
.gs-item:last-child { border-bottom: 0; }
.gs-item:hover { background: var(--surface-2); text-decoration: none; }
.gs-ref { font-family: var(--mono); font-size: 11.5px; color: var(--accent); font-weight: 600; flex: none; }
.gs-shop { font-weight: 600; color: var(--ink-strong); }
.gs-client { color: var(--muted); font-size: 12px; margin-left: auto; }
.gs-badge { flex: none; }
.gs-empty { padding: 14px; text-align: center; font-size: 13px; }

/* ---------- Badge "nouveau message" ---------- */
.ticket-row.is-unread {
  border-color: var(--danger); background: var(--danger-soft);
}
.ticket-row.is-unread::before { background: var(--danger) !important; }
.last-msg-unread { color: var(--danger); font-weight: 600; }
.last-msg-unread b { color: var(--danger); }
.unread-chip { animation: unread-pulse 1.8s ease-in-out infinite; }
@keyframes unread-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .72; } }

/* ---------- Transfert de dossier ---------- */
.transfer-form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.transfer-form select { width: auto; padding: 5px 9px; font-size: 12.5px; }

/* ---------- Notes internes ---------- */
.notes-panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 4px 16px;
}
.notes-panel summary {
  cursor: pointer; padding: 10px 0; font-weight: 600; font-size: 13.5px;
  display: flex; align-items: center; gap: 8px; list-style: none;
}
.notes-panel summary::-webkit-details-marker { display: none; }
.notes-panel .count {
  background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700;
  border-radius: 999px; padding: 1px 7px;
}
.notes-hint { font-weight: 400; font-size: 12px; }
.notes-list { display: flex; flex-direction: column; gap: 8px; padding: 2px 0 10px; }
.note-item { background: var(--warn-soft); border-radius: 9px; padding: 8px 11px; }
.note-head { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.note-author { font-weight: 700; color: var(--ink); }
.note-del {
  margin-left: auto; width: 18px; height: 18px; padding: 0; border: 0; background: none;
  color: var(--muted); font-size: 12px; line-height: 1; border-radius: 5px;
  display: grid; place-items: center; flex: none; box-shadow: none;
}
.note-del:hover { color: var(--danger); background: var(--danger-soft); filter: none; }
.note-body { font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.note-empty { padding: 4px 0 10px; }
.note-form { display: flex; gap: 8px; align-items: flex-end; padding-bottom: 12px; }
.note-form textarea { flex: 1; min-height: 40px; }
.note-form button { flex: none; }

/* ---------- Objectif du mois / classement ---------- */
.top-closer-banner {
  background: linear-gradient(135deg, #eab308, #f59e0b); color: #fff; font-weight: 600;
  border-radius: var(--radius); padding: 12px 18px; margin-bottom: 18px;
}
.goal-bar {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
  height: 12px; overflow: hidden; margin-top: 8px;
}
.goal-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.rank-cell { font-size: 16px; text-align: center; width: 2.5rem; }
tr.rank-1 { background: color-mix(in srgb, #eab308 8%, transparent); }

/* ---------- Bip / notif nouveau message client ---------- */
.ping-toasts {
  position: fixed; top: 18px; right: 18px; z-index: 70;
  display: flex; flex-direction: column; gap: 8px; max-width: 320px;
}
.ping-toast {
  display: block; background: var(--surface); border: 1px solid var(--line-strong);
  border-left: 3px solid var(--accent); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 10px 13px; text-decoration: none; color: var(--ink);
  animation: ping-in .18s ease-out;
}
.ping-toast:hover { border-color: var(--accent); text-decoration: none; background: var(--surface-2); }
.ping-toast b { display: block; color: var(--accent); font-size: 13px; margin-bottom: 2px; }
.ping-toast span { display: block; font-size: 12px; color: var(--muted); }
.ping-toast p { margin: 5px 0 0; font-size: 12.5px; color: var(--ink); white-space: pre-wrap; word-break: break-word; }
@keyframes ping-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 560px) {
  .ping-toasts { top: 8px; right: 8px; left: 8px; max-width: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 40; width: 250px; transform: translateX(-100%);
    transition: transform .2s;
  }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vw rgba(20,18,30,.4); }
  .menu-btn { display: grid; }
  .kpis, .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .queue-grid, .stat-2col { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .content { padding: 18px 15px 44px; }
  .topbar { padding: 11px 15px; }
  .top-search { max-width: none; }
  .kpis, .stat-cards { grid-template-columns: 1fr; }
  .msg { max-width: 88%; }
  .bar-list li { grid-template-columns: 6rem 1fr auto; }
}
