/* ===== Tokens ===== */
:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f2f4f7; --surface-3: #e9ecf1;
  --border: #e3e6eb; --border-strong: #cfd4dc;
  --text: #111827; --text-2: #4b5563; --muted: #6b7280; --subtle: #9ca3af;
  --primary: #2459e6; --primary-hover: #1d4ccc; --primary-soft: #eaf0ff; --primary-text: #1d47b8;
  --success: #13895a; --success-soft: #e5f6ee; --warning: #b45309; --warning-soft: #fdf3e2;
  --danger: #d1372e; --danger-soft: #fdecea; --hot: #e5560f; --hot-soft: #fff0e6;
  --violet: #6d4ee0; --violet-soft: #f0ecff;
  --bubble-in: #ffffff; --bubble-out: #2459e6; --bubble-ai: #eef2fb;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, .25), 0 4px 10px rgba(16, 24, 40, .06);
  --radius: 10px; --radius-sm: 7px; --radius-lg: 14px;
  --sidebar: 236px;
  --font: Inter, ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --surface: #151a22; --surface-2: #1b212b; --surface-3: #242b37;
    --border: #262d39; --border-strong: #353e4d;
    --text: #eef1f5; --text-2: #c3c9d3; --muted: #8f98a8; --subtle: #687284;
    --primary: #4c7dff; --primary-hover: #6690ff; --primary-soft: #1a2643; --primary-text: #8fb0ff;
    --success: #3ccf8e; --success-soft: #11291f; --warning: #f5b347; --warning-soft: #2c2312;
    --danger: #ff6b61; --danger-soft: #331715; --hot: #ff8a4c; --hot-soft: #33200f;
    --violet: #a48bff; --violet-soft: #241d3d;
    --bubble-in: #1b212b; --bubble-out: #3b6cf0; --bubble-ai: #1d2638;
    --shadow-sm: none; --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --surface: #151a22; --surface-2: #1b212b; --surface-3: #242b37;
  --border: #262d39; --border-strong: #353e4d;
  --text: #eef1f5; --text-2: #c3c9d3; --muted: #8f98a8; --subtle: #687284;
  --primary: #4c7dff; --primary-hover: #6690ff; --primary-soft: #1a2643; --primary-text: #8fb0ff;
  --success: #3ccf8e; --success-soft: #11291f; --warning: #f5b347; --warning-soft: #2c2312;
  --danger: #ff6b61; --danger-soft: #331715; --hot: #ff8a4c; --hot-soft: #33200f;
  --violet: #a48bff; --violet-soft: #241d3d;
  --bubble-in: #1b212b; --bubble-out: #3b6cf0; --bubble-ai: #1d2638;
  --shadow-sm: none; --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

/* ===== Base ===== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 20px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
p { margin: 0; }
code { font: 12.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2);
  padding: 1px 5px; border-radius: 5px; }
::selection { background: var(--primary-soft); }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 15px; height: 15px; } .icon.lg { width: 22px; height: 22px; }
.muted { color: var(--muted); } .subtle { color: var(--subtle); } .small { font-size: 12.5px; }
.nowrap { white-space: nowrap; } .ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grow { flex: 1; min-width: 0; } .hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 8px; } .row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack > .segmented { align-self: flex-start; }
.between { justify-content: space-between; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ===== Layout ===== */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; height: 100vh; height: 100dvh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column;
  min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--primary); display: grid;
  place-items: center; color: #fff; flex: none; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -.02em; }
.brand-sub { font-size: 11.5px; color: var(--muted); margin-top: -2px; }
.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 1px; overflow-y: auto; flex: 1; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--subtle);
  padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; text-decoration: none; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary-text); }
.nav a .count { margin-left: auto; font-size: 11.5px; font-weight: 600; background: var(--primary); color: #fff;
  border-radius: 99px; padding: 0 7px; line-height: 19px; min-width: 20px; text-align: center; }
.nav a .count.hot { background: var(--hot); }
.nav a .count:empty { display: none; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 12px; display: flex; align-items: center; gap: 10px; }
.sidebar-foot .who { min-width: 0; flex: 1; }
.sidebar-foot .who b { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.sidebar-foot .who span { font-size: 12px; color: var(--muted); }
.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 24px;
  border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar h1 { font-size: 17px; }
.topbar .crumb { color: var(--muted); font-size: 13px; }
.topbar .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.btn.menu-btn { display: none; }
.page { flex: 1; min-height: 0; overflow-y: auto; }
.page-inner { padding: 24px; max-width: 1240px; margin: 0 auto; }
.page.flush { overflow: hidden; display: flex; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--subtle); display: inline-block; }
.live-dot.on { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }

