/* Sahaba WhatsApp Desk. Dark Sahaba Club theme: violet, blue, cyan. No gold. */
:root {
  color-scheme: dark;
  --bg: #05070d;
  --bg-2: #0a0e18;
  --violet: #8b5cf6;
  --blue: #2e71ff;
  --cyan: #22d3ee;
  --rose: #f472b6;
  --red: #f87171;
  --green: #34d399;
  --text: #f3f4f8;
  --text-2: #a6acc2;
  --muted: #8a92ab;
  --glass: rgba(255, 255, 255, 0.045);
  --glass-2: rgba(255, 255, 255, 0.075);
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.16);
  --grad: linear-gradient(90deg, #8b5cf6 0%, #2e71ff 50%, #22d3ee 100%);
  --radius: 14px;
  --nav-w: 216px;
  --tab-h: 58px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", "Noto Sans", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased; overflow: hidden;
  background-image: radial-gradient(900px 500px at 12% -10%, rgba(139, 92, 246, 0.13), transparent 60%), radial-gradient(800px 500px at 100% 0%, rgba(34, 211, 238, 0.07), transparent 60%);
}
#root { height: 100vh; height: 100dvh; }
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 20px; letter-spacing: -0.01em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; display: flex; align-items: center; gap: 7px; }
h3.sub { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
h4 { font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; margin: 4px 0; }
a { color: var(--cyan); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--cyan); outline-offset: 2px;
}
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.13); border-radius: 9px; }
::-webkit-scrollbar-track { background: transparent; }
select option { background: #0e1220; color: #f3f4f8; }

.ico { display: inline-flex; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.warn-text { color: var(--rose); }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.gap { gap: 6px; }
.row.wrap { flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.glass, .card {
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.card { padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 8px 14px;
  border-radius: 10px; border: 1px solid var(--line-2); background: var(--glass-2); color: var(--text);
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; text-shadow: 0 1px 2px rgba(5, 7, 13, 0.45); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { background: #dc2626; border-color: transparent; color: #fff; }
.btn.danger-ghost { color: #fca5a5; border-color: rgba(248, 113, 113, 0.4); background: rgba(248, 113, 113, 0.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--glass-2); color: var(--text); }
.btn.sm { min-height: 32px; padding: 5px 10px; font-size: 12.5px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn:disabled, .icon-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.is-busy { position: relative; color: transparent !important; text-shadow: none; }
.btn.is-busy > * { visibility: hidden; }
.btn.is-busy::after, .spinner {
  content: ""; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.25); border-top-color: var(--cyan);
  animation: spin 0.7s linear infinite;
}
.btn.is-busy::after { position: absolute; inset: 0; margin: auto; width: 15px; height: 15px; border-top-color: #fff; }
.spinner { display: inline-block; width: 26px; height: 26px; }
.spinner.sm { width: 16px; height: 16px; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; flex: none; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--glass-2); color: var(--text); }
.icon-btn.xs { width: 26px; height: 26px; }
.icon-btn.ghost-slot { visibility: hidden; }
.input {
  width: 100%; min-height: 38px; padding: 8px 11px; border-radius: 10px; border: 1px solid var(--line-2);
  background: rgba(5, 7, 13, 0.55); color: var(--text); min-width: 0;
}
.input::placeholder { color: #7c849c; }
.input:disabled { opacity: 0.6; }
textarea.input { resize: vertical; line-height: 1.45; display: block; }
select.input { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, #a6acc2 50%), linear-gradient(135deg, #a6acc2 50%, transparent 50%); background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px; background-size: 5px 5px; background-repeat: no-repeat; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.field > small { color: var(--muted); font-size: 12px; }
.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; }
.check input, .person input { width: 17px; height: 17px; accent-color: var(--violet); flex: none; margin-top: 1px; }
.form-err { color: #fca5a5; font-size: 13px; }

.chip { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; border: 1px solid transparent; line-height: 1.5; }
.chip.st-bot { background: rgba(139, 92, 246, 0.16); color: #c4b5fd; border-color: rgba(139, 92, 246, 0.35); }
.chip.st-needs_human { background: rgba(244, 114, 182, 0.16); color: #f9a8d4; border-color: rgba(244, 114, 182, 0.45); }
.chip.st-human { background: rgba(46, 113, 255, 0.18); color: #9dbdff; border-color: rgba(46, 113, 255, 0.45); }
.chip.st-closed { background: rgba(255, 255, 255, 0.06); color: var(--text-2); border-color: var(--line-2); }
.chip.st-blocked, .chip.bad, .chip.sev-high, .chip.sent-negative { background: rgba(248, 113, 113, 0.14); color: #fca5a5; border-color: rgba(248, 113, 113, 0.4); }
.chip.ok, .chip.sent-positive { background: rgba(52, 211, 153, 0.13); color: #6ee7b7; border-color: rgba(52, 211, 153, 0.38); }
.chip.sev-medium { background: rgba(244, 114, 182, 0.14); color: #f9a8d4; border-color: rgba(244, 114, 182, 0.4); }
.chip.sev-low, .chip.sent-neutral { background: rgba(255, 255, 255, 0.06); color: var(--text-2); border-color: var(--line-2); }
.lang { font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; color: var(--text-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 0 5px; margin-inline-start: 6px; }
.conv-meta .lang { margin: 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags:empty { display: none; }
.tag { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 12px; background: var(--glass-2); border: 1px solid var(--line-2); color: var(--text-2); text-decoration: none; }
button.tag { cursor: pointer; min-height: 30px; }
button.tag:hover { color: var(--text); border-color: rgba(139, 92, 246, 0.6); }
.tag.on { background: rgba(139, 92, 246, 0.22); border-color: rgba(139, 92, 246, 0.65); color: #ddd6fe; }
.tag.danger { background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.4); color: #fca5a5; }

.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: #fff; background: linear-gradient(135deg, rgba(139, 92, 246, 0.75), rgba(46, 113, 255, 0.75)); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }

.state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 36px 20px; color: var(--text-2); min-height: 160px; }
.state h3 { color: var(--text); font-size: 15px; }
.state p { max-width: 380px; }
.state-ico { width: 54px; height: 54px; border-radius: 16px; display: flex; align-items: center; justify-content: center; background: rgba(139, 92, 246, 0.14); color: #c4b5fd; border: 1px solid rgba(139, 92, 246, 0.3); }
.state-err .state-ico { background: rgba(248, 113, 113, 0.12); color: #fca5a5; border-color: rgba(248, 113, 113, 0.35); }
.state-ico.lock { margin: 4px auto 0; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 13px; align-items: center; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.meter { display: flex; align-items: center; gap: 8px; }
.meter-track { flex: 1; height: 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.1); overflow: hidden; min-width: 60px; }
.meter-track i { display: block; height: 100%; background: var(--grad); border-radius: 6px; }
.meter b { font-size: 13px; min-width: 24px; text-align: end; }

.stars { display: inline-flex; gap: 2px; }
.star { font-size: 17px; line-height: 1; color: rgba(255, 255, 255, 0.2); }
.star.on { color: var(--cyan); }
.stars.editable .star { background: none; border: 0; cursor: pointer; font-size: 26px; padding: 3px; border-radius: 6px; }
.stars.editable .star:hover { color: #a5f3fc; }

.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); gap: 2px; max-width: 100%; overflow-x: auto; }
.seg-btn { border: 0; background: transparent; color: var(--text-2); padding: 7px 13px; border-radius: 8px; cursor: pointer; font-weight: 600; white-space: nowrap; min-height: 34px; display: inline-flex; align-items: center; gap: 6px; }
.seg-btn.on { background: rgba(139, 92, 246, 0.3); color: #fff; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--rose); display: inline-block; }
.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filter { flex: none; border: 1px solid var(--line-2); background: transparent; color: var(--text-2); padding: 5px 11px; border-radius: 999px; cursor: pointer; font-size: 12.5px; font-weight: 600; min-height: 32px; display: inline-flex; align-items: center; gap: 6px; }
.filter:hover { color: var(--text); }
.filter.on { background: rgba(139, 92, 246, 0.24); border-color: rgba(139, 92, 246, 0.7); color: #fff; }
.filter b { background: rgba(255, 255, 255, 0.14); border-radius: 999px; padding: 0 6px; font-size: 11px; }
.filter:first-child + .filter b, .filter[role="tab"] b { background: var(--rose); color: #2a0a1b; }

/* ---------- toasts, modal, popover ---------- */
#toasts { position: fixed; z-index: 90; top: 14px; right: 14px; display: flex; flex-direction: column; gap: 8px; width: min(400px, calc(100vw - 24px)); pointer-events: none; }
.toast { display: flex; gap: 9px; align-items: flex-start; padding: 11px 14px; border-radius: 12px; background: #131829; border: 1px solid var(--line-2); box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5); animation: rise 0.2s ease-out; pointer-events: auto; }
.toast .ico { margin-top: 1px; color: var(--cyan); }
.toast.ok .ico { color: var(--green); }
.toast.error { border-color: rgba(248, 113, 113, 0.55); }
.toast.error .ico { color: var(--red); }
.toast.out { opacity: 0; transition: opacity 0.25s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.modal-wrap { position: fixed; inset: 0; z-index: 80; background: rgba(3, 4, 9, 0.72); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: min(460px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: #0f1322; border: 1px solid var(--line-2); border-radius: 16px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 10px 6px 18px; }
.modal-body { padding: 8px 18px 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-text { color: var(--text-2); line-height: 1.55; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; flex-wrap: wrap; }
.popover { position: fixed; z-index: 70; min-width: 190px; max-width: min(340px, calc(100vw - 16px)); max-height: min(360px, 60vh); overflow-y: auto; padding: 6px; border-radius: 12px; background: #121728; border: 1px solid var(--line-2); box-shadow: 0 16px 44px rgba(0, 0, 0, 0.55); display: flex; flex-direction: column; gap: 2px; }
.menu-item { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 3px 10px; text-align: start; border: 0; background: transparent; padding: 9px 10px; border-radius: 8px; cursor: pointer; min-height: 40px; color: var(--text); }
.menu-item > span:first-child:not(.ico) { grid-column: 1 / -1; font-weight: 600; }
.menu-item small { grid-column: 1 / -1; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.menu-item:hover, .menu-item:focus-visible { background: var(--glass-2); }
.menu-item.danger { color: #fca5a5; }

/* ---------- sign-in ---------- */
.auth { min-height: 100%; height: 100%; overflow-y: auto; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: min(410px, 100%); padding: 26px; display: flex; flex-direction: column; gap: 12px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.auth-brand h1 { font-size: 19px; }
.auth-brand p { color: var(--muted); font-size: 12.5px; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; border-radius: 28%; background: var(--grad); color: #fff; flex: none; }
.auth-lead { color: var(--text-2); line-height: 1.55; }
.auth-title { text-align: center; font-size: 18px; }
.auth-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-foot { color: var(--muted); font-size: 12px; text-align: center; }

/* ---------- shell ---------- */
.shell { height: 100%; display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); }
.nav { display: flex; flex-direction: column; gap: 14px; padding: 16px 12px; border-right: 1px solid var(--line); background: rgba(8, 11, 20, 0.7); min-height: 0; }
.nav-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); padding: 2px 6px 8px; }
.nav-brand span:last-child { display: flex; flex-direction: column; line-height: 1.2; }
.nav-brand small { color: var(--muted); font-size: 11.5px; }
.nav-links { display: flex; flex-direction: column; gap: 3px; flex: 1; overflow-y: auto; }
.nav-link, .tab { position: relative; display: flex; align-items: center; gap: 11px; padding: 10px 11px; border-radius: 10px; color: var(--text-2); text-decoration: none; font-weight: 600; border: 0; background: none; cursor: pointer; }
.nav-link:hover { background: var(--glass); color: var(--text); }
.nav-link.active { background: rgba(139, 92, 246, 0.2); color: #fff; }
.nav-link.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--grad); background: linear-gradient(180deg, #8b5cf6, #22d3ee); }
.nav-badge { margin-left: auto; background: var(--rose); color: #2a0a1b; border-radius: 999px; padding: 0 7px; font-size: 11.5px; min-width: 20px; text-align: center; line-height: 1.65; }
[data-badge="errors"].nav-badge { background: var(--red); color: #2b0a0a; }
.nav-foot { display: flex; flex-direction: column; gap: 10px; }
.demo-pill { align-self: flex-start; font-size: 11.5px; font-weight: 700; color: #a5f3fc; border: 1px dashed rgba(34, 211, 238, 0.5); border-radius: 999px; padding: 2px 10px; }
.nav-live { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); padding: 0 6px; }
.nav-live i { width: 8px; height: 8px; border-radius: 50%; background: #6b7391; }
.nav-live.on i { background: var(--green); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18); }
.nav-me { display: flex; align-items: center; gap: 9px; padding: 8px 4px 0 6px; border-top: 1px solid var(--line); }
.nav-me-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.nav-me-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.nav-me-text small { color: var(--muted); font-size: 11.5px; }
.tabbar { display: none; }

.main { min-width: 0; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); height: 100%; overflow: hidden; }
.pane-list { display: none; min-height: 0; }
.pane-main { min-width: 0; min-height: 0; overflow-y: auto; height: 100%; }
.shell.is-conv .main { grid-template-columns: 350px minmax(0, 1fr); }
.shell.is-conv .pane-list { display: flex; flex-direction: column; border-right: 1px solid var(--line); background: rgba(8, 11, 20, 0.45); height: 100%; overflow: hidden; }
.shell.is-conv .pane-main { overflow: hidden; }
.pane-empty { height: 100%; display: flex; align-items: center; justify-content: center; }

.page { padding: 22px 26px 40px; max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.page.narrow { max-width: 860px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head p { margin-top: 3px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar-filters .input { width: auto; min-width: 150px; }

/* ---------- inbox ---------- */
.list-head { padding: 16px 14px 10px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); flex: none; }
.list-title { display: flex; align-items: baseline; justify-content: space-between; }
.search { position: relative; }
.search .ico { position: absolute; left: 11px; top: 11px; color: var(--muted); pointer-events: none; }
.search-input { padding-left: 34px; }
.conv-list { flex: 1; overflow-y: auto; min-height: 0; }
.conv { display: flex; gap: 11px; padding: 12px 14px; text-decoration: none; color: var(--text); border-bottom: 1px solid rgba(255, 255, 255, 0.05); border-left: 3px solid transparent; }
.conv:hover { background: var(--glass); }
.conv.active { background: rgba(139, 92, 246, 0.14); border-left-color: var(--violet); }
.conv-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.conv-top, .conv-mid { display: flex; align-items: center; gap: 8px; }
.conv-name { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.conv.unread .conv-name { font-weight: 800; }
.conv-time { color: var(--muted); font-size: 12px; flex: none; }
.conv.unread .conv-time { color: var(--cyan); }
.conv-preview { flex: 1; min-width: 0; color: var(--text-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.conv.unread .conv-preview { color: var(--text); }
.unread-badge { background: var(--cyan); color: #04222a; font-size: 11.5px; border-radius: 999px; min-width: 20px; padding: 0 6px; text-align: center; line-height: 1.7; flex: none; }
.conv-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.tagline { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.err-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.2); }
.conv-rating { color: #a5f3fc; font-size: 12px; font-weight: 700; margin-left: auto; }

/* ---------- chat ---------- */
.chat { height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) 340px; min-height: 0; position: relative; }
.chat-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; }
.chat-head { display: flex; align-items: center; gap: 11px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: rgba(8, 11, 20, 0.6); flex: none; min-height: 62px; }
.chat-head .back { display: none; }
.chat-who { flex: 1; min-width: 0; }
.chat-who h1 { font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.chat-sub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.num { color: var(--text-2); font-size: 12.5px; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.head-actions { display: flex; gap: 7px; align-items: center; flex: none; }
.head-actions.wide, .side-toggle { display: none; }

.thread { flex: 1; overflow-y: auto; min-height: 0; padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.day-sep { align-self: center; margin: 8px 0 2px; }
.day-sep span, .msg-sys { font-size: 12px; color: var(--text-2); background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; }
.msg-sys { align-self: center; display: flex; gap: 8px; align-items: center; max-width: 92%; text-align: center; border-radius: 12px; }
.msg-sys time { color: var(--muted); font-size: 11px; flex: none; }
.msg { display: flex; flex-direction: column; gap: 3px; max-width: min(74%, 620px); align-self: flex-start; align-items: flex-start; }
.msg.bot, .msg.agent { align-self: flex-end; align-items: flex-end; }
.msg-who { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); padding: 0 4px; }
.msg.bot .msg-who { color: #c4b5fd; }
.msg.agent .msg-who { color: #9dbdff; }
.bubble { padding: 9px 12px 6px; border-radius: 16px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.07); border-top-left-radius: 5px; cursor: pointer; min-width: 84px; max-width: 100%; display: flex; flex-direction: column; gap: 6px; }
.msg.bot .bubble { background: rgba(139, 92, 246, 0.2); border-color: rgba(139, 92, 246, 0.4); border-top-left-radius: 16px; border-top-right-radius: 5px; }
.msg.agent .bubble { background: rgba(46, 113, 255, 0.22); border-color: rgba(46, 113, 255, 0.45); border-top-left-radius: 16px; border-top-right-radius: 5px; }
.msg.failed .bubble { background: rgba(248, 113, 113, 0.13); border-color: rgba(248, 113, 113, 0.6); }
.msg.flash .bubble { animation: flash 2.4s ease-out; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 3px var(--cyan); } 100% { box-shadow: 0 0 0 3px transparent; } }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; text-align: start; line-height: 1.5; font-size: 14.5px; unicode-bidi: plaintext; }
.msg-meta { display: flex; align-items: center; justify-content: flex-end; gap: 5px; font-size: 11px; color: var(--muted); direction: ltr; }
.tick { display: inline-flex; color: var(--muted); }
.tick.read { color: var(--cyan); }
.tick.failed { color: var(--red); }
.msg-error { display: flex; gap: 6px; align-items: flex-start; color: #fca5a5; font-size: 12.5px; padding: 0 4px; text-align: start; }
.msg-details { width: 100%; min-width: 230px; padding: 10px 12px; border-radius: 12px; background: rgba(5, 7, 13, 0.6); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.msg-details .kv { font-size: 12.5px; }
.msg-details .row { flex-wrap: wrap; }
.translated { padding: 8px 10px; border-radius: 9px; background: rgba(34, 211, 238, 0.09); border: 1px solid rgba(34, 211, 238, 0.28); text-align: start; white-space: pre-wrap; }
.voice { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); font-weight: 600; }
.media-slot:empty { display: none; }
.media-img { display: block; max-width: min(320px, 100%); max-height: 320px; border-radius: 10px; }
.audio { width: min(260px, 100%); height: 38px; display: block; }
.transcript { border-inline-start: 2px solid rgba(34, 211, 238, 0.6); padding-inline-start: 9px; }
.transcript small { color: #a5f3fc; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.transcript p { white-space: pre-wrap; text-align: start; line-height: 1.5; unicode-bidi: plaintext; }

.composer-area { flex: none; border-top: 1px solid var(--line); background: rgba(8, 11, 20, 0.7); padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.composer-note { display: flex; align-items: center; gap: 10px; color: var(--text-2); padding: 4px 2px; flex-wrap: wrap; }
.composer-note > span:nth-child(2) { flex: 1; min-width: 180px; }
.composer-note.warn { color: #f9a8d4; }
.window { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); }
.window.soon { color: #f9a8d4; }
.window.closed { align-items: flex-start; color: #fca5a5; background: rgba(248, 113, 113, 0.09); border: 1px solid rgba(248, 113, 113, 0.35); border-radius: 10px; padding: 9px 11px; line-height: 1.5; }
.window.closed .ico { margin-top: 2px; }
.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; min-height: 42px; max-height: 180px; font-size: 14.5px; }
.send { width: 46px; min-height: 42px; padding: 0; flex: none; }
.composer-tools { display: flex; gap: 2px; flex-wrap: wrap; align-items: center; }
.composer-tools .btn.ghost { color: #c4b5fd; }
.composer-tools .undo { color: var(--muted); margin-left: auto; }
.suggestions { display: flex; flex-direction: column; gap: 6px; position: relative; padding-right: 34px; }
.suggestions small { color: var(--muted); }
.suggestions .icon-btn { position: absolute; top: -6px; right: 0; width: 28px; height: 28px; }
.suggestion { text-align: start; padding: 8px 11px; border-radius: 11px; border: 1px solid rgba(139, 92, 246, 0.45); background: rgba(139, 92, 246, 0.12); cursor: pointer; line-height: 1.45; }
.suggestion:hover { background: rgba(139, 92, 246, 0.22); }
.canned-pop { width: 320px; }

.side { border-left: 1px solid var(--line); overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; min-height: 0; background: rgba(8, 11, 20, 0.45); }
.side-head { display: none; align-items: center; justify-content: space-between; }
.side .card { padding: 14px; gap: 10px; }
.contact-head { display: flex; gap: 12px; align-items: center; }
.contact-head > div { min-width: 0; }
.ai-summary { line-height: 1.55; text-align: start; }
.ai-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.lead-box { background: rgba(34, 211, 238, 0.07); border: 1px solid rgba(34, 211, 238, 0.25); border-radius: 10px; padding: 10px; }
.rating { display: flex; flex-direction: column; gap: 10px; }
.rating-others { display: flex; flex-direction: column; gap: 8px; }
.rating-other { padding: 9px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.rating-other p, .note p { text-align: start; }
.notes { display: flex; flex-direction: column; gap: 8px; }
.note { padding: 9px 10px; border-radius: 10px; background: rgba(34, 211, 238, 0.06); border: 1px solid rgba(34, 211, 238, 0.2); display: flex; flex-direction: column; gap: 4px; }
.note p { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- review ---------- */
.rq { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 16px; align-items: start; }
.rq-side { padding: 12px; position: sticky; top: 0; max-height: calc(100dvh - 150px); }
.rq-side .filters { flex-wrap: wrap; }
.rq-list { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; min-height: 0; }
.rq-item { text-align: start; border: 1px solid transparent; background: transparent; border-radius: 10px; padding: 9px 10px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.rq-item:hover { background: var(--glass); }
.rq-item.active { background: rgba(139, 92, 246, 0.16); border-color: rgba(139, 92, 246, 0.5); }
.rq-card { padding: 0; gap: 0; overflow: hidden; }
.rq-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.rq-who { min-width: 0; }
.rq-who h2 { text-align: start; }
.rq-nav { display: flex; align-items: center; gap: 6px; }
.rq-ai { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: rgba(139, 92, 246, 0.07); color: var(--text-2); }
.rq-ai .ico { color: #c4b5fd; margin-top: 2px; }
.rq-ai > div { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.rq-ai p { text-align: start; }
.rq-thread { max-height: 44dvh; min-height: 180px; flex: none; }
.rq-rate { padding: 14px 16px; border-top: 1px solid var(--line); background: rgba(8, 11, 20, 0.5); display: flex; flex-direction: column; gap: 8px; }

/* ---------- errors ---------- */
.err-list { display: flex; flex-direction: column; gap: 10px; }
.err { flex-direction: row; align-items: center; gap: 14px; border-left: 3px solid var(--line-2); }
.err.sev-high { border-left-color: var(--red); }
.err.sev-medium { border-left-color: var(--rose); }
.err-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.err-top { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.err-detail { color: var(--text-2); text-align: start; overflow-wrap: anywhere; }
.err-side { display: flex; gap: 8px; align-items: center; flex: none; }
.err-side .btn span { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- insights ---------- */
.ins-body { display: flex; flex-direction: column; gap: 16px; }
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.tile { padding: 14px; gap: 2px; }
.tile-name { color: var(--text-2); font-size: 12.5px; }
.tile-val { font-size: 24px; letter-spacing: -0.02em; line-height: 1.25; }
.panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.chart { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.chart-plot { position: relative; }
.chart-svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.chart-svg .grid { stroke: rgba(255, 255, 255, 0.08); stroke-width: 1; }
.chart-svg .axis { fill: #8a92ab; font-size: 11px; }
.chart-svg .val { fill: #f3f4f8; font-size: 12px; font-weight: 700; }
.chart-svg .cross { stroke: rgba(255, 255, 255, 0.3); stroke-width: 1; }
.chart-svg .dot { stroke: #0a0e18; stroke-width: 2; }
.chart-svg .bar:hover { filter: brightness(1.2); }
.legend, .share-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--text-2); }
.legend span, .share-legend span, .chart-tip span { display: inline-flex; align-items: center; gap: 6px; }
.legend i, .share-legend i, .chart-tip i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; flex: none; }
.chart-tip { position: absolute; top: 6px; pointer-events: none; background: #131829; border: 1px solid var(--line-2); border-radius: 9px; padding: 7px 10px; font-size: 12px; display: flex; flex-direction: column; gap: 3px; white-space: nowrap; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); }
.barlist { display: flex; flex-direction: column; gap: 9px; }
.barlist-row { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.barlist-name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barlist-track { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.barlist-track i { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.barlist-val { font-weight: 700; min-width: 28px; text-align: end; }
.share { display: flex; flex-direction: column; gap: 12px; }
.share-bar { display: flex; gap: 2px; height: 14px; border-radius: 5px; overflow: hidden; }
.share-bar i { min-width: 3px; }
.share-legend b { color: var(--text); }
.share-legend em { font-style: normal; color: var(--muted); }
.ask-row { display: flex; gap: 8px; align-items: flex-end; }
.ask-answers { display: flex; flex-direction: column; gap: 10px; }
.ask-answers:empty { display: none; }
.ask-item { border-radius: 12px; border: 1px solid rgba(139, 92, 246, 0.35); background: rgba(139, 92, 246, 0.08); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.ask-q { font-weight: 700; text-align: start; }
.ask-a { white-space: pre-wrap; line-height: 1.6; color: var(--text-2); text-align: start; }

/* ---------- team ---------- */
.roles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.role-card { gap: 5px; padding: 14px; }
.role-card p { color: var(--text-2); }
.team-list, .team-results { display: flex; flex-direction: column; }
.team-results:empty { display: none; }
.team-results .state { min-height: 60px; padding: 12px; flex-direction: row; }
.team-row { display: flex; align-items: center; gap: 11px; padding: 10px 0; border-top: 1px solid var(--line); }
.team-row:first-child { border-top: 0; }
.team-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.team-who b, .team-who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-select { width: 112px; flex: none; }

/* ---------- settings ---------- */
.settings-body { display: flex; flex-direction: column; gap: 16px; }
.bot-card { border-color: rgba(248, 113, 113, 0.4); }
.bot-card.on { border-color: rgba(52, 211, 153, 0.45); background: rgba(52, 211, 153, 0.05); }
.bot-state { font-weight: 700; margin: 4px 0 2px; color: #fca5a5; }
.bot-card.on .bot-state { color: #6ee7b7; }
.switch { width: 58px; height: 32px; border-radius: 999px; border: 1px solid var(--line-2); background: rgba(255, 255, 255, 0.1); position: relative; cursor: pointer; flex: none; transition: background 0.15s; }
.switch i { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch.on { background: var(--green); border-color: transparent; }
.switch.on i { transform: translateX(26px); }
.people { display: flex; flex-wrap: wrap; gap: 8px; }
.person { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 9px; border: 1px solid var(--line-2); border-radius: 999px; cursor: pointer; background: var(--glass); }
.person input { margin: 0; }
.canned { display: flex; flex-direction: column; }
.canned-row { display: flex; gap: 8px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.canned-text { flex: 1; min-width: 0; }
.canned-text b { display: block; text-align: start; }
.canned-text p { color: var(--text-2); text-align: start; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.health { display: flex; flex-direction: column; gap: 12px; }
.health-banner { display: flex; gap: 9px; align-items: center; padding: 10px 12px; border-radius: 10px; font-weight: 700; overflow-wrap: anywhere; }
.health-banner.good { background: rgba(52, 211, 153, 0.1); border: 1px solid rgba(52, 211, 153, 0.4); color: #6ee7b7; }
.health-banner.bad { background: rgba(248, 113, 113, 0.11); border: 1px solid rgba(248, 113, 113, 0.5); color: #fca5a5; }
.health-rows { display: flex; flex-direction: column; }
.health-row { display: flex; gap: 11px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.health-row:first-child { border-top: 0; }
.health-row > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.health-row code { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.health-row.missing p { color: #fca5a5; }
.health-ico { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: none; background: rgba(52, 211, 153, 0.16); color: #6ee7b7; }
.health-row.missing .health-ico { background: rgba(248, 113, 113, 0.18); color: #fca5a5; }

/* ---------- prompt ---------- */
.prompt-page { max-width: 1400px; }
.prompt-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
.prompt-left { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.prompt-editor { min-height: 340px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Noto Sans Arabic", monospace; font-size: 13px; line-height: 1.6; text-align: start; }
.versions { display: flex; flex-direction: column; }
.version { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.version:first-child { border-top: 0; }
.version-text { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 3px 8px; }
.version-text b { text-align: start; }
.version-text .muted { flex-basis: 100%; }
.test-card { position: sticky; top: 0; }
.test-thread { height: min(48dvh, 460px); flex: none; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(5, 7, 13, 0.5); }
.test-thread .msg { max-width: 88%; }
.test-thread .bubble { cursor: default; }
.test-empty { margin: auto; text-align: center; }
.typing { display: inline-flex; gap: 4px; padding: 5px 2px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: #c4b5fd; animation: blink 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: 0.18s; }
.typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

@media (min-width: 1700px) { .head-actions.wide { display: flex; } .head-actions.narrow { display: none; } }
/* ---------- responsive ---------- */
@media (max-width: 1320px) {
  .chat { grid-template-columns: minmax(0, 1fr); }
  .side { position: absolute; top: 0; right: 0; bottom: 0; width: min(370px, 100%); z-index: 20; background: #0a0e18; transform: translateX(105%); transition: transform 0.18s ease-out; box-shadow: -20px 0 50px rgba(0, 0, 0, 0.5); visibility: hidden; }
  .chat.side-open .side { transform: none; visibility: visible; }
  .side-head { display: flex; }
  .side-toggle { display: inline-flex; }
}
@media (max-width: 1100px) {
  :root { --nav-w: 68px; }
  .nav { padding: 14px 8px; align-items: center; }
  .nav-brand span:last-child, .nav-link .nav-label, .nav-me-text, .nav-live span, .demo-pill, .nav-me .avatar { display: none; }
  .nav-link { justify-content: center; padding: 11px; width: 48px; }
  .nav-link.active::before { left: -10px; }
  .nav-badge { position: absolute; top: 2px; right: 0; padding: 0 5px; font-size: 10.5px; min-width: 17px; }
  .nav-me { padding: 8px 0 0; justify-content: center; }
  .nav-live { justify-content: center; }
  .shell.is-conv .main { grid-template-columns: 310px minmax(0, 1fr); }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .prompt-grid { grid-template-columns: minmax(0, 1fr); }
  .test-card { position: static; }
  .rq { grid-template-columns: 240px minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .nav { display: none; }
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border-top: 1px solid var(--line); background: #080b14; padding-bottom: env(safe-area-inset-bottom); }
  .tab { flex-direction: column; gap: 2px; justify-content: center; font-size: 11px; padding: 7px 2px; min-height: var(--tab-h); border-radius: 0; }
  .tab.active { color: #fff; }
  .tab.active .ico { color: #c4b5fd; }
  .tab .nav-badge { position: absolute; top: 5px; left: calc(50% + 6px); margin: 0; font-size: 10.5px; padding: 0 5px; min-width: 17px; }
  .shell.is-conv .main { grid-template-columns: minmax(0, 1fr); }
  body[data-route="inbox"] .shell.is-conv .pane-main { display: none; }
  body[data-route="chat"] .shell.is-conv .pane-list, body[data-route="chat"] .shell .tabbar { display: none; }
  .chat-head { padding: 8px 8px 8px 4px; gap: 8px; }
  .chat-head .back { display: inline-flex; }
  .head-primary { display: none; }
  .chat-head .avatar { width: 34px; height: 34px; font-size: 12px; }
  .chat-sub .tagline { display: none; }
  .thread { padding: 12px 10px; }
  .msg { max-width: 86%; }
  .composer-area { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
  .composer-tools { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -10px; padding: 0 6px; }
  .composer-tools::-webkit-scrollbar { display: none; }
  .composer-tools .btn { flex: none; }
  .keys-hint { display: none; }
  .side { width: 100%; }
  .page { padding: 16px 14px 28px; gap: 14px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile-val { font-size: 21px; }
  .panels { grid-template-columns: minmax(0, 1fr); }
  .roles { grid-template-columns: minmax(0, 1fr); }
  .rq { grid-template-columns: minmax(0, 1fr); }
  .rq-side { position: static; max-height: none; }
  .rq-list { display: none; }
  .rq-thread { max-height: 40dvh; }
  .hint-keys { display: none; }
  .err { flex-direction: column; align-items: stretch; }
  .err-side { justify-content: space-between; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .side .grid2 { grid-template-columns: 1fr 1fr; }
  .team-row { flex-wrap: wrap; }
  .team-who { flex-basis: calc(100% - 60px); }
  .team-row .role-select { margin-inline-start: 51px; flex: 1; }
  .version { flex-wrap: wrap; }
  .version-text { flex-basis: 100%; }
  .canned-pop { width: calc(100vw - 16px); }
  .ask-row { flex-direction: column; align-items: stretch; }
  #toasts { top: 10px; right: 12px; left: 12px; width: auto; }
  .input, .btn { font-size: 16px; }
  .btn.sm { font-size: 13px; }
  .toolbar-filters .input { min-width: 0; flex: 1; }
  .toolbar-filters { width: 100%; }
}
@media (min-width: 761px) { .panel.span2 { grid-column: span 2; } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }
