:root {
  --bg: #f4f5f7;
  --chat-bg: #eef1f5;
  --panel: #ffffff;
  --panel-2: #f8f9fb;
  --border: #e3e6eb;
  --text: #1c2330;
  --muted: #6b7484;
  --accent: #2f6fed;
  --accent-soft: #e6eefe;
  --out: #dcebff;
  --in: #ffffff;
  --danger: #d6453d;
  --danger-soft: #fdeceb;
  --ok: #2aa868;
  --warn: #d99a1e;
  --hover: #eef1f5;
  --shadow: 0 8px 30px rgba(20, 30, 50, .14);
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1217;
    --chat-bg: #0c0f14;
    --panel: #161a21;
    --panel-2: #1b2029;
    --border: #262c37;
    --text: #e6e9ef;
    --muted: #8a93a3;
    --accent: #5b8cff;
    --accent-soft: #1f2a44;
    --out: #22385c;
    --in: #1c2129;
    --danger: #ff6b61;
    --danger-soft: #3a1f1e;
    --hover: #1f2530;
    --shadow: 0 8px 30px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- controls ---------- */
.btn {
  border: 1px solid var(--border); background: var(--panel); border-radius: 8px;
  padding: 6px 12px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.input, .select, textarea, .modal-body input, .modal-body select {
  border: 1px solid var(--border); background: var(--panel-2); border-radius: 8px; padding: 7px 10px;
  outline: none; width: 100%;
}
.input:focus, textarea:focus, .modal-body input:focus, .modal-body select:focus { border-color: var(--accent); }
.select { width: auto; min-width: 200px; }
.form-error { color: var(--danger); min-height: 18px; font-size: 13px; }

/* ---------- login ---------- */
.login-screen { height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 340px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow);
}
.login-card label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
.login-card input { border: 1px solid var(--border); background: var(--panel-2); border-radius: 8px; padding: 9px 10px; }

/* ---------- layout ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 6px; }
.brand-lg { font-size: 20px; margin-bottom: 6px; }
.brand-mark { color: var(--accent); }
.spacer { flex: 1; }
.me { color: var(--muted); font-size: 13px; }
.main { flex: 1; display: grid; grid-template-columns: 260px 330px 1fr; min-height: 0; }

/* ---------- avatars ---------- */
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center;
  color: #fff; font-weight: 600; font-size: 14px; position: relative; overflow: hidden; user-select: none;
}
.avatar > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.av-wrap { position: relative; flex: none; }
.av-wrap .dot {
  position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--panel); background: var(--muted); z-index: 1;
}
.dot.active, .dot.online { background: var(--ok); }
.dot.revoked, .dot.error, .dot.banned { background: var(--danger); }
.dot.pending, .dot.offline { background: var(--warn); }

/* ---------- accounts rail ---------- */
.rail { background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.rail-search { padding: 10px; border-bottom: 1px solid var(--border); }
.acc-list { flex: 1; overflow-y: auto; padding: 4px 6px 10px; }
.group-head {
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted);
  padding: 12px 8px 4px; display: flex; justify-content: space-between; gap: 6px;
}
.group-head .mgr { text-transform: none; letter-spacing: 0; opacity: .8; }
.acc {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: pointer;
  position: relative;
}
.acc:hover { background: var(--hover); }
.acc.active { background: var(--accent-soft); }
.acc .num { position: absolute; left: 2px; top: 2px; font-size: 9px; color: var(--muted); z-index: 2; }
.acc .avatar { width: 38px; height: 38px; font-size: 13px; }
.acc-info { min-width: 0; flex: 1; }
.acc-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  background: var(--accent); color: #fff; border-radius: 10px; min-width: 20px; height: 20px;
  padding: 0 6px; font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; flex: none;
}
.hint { font-size: 11px; color: var(--muted); padding: 8px 12px; border-top: 1px solid var(--border); line-height: 1.5; }