/* ===== Controls ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: 500 13.5px/1 var(--font); cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background .12s, border-color .12s, color .12s; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.icon-only { width: 36px; padding: 0; } .btn.sm.icon-only { width: 30px; }
.btn .spinner { width: 14px; height: 14px; }
.back-btn { display: none; }
.input, .select, .textarea { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: 14px var(--font);
  transition: border-color .12s, box-shadow .12s; }
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 84px; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft); }
.input::placeholder, .textarea::placeholder { color: var(--subtle); }
.select { appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a93a3' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
.select.sm, .input.sm { height: 32px; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field .hint { font-size: 12.5px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.search { position: relative; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--subtle); }
.search .input { padding-left: 34px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 36px; height: 20px; border-radius: 99px; background: var(--border-strong); position: relative;
  transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
  padding: 3px; gap: 2px; }
.segmented button { border: 0; background: none; color: var(--text-2); font: 500 13px var(--font); padding: 5px 10px;
  border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented button .n { font-size: 11.5px; color: var(--muted); font-weight: 600; }

/* ===== Surfaces ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 15px; } .card-head .actions { margin-left: auto; display: flex; gap: 8px; }
.card-body { padding: 20px; }
.card-body.tight { padding: 8px; }
.section-title { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }  /* карточки по своей высоте, без растягивания под соседа */
.grid-2 > * { min-width: 0; }  /* чтобы широкие таблицы скроллились внутри карточки, а не распирали страницу */
@media (max-width: 920px) { .grid-2 { grid-template-columns: 1fr; } }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi { padding: 18px 20px; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 7px; }
.kpi .value { font-size: 28px; font-weight: 650; letter-spacing: -.02em; margin-top: 6px; line-height: 1.1; }
.kpi .sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.kpi .value.hot { color: var(--hot); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 8px; }
.bars .bar { flex: 1; background: var(--primary-soft); border-radius: 5px 5px 2px 2px; position: relative; min-height: 3px;
  transition: background .12s; }
.bars .bar:hover { background: var(--primary); }
.bars .bar .tip { display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--surface); font-size: 12px; padding: 3px 7px; border-radius: 5px; white-space: nowrap; }
.bars .bar:hover .tip { display: block; }
.bar-labels { display: flex; gap: 6px; margin-top: 6px; } .bar-labels span { flex: 1; text-align: center; font-size: 11px; color: var(--subtle); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; text-decoration: none; color: inherit; }
.list-row:hover { background: var(--surface-2); text-decoration: none; }
.status-line { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--border); }
.status-line:last-child { border-bottom: 0; }

/* ===== Badges, avatars ===== */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px;
  font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--text-2); white-space: nowrap;
  border: 1px solid transparent; }
