:root {
  --c: #6366f1;
  --c-dark: #4f46e5;
  --c-soft: #eef2ff;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --ink: #0f172a;
  --ink-2: #475569;
  --muted: #94a3b8;
  --line: #e2e8f0;
  --danger: #ef4444;
  --ok: #10b981;
  --r: 12px;
}

[hidden] { display: none !important; }

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: Vazirmatn, -apple-system, "Segoe UI", Tahoma, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
}
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--ink); }
h2, h3 { font-weight: 700; }

/* ---------- دکمه‌ها ---------- */
.btn { border: none; border-radius: 9px; padding: 10px 16px; font-weight: 600; }
.btn-sm { padding: 7px 13px; font-size: 13px; }
.btn-primary { background: var(--c); color: #fff; }
.btn-primary:hover { background: var(--c-dark); }
.btn-ghost { background: none; border: 1.5px solid var(--line); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--c); color: var(--c); }
.btn-danger { background: #fef2f2; color: var(--danger); }
.btn-danger:hover { background: #fee2e2; }

/* ---------- ورود ---------- */
.login-wrap {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef2ff, #f4f6fa);
}
.login-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 38px 34px;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 12px 40px rgba(15,23,42,.1);
  text-align: center;
}
.login-logo { font-size: 40px; }
.login-card h1 { font-size: 20px; }
.login-sub { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.login-card input {
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  outline: none;
}
.login-card input:focus { border-color: var(--c); }
.form-error { color: var(--danger); font-size: 13px; }
.form-ok { color: var(--ok); font-size: 13px; }

/* ---------- چیدمان ---------- */
#app { display: flex; height: 100%; }
.view { flex: 1; display: flex; min-width: 0; overflow: hidden; }

#sidebar {
  width: 64px;
  background: #111827;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  gap: 6px;
  flex-shrink: 0;
}
.side-logo { font-size: 26px; margin-bottom: 10px; }
.side-btn {
  position: relative;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: none;
  color: #9ca3af;
  display: flex;
  align-items: center;
  justify-content: center;
}
.side-btn:hover { background: #1f2937; color: #e5e7eb; }
.side-btn.active { background: var(--c); color: #fff; }
.side-spacer { flex: 1; }
.nav-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  background: var(--danger);
  color: #fff;
  border-radius: 9px;
  font-size: 10.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

/* ---------- ستون فهرست گفتگو ---------- */
#conv-list-col {
  width: 320px;
  background: var(--surface);
  border-inline-end: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.col-head { padding: 16px 14px 10px; border-bottom: 1px solid var(--line); }
.col-head h2 { font-size: 17px; margin-bottom: 10px; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tab {
  flex: 1;
  padding: 7px;
  border: none;
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink-2);
  font-weight: 600;
  font-size: 13px;
}
.tab.active { background: var(--c-soft); color: var(--c); }
#conv-search {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  outline: none;
  font-size: 13px;
}
#conv-search:focus { border-color: var(--c); }
#conv-list { flex: 1; overflow-y: auto; }

.conv-item {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.conv-item:hover { background: #f8fafc; }
.conv-item.active { background: var(--c-soft); }
.conv-top { display: flex; align-items: center; gap: 7px; }
.conv-name { font-weight: 700; font-size: 13.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 11px; color: var(--muted); }
.conv-preview {
  font-size: 12.5px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-subject {
  font-size: 12px;
  font-weight: 700;
  color: var(--c, #6366f1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-subject.result { color: var(--ink-2); font-weight: 600; }
.conv-bottom { display: flex; align-items: center; gap: 6px; }
.conv-agent { font-size: 11px; color: var(--muted); flex: 1; }
.unread-pill {
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  background: var(--c);
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; flex-shrink: 0; }
.online-dot.off { background: #cbd5e1; }
.rating-stars { color: #f59e0b; font-size: 11px; }

/* ---------- ستون گفتگو ---------- */
#thread-col { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
}
.empty-icon { font-size: 46px; opacity: .5; }
#thread { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#thread-head {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.th-name { font-weight: 700; font-size: 15px; }
.th-status { font-size: 12px; color: var(--muted); }
.th-subject { font-size: 12.5px; font-weight: 700; color: var(--c, #6366f1); margin-top: 2px; }
#btn-away { font-size: 16px; }
#btn-away.away-on { background: #fef3c7; }
.th-actions { display: flex; gap: 8px; }

#thread-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.msg { display: flex; flex-direction: column; max-width: 70%; }
.msg.visitor { align-self: flex-end; align-items: flex-end; }
.msg.agent { align-self: flex-start; align-items: flex-start; }
.msg.sys { align-self: center; max-width: 90%; }
.bubble {
  padding: 9px 13px;
  border-radius: 13px;
  line-height: 1.7;
  word-break: break-word;
  white-space: pre-wrap;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15,23,42,.06);
}
.msg.agent .bubble { background: var(--c); color: #fff; border-bottom-right-radius: 4px; }
.msg.visitor .bubble { border-bottom-left-radius: 4px; }
.msg.sys .bubble { background: #eef2ff; color: #4338ca; font-size: 12.5px; box-shadow: none; }
.bubble img { max-width: 240px; max-height: 220px; border-radius: 8px; display: block; }
.bubble a { color: inherit; text-decoration: underline; }
.msg .meta { font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.msg .meta .seen { color: var(--c); }
.sender-name { font-size: 11px; color: var(--muted); margin-bottom: 2px; }

.typing-note { padding: 4px 20px 8px; font-size: 12px; color: var(--muted); }

#reply-box {
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 10px 14px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  position: relative;
}
#reply-box > button:first-child {
  background: none;
  border: none;
  font-size: 18px;
  width: 36px;
  height: 36px;
  border-radius: 9px;
}
#reply-box > button:first-child:hover { background: var(--bg); }
#reply-input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  max-height: 120px;
  padding: 8px 4px;
  line-height: 1.6;
}

#canned-pop {
  position: absolute;
  bottom: 62px;
  inset-inline-start: 14px;
  width: 320px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15,23,42,.14);
  z-index: 10;
}
.canned-opt { padding: 9px 13px; cursor: pointer; border-bottom: 1px solid #f1f5f9; }
.canned-opt:hover, .canned-opt.hl { background: var(--c-soft); }
.canned-opt b { color: var(--c); font-size: 12.5px; }
.canned-opt span { display: block; font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- ستون اطلاعات ---------- */
#info-col {
  width: 260px;
  background: var(--surface);
  border-inline-start: 1px solid var(--line);
  padding: 18px 16px;
  overflow-y: auto;
  flex-shrink: 0;
}
#info-col h3 { font-size: 13px; color: var(--ink-2); margin: 14px 0 8px; }
#info-col h3:first-child { margin-top: 0; }
#info-fields { display: flex; flex-direction: column; gap: 7px; }
#info-fields div { display: flex; flex-direction: column; }
#info-fields dt { font-size: 11px; color: var(--muted); }
#info-fields dd { font-size: 13px; word-break: break-all; }
#conv-note {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  outline: none;
  resize: vertical;
  font-size: 13px;
  margin-bottom: 6px;
}
.history-list { display: flex; flex-direction: column; gap: 5px; }
.history-item { font-size: 12px; color: var(--ink-2); background: var(--bg); border-radius: 8px; padding: 7px 10px; }

/* ---------- صفحه‌های عمومی ---------- */
.page-pad { flex: 1; overflow-y: auto; padding: 28px 36px; }
.page-pad.narrow { max-width: 900px; margin-inline: auto; width: 100%; }
#view-stats .page-pad { max-width: 1240px; margin-inline: auto; width: 100%; }
.page-title { font-size: 19px; margin-bottom: 4px; }
.page-sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.card {
  background: var(--surface);
  border-radius: var(--r);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(15,23,42,.06);
}
.card-title { font-size: 14.5px; margin-bottom: 14px; }

/* ---------- آمار ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 18px 0; }
.tile { background: var(--surface); border-radius: var(--r); padding: 16px 18px; box-shadow: 0 1px 3px rgba(15,23,42,.06); }
.tile .t-label { font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.tile .t-value { font-size: 24px; font-weight: 800; }
.tile .t-unit { font-size: 12px; color: var(--muted); font-weight: 400; }

.chart { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 8px; }
.chart .bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; position: relative; }
.chart .bar { width: 100%; max-width: 34px; background: var(--c); border-radius: 4px 4px 0 0; min-height: 2px; transition: opacity .1s; }
.chart .bar-wrap:hover .bar { opacity: .75; }
.chart .bar-label { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.chart .bar-tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 2px);
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 3;
}
.chart .bar-wrap:hover .bar-tip { display: block; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: right; font-size: 12px; color: var(--ink-2); padding: 8px 10px; border-bottom: 1.5px solid var(--line); }
.table td { padding: 9px 10px; border-bottom: 1px solid #f1f5f9; font-size: 13px; }

/* ---------- فرم‌ها ---------- */
.form-row { display: flex; gap: 10px; align-items: center; }
.form-row input { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: center; }
.form-col { display: flex; flex-direction: column; gap: 12px; }
.form-col label, .form-inline label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--ink-2); }
.form-inline { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.form-inline label.check { flex-direction: row; align-items: center; gap: 7px; padding-bottom: 8px; }
.form-col > label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink); }
.card input:not([type="color"]):not([type="checkbox"]), .card select {
  padding: 9px 12px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  outline: none;
}
.card input:focus { border-color: var(--c); }
input[type="color"] { width: 46px; height: 38px; border: 1.5px solid var(--line); border-radius: 9px; padding: 3px; background: var(--surface); cursor: pointer; }

.list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid #f1f5f9;
}
.list-row:last-child { border-bottom: none; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .sub { font-size: 12px; color: var(--muted); }
.badge {
  font-size: 11px;
  background: var(--c-soft);
  color: var(--c);
  padding: 2px 9px;
  border-radius: 8px;
  font-weight: 600;
}
.icon-del { background: none; border: none; color: var(--muted); font-size: 15px; padding: 6px; border-radius: 7px; }
.icon-del:hover { color: var(--danger); background: #fef2f2; }

.code-box {
  background: #0f172a;
  color: #a5f3fc;
  direction: ltr;
  text-align: left;
  padding: 14px 16px;
  border-radius: 10px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12.5px;
  overflow-x: auto;
  margin-bottom: 10px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---------- امکانات جدید ---------- */
.msg.bot .bubble { background: linear-gradient(135deg, #8b5cf6, #7c3aed); color: #fff; }
.msg.note { align-self: center; max-width: 85%; }
.msg.note .bubble {
  background: #fef9c3;
  border: 1px dashed #eab308;
  color: #713f12;
  box-shadow: none;
  font-size: 13px;
}
.msg .bubble audio { width: 230px; height: 40px; display: block; }
.msg .bubble .transcript {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px dashed var(--line);
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--ink-2);
  max-width: 300px;
}
.msg.agent .bubble .transcript, .msg.bot .bubble .transcript { border-top-color: rgba(255,255,255,.35); color: #fff; opacity: .95; }
.msg .bubble .transcript.muted { color: var(--muted); font-style: italic; }
.msg .bubble video { max-width: 260px; max-height: 220px; border-radius: 8px; display: block; }
.msg .bubble pre.code {
  direction: ltr;
  text-align: left;
  background: #0f172a;
  color: #a5f3fc;
  border-radius: 8px;
  padding: 8px 10px;
  margin: 4px 0;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre;
}
.msg .bubble code {
  direction: ltr;
  display: inline-block;
  background: #eef1f6;
  color: #334155;
  border-radius: 5px;
  padding: 0 5px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12px;
}
.msg.agent .bubble code, .msg.bot .bubble code { background: rgba(255,255,255,.2); color: #fff; }

.sent-news { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.sent-news-item {
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12.5px;
  line-height: 1.8;
  text-align: justify;
}
.sent-choices { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.sent-choice {
  border: 1.5px solid rgba(255,255,255,.55);
  background: rgba(255,255,255,.14);
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 12px;
}
a.sent-link { color: #fff; text-decoration: none; background: rgba(255,255,255,.16); }
a.sent-link:hover { background: rgba(255,255,255,.3); }

.typing-preview { color: var(--c); font-style: italic; margin-inline-start: 6px; }

.chan-tag { font-size: 12px; }
.soft-hr { border: none; border-top: 1px solid var(--line); margin: 4px 0; }

/* نوار قبول گفتگو (صف انتظار) */
#accept-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 14px;
  background: #fffbeb;
  border-top: 1px solid #fde68a;
  color: #92400e;
  font-size: 13.5px;
  flex-wrap: wrap;
}
#accept-bar[hidden] { display: none; }
.pending-tag { color: #d97706; font-weight: 700; font-size: 11.5px; }
#online-list { flex: 1; overflow-y: auto; }
.online-item .start-chat { margin-top: 8px; align-self: flex-start; }
#bh-days label.check { flex-direction: row; align-items: center; gap: 5px; font-size: 13px; color: var(--ink); }
#trigger-form input[type="number"] { width: 110px; }
.dept-tag {
  font-size: 10.5px;
  background: #f0fdf4;
  color: #15803d;
  padding: 1px 7px;
  border-radius: 7px;
  font-weight: 600;
}

/* ----- امتیازدهی اپراتورها ----- */
.pts-total {
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 999px;
  padding: 3px 12px;
  cursor: pointer;
}
.pts-total.pos { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.pts-total.neg { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.pts-total:hover { border-color: var(--c); }
.pts-history { max-height: 340px; overflow-y: auto; }
.pts-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 9px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.pts-row:last-child { border-bottom: none; }
.pts-row b.pos { color: #15803d; }
.pts-row b.neg { color: #b91c1c; }
.pts-row b { min-width: 34px; text-align: center; }

/* ----- ویرایش/حذف پیام ----- */
.msg { position: relative; }
.msg-actions {
  position: absolute;
  top: -10px;
  inset-inline-end: 4px;
  display: none;
  gap: 1px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 1px 3px;
  box-shadow: 0 4px 12px rgba(15,23,42,.12);
  z-index: 5;
}
.msg:hover .msg-actions { display: flex; }
.msg-actions button {
  border: none;
  background: none;
  font-size: 12.5px;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 6px;
  line-height: 1;
}
.msg-actions button:hover { background: var(--bg); }
.msg-actions .msg-del:hover { background: #fee2e2; }
.edited-tag { font-size: 9.5px; color: var(--muted); font-style: italic; }

/* ----- کد دوعاملی زنده ----- */
.totp-mini {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(0,0,0,.25);
  border-radius: 9px;
  padding: 6px 11px;
  margin-top: 4px;
  font-size: 12.5px;
}
.totp-mini .totp-code {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 16px;
  letter-spacing: 2px;
}

/* ----- پنجره نمایش زنده صفحه کاربر ----- */
#screen-viewer {
  position: fixed;
  bottom: 16px;
  inset-inline-start: 80px;
  width: 460px;
  background: #0f172a;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(15,23,42,.45);
  z-index: 200;
  overflow: hidden;
}
#screen-viewer.full {
  inset: 12px;
  width: auto;
  bottom: 12px;
}
.sv-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
}
.sv-head .sub { color: #94a3b8; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sv-live { display: inline-flex; align-items: center; gap: 6px; }
.sv-live i {
  width: 8px; height: 8px; border-radius: 50%;
  background: #ef4444; box-shadow: 0 0 8px #ef4444;
  animation: dotPulse 1.4s ease-in-out infinite;
}
@keyframes dotPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.3); } }
.sv-head button {
  border: none;
  background: rgba(255,255,255,.12);
  color: #fff;
  width: 26px; height: 26px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
.sv-head button:hover { background: rgba(255,255,255,.26); }
#sv-video { display: block; width: 100%; height: auto; background: #000; cursor: crosshair; }
#screen-viewer.full #sv-video { height: calc(100% - 84px); object-fit: contain; }
.sv-status { padding: 14px; color: #cbd5e1; font-size: 12.5px; text-align: center; }
.sv-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: #1e293b;
}
.sv-hint { color: #94a3b8; font-size: 11px; white-space: nowrap; }
#sv-point-label {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 12px;
  padding: 5px 9px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
}
/* بازخورد کلیک روی پنل */
.sv-dot {
  position: absolute;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 50%;
  border: 2.5px solid #6366f1;
  background: rgba(99,102,241,.3);
  pointer-events: none;
  animation: svDot 1.5s ease-out forwards;
}
@keyframes svDot {
  0% { transform: scale(.5); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}
@media (max-width: 760px) {
  #screen-viewer { inset-inline: 10px; width: auto; bottom: 68px; }
}

/* ----- صفحه فعلی کاربر ----- */
.live-page {
  background: #ecfeff;
  border: 1px solid #a5f3fc;
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 12px;
  line-height: 1.8;
  margin-bottom: 12px;
}
.live-page b { color: #0e7490; }
.lp-title { font-weight: 700; color: var(--ink); }
.lp-prod { color: var(--ink-2); }
.lp-url {
  display: block;
  color: #0891b2;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
}

/* ----- پروفایل مشتری ----- */
#v-profile input, #v-profile textarea {
  font: inherit;
  font-size: 12.5px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  width: 100%;
}
.perm-note {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 12.5px;
  line-height: 1.8;
}

/* ----- صندوق ورودی حرفه‌ای ----- */
.filter-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
#saved-filter-chips { display: flex; gap: 5px; flex-wrap: wrap; }
.sf-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  background: var(--c-soft);
  color: var(--c-deep, var(--c));
  border: 1px solid transparent;
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
}
.sf-chip:hover { border-color: var(--c); }
.sf-del { font-style: normal; opacity: .55; cursor: pointer; }
.sf-del:hover { opacity: 1; color: #dc2626; }
#filter-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}
#filter-panel select { font: inherit; font-size: 12.5px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }

#inbox-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 7px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.ib-select {
  font: inherit;
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
#inbox-bar .btn { padding: 3px 9px; }
#conv-tag-chips { display: flex; gap: 5px; flex-wrap: wrap; }
.tag-chip {
  font-size: 10.5px;
  font-weight: 700;
  background: #eef2ff;
  color: #4338ca;
  padding: 2px 8px;
  border-radius: 999px;
}
.tag-chip.status { background: #fff7ed; color: #c2410c; }
.conv-chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.conv-item.pinned { background: color-mix(in srgb, var(--c) 5%, var(--surface)); border-inline-start: 3px solid var(--c); }
.conv-item.pinned.active { background: var(--c-soft); }
#btn-pin.active { background: var(--c-soft); color: var(--c); border-color: var(--c); }

#snooze-pop {
  position: absolute;
  top: 60px;
  inset-inline-start: 18px;
  width: 230px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 34px rgba(15,23,42,.16);
  z-index: 20;
  overflow: hidden;
  padding-bottom: 4px;
}
.pop-title { padding: 10px 14px 6px; font-size: 12px; color: var(--muted); font-weight: 700; }
.pop-item {
  display: block;
  width: 100%;
  text-align: right;
  padding: 9px 14px;
  border: none;
  background: none;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.pop-item:hover { background: var(--c-soft); }
.pop-item.danger { color: #dc2626; }
.pop-input {
  display: block;
  width: calc(100% - 20px);
  margin: 4px 10px 6px;
  font: inherit;
  font-size: 12.5px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

#reply-box > button.active { background: #fef9c3; color: #a16207; }
#reply-box.note-mode { background: #fefce8; }
#reply-box > button { background: none; border: none; font-size: 17px; width: 34px; height: 34px; border-radius: 9px; }
#reply-box > button:hover { background: var(--bg); }

#transfer-pop, #ai-suggest-pop {
  position: absolute;
  top: 60px;
  inset-inline-end: 18px;
  width: 300px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 34px rgba(15,23,42,.16);
  z-index: 20;
  overflow: hidden;
}
#thread { position: relative; }
#ai-suggest-pop { top: auto; bottom: 66px; width: 360px; max-height: 320px; overflow-y: auto; padding: 8px; }
.tr-title { padding: 10px 14px 6px; font-size: 12px; color: var(--muted); font-weight: 700; }
.tr-opt { padding: 10px 14px; cursor: pointer; display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.tr-opt:hover { background: var(--c-soft); }
.ai-opt {
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  margin-bottom: 7px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.7;
}
.ai-opt:hover { border-color: var(--c); background: var(--c-soft); }
.ai-loading { padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }
#ai-suggest-pop .ai-close { width: 100%; }

.summary-text {
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.8;
  color: #4c1d95;
  margin-bottom: 6px;
}

.kb-item { padding: 14px 16px; }
.kb-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.kb-body { font-size: 13px; color: var(--ink-2); line-height: 1.9; white-space: pre-wrap; max-height: 130px; overflow-y: auto; }
#kb-form textarea {
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  outline: none;
  resize: vertical;
  font: inherit;
}
#kb-form textarea:focus { border-color: var(--c); }

/* ---------- مودال ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  animation: fade-in .15s ease-out;
}
@keyframes fade-in { from { opacity: 0; } }
.modal {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(15,23,42,.35);
  padding: 22px 24px;
  animation: modal-in .2s cubic-bezier(.21,1.02,.55,1);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.modal-head h3 { font-size: 16px; }
.modal-x {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 15px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
}
.modal-x:hover { background: var(--bg); color: var(--ink); }
.modal-sub { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }
.modal-body { display: flex; flex-direction: column; gap: 14px; margin: 14px 0 20px; }
.modal-field { display: flex; flex-direction: column; gap: 6px; }
.modal-label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.modal-label .req { color: var(--danger); font-style: normal; }
.modal-input {
  padding: 10px 13px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 13.5px;
  outline: none;
  resize: vertical;
  background: #fafbfc;
  transition: border-color .13s, box-shadow .13s;
}
.modal-input:focus {
  border-color: var(--c);
  background: #fff;
  box-shadow: 0 0 0 3.5px rgba(99,102,241,.12);
}
.modal-input.err { border-color: var(--danger); }
.modal-hint { font-size: 11.5px; color: var(--muted); }
.modal-err { font-size: 11.5px; color: var(--danger); }
.modal-foot { display: flex; justify-content: flex-start; gap: 10px; flex-direction: row-reverse; }

.toast {
  position: fixed;
  bottom: 20px;
  inset-inline-start: 80px;
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 13.5px;
  box-shadow: 0 10px 30px rgba(15,23,42,.3);
  cursor: pointer;
  z-index: 100;
  animation: toast-in .25s ease-out;
  max-width: 360px;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

/* ---------- ریسپانسیو ---------- */
.mob-only { display: none !important; }

@media (min-width: 761px) and (max-width: 1100px) { #info-col { display: none; } }
@media (min-width: 761px) and (max-width: 800px) {
  #conv-list-col { width: 250px; }
  .th-actions .btn { padding: 6px 9px; font-size: 12px; }
}

/* ---------- موبایل ---------- */
@media (max-width: 760px) {
  .mob-only { display: inline-flex !important; }

  /* نوار کناری → نوار پایین */
  #app { flex-direction: column-reverse; }
  #sidebar {
    width: 100%;
    height: 58px;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    padding: 4px 10px;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
    gap: 0;
    flex-shrink: 0;
  }
  .side-logo, .side-spacer { display: none; }
  .side-btn { width: 42px; height: 42px; }
  #my-avatar { width: 32px; height: 32px; font-size: 13px; }
  .view { min-height: 0; }

  /* گفتگوها: صفحه‌های پشته‌ای — فهرست ← گفتگو ← اطلاعات */
  #conv-list-col { width: 100%; border-inline-end: none; }
  .col-head { padding: 10px 12px 8px; }
  .col-head h2 { display: none; }
  .tabs { flex-wrap: wrap; gap: 4px; }
  .tab { font-size: 12px; padding: 6px 10px; }
  #thread-col { display: none; }
  #view-chats.mob-thread #conv-list-col { display: none; }
  #view-chats.mob-thread #thread-col { display: flex; }

  #btn-mob-back {
    border: none;
    background: var(--bg);
    color: var(--ink);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
  }

  /* اطلاعات بازدیدکننده به‌صورت لایه تمام‌صفحه (با دکمه 👤) */
  #info-col {
    display: none;
    position: fixed;
    inset: 0;
    bottom: 58px;
    width: 100%;
    z-index: 60;
    border: none;
    padding-bottom: 24px;
  }
  #view-chats.show-info #info-col { display: block !important; }

  #thread-head { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .th-actions { flex-wrap: wrap; gap: 5px; }
  .th-actions .btn { padding: 5px 8px; font-size: 11.5px; }
  #inbox-bar { padding: 6px 10px; }
  #thread-messages { padding: 12px; }
  .msg { max-width: 88%; }
  #reply-box { padding: 8px; gap: 4px; }
  #reply-box > button { width: 30px; height: 30px; font-size: 15px; }

  #transfer-pop, #ai-suggest-pop, #snooze-pop {
    inset-inline: 10px;
    width: auto;
    max-width: none;
  }

  /* صفحات محتوایی: تک‌ستونه و جدول‌های اسکرول‌شونده */
  .page-pad { padding: 14px 12px; }
  .page-pad.narrow { max-width: 100%; }
  .tiles { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-row { flex-wrap: wrap; }
  .form-inline { flex-wrap: wrap; }
  .card { padding: 14px 12px; }
  .card:has(.table) { overflow-x: auto; }
  .table { min-width: 560px; }
  #live-agents { overflow-x: auto; }

  /* مودال تمام‌عرض */
  .modal { width: calc(100vw - 24px) !important; max-width: none !important; }
  .toast { inset-inline: 12px; max-width: none; }
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
