:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --line: #e3e6ea;
  --text: #1d2329;
  --muted: #6b7580;
  --accent: #128c7e;
  --accent-soft: #e3f4f1;
  --in: #ffffff;
  --out: #d9f7ec;
  --agent: #eef1ff;
  --warn: #b54708;
  --warn-soft: #fff4e5;
  --danger: #c4320a;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); height: 100vh; display: flex; flex-direction: column; }
button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 12px; color: var(--text); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
input, textarea, select { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; color: var(--text); width: 100%; }
textarea { resize: vertical; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 24px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 16px; }
.tabs, .subtabs { display: flex; gap: 6px; }
.tabs button, .subtabs button { border: none; background: none; padding: 7px 12px; border-radius: 8px; color: var(--muted); }
.tabs button.active, .subtabs button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.status { margin-left: auto; display: flex; gap: 8px; }
.badge { font-size: 12px; padding: 3px 8px; border-radius: 99px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.badge.ok { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.view { flex: 1; min-height: 0; }

/* chats */
.chats-view { display: grid; grid-template-columns: 320px 1fr 360px; }
.chat-list { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.chat-list-head { padding: 12px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.filters { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 99px; }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
#conversations { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#conversations li { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; }
#conversations li:hover { background: var(--bg); }
#conversations li.active { background: var(--accent-soft); }
.c-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-time { font-size: 12px; color: var(--muted); }
.c-last { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-flags { display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
.unread { background: var(--accent); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; }
.flag { font-size: 11px; padding: 1px 6px; border-radius: 6px; }
.flag.manager { background: var(--warn-soft); color: var(--warn); }
.flag.draft { background: var(--agent); color: #3949ab; }
.mock { border-top: 1px dashed var(--line); padding: 10px 12px; display: grid; gap: 6px; background: #fffdf5; }
.mock-title { font-size: 12px; color: var(--warn); font-weight: 600; }

.chat { display: flex; flex-direction: column; min-height: 0; background: #efeae2; }
.chat .empty { margin: auto; color: var(--muted); }
.chat-head { background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.chat-head .title { font-weight: 600; }
.bee-typing { font-size: 12px; color: #3949ab; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.chat-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.toggle { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.toggle input { width: auto; }
.handoff-bar { background: var(--warn-soft); color: var(--warn); padding: 8px 16px; display: flex; gap: 10px; align-items: center; font-size: 13px; }
.messages { flex: 1; overflow-y: auto; padding: 16px 8%; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 70%; padding: 7px 10px; border-radius: var(--radius); background: var(--in); box-shadow: 0 1px 1px rgba(0,0,0,.06); word-wrap: break-word; }
.msg .t, .report, .k-item .body { white-space: pre-wrap; }
.msg.outgoing { align-self: flex-end; background: var(--out); }
.msg.agent { background: var(--agent); }
.msg .meta { font-size: 11px; color: var(--muted); margin-top: 3px; text-align: right; }
.msg a { color: var(--accent); }
.draft-box { background: var(--agent); border-top: 2px solid #9fa8da; padding: 10px 16px; display: grid; gap: 8px; }
.draft-box .head { font-size: 12px; color: #3949ab; font-weight: 600; }
.draft-box .row { display: flex; gap: 8px; }
.composer { background: var(--panel); border-top: 1px solid var(--line); padding: 10px 16px; display: flex; gap: 8px; }
.composer textarea { min-height: 40px; max-height: 160px; }

.side { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 14px; display: grid; gap: 16px; align-content: start; }
.card h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.events li { font-size: 12px; border-left: 3px solid var(--line); padding: 2px 8px; }
.events li.booking { border-color: var(--accent); }
.events li.handoff { border-color: var(--warn); }
.events li.error { border-color: var(--danger); }
.events li.draft, .events li.suggestion { border-color: #9fa8da; }
.events time { color: var(--muted); margin-right: 4px; }

/* office */
.office-view { display: flex; flex-direction: column; padding: 14px 20px; gap: 14px; overflow-y: auto; }
.office-body { display: grid; gap: 16px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.panel h3 { margin: 0 0 10px; font-size: 15px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat b { display: block; font-size: 22px; }
.stat span { color: var(--muted); font-size: 12px; }

.room { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.desk { background: linear-gradient(#fff7e0, #fff); border: 1px solid #f0dca8; border-radius: 14px; padding: 14px; text-align: center; cursor: pointer; }
.desk .bee { font-size: 38px; display: inline-block; }
.desk.director .bee::after { content: "👑"; font-size: 16px; position: relative; top: -26px; left: -12px; }
.desk.reading .bee, .desk.writing .bee, .desk.typing .bee { animation: buzz .5s infinite alternate; }
.desk.off { filter: grayscale(1); opacity: .6; }
.desk .name { font-weight: 600; margin-top: 4px; }
.desk .state { font-size: 12px; color: var(--muted); margin-top: 2px; }
.desk.waiting_you .state { color: #3949ab; font-weight: 600; }
@keyframes buzz { from { transform: translate(-2px, 0) rotate(-6deg); } to { transform: translate(2px, -2px) rotate(6deg); } }
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 420px; overflow-y: auto; }
.feed li { font-size: 13px; padding: 6px 8px; border-radius: 8px; background: var(--bg); cursor: pointer; }
.feed li time { color: var(--muted); margin-right: 6px; font-size: 12px; }

.bee-card { display: grid; gap: 8px; }
.bee-card .top { display: flex; gap: 10px; align-items: center; }
.bee-card .icon { font-size: 30px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); }
.pill.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.k-list { display: grid; gap: 8px; }
.k-item { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 4px; }
.k-item.off { opacity: .55; }
.k-item .body { white-space: pre-wrap; color: var(--muted); font-size: 13px; max-height: 4.5em; overflow: hidden; }
.k-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.k-tools select { width: auto; }
.suggest { background: #f5f6ff; border-color: #c5cae9; }

/* modal */
dialog { border: none; border-radius: 14px; padding: 0; width: min(720px, 94vw); max-height: 90vh; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20,25,30,.45); }
#modalForm { padding: 20px; display: grid; gap: 14px; overflow-y: auto; max-height: 90vh; }
#modalForm h3 { margin: 0; }
.field { display: grid; gap: 5px; }
.field > label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.choices label { display: flex; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 99px; padding: 4px 10px; font-size: 13px; cursor: pointer; }
.choices input { width: auto; }
.choices label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; position: sticky; bottom: -20px; background: #fff; padding: 10px 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.report { white-space: pre-wrap; font-size: 13px; }

@media (max-width: 1100px) { .chats-view { grid-template-columns: 280px 1fr; } .side { display: none; } }

/* история посещений справа */
.client-head { font-size: 14px; margin-bottom: 4px; }
.visit { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-top: 8px; background: #fff; }
.visit.future { border-color: #b7d3f5; background: #f4f9ff; }
.visit-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.vstatus { font-size: 12px; color: #666; }
.vstatus.ok { color: #1a8f3c; } .vstatus.ok::before { content: "✓ "; }
.vstatus.bad { color: #c0392b; } .vstatus.bad::before { content: "✕ "; }
.vstatus.info { color: #2a6fbf; }
.mute-toggle { white-space: nowrap; }
.mute-toggle:has(input:checked) { color: #c0392b; font-weight: 600; }

/* вход и команда */
.login-page { display: grid; place-items: center; min-height: 100vh; background: var(--bg, #f3f4f6); }
.login-box { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: 340px; display: grid; gap: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.06); }
.login-box .brand { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.login-err { color: #c0392b; font-size: 13px; min-height: 16px; }
.me { font-size: 13px; color: var(--text); margin-left: 6px; }
.link-btn { border: none; background: none; color: #2a6fbf; padding: 2px 6px; }
.user-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.user-row.off { opacity: .55; }
.role-badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #eef2f7; color: #445; margin-left: 4px; }
.role-badge.admin { background: #fde8e8; color: #a12; }
.role-badge.manager { background: #e7f0fd; color: #1f5fa8; }
.role-badge.operator { background: #e6f6ea; color: #1a7a36; }
.role-badge.off { background: #eee; color: #777; }
.field label.role-opt, .role-opt { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); display: block; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-top: 6px; cursor: pointer; }
.role-opt input { width: auto; margin-right: 6px; }
.role-opt:has(input:checked) { border-color: #2a6fbf; background: #f4f9ff; }

.chan { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 5px; color: #fff; vertical-align: 1px; }
.chan.wa { background: #25d366; }
.chan.ig { background: linear-gradient(45deg, #f09433, #dc2743, #bc1888); }

/* голосовые */

.older-wrap { text-align: center; margin: 4px 0 10px; }
.older-btn { background: #fff; border: 1px solid #d6dbe1; border-radius: 16px; padding: 6px 14px; font-size: 13px; cursor: pointer; color: #128c7e; }
.older-btn:hover { background: #f3f7f6; }
.older-btn:disabled { color: #888; cursor: default; }

.msg img.sticker { width: 140px; height: 140px; object-fit: contain; display: block; }
.msg img.photo, .msg video.photo { max-width: 280px; max-height: 320px; border-radius: 8px; display: block; }

.copy-btn { border: 0; background: none; padding: 0 2px; margin-left: 2px; cursor: pointer; color: #8a939c; vertical-align: -2px; line-height: 1; font-size: 12px; }
.copy-btn:hover { color: #128c7e; }
.copy-btn.copied { color: #128c7e; }

.visit-link { display: block; color: inherit; text-decoration: none; }
.visit-link:hover { color: #128c7e; text-decoration: underline; }

/* голосовые */
.voice { min-width: 300px; max-width: 460px; }
.vp { display: flex; align-items: center; gap: 10px; }
.vp-play { width: 44px; height: 44px; flex: none; border-radius: 50%; border: 0; background: #ececec; color: #555; display: grid; place-items: center; cursor: pointer; padding: 0; }
.vp-play:hover, .vp-play.on { background: #dde9e6; color: #128c7e; }
.vp-main { flex: 1; min-width: 120px; display: flex; flex-direction: column; gap: 2px; }
.vp-bar { width: 100%; height: 4px; margin: 6px 0 2px; accent-color: #556270; cursor: pointer; }
.vp-time { font-size: 12px; color: #128c7e; }
.vp-ico { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border: 0; background: none; color: #6b7480; cursor: pointer; padding: 0; border-radius: 8px; text-decoration: none; }
.vp-ico:hover, .vp-ico.on { background: #f0f2f4; color: #128c7e; }
.tr-box { margin-top: 8px; padding: 10px 12px; background: #eef0f2; border-radius: 10px; }
.tr-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: #6b7480; margin-bottom: 4px; }
.tr-head .copy-btn { font-size: 14px; }
.tr-text { font-size: 14px; white-space: pre-wrap; line-height: 1.4; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* панель над списком чатов */
.list-tools { display: flex; justify-content: flex-end; gap: 2px; }
.list-tools button { width: 30px; height: 30px; padding: 0; border: 0; background: none; border-radius: 8px; display: grid; place-items: center; color: #6b7480; cursor: pointer; }
.list-tools button:hover { background: #f0f2f4; color: #1d2329; }
.list-tools button.on { background: var(--accent-soft, #e3f3ef); color: var(--accent, #128c7e); }
.list-tools svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.list-tools button.busy svg { animation: spin 1s linear infinite; }
.list-sep { font-size: 11px; text-transform: uppercase; color: #8a939c; cursor: default !important; padding: 10px 12px 4px !important; background: none !important; }
.soft-toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: #1d2329; color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 13px; opacity: 0; transition: .2s; pointer-events: none; z-index: 50; }
.soft-toast.show { opacity: 1; transform: translateX(-50%); }
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.3); display: grid; place-items: center; z-index: 40; }
.modal { background: #fff; border-radius: 12px; padding: 18px 20px; width: 360px; display: grid; gap: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.modal h3 { margin: 0 0 4px; font-size: 16px; }
.modal label { display: grid; gap: 4px; font-size: 13px; color: #555; }
.modal .row { display: flex; gap: 8px; margin-top: 4px; }

.list-tools button { position: relative; }
.tool-badge { position: absolute; top: -3px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: #e5484d; color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; }

.check-btn { width: 34px; height: 34px; border-radius: 50%; border: 0; padding: 0; display: grid; place-items: center; cursor: pointer; }
.check-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.check-btn.need { background: #ffe9a8; color: #c2410c; }
.check-btn.need:hover { background: #ffdb70; }
.check-btn.done { background: #e3f3ef; color: #128c7e; cursor: default; }


/* ===== Размеры и шрифты как в WhatsApp Web ===== */
:root {
  --text: #0a0a0a;
  --muted: rgba(0, 0, 0, .6);
  --out: #d9fdd3;
  --in: #ffffff;
  --agent: #e2f1ff;
  --chat-bg: #f5f1eb;
  font-family: "Roboto Variable", Roboto, "Segoe UI", "Helvetica Neue", Helvetica, sans-serif;
}
.chats-view { grid-template-columns: minmax(340px, 30%) 1fr 360px; }

/* левая панель */
.chat-list-head { padding: 10px 10px 8px; border-bottom: 0; gap: 10px; }
#search { height: 40px; border: 0; border-radius: 1000px; background: rgba(194, 189, 184, .15); padding: 0 16px; font-size: 14px; line-height: 20px; letter-spacing: .16px; }
#search:focus { outline: 2px solid var(--accent); background: #fff; }
.filters { gap: 8px; }
.chip { height: 32px; padding: 0 12px; font-size: 14px; font-weight: 500; border-radius: 9999px; border: 1px solid rgba(0, 0, 0, .2); background: transparent; color: rgba(0, 0, 0, .6); }
.chip.active { background: #d9fdd3; color: #15603e; border-color: rgba(0, 0, 0, .2); font-weight: 600; }
#conversations { padding: 0 10px; }
#conversations li { display: flex; align-items: center; gap: 0; height: 72px; padding: 0 0 0 13px; border: 0; border-radius: 10px; }
#conversations li:hover { background: #f5f5f5; }
#conversations li.active { background: #f0f0f0; }
#conversations li.list-sep { height: auto; }
.av { position: relative; width: 48px; height: 48px; flex: none; border-radius: 50%; color: #fff; display: grid; place-items: center; font-size: 17px; font-weight: 500; margin-right: 13px; }
.av.sm { width: 40px; height: 40px; font-size: 15px; margin-right: 0; }
.av-chan { position: absolute; right: -2px; bottom: -2px; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; }
.av-chan.wa { background: #25d366; }
.av-chan.ig { background: linear-gradient(45deg, #f09433, #dc2743, #bc1888); }
.c-body { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: center; padding-right: 15px; border-bottom: 1px solid #e9edef; }
#conversations li:hover .c-body, #conversations li.active .c-body { border-bottom-color: transparent; }
.c-top, .c-bottom { display: flex; align-items: center; gap: 6px; min-width: 0; }
.c-name { flex: 1; min-width: 0; font-size: 16px; line-height: 24px; font-weight: 400; color: #0a0a0a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-time { flex: none; font-size: 12px; line-height: 16px; color: rgba(0, 0, 0, .6); }
li.has-unread .c-time { color: #1daa61; font-weight: 500; }
.c-last { flex: 1; min-width: 0; font-size: 14px; line-height: 20px; color: rgba(0, 0, 0, .6); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-flags { flex: none; }
.unread { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: #25d366; color: #fff; font-size: 12px; font-weight: 600; line-height: 20px; text-align: center; }

/* окно чата */
.chat { background: var(--chat-bg); }
.chat-head { height: 64px; padding: 0 16px; gap: 12px; border-bottom: 0; box-shadow: 0 1px 0 rgba(0, 0, 0, .06); }
.head-text { min-width: 0; }
.chat-head .title { font-size: 16px; line-height: 21px; font-weight: 400; }
.chat-head .muted.small { font-size: 13px; line-height: 20px; }
.messages { padding: 12px 57px 12px 62px; gap: 2px; }
.msg { max-width: 65%; padding: 6px 7px 8px 9px; border-radius: 7.5px; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); font-size: 14.2px; line-height: 19px; margin-top: 10px; }
.msg.incoming { border-top-left-radius: 0; }
.msg.outgoing { border-top-right-radius: 0; }
.msg.incoming + .msg.incoming, .msg.outgoing + .msg.outgoing { margin-top: 2px; border-radius: 7.5px; }
.msg .meta { font-size: 11px; line-height: 15px; color: rgba(0, 0, 0, .45); margin-top: 2px; }
.older-wrap { margin: 8px 0; }
.composer { background: transparent; border-top: 0; padding: 0 12px 12px; align-items: flex-end; }
.composer textarea { min-height: 52px; max-height: 160px; border: 0; border-radius: 26px; padding: 15px 20px; font-size: 15px; line-height: 22px; resize: none; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); }
.composer textarea:focus { outline: none; }
.composer button.primary { height: 52px; border-radius: 26px; padding: 0 22px; }

/* перетаскиваемая граница левой панели */
.chats-view { grid-template-columns: var(--list-w, minmax(340px, 30%)) 1fr 360px; }
.chat-list { position: relative; }
.list-resizer { position: absolute; top: 0; right: -4px; width: 8px; height: 100%; cursor: col-resize; z-index: 5; }
.list-resizer::after { content: ""; position: absolute; left: 3px; top: 0; width: 2px; height: 100%; background: transparent; transition: background .15s; }
.list-resizer:hover::after, body.resizing .list-resizer::after { background: var(--accent); }
body.resizing { cursor: col-resize; user-select: none; }

/* правая панель: две части */
.side { display: flex; flex-direction: column; padding: 0; gap: 0; overflow: hidden; }
.side-top { flex: 1 1 50%; min-height: 0; overflow-y: auto; padding: 14px; display: grid; gap: 16px; align-content: start; }
.side-bottom { flex: 1 1 50%; min-height: 0; display: flex; flex-direction: column; border-top: 1px solid var(--line); padding: 12px 14px 10px; background: #fafafa; }
.hist-head { display: flex; justify-content: space-between; align-items: baseline; }
.hist-head h4, .side-bottom > h4 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.hist-list { flex: 1; min-height: 0; overflow-y: auto; }
.pager { display: flex; justify-content: center; align-items: center; gap: 4px; padding-top: 8px; flex-wrap: wrap; }
.pg { min-width: 30px; height: 30px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 13px; }
.pg.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.pg:disabled { opacity: .35; }
.pg-gap { color: var(--muted); padding: 0 2px; }
.side-bottom { flex: 0 0 auto; max-height: 64%; }
.side-bottom .visit { margin-top: 6px; padding: 6px 10px; }

/* закреплённые чаты и меню по правой кнопке */
.pin-ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; transform: rotate(45deg); }
.pinned { color: rgba(0, 0, 0, .45); display: inline-flex; }
.ctx-menu { position: fixed; z-index: 60; min-width: 210px; background: #fff; border-radius: 10px; padding: 6px 0; box-shadow: 0 2px 5px rgba(11,20,26,.26), 0 2px 10px rgba(11,20,26,.16); }
.ctx-menu button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; border-radius: 0; background: none; padding: 9px 18px; text-align: left; font-size: 14.5px; color: #0a0a0a; }
.ctx-menu button:hover { background: #f5f5f5; }
.ctx-menu .pin-ico { color: rgba(0,0,0,.6); }

.usage-t { width: 100%; border-collapse: collapse; font-size: 13px; }
.usage-t td { padding: 5px 4px; border-bottom: 1px solid var(--line); }
.usage-t td:last-child { text-align: right; white-space: nowrap; }

/* кнопки журнала любимых филиалов */
.fav-branches { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.branch-btn { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 14px; border: 1px solid var(--line); background: #fff; color: var(--text); font-size: 13px; text-decoration: none; }
.branch-btn.main { background: #d9fdd3; border-color: #b5e8ad; color: #15603e; font-weight: 600; }
.branch-btn:hover { filter: brightness(.96); }

/* поле ввода как в WhatsApp: одна полоса, круглая зелёная кнопка со стрелкой */
.composer { margin: 0 12px 12px; padding: 5px 5px 5px 8px; background: #fff; border-radius: 28px; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); align-items: flex-end; gap: 6px; }
.composer textarea { flex: 1; min-height: 42px; box-shadow: none; background: transparent; padding: 10px 12px; border-radius: 0; }
.send-btn { flex: none; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 50%; background: #25d366; color: #fff; display: grid; place-items: center; cursor: pointer; transition: background .15s, transform .1s; }
.send-btn svg { margin-left: 3px; }
.send-btn:hover { background: #1fb855; }
.send-btn:active { transform: scale(.94); }
.send-btn:disabled { background: #b5e8c7; cursor: default; }

/* поле в одну строку, растёт по мере набора; кнопка по центру однострочного поля */
.composer textarea { field-sizing: content; height: auto; min-height: 42px; max-height: 160px; padding: 10px 12px; line-height: 22px; box-sizing: border-box; overflow-y: auto; }

/* фото и видео: превью в чате и окно просмотра */
.media-open { display: block; position: relative; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 8px; overflow: hidden; }
.media-open.video { cursor: pointer; }
.media-open .play-ico { position: absolute; inset: 0; margin: auto; width: 52px; height: 52px; border-radius: 50%; background: rgba(0,0,0,.5); color: #fff; display: grid; place-items: center; font-size: 20px; padding-left: 4px; box-sizing: border-box; pointer-events: none; }
.media-viewer { position: fixed; inset: 0; z-index: 100; background: rgba(11, 20, 26, .88); display: flex; flex-direction: column; animation: mvIn .15s ease-out; }
@keyframes mvIn { from { opacity: 0; } }
.mv-bar { display: flex; align-items: center; gap: 10px; padding: 14px 18px; }
.mv-title { flex: 1; color: #fff; font-size: 15px; }
.mv-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.5); background: transparent; color: #fff; cursor: pointer; padding: 0; text-decoration: none; }
.mv-btn:hover { background: rgba(255,255,255,.12); }
.mv-close { background: #fff; color: #111; border-color: #fff; }
.mv-close:hover { background: #e9e9e9; }
.mv-body { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 24px 24px; }
.mv-body img, .mv-body video { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.4); background: #000; }

/* Telegram */
.chan.tg { background: #2aabee; }
.av-chan.tg { background: #2aabee; }
.tg-steps { margin: 8px 0 0; padding-left: 20px; font-size: 13px; line-height: 1.6; }
.tg-conn { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; margin-top: 6px; font-size: 14px; }
.tg-dot { width: 9px; height: 9px; border-radius: 50%; background: #bbb; flex: none; }
.tg-dot.on { background: #25d366; }