.badge.blue { background: var(--primary-soft); color: var(--primary-text); }
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.amber { background: var(--warning-soft); color: var(--warning); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.hot { background: var(--hot-soft); color: var(--hot); }
.badge.violet { background: var(--violet-soft); color: var(--violet); }
.badge.outline { background: transparent; border-color: var(--border-strong); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-weight: 600; font-size: 13px; color: #fff; letter-spacing: .02em; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; } .avatar.lg { width: 56px; height: 56px; font-size: 19px; }
.unread-pill { background: var(--primary); color: #fff; font-size: 11px; font-weight: 600; border-radius: 99px;
  min-width: 19px; height: 19px; padding: 0 6px; display: inline-grid; place-items: center; }

/* ===== Table ===== */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

/* ===== Inbox ===== */
.inbox { display: grid; grid-template-columns: 360px 1fr 300px; flex: 1; min-height: 0; width: 100%; }
.inbox.no-client { grid-template-columns: 360px 1fr; }
.pane { min-height: 0; display: flex; flex-direction: column; background: var(--surface); }
.pane + .pane { border-left: 1px solid var(--border); }
.pane-head { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.tabs-scroll { overflow-x: auto; scrollbar-width: none; } .tabs-scroll::-webkit-scrollbar { display: none; }
.lead-list { overflow-y: auto; flex: 1; }
.lead-item { display: flex; gap: 11px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer;
  position: relative; text-decoration: none; color: inherit; }
.lead-item:hover { background: var(--surface-2); text-decoration: none; }
.lead-item.active { background: var(--primary-soft); }
.lead-item.active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--primary); }
.lead-item .top { display: flex; align-items: center; gap: 6px; }
.lead-item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-item.unread .name { color: var(--text); }
.lead-item .time { margin-left: auto; font-size: 12px; color: var(--subtle); white-space: nowrap; }
.lead-item .snippet { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.lead-item.unread .snippet { color: var(--text-2); font-weight: 500; }
.lead-item .meta { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.conv { flex: 1; min-width: 0; }
.conv-head { height: 60px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 18px;
  border-bottom: 1px solid var(--border); }
.conv-head .title { min-width: 0; overflow: hidden; }
.conv-head .title b { display: block; font-size: 14.5px; }
.conv-head .title span { display: block; font-size: 12.5px; color: var(--muted); }
.conv-head .actions { margin-left: auto; display: flex; gap: 6px; flex: none; }
.messages { flex: 1; overflow-y: auto; padding: 20px 22px; display: flex; flex-direction: column; gap: 4px;
  background: var(--bg); }
.day-sep { align-self: center; font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--border);
  border-radius: 99px; padding: 2px 10px; margin: 10px 0; }
.msg { max-width: min(72%, 560px); display: flex; flex-direction: column; margin-top: 6px; }
.msg .bubble { padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; line-height: 1.45;
  box-shadow: var(--shadow-sm); }
.msg.in { align-self: flex-start; } .msg.in .bubble { background: var(--bubble-in); border: 1px solid var(--border);
  border-bottom-left-radius: 5px; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.msg.out .bubble { background: var(--bubble-out); color: #fff; border-bottom-right-radius: 5px; }
.msg.ai .bubble { background: var(--bubble-ai); color: var(--text); border: 1px solid var(--border); }
.msg.queued .bubble { opacity: .7; border: 1px dashed rgba(255,255,255,.6); }
.msg.ai.queued .bubble { border-color: var(--border-strong); }
.msg.failed .bubble { background: var(--danger-soft); color: var(--text); border: 1px solid var(--danger); }
.msg .q-actions { display: flex; gap: 4px; margin-top: 4px; }
.msg .info { font-size: 11.5px; color: var(--subtle); margin-top: 3px; padding: 0 4px; display: flex; gap: 6px; align-items: center; }
.draft { margin: 0 18px; border: 1px solid var(--border); border-left: 3px solid var(--violet); border-radius: var(--radius);
  background: var(--surface); padding: 12px 14px; box-shadow: var(--shadow); }
.draft-wrap { padding: 12px 0 0; background: var(--bg); }
.draft .head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; white-space: nowrap; }
.draft .head b { color: var(--violet); font-weight: 600; }
.draft textarea { border: 0; background: transparent; padding: 0; min-height: 44px; max-height: 260px; resize: none; box-shadow: none !important; overflow-y: auto; }
.draft .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.composer { border-top: 1px solid var(--border); padding: 12px 18px 14px; background: var(--surface); }
.composer .box { border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
  transition: border-color .12s, box-shadow .12s; }
.composer .box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.composer textarea { border: 0; width: 100%; resize: none; background: transparent; color: var(--text);
  font: 14px/1.5 var(--font); padding: 10px 12px 4px; min-height: 44px; max-height: 200px; outline: none; }
.composer .bar { display: flex; align-items: center; gap: 8px; padding: 6px 8px 8px 10px; flex-wrap: wrap; }
.composer .hint { font-size: 12px; color: var(--subtle); }
.mode-pick { min-width: 0; }
.mode-pick .select { width: auto; max-width: 100%; }
@media (max-width: 640px) { .composer .hint { display: none; } }
.client { width: 100%; overflow-y: auto; }
.client-top { padding: 22px 18px 16px; text-align: center; border-bottom: 1px solid var(--border); }
.client-top .avatar { margin: 0 auto 10px; }
.client-top b { font-size: 15px; display: block; }
.client-section { padding: 16px 18px; border-bottom: 1px solid var(--border); }
.client-section h4 { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--subtle); margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 7px 10px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; color: var(--text); word-break: break-word; }
.quote { font-size: 13px; color: var(--text-2); background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 9px 11px; white-space: pre-wrap; }
.interest { display: flex; gap: 4px; } .interest i { height: 6px; flex: 1; border-radius: 3px; background: var(--surface-3); }
.interest.cold i:nth-child(1) { background: var(--primary); }
.interest.warm i:nth-child(-n+2) { background: var(--warning); }
.interest.hot i { background: var(--hot); }

/* ===== Chats ===== */
.inbox.chats { grid-template-columns: 320px 1fr; }
@media (min-width: 1281px) {  /* на широком экране карточку клиента можно скрыть — выбор запоминается */
  .inbox.hide-client { grid-template-columns: 360px 1fr; } .inbox.hide-client .client-pane { display: none; } }
.btn.toggled { background: var(--primary-soft); color: var(--primary-text); }
.client { position: relative; }
.client-close { position: absolute; top: 10px; right: 10px; }
.dialogs { width: 320px; flex: none; }
.dialog { display: flex; gap: 11px; padding: 11px 14px; cursor: pointer; border-bottom: 1px solid var(--border); align-items: center; position: relative; }
.dialog:hover { background: var(--surface-2); } .dialog.active { background: var(--primary-soft); }
.dialog.pinned { background: var(--surface-2); } .dialog.pinned:hover { background: var(--surface-3, var(--surface-2)); }
.pin-mark { color: var(--subtle); width: 13px; height: 13px; flex: none; margin-right: 2px; }
.dlg-acts { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: none; gap: 2px;
  background: var(--surface); border-radius: 8px; padding: 2px; box-shadow: 0 1px 6px rgba(0,0,0,.25); }
.dialog:hover .dlg-acts { display: flex; }
.dlg-acts button { border: 0; background: none; color: var(--subtle); border-radius: 6px; width: 28px; height: 28px;
  display: grid; place-items: center; cursor: pointer; }
.dlg-acts button:hover { background: var(--surface-2); color: var(--text); }
.dlg-acts button[data-del]:hover { color: var(--danger); }
.dialog.special { gap: 12px; }
.dialog.special .sp-ico { width: 38px; height: 38px; border-radius: 50%; background: var(--surface-2); display: grid;
  place-items: center; color: var(--muted); flex: none; }
.dialog.special .sp-ico.star { background: var(--primary-soft); color: var(--primary); }
.dialog.special b { font-size: 14px; } .dialog.special .unread-pill { margin-left: auto; }
/* ===== Профиль собеседника/группы (как в клиенте Telegram) ===== */
.chat-peer { display: flex; align-items: center; gap: 12px; min-width: 0; background: none; border: 0; cursor: pointer; color: inherit; text-align: left; padding: 0; }
.chat-peer .title { min-width: 0; } .chat-peer .title b { display: block; font-size: 14.5px; } .chat-peer .title span { font-size: 12.5px; color: var(--muted); }
.peer { margin: -4px -4px -8px; }
.peer-top { text-align: center; padding: 8px 16px 18px; border-bottom: 1px solid var(--border); }
.peer-ava { position: relative; width: 96px; height: 96px; margin: 0 auto 12px; }
.peer-ava .avatar.xl, .peer-ava .ava-wrap.xl { width: 96px; height: 96px; font-size: 34px; }
.ava-wrap { position: relative; display: inline-block; line-height: 0; flex: none; }
.ava-real { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; opacity: 0; transition: opacity .2s; }
.ava-real.on { opacity: 1; }
.peer-name { font-size: 19px; font-weight: 650; } .peer-status { color: var(--muted); font-size: 13px; margin-top: 3px; }
.peer-section { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.peer-section h4 { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--subtle); margin-bottom: 10px; }
.peer-row { display: flex; gap: 13px; align-items: flex-start; padding: 7px 0; }
.peer-row .icon { color: var(--subtle); margin-top: 2px; flex: none; }
.peer-val { font-size: 14px; word-break: break-word; } .peer-val.accent { color: var(--primary); }
.peer-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.peer-stat { display: flex; gap: 11px; align-items: center; padding: 7px 0; font-size: 13.5px; }
.peer-stat .icon { color: var(--subtle); flex: none; } .peer-stat b { font-weight: 600; }
.peer-members { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; }
.peer-member { display: flex; gap: 10px; align-items: center; padding: 6px 0; }
.peer-member .grow { min-width: 0; } .peer-member b { font-size: 13.5px; display: block; }
.peer-actions { display: flex; flex-wrap: wrap; gap: 8px; border-bottom: 0; }
@media (max-width: 520px) { .peer-stats { grid-template-columns: 1fr; } }

/* ===== Empty, loaders ===== */
.empty { text-align: center; padding: 56px 24px; color: var(--muted); }
.empty .ico { width: 52px; height: 52px; border-radius: 14px; background: var(--surface-2); display: grid; place-items: center;
  margin: 0 auto 14px; color: var(--subtle); }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.empty p { max-width: 380px; margin: 0 auto; font-size: 13.5px; }
.empty .btn { margin-top: 16px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite; display: inline-block; opacity: .8; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: grid; place-items: center; padding: 48px; color: var(--subtle); }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%;
  animation: shimmer 1.2s infinite; border-radius: 6px; height: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius);
  background: var(--warning-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent); }
