:root {
  --bg: #f4f6f5;
  --panel: #ffffff;
  --panel-2: #f8faf9;
  --line: #e3e8e6;
  --line-2: #d3dbd8;
  --text: #17201d;
  --muted: #5f6d68;
  --faint: #8a9792;
  --primary: #0b7a63;
  --primary-2: #096652;
  --primary-soft: #e3f3ee;
  --blue: #2563eb;
  --blue-soft: #e8efff;
  --amber: #b45309;
  --amber-soft: #fff4e0;
  --red: #c2352b;
  --red-soft: #fdecea;
  --violet: #6d4bd8;
  --violet-soft: #efeafe;
  --bubble: #e7f8dc;
  --chat-bg: #efe9e0;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 1px 1px rgba(16, 24, 20, .04);
  --shadow-lg: 0 18px 50px rgba(16, 24, 20, .22);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1513; --panel: #161e1b; --panel-2: #1b2421; --line: #26312d; --line-2: #33403b;
    --text: #e6edea; --muted: #a2b0ab; --faint: #7d8b86;
    --primary: #2bb38f; --primary-2: #35c49e; --primary-soft: #133429;
    --blue: #7aa2ff; --blue-soft: #18233d; --amber: #f0a948; --amber-soft: #34260f;
    --red: #ff7a6e; --red-soft: #3a1714; --violet: #a993ff; --violet-soft: #241c3d;
    --bubble: #1f3b2c; --chat-bg: #0d1412;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 21px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0 0 10px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; background: linear-gradient(90deg, var(--panel) 0 231px, var(--line) 231px 232px, transparent 232px); }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; }
.brand .logo { width: 34px; height: 34px; border-radius: 9px; background: var(--primary); color: #fff; display: grid; place-items: center; flex: none; }
.brand b { display: block; font-size: 14.5px; }
.brand span { display: block; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 12px 10px 4px; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--text); font-weight: 500; }
.nav a:hover { background: var(--panel-2); text-decoration: none; }
.nav a.on { background: var(--primary-soft); color: var(--primary); }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a .count { margin-left: auto; background: var(--red); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 6px; line-height: 18px; font-weight: 600; }
.side-foot { margin-top: auto; padding: 12px 10px 4px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.side-foot .dot { margin-right: 4px; }
.main { min-width: 0; padding: 22px 28px 60px; }
.topbar { display: none; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; max-width: 760px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- cards & grids ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > .hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.card > .hd .sub { font-size: 12.5px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.card > .bd { padding: 14px 16px; }
.card > .bd.flush { padding: 0; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-side { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 24px; font-weight: 650; margin-top: 2px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 11.5px; color: var(--faint); }

/* ---------- buttons & inputs ---------- */
.btn { appearance: none; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); border-radius: 8px; padding: 7px 13px; font: 500 13.5px var(--font); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; line-height: 1.3; }
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { color: var(--red); }
.btn.danger.solid { background: var(--red); color: #fff; border-color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; border-radius: 7px; }
.btn svg { width: 16px; height: 16px; }
input[type=text], input[type=password], input[type=number], input[type=time], input[type=date], input[type=search], input[type=url], input:not([type]), select, textarea {
  width: 100%; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel); color: var(--text); font: 14px var(--font); padding: 8px 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { resize: vertical; min-height: 90px; line-height: 1.45; }
textarea.code { font-family: var(--mono); font-size: 13px; min-height: 120px; }
select { padding-right: 28px; }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 15px; height: 15px; margin: 0; vertical-align: -2px; }
.field { margin-bottom: 14px; }
.field > label:not(.switch):not(.check), .label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field.inline { display: flex; align-items: center; gap: 8px; }
.fields { display: grid; gap: 0 14px; }
.fields.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fields.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fields.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; margin-right: 14px; font-size: 13.5px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 0; }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row > input, .input-row > select { flex: 1; }
.inline-num { width: 76px !important; display: inline-block; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .tr { width: 36px; height: 20px; border-radius: 20px; background: var(--line-2); position: relative; transition: .15s; flex: none; }
.switch .tr::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + .tr { background: var(--primary); }
.switch input:checked + .tr::after { left: 18px; }
.switch input:focus-visible + .tr { box-shadow: 0 0 0 3px var(--primary-soft); }

/* ---------- badges, dots, chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 20px; padding: 1px 9px; font-size: 12px; font-weight: 600; line-height: 19px; white-space: nowrap; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.badge.green { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.badge.blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.badge.amber { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.badge.red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.badge.violet { background: var(--violet-soft); color: var(--violet); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--faint); flex: none; }
.dot.green { background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, .15); }
.dot.amber { background: #d97706; }
.dot.red { background: var(--red); }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 0 7px; font-size: 12px; line-height: 20px; margin: 1px 2px 1px 0; color: var(--muted); }
.chip.pick { cursor: pointer; user-select: none; }
.chip.pick.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.chip .x { cursor: pointer; opacity: .6; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); white-space: nowrap; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--panel-2); }
table.t td.w1 { width: 1%; white-space: nowrap; }
.cell-main { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--muted); }
.clip { max-width: 360px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pager { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.bulkbar { position: sticky; top: 8px; z-index: 5; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--text); color: var(--panel); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; box-shadow: var(--shadow-lg); }
.bulkbar .btn { background: transparent; color: inherit; border-color: rgba(255,255,255,.3); }
.bulkbar .btn:hover { background: rgba(255,255,255,.1); }

/* ---------- misc blocks ---------- */
.note { border-radius: 9px; padding: 10px 13px; background: var(--panel-2); border: 1px solid var(--line); font-size: 13px; }
.note.green { background: var(--primary-soft); border-color: transparent; }
.note.amber { background: var(--amber-soft); border-color: transparent; color: var(--text); }
.note.red { background: var(--red-soft); border-color: transparent; }
.note.blue { background: var(--blue-soft); border-color: transparent; }
.note b:first-child { margin-right: 2px; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; font-size: 15px; }
.bar { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: 6px; }
.bar.amber > i { background: #d97706; }
.bar.red > i { background: var(--red); }
.list-item { display: flex; gap: 12px; align-items: flex-start; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; flex: none; font-size: 13px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 5px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs a { padding: 8px 12px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--primary); border-color: var(--primary); text-decoration: none; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.setup li { padding: 6px 0; display: flex; gap: 10px; align-items: center; }
.setup { list-style: none; margin: 0; padding: 0; }
.tick { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-2); display: grid; place-items: center; flex: none; color: #fff; font-size: 12px; }
.tick.on { background: var(--primary); border-color: var(--primary); }
.copybox { display: flex; gap: 8px; align-items: stretch; }
.copybox code, .copybox input { flex: 1; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; overflow-x: auto; white-space: nowrap; }
pre.code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow-x: auto; font: 12.5px/1.5 var(--mono); margin: 0; white-space: pre; }

/* ---------- number cards ---------- */
.numbers { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.num .hd .title { display: flex; align-items: center; gap: 9px; }
.num .meta { display: grid; gap: 10px; }
.num .metric .row { justify-content: space-between; font-size: 12.5px; margin-bottom: 4px; }
.qr-box { display: grid; place-items: center; min-height: 300px; background: #fff; border-radius: 10px; border: 1px solid var(--line); }
.qr-box img { width: 280px; height: 280px; image-rendering: pixelated; }
.pair-code { font: 700 34px/1 var(--mono); letter-spacing: .12em; text-align: center; padding: 26px 0; color: var(--text); }
.howto { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.howto li { counter-increment: s; position: relative; padding: 0 0 10px 32px; }
.howto li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 12px; display: grid; place-items: center; }

/* ---------- campaign editor ---------- */
.step { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); margin-bottom: 12px; }
.step .shd { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); border-radius: 10px 10px 0 0; flex-wrap: wrap; }
.step .shd .n { width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.step .sbd { padding: 10px 12px; }
.step textarea { min-height: 110px; }
.step.dim { opacity: .55; }
.step .snip { color: var(--muted); font-size: 12.5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 1 1 120px; min-width: 0; }
.step .snip.ph { color: var(--amber); }
.step .shd .badge { font-weight: 600; }
.step.closed .shd { border-bottom: 0; border-radius: 10px; }
.toolbar { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; align-items: center; }
.toolbar select { width: auto; padding: 3px 26px 3px 8px; font-size: 12.5px; }
.attach { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.timeline-gap { font-size: 12px; color: var(--muted); padding: 0 0 10px 14px; border-left: 2px dashed var(--line-2); margin: -4px 0 8px 23px; }

/* WhatsApp-like preview */
.phone { background: var(--chat-bg); border-radius: 14px; padding: 14px; min-height: 160px; border: 1px solid var(--line); }
.bubble { background: var(--bubble); border-radius: 9px 9px 9px 2px; padding: 7px 10px 18px; max-width: 92%; position: relative; box-shadow: 0 1px 1px rgba(0,0,0,.08); white-space: pre-wrap; word-wrap: break-word; font-size: 14px; margin-bottom: 8px; }
.bubble .t { position: absolute; right: 8px; bottom: 3px; font-size: 10.5px; color: var(--faint); }
.bubble code { background: rgba(0,0,0,.06); padding: 0 3px; border-radius: 3px; }
.bubble pre { font: 12px/1.35 var(--mono); margin: 2px 0; white-space: pre; overflow-x: auto; }
.bubble .att { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.06); border-radius: 6px; padding: 8px; margin-bottom: 6px; font-size: 12.5px; }
.bubble img.att-img { display: block; width: 100%; border-radius: 6px; margin-bottom: 6px; }

/* ---------- modal & toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 18, 15, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; z-index: 50; overflow-y: auto; animation: fade .12s; }
.modal { background: var(--panel); border-radius: 12px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); animation: pop .14s; }
.modal.wide { max-width: 860px; }
.modal.xwide { max-width: 1080px; }
.modal .mh { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); gap: 10px; }
.modal .mh h2 { font-size: 16px; }
.modal .mb { padding: 16px 18px; max-height: 72vh; overflow-y: auto; }
.modal .mf { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--panel-2); border-radius: 0 0 12px 12px; flex-wrap: wrap; }
.modal .mf .left { margin-right: auto; }
.x-btn { background: none; border: 0; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.x-btn:hover { background: var(--panel-2); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 80; }
.toast { background: var(--text); color: var(--panel); padding: 10px 14px; border-radius: 9px; box-shadow: var(--shadow-lg); max-width: 380px; font-size: 13.5px; animation: pop .15s; }
.toast.err { background: var(--red); color: #fff; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; }
.login .bd { padding: 26px; }
.login .logo { width: 48px; height: 48px; border-radius: 12px; background: var(--primary); color: #fff; display: grid; place-items: center; margin-bottom: 14px; }

/* ---------- guide ---------- */
.guide h2 { margin: 6px 0 8px; font-size: 16px; }
.guide ul { margin: 0 0 6px; padding-left: 20px; }
.guide li { margin-bottom: 6px; }
.rule { display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rule:last-child { border-bottom: 0; }
.rule .ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.rule .ic.bad { background: var(--red-soft); color: var(--red); }

/* ---------- responsive ---------- */
@media (max-width: 1250px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g-side { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 980px) { .g2, .g3 { grid-template-columns: minmax(0, 1fr); } .fields.c3, .fields.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; background: none; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .18s; box-shadow: none; }
  .app.menu .side { transform: none; box-shadow: var(--shadow-lg); }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
  .main { padding: 16px 16px 60px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fields.c2, .fields.c3, .fields.c4 { grid-template-columns: minmax(0, 1fr); }
  .numbers { grid-template-columns: minmax(0, 1fr); }
  .hide-sm { display: none; }
}

/* shown when the Desk process can't be reached */
.offline-bar { position: sticky; top: 0; z-index: 90; background: var(--red); color: #fff; padding: 10px 18px; font-size: 13.5px; text-align: center; box-shadow: var(--shadow-lg); }

/* ---------- chats (WhatsApp-Web-like window) ---------- */
.nav a .count.green { background: var(--primary); }
.icon-btn { padding: 6px; }
.icon-btn svg { width: 19px; height: 19px; }
.main.chat-main { padding: 0; height: 100vh; height: 100dvh; overflow: hidden; }
.chatwin { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: 100%; background: var(--panel); }
.chatwin.with-panel { grid-template-columns: 340px minmax(0, 1fr) 320px; }
.chatwin:not(.with-panel) .cp { display: none; }

.cl { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--panel); }
.cl-hd { padding: 14px 14px 8px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.cl-hd h1 { font-size: 19px; }
.cl-snd { padding: 6px 28px 6px 9px; font-size: 13px; }
.cl-search { position: relative; }
.cl-search svg { position: absolute; left: 10px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.cl-search input { padding-left: 33px; background: var(--panel-2); border-color: var(--line); border-radius: 9px; }
.cl-filters { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.cl-filters::-webkit-scrollbar { display: none; }
.cl-filters a { white-space: nowrap; font-size: 12.5px; padding: 3px 10px; border-radius: 14px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.cl-filters a:hover { text-decoration: none; color: var(--text); }
.cl-filters a.on { background: var(--primary-soft); color: var(--primary); border-color: transparent; font-weight: 600; }
.cl-list { flex: 1; overflow-y: auto; }
.cl-row { display: flex; gap: 11px; align-items: center; padding: 10px 14px; color: var(--text); border-bottom: 1px solid var(--line); }
.cl-row:hover { background: var(--panel-2); text-decoration: none; }
.cl-row.on { background: var(--primary-soft); }
.cl-row .avatar { width: 42px; height: 42px; font-size: 14px; }
.avatar.grp { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.avatar svg { width: 20px; height: 20px; }
.cl-mid { flex: 1; min-width: 0; }
.cl-top, .cl-bot { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.cl-top b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.cl-time { font-size: 11.5px; color: var(--faint); flex: none; }
.cl-row.unread .cl-time { color: var(--primary); font-weight: 600; }
.cl-prev { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cl-row.unread .cl-prev { color: var(--text); }
.cl-badges { display: flex; gap: 4px; align-items: center; flex: none; }
.ub { background: var(--primary); color: #fff; border-radius: 11px; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; display: grid; place-items: center; }
.pin { font-size: 11px; opacity: .7; }
.cl-tags { display: flex; gap: 4px; margin-top: 3px; flex-wrap: wrap; }
.ct-type, .ct-tag, .ct-num { font-size: 10.5px; line-height: 16px; padding: 0 6px; border-radius: 4px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.ct-type.lead { background: var(--violet-soft); color: var(--violet); border-color: transparent; }
.ct-type.customer { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.ct-num { border-style: dashed; }

.cv { position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--chat-bg); }
.cv.drop::after { content: "Drop the file to attach it"; position: absolute; inset: 10px; border: 2px dashed var(--primary); border-radius: 12px; display: grid; place-items: center; background: rgba(255,255,255,.7); color: var(--primary); font-weight: 600; z-index: 6; }
.cv-empty { margin: auto; text-align: center; max-width: 420px; padding: 30px; }
.cv-empty .logo { width: 64px; height: 64px; border-radius: 18px; background: var(--primary); color: #fff; display: grid; place-items: center; margin: 0 auto 16px; }
.cv-empty .logo svg { width: 34px; height: 34px; }
.cv-empty h2 { font-size: 18px; margin-bottom: 8px; }
.cv-hd { display: flex; align-items: center; gap: 10px; padding: 9px 14px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 58px; }
.cv-hd .avatar { width: 38px; height: 38px; }
.cv-back { display: none; }
.cv-title { flex: 1; min-width: 0; cursor: pointer; }
.cv-title b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-title span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-msgs { flex: 1; overflow-y: auto; padding: 12px 6% 16px; }
.cv-older { text-align: center; margin: 4px 0 10px; }
.cv-hint { text-align: center; color: var(--muted); margin-top: 30px; }
.cv-new { position: absolute; right: 24px; bottom: 76px; z-index: 5; border: 0; border-radius: 16px; padding: 6px 12px; background: var(--primary); color: #fff; font: 600 12.5px var(--font); cursor: pointer; box-shadow: var(--shadow-lg); }
.day { text-align: center; margin: 12px 0 8px; position: sticky; top: 0; z-index: 2; }
.day span { background: var(--panel); color: var(--muted); font-size: 11.5px; padding: 3px 10px; border-radius: 8px; box-shadow: var(--shadow); }
.msg { display: flex; flex-direction: column; margin: 2px 0; max-width: min(78%, 620px); position: relative; }
.msg.in { align-items: flex-start; margin-right: auto; }
.msg.out { align-items: flex-end; margin-left: auto; }
.msg .b { position: relative; padding: 6px 9px 7px; border-radius: 9px; box-shadow: 0 1px 1px rgba(0,0,0,.08); background: var(--panel); min-width: 70px; max-width: 100%; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.out .b { background: var(--bubble); }
.msg.in .b { border-top-left-radius: 2px; }
.msg.out .b { border-top-right-radius: 2px; }
.msg.stk .b { background: transparent; box-shadow: none; }
.msg .tx { white-space: pre-wrap; font-size: 14.2px; line-height: 1.42; padding-right: 2px; }
.msg .tx pre { font: 12.5px/1.35 var(--mono); white-space: pre; overflow-x: auto; margin: 2px 0; }
.msg .tx a { word-break: break-all; }
.msg .au { font-size: 12.5px; font-weight: 600; margin-bottom: 2px; }
.msg .meta { display: flex; justify-content: flex-end; align-items: center; gap: 5px; font-size: 10.5px; color: var(--faint); margin: 2px 0 -2px 12px; float: right; position: relative; top: 4px; white-space: nowrap; }
.msg .meta .via { background: rgba(0,0,0,.05); border-radius: 4px; padding: 0 4px; color: var(--muted); max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
.msg .b::after { content: ""; display: block; clear: both; }
.msg .mm { position: absolute; top: 2px; right: 3px; border: 0; background: inherit; color: var(--muted); font-size: 15px; line-height: 1; padding: 1px 4px 3px; border-radius: 6px; cursor: pointer; opacity: 0; transition: opacity .1s; }
.msg .b:hover .mm, .msg .mm:focus { opacity: 1; }
.msg.sys { max-width: 90%; margin: 8px auto; align-items: center; }
.msg.sys span { background: var(--panel); border-radius: 8px; padding: 4px 10px; font-size: 12.5px; color: var(--muted); box-shadow: var(--shadow); }
.msg .deleted { font-style: italic; color: var(--muted); font-size: 13.5px; }
.msg.flash .b { box-shadow: 0 0 0 3px var(--primary); }
.tk { font-size: 11px; letter-spacing: -3px; margin-right: 3px; color: var(--faint); font-weight: 600; }
.tk.read { color: #34b7f1; }
.tk.wait { letter-spacing: 0; font-size: 10px; }
.tk.fail { color: #fff; background: var(--red); border-radius: 50%; width: 14px; height: 14px; display: inline-grid; place-items: center; letter-spacing: 0; font-size: 10px; margin-right: 0; }
.tk.sm { margin-right: 6px; }
.qt { display: flex; flex-direction: column; border-left: 3px solid var(--primary); background: rgba(0,0,0,.05); border-radius: 6px; padding: 4px 8px; margin-bottom: 5px; font-size: 12.5px; cursor: pointer; max-width: 100%; }
.qt b { color: var(--primary); font-size: 12px; }
.qt span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reacts { display: flex; gap: 2px; margin: -4px 8px 2px; z-index: 1; }
.reacts span { background: var(--panel); border-radius: 12px; padding: 0 5px; font-size: 13px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.failrow { font-size: 11.5px; color: var(--red); margin: 2px 4px; }
.failrow.amber { color: var(--amber); }
.media { display: block; margin: 0 0 5px; border-radius: 7px; overflow: hidden; position: relative; }
.media.img img, .media.img video { display: block; max-width: min(330px, 100%); max-height: 360px; border-radius: 7px; background: rgba(0,0,0,.06); }
.media.sticker img { width: 150px; height: 150px; object-fit: contain; }
.media.gone { display: none; }
.media .load { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(0,0,0,.55); color: #fff; border: 0; }
.media.audio { display: flex; align-items: center; gap: 8px; min-width: 260px; }
.media.audio audio { height: 36px; max-width: 280px; }
.media.doc { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.05); border-radius: 7px; padding: 8px 10px; min-width: 240px; color: var(--text); }
a.media.doc:hover { text-decoration: none; background: rgba(0,0,0,.08); }
.doc-ic { width: 34px; height: 40px; border-radius: 5px; background: var(--red); color: #fff; font: 700 9.5px/40px var(--font); text-align: center; flex: none; }
.cv-reply, .cv-att { display: flex; gap: 10px; align-items: center; padding: 8px 14px; background: var(--panel-2); border-top: 1px solid var(--line); }
.cv-reply .qt { flex: 1; margin: 0; cursor: default; }
.att-prev { width: 54px; height: 54px; object-fit: cover; border-radius: 6px; }
.cv-comp { display: flex; gap: 4px; align-items: flex-end; padding: 8px 10px; background: var(--panel); border-top: 1px solid var(--line); }
.cv-comp textarea { flex: 1; min-height: 40px; max-height: 160px; resize: none; padding: 9px 12px; border-radius: 10px; line-height: 1.35; overflow-y: auto; }
.cv-comp .btn { flex: none; height: 40px; }
.cv-comp .send { width: 44px; justify-content: center; border-radius: 50%; }
.cv-warn { padding: 7px 14px; background: var(--amber-soft); color: var(--amber); font-size: 12.5px; border-top: 1px solid var(--line); }
.cv-ro { padding: 12px 16px; background: var(--panel); border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; text-align: center; }
.cv-pop { position: absolute; left: 10px; bottom: 62px; z-index: 8; width: min(420px, calc(100% - 20px)); max-height: 320px; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); }
.pop-hd { display: flex; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; position: sticky; top: 0; background: var(--panel); }
.pop-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-bottom: 1px solid var(--line); font: 13px var(--font); color: var(--text); cursor: pointer; }
.pop-item:hover { background: var(--panel-2); }
.pop-item .clip { display: block; max-width: 100%; font-size: 12px; }
.emojis { display: grid; grid-template-columns: repeat(9, 1fr); padding: 6px; }
.emojis button { border: 0; background: none; font-size: 21px; padding: 4px; cursor: pointer; border-radius: 6px; }
.emojis button:hover { background: var(--panel-2); }
.float-menu { position: fixed; z-index: 70; min-width: 190px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 4px; animation: pop .1s; }
.float-menu > button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 7px; font: 13.5px var(--font); color: var(--text); cursor: pointer; }
.float-menu > button:hover { background: var(--panel-2); }
.float-menu > button.danger { color: var(--red); }
.fm-react { display: flex; gap: 2px; padding: 4px 4px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.fm-react button { border: 0; background: none; font-size: 20px; cursor: pointer; border-radius: 8px; padding: 2px 4px; }
.fm-react button:hover { background: var(--panel-2); }
.fm-info { font-size: 11.5px; color: var(--faint); padding: 6px 10px 4px; border-top: 1px solid var(--line); margin-top: 4px; }

.cp { border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.cp-hd { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); min-height: 58px; }
.cp-bd { padding: 14px 16px 30px; overflow-y: auto; flex: 1; }
.cp-top { text-align: center; margin-bottom: 14px; }
.cp-top h2 { margin-top: 8px; font-size: 16px; }
.avatar.big { width: 72px; height: 72px; font-size: 24px; margin: 0 auto; }
.avatar.big svg { width: 32px; height: 32px; }
.cp-crm { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; margin-bottom: 14px; font-size: 13px; }
.cp-form .field { margin-bottom: 10px; }
.cp-form input, .cp-form select, .cp-form textarea { font-size: 13.5px; padding: 6px 9px; }
.tagbox { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; border: 1px solid var(--line-2); border-radius: 8px; padding: 4px 6px; background: var(--panel); }
.tagbox input { border: 0 !important; box-shadow: none !important; padding: 3px 4px !important; flex: 1; min-width: 90px; width: auto; }
.nc-groups { max-height: 200px; overflow-y: auto; margin-top: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; }

@media (max-width: 1100px) { .chatwin.with-panel { grid-template-columns: 300px minmax(0, 1fr); } .chatwin.with-panel .cp { position: fixed; right: 0; top: 0; bottom: 0; width: min(360px, 100%); z-index: 45; box-shadow: var(--shadow-lg); } .chatwin { grid-template-columns: 300px minmax(0, 1fr); } }
@media (max-width: 820px) {
  .main.chat-main { height: calc(100vh - 51px); height: calc(100dvh - 51px); }
  .chatwin, .chatwin.with-panel { grid-template-columns: minmax(0, 1fr); }
  .chatwin .cv { display: none; }
  .chatwin.open .cl { display: none; }
  .chatwin.open .cv { display: flex; }
  .cv-back { display: inline-flex; }
  .cv-msgs { padding: 10px 10px 14px; }
  .msg { max-width: 88%; }
  .msg .mm { opacity: .6; }
  .cv-comp .btn[data-act=emoji] { display: none; }
}
@media (prefers-color-scheme: dark) {
  .msg .tx a { color: #53bdeb; }
  .qt, .media.doc, .msg .meta .via { background: rgba(255,255,255,.06); }
  .cv.drop::after { background: rgba(0,0,0,.6); }
}