/* ---------- dialogs ---------- */
.dialogs { background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.dlg-head { padding: 10px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.tabs { display: flex; gap: 4px; }
.tab { border: 0; background: transparent; padding: 4px 10px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.dlg-list { flex: 1; overflow-y: auto; }
.dlg { display: flex; gap: 10px; padding: 8px 12px; cursor: pointer; align-items: center; }
.dlg .avatar { width: 46px; height: 46px; font-size: 15px; }
.dlg:hover { background: var(--hover); }
.dlg.active { background: var(--accent-soft); }
.dlg-body { flex: 1; min-width: 0; }
.dlg-top { display: flex; justify-content: space-between; gap: 6px; }
.dlg-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dlg-time { font-size: 11px; color: var(--muted); flex: none; }
.dlg-bottom { display: flex; justify-content: space-between; gap: 6px; align-items: center; margin-top: 2px; }
.dlg-last { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.typing { color: var(--accent) !important; font-style: italic; }
.online-text { color: var(--accent); }
.chk { color: var(--muted); font-size: 11px; letter-spacing: -3px; margin-right: 3px; }
.chk.read { color: var(--accent); }
.empty { color: var(--muted); padding: 30px 16px; text-align: center; }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; position: relative; background: var(--chat-bg); }
.chat-head {
  min-height: 58px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.head-text { flex: 1; min-width: 0; }
.chat-head .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .sub { font-size: 12px; color: var(--muted); }
.head-side { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; font-size: 12px; color: var(--muted); min-width: 0; }
.head-side .copy { cursor: pointer; color: var(--accent); }
.head-side .copy:hover { text-decoration: underline; }
.head-side .via { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.banner { padding: 8px 16px; font-size: 13px; background: var(--danger-soft); color: var(--danger); display: flex; gap: 10px; align-items: center; }
.banner.info { background: var(--accent-soft); color: var(--accent); }

.msg-wrap { flex: 1; position: relative; min-height: 0; display: flex; }
.msg-list { flex: 1; overflow-y: auto; padding: 12px 18px 16px; display: flex; flex-direction: column; gap: 3px; overscroll-behavior: contain; }
.day { align-self: center; font-size: 12px; color: var(--muted); background: var(--panel); border-radius: 12px; padding: 2px 10px; margin: 10px 0 6px; position: sticky; top: 4px; z-index: 1; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.service-msg { align-self: center; color: var(--muted); font-size: 12px; padding: 4px 10px; }
.load-more { align-self: center; font-size: 12px; color: var(--muted); padding: 6px; }

.msg-row { display: flex; align-items: flex-end; gap: 4px; }
.msg-row.out { flex-direction: row-reverse; }
.msg-row.flash .msg { box-shadow: 0 0 0 3px var(--accent); transition: box-shadow .3s; }
.msg {
  max-width: min(560px, 76%); padding: 6px 10px 4px; border-radius: 14px; background: var(--in);
  word-wrap: break-word; overflow-wrap: anywhere; box-shadow: 0 1px 1px rgba(0,0,0,.06); min-width: 70px;
}
.msg.out { background: var(--out); }
.msg.bare { background: transparent; box-shadow: none; padding: 0; }
.msg.bare .meta { background: rgba(0,0,0,.35); color: #fff; border-radius: 10px; padding: 0 6px; align-self: flex-end; display: inline-flex; float: right; }
.msg.deleted { outline: 1px dashed var(--danger); opacity: .85; }
.msg .sender { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.msg .text { white-space: pre-wrap; }
.msg .text a { color: var(--accent); }
.msg .meta { font-size: 11px; color: var(--muted); display: flex; gap: 6px; justify-content: flex-end; align-items: center; margin-top: 1px; flex-wrap: wrap; }
.meta .del { color: var(--danger); font-weight: 600; }
.meta .crm { color: var(--accent); }
.meta .edited { cursor: help; text-decoration: underline dotted; }
.fwd { font-size: 12px; color: var(--accent); margin-bottom: 3px; }
.reply-quote {
  border-left: 3px solid var(--accent); background: rgba(47,111,237,.08); border-radius: 4px;
  padding: 3px 8px; margin-bottom: 4px; cursor: pointer; display: flex; flex-direction: column; font-size: 12px; min-width: 0;
}
.reply-quote b { color: var(--accent); font-weight: 600; }
.reply-quote span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg img.photo { display: block; max-width: 100%; max-height: 380px; min-height: 60px; border-radius: 10px; cursor: zoom-in; margin: 2px 0 4px; background: var(--hover); }
.msg video.video { display: block; max-width: 100%; max-height: 380px; border-radius: 10px; margin: 2px 0 4px; background: #000; }
.msg video.round { width: 240px; height: 240px; border-radius: 50%; object-fit: cover; display: block; background: #000; }
.msg .voice { display: flex; align-items: center; gap: 8px; }
.msg audio { display: block; width: 260px; max-width: 100%; height: 36px; margin: 2px 0; }
.msg .dur { font-size: 12px; color: var(--muted); }
.msg .sticker { font-size: 64px; line-height: 1.1; }
.msg .sticker-img { display: block; width: 160px; height: 160px; object-fit: contain; }
.msg .media-label { color: var(--muted); font-style: italic; }
.msg .file-card { display: inline-block; color: var(--accent); background: var(--hover); padding: 6px 10px; border-radius: 8px; text-decoration: none; margin: 2px 0 4px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 2px; }
.react { border: 0; border-radius: 12px; padding: 1px 8px; background: var(--hover); cursor: pointer; font-size: 13px; }
.react.mine { background: var(--accent); color: #fff; }
.react b { font-weight: 600; font-size: 12px; }

.msg-tools { display: flex; gap: 2px; opacity: 0; transition: opacity .1s; padding-bottom: 4px; }
.msg-row:hover .msg-tools { opacity: 1; }
.msg-tools button { border: 0; background: var(--panel); border-radius: 50%; width: 26px; height: 26px; cursor: pointer; color: var(--muted); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.msg-tools button:hover { color: var(--accent); }

.scroll-down {
  position: absolute; right: 18px; bottom: 14px; width: 42px; height: 42px; border-radius: 50%; border: 0;
  background: var(--panel); box-shadow: var(--shadow); cursor: pointer; font-size: 18px; color: var(--muted);
}
.scroll-down .badge { position: absolute; top: -6px; right: -4px; }

/* ---------- composer ---------- */
.composer { background: var(--panel); border-top: 1px solid var(--border); padding: 8px 12px 10px; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { resize: none; max-height: 200px; min-height: 40px; border-radius: 20px; padding: 9px 14px; flex: 1; }
.attach { cursor: pointer; font-size: 20px; padding: 6px 4px; user-select: none; }
.round-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--hover); cursor: pointer; font-size: 17px; flex: none; }
.round-btn.send { background: var(--accent); color: #fff; }
.round-btn:disabled { opacity: .5; }
.composer-bar { display: flex; align-items: center; gap: 10px; padding: 4px 4px 8px; }
.composer-bar .bar-icon { color: var(--accent); font-size: 18px; width: 24px; text-align: center; }
.composer-bar .bar-text { flex: 1; min-width: 0; border-left: 3px solid var(--accent); padding-left: 8px; display: flex; flex-direction: column; font-size: 12px; }
.composer-bar .bar-text b { color: var(--accent); }
.composer-bar .bar-text span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-preview { display: flex; gap: 10px; align-items: center; padding: 2px 4px 8px; font-size: 13px; }
.file-preview img { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; }
.file-preview .file-ico { font-size: 26px; }
.file-preview .fp-name { font-weight: 600; }
.file-preview .fp-hint { color: var(--muted); font-size: 12px; flex: 1; }
.rec-ui { display: none; align-items: center; gap: 10px; height: 40px; }
.composer.recording .composer-row, .composer.recording .composer-bar, .composer.recording .file-preview { display: none !important; }
.composer.recording .rec-ui { display: flex; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
.rec-hint { color: var(--muted); flex: 1; }
#recTime { font-variant-numeric: tabular-nums; font-weight: 600; }
@keyframes blink { 50% { opacity: .2; } }
.drop-zone {
  position: absolute; inset: 58px 0 0 0; background: rgba(47,111,237,.12); border: 3px dashed var(--accent);
  display: grid; place-items: center; font-size: 18px; color: var(--accent); z-index: 5; pointer-events: none;
}

/* ---------- menu / lightbox ---------- */
.menu {
  position: fixed; z-index: 70; background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; min-width: 210px; display: flex; flex-direction: column;
}
.menu-reacts { display: flex; flex-wrap: wrap; gap: 2px; padding: 2px 2px 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; max-width: 260px; }
.menu-reacts button { border: 0; background: transparent; font-size: 20px; border-radius: 8px; cursor: pointer; width: 34px; height: 34px; }
.menu-reacts button:hover { background: var(--hover); transform: scale(1.15); }
.menu-item { border: 0; background: transparent; text-align: left; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.menu-item:hover { background: var(--hover); }
.menu-item.danger { color: var(--danger); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 80; display: grid; place-items: center; cursor: zoom-out; padding: 20px; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(10, 15, 25, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal-box { background: var(--panel); border-radius: 14px; width: 100%; max-width: 860px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 16px 18px 20px; overflow-y: auto; }
.modal-body label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.modal-body label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
.modal-body label.check input { width: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mt { margin-top: 14px; }
.section-title { font-weight: 600; margin: 4px 0 10px; }
.people { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.person { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px solid var(--border); }
.person:last-child { border-bottom: 0; }
.person .pname { font-weight: 600; }
.person .plogin { color: var(--muted); font-size: 12px; }
.role { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--hover); color: var(--muted); }
.role.admin { background: var(--danger-soft); color: var(--danger); }
.role.manager { background: var(--accent-soft); color: var(--accent); }
.inactive { opacity: .5; }
table.accs { width: 100%; border-collapse: collapse; }
table.accs th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 6px; border-bottom: 1px solid var(--border); }
table.accs td { padding: 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.accs td input, table.accs td select { padding: 5px 7px; font-size: 13px; }
.status { font-size: 12px; font-weight: 600; }
.status.active { color: var(--ok); }
.status.revoked, .status.error, .status.banned { color: var(--danger); }
.status.pending, .status.offline { color: var(--warn); }
.qr-box { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.qr-img { width: 240px; height: 240px; background: #fff; border-radius: 12px; padding: 8px; display: grid; place-items: center; flex: none; }
.qr-img svg { width: 100%; height: 100%; }
.qr-steps { flex: 1; min-width: 220px; }
.qr-steps ol { padding-left: 18px; margin: 6px 0; }
.qr-status { margin-top: 10px; font-weight: 600; }

.toasts { position: fixed; top: 118px; right: 20px; display: flex; flex-direction: column; align-items: stretch; gap: 6px; z-index: 60; pointer-events: none; width: min(360px, calc(100vw - 32px)); }
.toast:not(:hover) { opacity: .96; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 8px; box-sizing: border-box; background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 8px; padding: 8px 8px 8px 12px; box-shadow: var(--shadow); cursor: pointer; font-size: 13px; line-height: 1.35; animation: toastIn .18s ease-out; }
.toast-text { flex: 1; min-width: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; word-break: break-word; }
.toast.sticky .toast-text { display: block; -webkit-line-clamp: unset; }
.toast-x { flex: none; border: 0; background: none; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 4px; cursor: pointer; }
.toast-x:hover { color: var(--text); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.toast.error { border-left-color: var(--danger); }

@media (max-width: 1100px) {
  .main { grid-template-columns: 220px 290px 1fr; }
  .head-side { display: none; }
}
@media (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; }
}

/* ---------- employees ---------- */
.rail-search { display: flex; flex-direction: column; gap: 8px; }
.add-emp { width: 100%; }
.emp {
  display: flex; align-items: center; gap: 8px; padding: 8px 6px 8px 2px; margin-top: 6px; border-radius: 8px; cursor: pointer;
}
.emp:hover { background: var(--hover); }
.emp.active { background: var(--accent-soft); }
.emp .emp-av { width: 34px; height: 34px; font-size: 13px; border-radius: 10px; }
.emp-info { flex: 1; min-width: 0; }
.emp-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emp-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emp-toggle { border: 0; background: transparent; color: var(--muted); cursor: pointer; width: 18px; padding: 0; transition: transform .15s; }
.emp-toggle.closed { transform: rotate(-90deg); }
.emp-add { border: 1px solid var(--border); background: var(--panel); color: var(--accent); border-radius: 8px; width: 26px; height: 26px; cursor: pointer; font-size: 16px; line-height: 1; flex: none; opacity: .0; }
.emp:hover .emp-add, .emp.active .emp-add { opacity: 1; }
.acc { margin-left: 18px; }
.acc.in-view { box-shadow: inset 3px 0 0 var(--accent); }
.acc-empty { margin-left: 28px; font-size: 12px; color: var(--muted); padding: 4px 0 6px; }
.acc-empty a { color: var(--accent); }
.dlg-title { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dlg-title b { color: var(--text); }
.dlg-title:empty { display: none; }
.acc-pill {
  display: inline-block; margin-top: 3px; font-size: 10px; padding: 0 6px; border-radius: 8px; max-width: 100%;
  color: var(--c); border: 1px solid var(--c); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.owner-summary { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 30px 16px; max-width: 460px; width: 100%; text-align: center; }
.owner-summary h2 { margin: 4px 0 0; font-size: 20px; }
.owner-summary .muted, .muted { color: var(--muted); font-size: 13px; }
.avatar.big { width: 80px; height: 80px; font-size: 28px; border-radius: 24px; }
.sum-list { width: 100%; display: flex; flex-direction: column; gap: 4px; margin: 10px 0; text-align: left; }
.sum-acc { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--panel); cursor: pointer; }
.sum-acc:hover { background: var(--hover); }

/* ---------- emoji / stickers ---------- */
.round-btn.ghost { background: transparent; }
.round-btn.ghost.on { background: var(--accent-soft); }
.emoji-panel {
  position: absolute; left: 12px; bottom: 64px; width: 370px; max-width: calc(100% - 24px); height: 400px; z-index: 30;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.panel-tabs { display: flex; gap: 4px; padding: 8px 8px 4px; }
.panel-cats { display: flex; gap: 2px; padding: 2px 6px 6px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; flex: none; }
.panel-cats button { border: 0; background: transparent; border-radius: 8px; cursor: pointer; font-size: 18px; min-width: 32px; height: 32px; flex: none; }
.sticker-cats button { font-size: 12px; padding: 0 8px; color: var(--muted); }
.sticker-cats button:first-child, .sticker-cats button:nth-child(2) { font-size: 16px; }
.panel-cats button:hover { background: var(--hover); }
.panel-cats button.active { background: var(--accent-soft); color: var(--accent); }
.panel-body { flex: 1; overflow-y: auto; padding: 4px 8px 10px; position: relative; }
.sec-title { font-size: 12px; color: var(--muted); margin: 8px 2px 4px; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); }
.emoji-grid button { border: 0; background: transparent; font-size: 24px; height: 38px; border-radius: 8px; cursor: pointer; padding: 0; }
.emoji-grid button:hover { background: var(--hover); }
.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 4px; padding-top: 6px; }
.sticker-grid button { border: 0; background: transparent; height: 80px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; font-size: 34px; }
.sticker-grid button:hover { background: var(--hover); }
.sticker-grid img { max-width: 72px; max-height: 72px; object-fit: contain; }

/* ---------- managers ---------- */
.add-row { flex-wrap: nowrap; }
.add-row .add-emp { flex: 1; padding: 6px 4px; }
.emp.lead .emp-av { border-radius: 50%; }
.role-tag { font-size: 10px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 0 6px; border-radius: 8px; vertical-align: 1px; }
.role-tag.me-tag { color: var(--muted); background: var(--hover); }
.sum-title { align-self: flex-start; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin-top: 12px; }
.sum-move { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.sum-move select { border: 1px solid var(--border); background: var(--panel-2); border-radius: 8px; padding: 5px 8px; }
.owner-summary .sum-list { margin: 4px 0; }
.toast.sticky { border-left-color: var(--warn); user-select: text; }

/* ---------- Telegram / WhatsApp ---------- */
.kind-badge {
  display: inline-flex; align-items: center; justify-content: center; font-size: 8.5px; font-weight: 700;
  letter-spacing: .02em; color: #fff; border-radius: 4px; padding: 1px 3px; line-height: 1.2; vertical-align: middle;
}
.kind-badge.tg { background: #2aa3e0; }
.kind-badge.wa { background: #25a35a; }
.av-wrap .kind-badge { position: absolute; left: -3px; top: -3px; z-index: 1; border: 1.5px solid var(--panel); }
.av-wrap .kind-badge.mini { font-size: 7.5px; padding: 0 2px; }
.kind-pick { display: flex; gap: 8px; margin-bottom: 14px; }
.kind-opt {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px;
  border: 1.5px solid var(--border); border-radius: var(--radius); background: var(--panel-2); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer;
}
.kind-opt.active { border-color: var(--accent); background: var(--accent-soft); }
.kind-opt .kind-badge { font-size: 10px; padding: 2px 4px; }
.sum-perm { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; color: var(--text); margin: 4px 0; cursor: pointer; }

/* ---------- перевод ---------- */
.msg .tr { margin-top: 6px; padding: 5px 0 0 8px; border-left: 2px solid var(--accent); white-space: pre-wrap; word-break: break-word; }
.msg .tr-label { font-size: 11px; color: var(--accent); font-weight: 600; margin-bottom: 2px; }
.msg .tr.loading, .msg .tr.err { font-size: 12px; color: var(--muted); }
.msg .tr.err { color: var(--danger); border-left-color: var(--danger); }
.btn.tr-toggle { margin-left: 8px; white-space: nowrap; }
.btn.tr-toggle.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.round-btn.tr-send { position: relative; }
.round-btn.tr-send span { position: absolute; right: -2px; bottom: 0; font-size: 8.5px; font-weight: 700; color: var(--accent); background: var(--panel); border-radius: 4px; padding: 0 2px; line-height: 1.3; }
.round-btn.tr-send:disabled { opacity: .5; }
.lang-menu { max-height: 70vh; overflow-y: auto; }
.lang-menu .menu-head { font-size: 12px; color: var(--muted); padding: 4px 10px 6px; }
.lang-menu .menu-item.cur { color: var(--accent); font-weight: 600; }
.del-list { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.row .spacer { flex: 1; }

/* ---------- исчезающие сообщения и кружки ---------- */
.ttl-btn { position: relative; }
.ttl-btn.on { background: var(--accent-soft); }
.ttl-btn span { position: absolute; right: -3px; bottom: 0; font-size: 8.5px; font-weight: 700; color: var(--accent); background: var(--panel); border-radius: 4px; padding: 0 2px; line-height: 1.3; }
.ttl-badge { color: var(--accent); font-weight: 600; }
.ttl-head { font-size: 11px; color: var(--accent); }
.ttl-menu .menu-head.sep { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; }
.ttl-menu .menu-note { font-size: 11px; color: var(--muted); padding: 2px 10px 4px; max-width: 280px; }
.ttl-menu { max-width: 320px; }
.round-rec { position: absolute; left: 0; right: 0; bottom: 0; background: var(--panel); border-top: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px; z-index: 30; }
.round-rec.hidden { display: none; }
.round-cam { position: relative; width: 240px; height: 240px; }
.round-cam video { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; transform: scaleX(-1); background: #000; }
.round-ring { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); transform: rotate(-90deg); pointer-events: none; }
.round-ring circle { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; }
.round-ctl { display: flex; align-items: center; gap: 10px; }
.composer.rounding { visibility: hidden; }

/* ---------- профиль клиента: медиатека и заметки ---------- */
.profile { position: absolute; top: 0; right: 0; bottom: 0; width: 380px; max-width: 100%; background: var(--panel);
  border-left: 1px solid var(--border); box-shadow: -8px 0 24px rgba(20, 30, 50, .08); z-index: 40; display: flex; flex-direction: column; }
.profile.hidden { display: none; }
.prof-head { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 18px 16px 10px; text-align: center; }
.prof-head .avatar.big { width: 72px; height: 72px; font-size: 26px; }
.prof-close { position: absolute; right: 10px; top: 10px; border: 0; background: transparent; font-size: 16px; cursor: pointer; color: var(--muted); width: 30px; height: 30px; border-radius: 8px; }
.prof-close:hover { background: var(--hover); }
.prof-name { font-weight: 700; font-size: 16px; }
.prof-contacts { font-size: 13px; color: var(--accent); }
.prof-contacts .copy { cursor: pointer; }
.prof-via { font-size: 12px; color: var(--muted); }
.prof-tabs { display: flex; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.prof-tabs .tab { flex: 1; white-space: nowrap; font-size: 13px; padding: 8px 6px; }
.prof-tabs .tab b { color: var(--accent); }
.prof-body { flex: 1; overflow-y: auto; padding: 10px; }
.prof-more { display: flex; justify-content: center; padding: 10px; }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.mg-item { position: relative; aspect-ratio: 1; background: var(--panel-2); overflow: hidden; cursor: pointer; border-radius: 4px; }
.mg-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mg-ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 26px; }
.mg-play { position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; border-radius: 6px; padding: 1px 5px; }
.mg-ttl { position: absolute; left: 4px; top: 4px; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; border-radius: 6px; padding: 0 4px; }
.mg-goto { position: absolute; right: 4px; top: 4px; border: 0; border-radius: 6px; background: rgba(0,0,0,.5); color: #fff; font-size: 12px; cursor: pointer; opacity: 0; transition: opacity .15s; }
.mg-item:hover .mg-goto { opacity: 1; }
.pf-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.pf-row audio { width: 170px; height: 34px; flex: none; }
.pf-round { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex: none; background: #000; }
.pf-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; font-size: 18px; flex: none; text-decoration: none; }
.pf-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pf-title { color: var(--accent); text-decoration: none; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.pf-title:hover { text-decoration: underline; }
.pf-sub { font-size: 12px; color: var(--muted); }
.pf-snip { font-size: 12px; color: var(--text); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.note-form { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.note-form textarea, .note-edit { width: 100%; box-sizing: border-box; resize: vertical; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font: inherit; background: var(--panel-2); color: var(--text); }
.note { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; background: var(--panel-2); }
.note-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.note-meta .spacer { flex: 1; }
.note-text { white-space: pre-wrap; word-break: break-word; font-size: 13.5px; }
.link-btn { border: 0; background: transparent; color: var(--accent); cursor: pointer; font-size: 12px; padding: 0 2px; }
.link-btn.danger { color: var(--danger); }
.btn.prof-btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.muted.small { font-size: 11px; }
.chat-head .avatar, .chat-head .head-text .title { cursor: pointer; }
@media (min-width: 1100px) {
  .chat.with-profile > .chat-head, .chat.with-profile > .banner, .chat.with-profile > .msg-wrap,
  .chat.with-profile > .composer, .chat.with-profile > .round-rec { margin-right: 380px; }
  .chat.with-profile > .round-rec { right: 380px; margin-right: 0; }
}
.chat.with-profile .chat-head .via, .chat.with-profile .chat-head .ttl-head { display: none; }
.chat-head .head-text { min-width: 80px; }

/* ---------- вход по номеру ---------- */
.method-pick { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.method-pick .check { margin: 0; }
.pair-code { font: 700 30px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 3px; color: #111; text-align: center; padding: 10px; }

/* ---------- безопасность ---------- */
.sec-on { color: var(--ok); font-weight: 600; }
.sec-off { color: var(--muted); font-weight: 500; }
.sec-qr { display: flex; justify-content: center; margin: 8px 0; }
.sec-qr svg { width: 200px; height: 200px; background: #fff; padding: 8px; border-radius: 10px; }
.sec-key { font-size: 13px; user-select: all; }
.sec-steps { margin: 4px 0; padding-left: 18px; font-size: 13px; line-height: 1.6; }

/* ---------- заработок ---------- */
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.earn-view { flex: 1; overflow-y: auto; background: var(--bg); min-height: 0; }
.earn-view.hidden, .main.hidden { display: none; }
.earn-wrap { max-width: 1180px; margin: 0 auto; padding: 18px 20px 40px; display: flex; flex-direction: column; gap: 14px; }
.earn-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.earn-head h2 { margin: 0 6px 0 0; font-size: 20px; }
.earn-head .spacer { flex: 1; }
.earn-periods { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--panel); color: var(--text); border-radius: 999px; padding: 5px 11px; font: inherit; font-size: 13px; cursor: pointer; }
.chip:hover { background: var(--hover); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.earn-custom input { border: 1px solid var(--border); border-radius: 8px; padding: 4px 6px; background: var(--panel); color: var(--text); font: inherit; }
.earn-stats { display: grid; grid-template-columns: 2fr 1fr 1fr 1.3fr; gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; min-width: 0; }
.stat-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.hero .stat-value { font-size: 32px; }
.stat-value.small { font-size: 17px; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.delta { font-weight: 700; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--danger); }
.earn-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
.earn-card-title { font-weight: 600; margin-bottom: 10px; }
.chart-box { position: relative; }
.earn-chart { width: 100%; height: 240px; display: block; overflow: visible; }
.earn-chart .grid { stroke: var(--border); stroke-width: 1; }
.earn-chart .axis { fill: var(--muted); font-size: 11px; }
.earn-chart .bar { fill: var(--accent); }
.earn-chart .bar.neg { fill: var(--danger); }
.earn-chart .hit { fill: transparent; }
.earn-chart .bar-g.hover .hit { fill: var(--hover); }
.chart-tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 8px; padding: 6px 9px; font-size: 12px; white-space: nowrap; }
.chart-tip.hidden { display: none; }
.tip-label { color: var(--muted); }
.tip-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.earn-teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.team-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.team-head .spacer { flex: 1; }
.team-head b { font-variant-numeric: tabular-nums; }
.team-name { font-weight: 700; font-size: 15px; color: var(--text); padding: 0; }
.team-row { display: grid; grid-template-columns: minmax(0, 1.3fr) 1fr auto; align-items: center; gap: 10px; padding: 5px 4px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.team-row:hover { background: var(--hover); }
.tr-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-bar { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.tr-bar span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.tr-val { font-variant-numeric: tabular-nums; text-align: right; min-width: 70px; }
.earn-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.earn-table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.earn-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.earn-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.earn-table .num.neg { color: var(--danger); }
.earn-table .note-cell { max-width: 320px; word-break: break-word; }
.earn-table .acts { white-space: nowrap; text-align: right; }
.earn-cur { text-align: right; }
@media (max-width: 900px) { .earn-stats { grid-template-columns: 1fr 1fr; } }

/* ---------- устройства ---------- */
.pw-modal { z-index: 60; }
.pw-box { max-width: 380px; }
.pw-box input { width: 100%; box-sizing: border-box; }
.dev-pw { padding: 10px 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--border); font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dev-pw.warn { background: #fff6e5; border-color: #f0c36d; color: #6b4a00; }
@media (prefers-color-scheme: dark) { .dev-pw.warn { background: #3a2c10; border-color: #7a5a1c; color: #f4d79a; } }
.dev-pw-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.dev-group { margin-top: 14px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.dev-user { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--panel-2); font-size: 13px; }
.dev-user .spacer { flex: 1; }
.dev-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--border); font-size: 13px; }
.dev-ico { font-size: 20px; }
.dev-main { flex: 1; min-width: 0; }

/* ---------- клиенты ---------- */
#btnClients { position: relative; }
#btnClients .badge, #btnCalls .badge { margin-left: 6px; }
.cl-wrap { max-width: 1400px; }
.cl-filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.cl-filters #clSearch { flex: 1; min-width: 240px; }
.cl-bulk { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px; background: var(--accent-soft); border: 1px solid var(--accent); flex-wrap: wrap; }
.cl-bulk .spacer { flex: 1; }
.cl-card { padding: 6px 8px; overflow-x: auto; }
.cl-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.cl-table th.sorted { color: var(--accent); }
.cl-table td { vertical-align: middle; }
.cl-table tr.sel td { background: var(--accent-soft); }
.cl-table .chk-col { width: 26px; }
.cl-name { font-weight: 600; }
.cl-name a { text-decoration: none; }
.cl-note { font-size: 12px; color: var(--muted); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-source { width: 130px; border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 3px 6px; font: inherit; color: var(--text); }
.cl-source:hover, .cl-source:focus { border-color: var(--border); background: var(--panel-2); outline: none; }
.cl-profit { font-weight: 600; font-variant-numeric: tabular-nums; }
.cl-new { color: var(--accent); font-weight: 600; font-size: 12px; }
.im-sum { padding: 8px 10px; background: var(--panel-2); border-radius: 8px; }
.im-table { max-height: 280px; overflow: auto; margin-top: 8px; }
.im-table tr.dup td { color: var(--muted); }
#imText { width: 100%; box-sizing: border-box; border: 1px solid var(--border); border-radius: 8px; padding: 8px; font: inherit; background: var(--panel-2); color: var(--text); }
.acc-pick { display: flex; width: 100%; margin-bottom: 6px; justify-content: flex-start; gap: 8px; }
.prof-client { display: flex; gap: 12px; align-items: center; font-size: 12px; margin-top: 4px; color: var(--muted); }

/* вкладки Telegram / WhatsApp, «Все аккаунты», избранное, архив */
.kind-tabs { margin: 0 10px 6px; padding: 2px; display: grid; grid-template-columns: auto 1fr 1fr; gap: 2px; background: var(--hover); border-radius: 8px; }
.kind-tabs .tab { font-size: 12px; padding: 4px 6px; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
.kind-tabs .tab.active { background: var(--panel); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.kind-tabs [data-acckind=tg].active { color: #229ed9; }
.kind-tabs [data-acckind=wa].active { color: #1fa855; }
.tab-n { margin-left: 2px; font-size: 10px; font-weight: 700; color: #fff; background: var(--accent); border-radius: 9px; padding: 0 4px; line-height: 14px; }
.tab-n:empty { display: none; }
#dlgTabs { flex-wrap: nowrap; gap: 0; overflow-x: auto; scrollbar-width: none; }
#dlgTabs::-webkit-scrollbar { display: none; }
#dlgTabs .tab { padding: 4px 5px; font-size: 12px; white-space: nowrap; flex: none; display: inline-flex; align-items: center; }
.all-row .emp-name { font-weight: 700; }
.all-av { background: var(--accent-soft) !important; color: var(--accent); font-size: 16px; }
.dlg-fav { flex: none; border: 0; background: none; padding: 0 2px; margin-left: auto; cursor: pointer; color: var(--muted); font-size: 14px; line-height: 1; visibility: hidden; }
.dlg:hover .dlg-fav, .dlg-fav.on { visibility: visible; }
.dlg-fav.on { color: #f5b400; }
.dlg-fav:hover { color: #f5b400; }
.icon-btn { min-width: 32px; padding-left: 8px; padding-right: 8px; }
#btnFav.on { color: #f5b400; }
.ctx-menu { position: fixed; z-index: 70; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 4px; display: flex; flex-direction: column; min-width: 190px; }
.ctx-menu button { border: 0; background: none; text-align: left; padding: 7px 10px; border-radius: 6px; cursor: pointer; color: var(--text); font: inherit; }
.ctx-menu button:hover { background: var(--hover); }
.badge.muted { background: #9aa3b2; }
.muted-ic { font-size: 11px; opacity: .7; }
#btnMute.on { background: var(--hover); }
.ctx-sep { height: 1px; background: var(--border); margin: 4px 2px; }
.ctx-label { padding: 6px 10px 2px; font-size: 12px; color: var(--muted); }
.ctx-menu .ctx-indent { padding-left: 26px; }
.ctx-sub { display: block; font-size: 11px; color: var(--muted); }

/* предпросмотр чата */
.peek { position: fixed; inset: 0; z-index: 55; background: rgba(10, 15, 25, .35); display: grid; place-items: center; padding: 16px; animation: toastIn .15s ease-out; }
.peek-box { width: min(520px, 100%); height: min(640px, 85vh); background: var(--bg); border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.peek-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel); border-bottom: 1px solid var(--border); }
.peek-head .head-text { flex: 1; min-width: 0; }
.peek-head .title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peek-head .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peek-list { flex: 1; overflow-y: auto; padding: 10px 12px; }
.peek-list .msg { max-width: 82%; }
.peek-img { display: block; max-width: 240px; max-height: 200px; border-radius: 10px; margin-bottom: 4px; cursor: zoom-in; }
.peek-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; background: var(--panel); border-top: 1px solid var(--border); font-size: 12px; }
.dlg { user-select: none; -webkit-touch-callout: none; }

/* звонки */
.call-card { display: flex; align-items: center; gap: 10px; min-width: 190px; padding: 2px 0; }
.call-ic { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); font-size: 16px; flex: none; }
.call-card.missed .call-ic { background: rgba(229, 72, 77, .14); }
.call-card.missed .call-title { color: var(--danger); }
.call-title { font-weight: 600; }
.call-sub { font-size: 12px; color: var(--muted); }
.toast.call-ring { border-left-color: #1fa855; align-items: flex-start; cursor: default; animation: toastIn .18s ease-out, ringPulse 1.6s ease-in-out infinite; }
.ring-ic { font-size: 22px; line-height: 1; padding-top: 2px; }
.ring-body { flex: 1; min-width: 0; }
.ring-sub, .ring-hint { font-size: 12px; color: var(--muted); }
.ring-btns { display: flex; gap: 6px; margin-top: 6px; }
.btn.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
@keyframes ringPulse { 0%, 100% { box-shadow: var(--shadow); } 50% { box-shadow: 0 0 0 4px rgba(31, 168, 85, .25), var(--shadow); } }
#btnCalls { position: relative; }
.calls-tabs { margin-bottom: 10px; }
.calls-list { display: flex; flex-direction: column; max-height: 60vh; overflow-y: auto; }
.call-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 8px; cursor: pointer; }
.call-row:hover { background: var(--hover); }
.call-info { flex: 1; min-width: 0; }
.call-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-what { font-size: 13px; color: var(--muted); }
.call-row.missed .call-what { color: var(--danger); }
.call-meta { text-align: right; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }

/* безопасность */
.sec-force { background: rgba(229, 72, 77, .1); border: 1px solid var(--danger); color: var(--text); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.sl-list { max-height: 65vh; overflow-y: auto; }
.sl-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sl-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.sl-ts { white-space: nowrap; color: var(--muted); }
.sl-login_fail td:nth-child(2) b, .sl-otp_fail td:nth-child(2) b, .sl-login_blocked td:nth-child(2) b, .sl-login_new_ip td:nth-child(2) b,
.sl-rate_limited td:nth-child(2) b, .sl-csrf_blocked td:nth-child(2) b, .sl-2fa_off td:nth-child(2) b { color: var(--danger); }

/* удалённые сообщения */
.del-label { font-size: 11.5px; font-weight: 600; color: var(--danger); margin-bottom: 3px; }
.msg.deleted { outline: 1px dashed var(--danger); opacity: 1; background: color-mix(in srgb, var(--danger) 6%, var(--in)); }
.msg.out.deleted { background: color-mix(in srgb, var(--danger) 7%, var(--out)); }
.orig-text { margin-top: 4px; padding: 4px 8px; border-left: 3px solid var(--muted); font-size: 13px; color: var(--muted); white-space: pre-wrap; }
.meta .edited { cursor: pointer; }
.removed-ic { font-size: 12px; }
.del-text { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.del-who { font-size: 11px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.del-who.out { color: var(--accent); }

/* ================= телефон ================= */
.m-only { display: none !important; }
.chat-head-wrap { display: flex; align-items: stretch; background: var(--panel); border-bottom: 1px solid var(--border); }
.chat-head-wrap .chat-head { flex: 1; min-width: 0; border-bottom: 0; }
.m-head-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.m-back { border: 0; background: none; color: var(--accent); font-size: 34px; line-height: 1; padding: 0 10px 4px 6px; cursor: pointer; flex: none; }

@media (max-width: 760px) {
  .m-only { display: inline-flex !important; }
  .app { height: 100dvh; }
  body { -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
  /* поля ввода 16px — иначе iPhone приближает страницу при вводе */
  .input, .select, textarea, .modal-body input, .modal-body select, .composer textarea { font-size: 16px; }

  /* шапка: логотип, фильтр сотрудника, меню */
  .topbar { padding: 6px 8px; gap: 6px; padding-top: max(6px, env(safe-area-inset-top)); }
  .topbar > .btn:not(#btnMenu), .topbar .me { display: none; }
  .topbar .brand { font-size: 0; gap: 0; }
  .topbar .brand-mark { font-size: 20px; }
  .topbar .select { min-width: 0; flex: 1; width: 100%; }
  .topbar .spacer { display: none; }
  #btnMenu { font-size: 22px; padding: 4px 10px; position: relative; }
  #menuBadge { position: absolute; top: 2px; right: 2px; min-width: 9px; height: 9px; padding: 0; font-size: 0; }

  /* один экран за раз: аккаунты → чаты → переписка */
  .main { grid-template-columns: 1fr; position: relative; }
  .rail, .dialogs, .chat { grid-area: 1 / 1; border-right: 0; min-height: 0; height: 100%; }
  body[data-mview="rail"] .dialogs, body[data-mview="rail"] .chat,
  body[data-mview="dialogs"] .rail, body[data-mview="dialogs"] .chat,
  body[data-mview="chat"] .rail, body[data-mview="chat"] .dialogs { display: none; }
  .rail .hint { display: none; }
  .rail-search { padding: 8px; }
  .acc-list { padding-bottom: env(safe-area-inset-bottom); }
  .emp, .acc { min-height: 48px; }
  .dlg-head { padding: 6px 8px 8px; }
  .dlg-title { font-size: 14px; }
  .dlg { padding-top: 10px; padding-bottom: 10px; }
  .dlg-fav { visibility: visible; opacity: .35; }
  .dlg-fav.on { opacity: 1; }

  /* переписка */
  .chat-head { padding: 6px 8px 6px 0; gap: 8px; min-height: 52px; }
  .chat-head .avatar { width: 36px; height: 36px; }
  .chat-head .head-side, #btnFav, #btnMute, #btnArch, #btnAutoTr, #btnMarkRead { display: none !important; }
  #btnProfile { font-size: 0; padding: 6px 8px; }
  #btnProfile::before { content: '👤'; font-size: 16px; }
  #btnHeadMore { font-size: 18px; padding: 4px 10px; }
  .msg-list { padding: 8px 8px 12px; }
  .msg { max-width: 86%; }
  .msg-tools { display: none; }
  .msg img, .msg video { max-width: 100%; }
  .banner { padding: 6px 10px; font-size: 12px; }
  .scroll-down { right: 12px; bottom: 12px; }

  /* поле ввода: ＋ (файл, смайлики, кружок, таймер, перевод) · текст · голосовое/отправить */
  .composer { padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .composer-row { gap: 4px; align-items: flex-end; }
  .composer .attach, #btnTimer, #btnEmoji, #btnTrSend, #btnRound { display: none; }
  .composer textarea { min-height: 40px; padding: 9px 12px; max-height: 140px; }
  #btnPlus { font-size: 22px; align-items: center; justify-content: center; }
  .emoji-panel { left: 0; right: 0; width: auto; max-width: none; }
  .rec-ui { gap: 8px; }

  /* профиль клиента и окна — на весь экран */
  .profile { width: 100%; z-index: 30; }
  .modal { padding: 0; place-items: stretch; }
  .modal-box { max-width: none; max-height: none; height: 100dvh; border-radius: 0; }
  .modal-head { padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); }
  .modal-body { padding: 12px 12px calc(20px + env(safe-area-inset-bottom)); }
  .modal-body .row { flex-wrap: wrap; }
  .ctx-menu { min-width: 220px; max-width: calc(100vw - 16px); }
  .ctx-menu button { padding: 11px 12px; font-size: 15px; }
  .toasts { top: calc(56px + env(safe-area-inset-top)); right: 8px; left: 8px; width: auto; }
  .lightbox img { max-width: 100vw; max-height: 100dvh; }

  /* клиенты и заработок: таблицы прокручиваются вбок, панели переносятся */
  .earn-view { padding-bottom: env(safe-area-inset-bottom); }
  .earn-view table { font-size: 13px; }
  .earn-card, .im-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .cl-table { min-width: 720px; }
  .earn-table th, .earn-table td { white-space: nowrap; }
  .earn-table .note-cell { white-space: normal; min-width: 160px; }
  .call-row { gap: 8px; }
  .call-meta { max-width: 40%; }
  .acc-pill { white-space: normal; text-align: right; }

  /* меню ☰ */
  .m-me { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
  .m-top-menu { display: flex; flex-direction: column; gap: 6px; }
  .m-top-item { display: flex; align-items: center; justify-content: space-between; text-align: left; padding: 14px 14px; font-size: 16px;
    border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); cursor: pointer; }
  .peek-box { height: 90dvh; }
}

/* работа сотрудников */
.wait-chip { font-size: 10.5px; font-weight: 700; color: #8a5a00; background: #fff1cc; border-radius: 8px; padding: 1px 6px; margin-left: 4px; white-space: nowrap; flex: none; }
.wait-chip.mid { color: #8a5a00; background: #ffe08a; }
.wait-chip.bad { color: #fff; background: var(--danger); }
.perf-tabs { margin: 4px 0 10px; }
.perf-note { margin: 0 0 8px; }
.perf-table .perf-row, .perf-urow, .perf-lazy-row { cursor: pointer; }
.perf-table .perf-row:hover td, .perf-urow:hover td { background: var(--hover); }
.perf-urow.open td { background: var(--accent-soft); }
.rt { font-weight: 700; }
.rt.good { color: #1f9d55; }
.rt.mid { color: #c27c00; }
.rt.bad { color: var(--danger); }
.bad-n { color: var(--danger); font-weight: 700; }
.perf-stats th.sortable { cursor: pointer; white-space: nowrap; }
.perf-stats th.sorted { color: var(--accent); }
.perf-detail td { background: var(--bg); }
.perf-detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; padding: 6px 2px; white-space: normal; }
.mini-bars { width: 100%; }
.mb-bars { height: 90px; display: flex; align-items: flex-end; gap: 2px; border-bottom: 1px solid var(--border); }
.mb-col { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; min-width: 0; }
.mb-bar { width: 100%; max-width: 26px; background: var(--accent); opacity: .85; border-radius: 3px 3px 0 0; }
.rt-bars .mb-bar { background: #e0a800; }
.mb-col:hover .mb-bar { opacity: 1; }
.mb-labels { display: flex; gap: 2px; }
.mb-labels span { flex: 1; min-width: 0; font-size: 10.5px; color: var(--muted); text-align: center; white-space: nowrap; overflow: visible; }
.perf-lazy-row { padding: 6px 4px; border-bottom: 1px solid var(--border); }
.perf-lazy-row:hover { background: var(--hover); }
.reason { display: inline-block; font-size: 11.5px; background: rgba(229, 72, 77, .1); color: var(--danger); border-radius: 8px; padding: 1px 7px; margin: 2px 3px 0 0; }
.perf-settings .ps-row { margin: 6px 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 14px; }
.small-num { width: 74px !important; min-width: 0; padding: 5px 8px; }
.ps-steps { margin: 8px 0; padding-left: 20px; }
.ok-pill { font-size: 12px; color: #1f9d55; background: rgba(31, 157, 85, .12); border-radius: 8px; padding: 1px 8px; margin-left: 6px; }
#btnPerf .badge { margin-left: 6px; }
.perf-settings + .perf-settings { margin-top: 12px; }
@media (max-width: 1320px) and (min-width: 761px) {
  .topbar .me { display: none; }
  .topbar .btn { padding-left: 9px; padding-right: 9px; }
}
.peek-tr-btn.on { background: var(--accent-soft); color: var(--accent); }
.peek-list .photo { max-width: 260px; max-height: 260px; cursor: zoom-in; }
.peek-list video.video { max-width: 280px; max-height: 300px; }
.peek-list video.round { width: 180px; height: 180px; }

/* боты */
.bot-kb { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.bot-row { display: flex; gap: 4px; }
.bot-btn { flex: 1; min-width: 0; display: inline-flex; align-items: center; justify-content: center; text-align: center; padding: 7px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel); color: var(--accent); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: normal; word-break: break-word; }
.bot-btn:hover { background: var(--accent-soft); }
.bot-btn.off { color: var(--muted); cursor: not-allowed; font-weight: 500; }
.bot-btn.busy { opacity: .5; pointer-events: none; }
.bot-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-top: 4px; background: var(--panel); }
.bot-list-g { font-size: 11.5px; color: var(--muted); padding: 6px 10px 2px; text-transform: uppercase; }
.bot-list-item { border: 0; border-top: 1px solid var(--border); background: none; text-align: left; padding: 8px 10px; cursor: pointer; font: inherit; color: var(--text); display: flex; flex-direction: column; }
.bot-list-item:hover { background: var(--hover); }
.bot-list-item span { font-size: 12px; color: var(--muted); }
.bot-panel { border-top: 1px solid var(--border); padding: 8px; max-height: 40vh; overflow-y: auto; background: var(--bg); }
.bot-panel .bot-kb.reply { margin: 0 0 6px; }
.bot-cmds { display: flex; flex-direction: column; }
.bot-cmd { border: 0; background: none; text-align: left; padding: 7px 8px; border-radius: 6px; cursor: pointer; font: inherit; color: var(--text); display: flex; gap: 10px; align-items: baseline; }
.bot-cmd:hover { background: var(--hover); }
.bot-cmd b { color: var(--accent); }
.bot-cmd span { color: var(--muted); font-size: 13px; }
.bot-start { width: 100%; padding: 10px; border-radius: 8px; border: 0; background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; margin-bottom: 6px; }
.bot-alert { white-space: pre-wrap; }