.banner.info { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 25%, transparent); }
.banner .icon { color: var(--warning); margin-top: 1px; } .banner.info .icon { color: var(--primary); }

/* ===== Modal, toast ===== */
.overlay { position: fixed; inset: 0; background: rgba(13, 17, 23, .5); display: grid; place-items: center; z-index: 50;
  padding: 16px; animation: fade .12s ease-out; backdrop-filter: blur(2px); }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%;
  max-width: 520px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column; animation: pop .16s ease-out; }
.modal.wide { max-width: 680px; }
.modal-head { padding: 18px 22px 0; display: flex; align-items: flex-start; gap: 12px; }
.modal-head h2 { font-size: 17px; } .modal-head p { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.modal-head .close { margin-left: auto; margin-top: -4px; margin-right: -8px; }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px 18px; display: flex; justify-content: flex-end; gap: 8px; }
@keyframes fade { from { opacity: 0; } } @keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 60;
  max-width: calc(100vw - 40px); }
.toast { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); border-radius: var(--radius);
  padding: 12px 14px; display: flex; gap: 11px; align-items: flex-start; width: 360px; max-width: 100%;
  animation: pop .18s ease-out; cursor: default; }
.toast.clickable { cursor: pointer; }
.toast .icon { margin-top: 1px; } .toast.ok .icon { color: var(--success); } .toast.err .icon { color: var(--danger); }
.toast.lead .icon { color: var(--primary); } .toast.hot .icon { color: var(--hot); }
.toast b { display: block; font-size: 13.5px; } .toast span { font-size: 13px; color: var(--muted); display: block; }
.copy-box { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 8px 8px 12px; font: 13px ui-monospace, Menlo, monospace; word-break: break-all; }
.creds { display: grid; grid-template-columns: 90px 1fr; gap: 8px 12px; align-items: center; }

/* ===== Account cards ===== */
/* аккаунты — строки (компактный список вместо плиток) */
.acc-list { display: flex; flex-direction: column; gap: 10px; }
.acc-row { display: flex; align-items: center; gap: 14px; padding: 12px 16px; flex-wrap: nowrap; }
.acc-main { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1 1 240px; }
.acc-main .avatar, .acc-main .acc-av { flex: none; }
.acc-id { min-width: 0; } .acc-id b { display: block; font-size: 14px; } .acc-id .small { display: block; }
.acc-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; flex: 0 1 auto; justify-content: flex-end; }
.acc-acts { display: flex; gap: 5px; align-items: center; flex: none; }
@media (max-width: 860px) { .acc-row { flex-wrap: wrap; } .acc-meta { justify-content: flex-start; } .acc-acts { width: 100%; } }

/* ===== Media in messages ===== */
.msg .bubble:has(.media) { padding: 5px; }
.msg .bubble:has(.media) .media-text, .msg .bubble:has(.media) .media-caption { padding: 4px 8px 3px; }
.media img, .media video { display: block; border-radius: 10px; }
.media-img { max-width: min(320px, 100%); max-height: 380px; object-fit: cover; cursor: zoom-in; background: var(--surface-2); min-width: 80px; min-height: 60px; }
.media-video { max-width: min(360px, 100%); max-height: 400px; background: #000; }
.media-round { width: 200px; height: 200px; border-radius: 50% !important; object-fit: cover; background: #000; }
.media-sticker { width: 140px; height: 140px; object-fit: contain; }
.media-emoji { font-size: 48px; line-height: 1.1; padding: 4px 8px; display: inline-block; }
.media-audio { display: flex; align-items: center; gap: 8px; padding: 4px 6px; }
.media-audio audio { height: 36px; max-width: 260px; }
.media-audio span { font-size: 12px; opacity: .75; }
.media-file { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; min-width: 220px; max-width: 320px;
  background: rgba(127, 127, 127, .12); color: inherit; text-decoration: none; }
.media-file:hover { background: rgba(127, 127, 127, .2); text-decoration: none; }
.media-file .grow { display: flex; flex-direction: column; min-width: 0; }
.media-file .small { opacity: .75; }
.media-meta { font-size: 12px; opacity: .75; padding: 4px 6px 0; }
.media-meta a { color: inherit; text-decoration: underline; }
.media-missing { font-size: 12.5px; opacity: .7; padding: 10px 12px; border: 1px dashed currentColor; border-radius: 9px; }
.media-caption { font-size: 12.5px; opacity: .78; font-style: italic; white-space: pre-wrap; }
.msg.out .media-file { background: rgba(255, 255, 255, .16); }
.lightbox { flex-direction: column; gap: 12px; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .85); cursor: zoom-out; }
.lightbox img { max-width: 94vw; max-height: 86vh; border-radius: 8px; box-shadow: var(--shadow-lg); }

/* ===== Deals board ===== */
.dl-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.dl-q { flex: 1 1 220px; max-width: 340px; }
.dl-bar .select { width: auto; min-width: 170px; max-width: 250px; flex: 0 1 auto; }
.dl-bar .segmented { flex: none; }
.dl-check { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.dl-sum { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 13px; color: var(--muted); margin: 0 2px 12px; }
.dl-sum b { color: var(--text); } .dl-sum .bad b { color: var(--danger); }
.board { display: flex; gap: 12px; overflow: auto; align-items: stretch; padding-bottom: 6px; }
.board-col { flex: 0 0 260px; min-width: 0; display: flex; flex-direction: column; min-height: 0; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); transition: flex-basis .14s ease; }
.col-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px; cursor: pointer; user-select: none; flex: none; }
.col-head h3 { font-size: 13px; display: flex; align-items: center; gap: 6px; margin: 0; }
.col-head .sum { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
.col-body { padding: 0 8px 8px; overflow-y: auto; overflow-x: hidden; flex: 1; min-height: 0; min-width: 0; }
.col-empty { color: var(--subtle); font-size: 12.5px; text-align: center; padding: 18px 0; }
.board-col.collapsed { flex-basis: 44px; }
.board-col.collapsed .col-head { flex-direction: column; padding: 10px 0; gap: 10px; align-items: center; }
.board-col.collapsed .col-head h3 { flex-direction: column-reverse; gap: 10px; }
.board-col.collapsed .col-name { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; color: var(--text-2); }
.board-col.collapsed .sum, .board-col.collapsed .col-body { display: none; }
.board-col.collapsed.peek { flex-basis: 230px; }
.board-col.collapsed.peek .col-head { flex-direction: row; padding: 10px 12px; }
.board-col.collapsed.peek .col-head h3 { flex-direction: row; }
.board-col.collapsed.peek .col-name { writing-mode: horizontal-tb; transform: none; }
.board-col.collapsed.peek .col-body { display: block; }
.board-col.collapsed.peek .col-body::before { content: 'Перетащите сюда'; display: block; color: var(--subtle); font-size: 12.5px; text-align: center; padding: 14px 0; }
.deal { position: relative; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--border); border-radius: var(--radius);
  padding: 7px 10px 8px 10px; margin-bottom: 6px; box-shadow: var(--shadow-sm); cursor: pointer; }
.deal:hover { border-color: var(--primary); } .deal:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.deal.t-hot { border-left-color: var(--hot); } .deal.t-warm { border-left-color: var(--warning); } .deal.t-cold { border-left-color: var(--subtle); }
.deal-l1 { display: flex; align-items: center; gap: 6px; min-width: 0; }
.deal-l2 { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 12px; color: var(--muted); margin-top: 3px; }
.deal .amt { margin-left: auto; flex: none; color: var(--text); font-weight: 650; font-size: 12.5px; white-space: nowrap; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.deal-name { font-weight: 600; font-size: 13.5px; flex: 0 1 auto; }
.deal .moves { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.ch { flex: none; display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 6px; font-size: 10.5px; font-weight: 650;
  letter-spacing: .02em; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.ch-tg, .ch-vk { background: var(--primary-soft); color: var(--primary-text); border-color: transparent; }
.ch-instagram { background: var(--hot-soft); color: var(--hot); border-color: transparent; }
.ch-youtube { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.wait { flex: none; margin-left: auto; font-size: 11px; font-weight: 600; color: var(--warning); background: var(--warning-soft); border-radius: 99px; padding: 1px 7px; white-space: nowrap; }
.wait.bad { color: var(--danger); background: var(--danger-soft); }
.age { flex: none; font-size: 11px; color: var(--muted); white-space: nowrap; } .age.warn { color: var(--warning); font-weight: 600; } .age.bad { color: var(--danger); font-weight: 650; }
.deal-acts { position: absolute; top: 3px; right: 3px; display: none; gap: 1px; padding: 2px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow); }
.deal-acts .btn { height: 24px; min-width: 24px; padding: 0 5px; }
.deal-l3 { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.deal-l3 .cl { display: inline-flex; align-items: center; gap: 4px; } .deal-l3 .icon, .contact-line .icon { width: 12px; height: 12px; }
.rem { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--primary-text); white-space: nowrap; } .rem.bad { color: var(--danger); }
.rem .icon, .rem-row .when .icon { width: 12px; height: 12px; }
.rem-row .when { display: inline-flex; align-items: center; gap: 5px; }
.cl { white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font: 500 13px var(--font); padding: 6px 12px; border-radius: 99px; cursor: pointer; }
.chip:hover { border-color: var(--primary); } .chip.on { background: var(--primary-soft); color: var(--primary-text); border-color: var(--primary); }
.contact-line { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; } .contact-line span { display: inline-flex; align-items: center; gap: 6px; }
.dm-rem { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.dm-rem h4 { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0; }
.rem-row { display: flex; align-items: center; gap: 8px; width: 100%; font-size: 13px; } .rem-row .when { font-weight: 600; white-space: nowrap; } .rem-row.bad .when { color: var(--danger); }
.nontg-hint { display: flex; align-items: center; gap: 10px; margin: 0 16px 8px; padding: 8px 12px; border-radius: var(--radius); background: var(--warning-soft);
  color: var(--text); font-size: 13px; } .nontg-hint .icon { flex: none; color: var(--warning); }
.dl-table td.acts { width: 1%; padding-left: 4px; }
.deal:hover .deal-acts, .deal:focus-within .deal-acts { display: flex; }
@media (hover: none) { .deal-acts { display: flex; box-shadow: none; border-color: transparent; background: transparent; } .deal-l1 { padding-right: 104px; } }
.deal[draggable=true] { cursor: grab; }
.deal.drag { opacity: .45; }
.board-col.drop { outline: 2px dashed var(--primary); outline-offset: -2px; background: var(--primary-soft); }
.deal-unread { flex: none; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--primary); color: #fff;
  font-size: 11px; font-weight: 650; display: inline-flex; align-items: center; justify-content: center; }
.dm-info { margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--border); }
.dm-info h4 { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.deal-lost { color: var(--danger); font-size: 12.5px; margin: 4px 0; }
.deal.lost { opacity: .92; }
.lost { margin-top: 18px; }
.lost summary { cursor: pointer; font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 6px; padding: 6px 2px; }
.lost-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-top: 8px; }
.lost-list .deal { margin-bottom: 0; }
.deal-lost-box { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 12px;
  background: var(--danger-soft); border: 1px solid var(--danger); border-radius: var(--radius); color: var(--text); }
.deal-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.deal-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding-top: 4px; }
.stage-seg { flex-wrap: wrap; }
.dm-feed { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.dm-feed h4 { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.feed { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow: auto; margin-bottom: 10px; }
.feed-c { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; }
.feed-h { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.feed-h time { color: var(--muted); font-size: 11.5px; }
.feed-h .icon-only { margin-left: auto; }
.feed-t { white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.feed-ev { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); padding: 0 2px; }
.feed-ev time { white-space: nowrap; }
.feed-add { display: flex; gap: 8px; align-items: flex-end; }
.feed-add .textarea { flex: 1; min-height: 44px; }
.pct { display: inline-block; min-width: 42px; }
.dl-sort { display: none; align-items: center; gap: 8px; margin-bottom: 10px; }
.dl-table th { cursor: pointer; user-select: none; white-space: nowrap; } .dl-table th.sorted { color: var(--text); }
.dl-table th .arr { font-size: 9px; margin-left: 4px; }
.dl-table td { padding: 9px 12px; } .dl-table td.num { white-space: nowrap; font-weight: 600; text-align: right; }
.dl-row { cursor: pointer; } .dl-row.t-hot td:first-child { box-shadow: inset 3px 0 0 var(--hot); } .dl-row.t-warm td:first-child { box-shadow: inset 3px 0 0 var(--warning); }
.dl-row.t-cold td:first-child { box-shadow: inset 3px 0 0 var(--subtle); }
.dl-row .deal-unread { margin-left: 6px; }
@media (max-width: 860px) {
  .board { height: auto !important; }
  .board-col { flex-basis: 78vw; } .board-col.collapsed { flex-basis: 44px; } .col-body { overflow-y: visible; }
  .dl-q { max-width: none; }
  .dl-bar .select { flex: 1 1 140px; min-width: 140px; max-width: none; }
  .dl-sort { display: flex; }
  .table.dl-table thead { display: none; }
  .table.dl-table, .table.dl-table tbody, .table.dl-table tr { display: block; }
  .table.dl-table tr { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--border); border-radius: var(--radius); padding: 8px 10px; margin-bottom: 8px; }
  .table.dl-table tr.t-hot { border-left-color: var(--hot); } .table.dl-table tr.t-warm { border-left-color: var(--warning); } .table.dl-table tr.t-cold { border-left-color: var(--subtle); }
  .table.dl-table td, .table.dl-table td:nth-child(n+4) { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; border: 0; text-align: right; }
  .table.dl-table td:empty { display: none !important; }
  .table.dl-table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex: none; }
  .table.dl-table td:first-child { font-size: 14px; } .table.dl-table td:first-child::before { content: none; }
  .table.dl-table tr:hover td { background: none; }
  .dl-row.t-hot td:first-child, .dl-row.t-warm td:first-child, .dl-row.t-cold td:first-child { box-shadow: none; }
}

/* ===== Market ===== */
.lot-row { display: flex; gap: 14px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.lot-row:last-child { border-bottom: 0; }
.lot-row img, .lot-row .noimg { width: 84px; height: 62px; object-fit: cover; border-radius: 8px; background: var(--surface-2); flex: none; }
.lot-row .price { font-weight: 650; font-size: 15px; white-space: nowrap; }
.quote-total { font-size: 26px; font-weight: 650; letter-spacing: -.02em; }
@media (max-width: 860px) { .lot-row { flex-wrap: wrap; } .lot-row .price { width: 100%; } }

.health { display: flex; flex-direction: column; gap: 6px; font-size: 13px; border-top: 1px dashed var(--border); padding-top: 12px; }
.health .line { display: flex; gap: 8px; align-items: center; } .health .line > span:first-child { color: var(--muted); width: 74px; flex: none; }

/* ===== Account profile ===== */
.acc-av { position: relative; overflow: hidden; }
.acc-av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.xl { width: 112px; height: 112px; font-size: 34px; }
.profile-grid { display: grid; grid-template-columns: 150px 1fr; gap: 22px; }
.profile-photo { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.profile-photo .btn { width: 100%; }
.counter { font-size: 12px; color: var(--subtle); text-align: right; }
.counter.over { color: var(--danger); }
.input-prefix { position: relative; } .input-prefix span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--subtle); }
.input-prefix .input { padding-left: 26px; }
@media (max-width: 560px) { .profile-grid { grid-template-columns: 1fr; } }

/* ===== KB ===== */
.kb-item { padding: 16px 18px; border-bottom: 1px solid var(--border); }
.kb-item:last-child { border-bottom: 0; }
.kb-item .q { font-weight: 600; }
.kb-item .a { color: var(--text-2); margin-top: 4px; white-space: pre-wrap; }

/* ===== Responsive ===== */
@media (max-width: 1280px) { .inbox, .inbox.no-client { grid-template-columns: 340px 1fr; } .inbox .client-pane { display: none; }
  .inbox.show-client .client-pane { display: flex; position: fixed; right: 0; top: 0; bottom: 0; width: 320px; z-index: 30;
    box-shadow: var(--shadow-lg); } }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; z-index: 40; transform: translateX(-100%);
    transition: transform .2s; box-shadow: var(--shadow-lg); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 35; }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 0 12px; } .page-inner { padding: 16px; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .inbox { grid-template-columns: 1fr; } .inbox .conv { display: none; }
  .inbox.has-lead .list-pane { display: none; } .inbox.has-lead .conv { display: flex; }
  .inbox.chats { grid-template-columns: 1fr; }
  .dialogs { width: 100%; } .chats.has-chat .dialogs { display: none; } .chats.has-chat .conv { display: flex; }
  .msg { max-width: 88%; } .messages { padding: 14px; } .conv-head { padding: 0 10px; }
  .composer { padding: 10px; } .draft { margin: 0 10px; } .draft .head .opt { display: none; } .draft textarea { max-height: 150px; }
  .back-btn { display: inline-flex !important; }
  .toasts { right: 12px; left: 12px; bottom: 12px; } .toast { width: 100%; }
  .table th:nth-child(n+4), .table td:nth-child(n+4) { display: none; }
  .table td.keep, .table th.keep { display: table-cell !important; }
}
@media (max-width: 520px) { .kpis { grid-template-columns: 1fr 1fr; gap: 10px; } .kpi { padding: 14px; } .kpi .value { font-size: 23px; }
  .topbar .actions .btn span.label { display: none; }
  #dl-view button { padding: 5px 8px; font-size: 12.5px; } .topbar:has(#dl-view) #crumb { display: none; } }
/* ===== Медиатека: пул аватарок ===== */
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 12px; }
.av-cell { position: relative; aspect-ratio: 1; }
.av-cell img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); }
.av-del { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0;
  background: var(--danger); color: #fff; display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity .12s; }
.av-cell:hover .av-del { opacity: 1; }
.av-cell img { cursor: zoom-in; }
.note-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--border); }
.note-row .grow { min-width: 0; }
.mb-8 { margin-bottom: 8px; }

/* ===== Вложение в композере (фото, видео, документ) ===== */
.attach-chip { display: flex; flex-direction: column; gap: 6px; margin: 10px 10px 0; max-height: 220px; overflow-y: auto; }
.attach-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-2); }
.media-album { display: flex; flex-wrap: wrap; gap: 6px; } .media-album > * { max-width: min(220px, 100%); }
.attach-item img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; flex: none; }
.attach-item .ico { width: 44px; height: 44px; border-radius: 8px; background: var(--surface); display: grid; place-items: center;
  color: var(--muted); flex: none; }
.attach-item .grow { display: flex; flex-direction: column; min-width: 0; }
.composer .box.drop { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* ===== Расчёт авто из Кыргызстана: построчная разбивка ===== */
.kg-lines { margin-top: 12px; border-top: 1px solid var(--border); }
.kg-line { display: flex; gap: 14px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--border); }
.kg-line .grow { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.kg-sum { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.kg-total { border-bottom: 0; } .kg-total .kg-sum { font-size: 17px; }

.client-msg { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.client-msg .textarea { width: 100%; resize: vertical; }

.verdict-box { background: var(--surface-2); }

.acc-pick { max-width: 210px; text-overflow: ellipsis; }
.acc-pick.flash { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

@media (max-width: 700px) { .hit-row { flex-wrap: wrap; } .hit-row > .grow { flex: 1 1 calc(100% - 48px); } .hit-row .hit-acts { width: 100%; padding-left: 42px; } }

/* мониторинг: лента совпадений карточками и правила по аккаунтам */
.hits-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; align-items: start; }
.hit-card { border: 1px solid var(--border); border-left: 3px solid var(--border-strong); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.hit-card.v-lead { border-left-color: var(--success); } .hit-card.v-maybe { border-left-color: var(--warning); } .hit-card.v-not_lead { opacity: .72; }
.hit-top { display: flex; gap: 10px; align-items: center; } .hit-who { display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; }
.hit-text { white-space: pre-wrap; word-break: break-word; font-size: 14px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.hit-text.open { -webkit-line-clamp: unset; display: block; }
.hit-reason { display: flex; gap: 6px; align-items: flex-start; font-size: 12.5px; color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 7px 9px; }
.hit-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.rules-card > summary { list-style: none; cursor: pointer; } .rules-card > summary::-webkit-details-marker { display: none; }
.rule-acc { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.rule-acc-h { display: flex; gap: 10px; align-items: baseline; padding: 9px 14px; background: var(--surface-2); }
.rule-row { display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.rule-where { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 2px; }
.chip-s { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; font-size: 12.5px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 700px) { .hits-grid { grid-template-columns: 1fr; } .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
#hit-f { max-width: 100%; overflow-x: auto; }
@media (max-width: 700px) { #mon .card-head { flex-wrap: wrap; row-gap: 8px; } #hit-f { order: 3; width: 100%; } #hit-f button { flex: 1; white-space: nowrap; } }

/* активность аккаунтов */
.act-row { border: 1px solid var(--border); border-left: 3px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.act-row.lv-ok { border-left-color: var(--success); } .act-row.lv-warn { border-left-color: var(--warning); } .act-row.lv-err { border-left-color: var(--danger); }
.act-row > summary { list-style: none; cursor: pointer; padding: 11px 14px; display: flex; flex-direction: column; gap: 6px; } .act-row > summary::-webkit-details-marker { display: none; }
.act-main { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } .act-diag { font-size: 13.5px; line-height: 1.4; }
.act-stats { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); } .act-stats b { color: var(--text); } .act-stats .bad b { color: var(--danger); }
.act-detail { border-top: 1px solid var(--border); padding: 10px 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.act-events { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow: auto; }
.act-ev { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 13px; } .act-ev.bad span:last-child { color: var(--danger); }
