﻿:root {
  --coral: #E85D2A;
  --coral-deep: #C94A1F;
  --gold: #F0C040;
  --sky: #5BA3D9;
  --deep-blue: #1E4D8C;
  --ink: #1a2a3a;
  --muted: #5a6b7c;
  --line: rgba(30,77,140,.14);
  --paper: #fff;
  --soft: #eef4f9;
  --green: #2e7d52;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: Manrope, sans-serif; color: var(--ink);
  background: linear-gradient(160deg, #eef4f9 0%, #f7f0ea 45%, #e8f1f8 100%); }
#app { height: 100%; }
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px; box-shadow: 0 12px 40px rgba(30,77,140,.08); }
.login-card img { width: 72px; height: 72px; border-radius: 50%; display: block; margin: 0 auto 14px; }
.login-card h1 { text-align: center; margin: 0 0 6px; color: var(--deep-blue); font-size: 22px; }
.login-card p { text-align: center; color: var(--muted); margin: 0 0 18px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; font: inherit; }
.btn { appearance: none; border: 1px solid var(--deep-blue); background: var(--deep-blue); color: #fff;
  border-radius: 12px; padding: 11px 18px; font: inherit; font-weight: 600; cursor: pointer; }
.btn.coral { background: var(--coral); border-color: var(--coral); }
.btn.ghost { background: #fff; color: var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.err { color: #b42318; background: #fdecec; border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; }
.shell { height: 100%; display: grid; grid-template-columns: 220px 1fr; }
.side { background: #edf2f7; border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 6px; }
.brand { display: flex; gap: 10px; align-items: center; padding: 8px 10px 16px; }
.brand img { width: 40px; height: 40px; border-radius: 50%; }
.brand strong { display: block; color: var(--deep-blue); }
.brand span { font-size: 12px; color: var(--muted); }
.nav-btn { text-align: left; border: 0; background: transparent; border-radius: 12px; padding: 12px 14px;
  font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.nav-btn.on { background: #fff; color: var(--ink); border: 1px solid var(--line); border-left: 3px solid var(--coral); }
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 20px; background: rgba(255,255,255,.7); border-bottom: 1px solid var(--line); }
.content { flex: 1; overflow: auto; padding: 20px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 14px; }
.card h2 { margin: 0 0 8px; font-size: 20px; color: var(--deep-blue); }
.dash { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 14px; }
.dash-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; position: relative; overflow: hidden; }
.dash-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--coral); }
.dash-k { font-size: 12px; color: var(--muted); text-transform: uppercase; }
.dash-v { font-size: 28px; font-weight: 700; color: var(--deep-blue); margin-top: 4px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 13.5px; vertical-align: top; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--soft); font-size: 12px; }
.monitor.on { background: var(--green); border-color: var(--green); }
.bar { height: 10px; background: #e6eef6; border-radius: 999px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--coral), var(--gold)); }
.meta { color: var(--muted); font-size: 13px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.source-row { display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: #fff; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr; }
}

.lead-keys { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }
.key-chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: rgba(30,77,140,.08); color: var(--deep-blue);
  font-size: 11px; font-weight: 600;
}
.lead-hist-badge {
  display: inline-block; padding: 1px 7px; border-radius: 999px; background: #e8f1f8;
  font-size: 11px; font-weight: 700; color: var(--deep-blue); vertical-align: middle;
}
.lead-history-wrap { margin-top: 8px; }
.lead-history-toggle { margin: 0; }
.lead-history {
  margin-top: 8px; display: grid; gap: 8px;
  border-left: 3px solid rgba(30,77,140,.2); padding-left: 10px;
}
.lead-history-item {
  background: var(--soft); border-radius: 10px; padding: 8px 10px;
}
.lead-history-meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.lead-history-meta a { color: var(--deep-blue); }
.lead-history-text { font-size: 13.5px; line-height: 1.4; white-space: pre-wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.lead-sort-row { margin-top: -4px; margin-bottom: 12px; align-items: center; }
.chip { border: 1px solid var(--line); background: #fff; padding: 8px 14px; font: inherit; font-weight: 600;
  font-size: 13px; cursor: pointer; color: var(--muted); border-radius: 12px; }
.chip.on { background: var(--deep-blue); color: #fff; border-color: var(--deep-blue); }
select, .status-select { border-radius: 12px !important; }
.lock-hint { background: #fff7ed; border: 1px solid rgba(232,93,42,.25); color: var(--coral-deep);
  border-radius: 12px; padding: 10px 12px; margin: 0 0 12px; }
.btn.locked, .nav-btn.locked { opacity: .55; }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.feature-lock { text-align: center; }
.feature-lock__icon { font-size: 36px; margin-bottom: 8px; }
.license-row { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; padding: 14px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--soft); }
.license-actions { display: grid; gap: 8px; }
.license-actions input { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font: inherit; }
.license-status.on { color: var(--green); font-weight: 700; }
.license-status.off { color: var(--muted); font-weight: 700; }
.ok { background: var(--green-bg); color: var(--green); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; }
@media (max-width: 900px) { .license-row { grid-template-columns: 1fr; } }
/* —— live chat —— */
.lead-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.chat-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(20, 30, 45, 0.45);
  display: flex; align-items: stretch; justify-content: flex-end;
}
.chat-panel {
  width: min(520px, 100%);
  background: var(--paper);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  box-shadow: -18px 0 50px rgba(0,0,0,.18);
  border-radius: 14px 0 0 14px;
}
.chat-head {
  display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.chat-head-actions { display: flex; gap: 8px; }
.chat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.chat-live {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 6px;
  font-size: 12px; color: var(--green); font-weight: 600;
}
.chat-live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.chat-lead-orig {
  margin: 12px 16px 0; padding: 10px 12px; border-radius: 12px;
  background: var(--soft); border: 1px solid var(--line);
}
.chat-lead-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
.chat-lead-text { white-space: pre-wrap; font-size: 13.5px; line-height: 1.4; }
.chat-thread {
  flex: 1; overflow: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
  background: linear-gradient(180deg, #eef4f9, #f7f0ea);
}
.chat-empty { color: var(--muted); font-size: 13px; line-height: 1.45; }
.chat-bubble {
  max-width: 88%; padding: 10px 12px; border-radius: 14px;
  border: 1px solid var(--line); background: #fff;
}
.chat-bubble.out {
  align-self: flex-end; background: var(--deep-blue); color: #f5f7f9; border-color: var(--deep-blue);
}
.chat-bubble.in { align-self: flex-start; }
.chat-bubble-text { white-space: pre-wrap; word-break: break-word; font-size: 14px; line-height: 1.4; }
.chat-bubble-meta { margin-top: 6px; font-size: 11px; opacity: .7; }
.chat-compose {
  padding: 12px 16px 16px; border-top: 1px solid var(--line); background: var(--paper);
}
.chat-compose textarea {
  width: 100%; resize: vertical; min-height: 72px; border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; font: inherit; background: #fff;
}
.chat-compose-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.ok { color: var(--green); background: #edf7f1; border-radius: 12px; padding: 8px 12px; margin: 8px 16px 0; font-size: 13px; }
.btn.sm { padding: 7px 10px; font-size: 12.5px; }
/* —— statuses / kanban / monitor —— */
:root { --green-bg: #edf7f1; }
.view-toggle { display: inline-flex; gap: 6px; margin-left: auto; }
.lead-search-row { display: flex; gap: 8px; margin-bottom: 12px; }
.lead-search-row input { flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font: inherit; }
.status-tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--soft); }
.status-tag.status-new { background: #e8f1fb; color: var(--deep-blue); }
.status-tag.status-contacted { background: #fff4e5; color: #9a5b00; }
.status-tag.status-replied { background: #eaf7ef; color: var(--green); }
.status-tag.status-done { background: #eceff3; color: #445; }
.status-tag.status-skip { background: #fdecec; color: #b42318; }
.status-select { font: inherit; font-size: 12px; padding: 5px 8px; border: 1px solid var(--line); background: #fff; max-width: 140px; }
.kanban { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kanban-col { background: var(--soft); border: 1px solid var(--line); border-radius: 14px; min-height: 280px; display: flex; flex-direction: column; }
.kanban-head { padding: 12px 14px; font-weight: 700; color: var(--deep-blue); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.kanban-count { background: #fff; border-radius: 999px; padding: 2px 8px; font-size: 12px; color: var(--muted); }
.kanban-cards { padding: 10px; display: flex; flex-direction: column; gap: 8px; overflow: auto; max-height: 62vh; }
.kanban-empty { color: var(--muted); text-align: center; padding: 18px 8px; font-size: 13px; }
.kanban-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.kanban-card-dir { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.kanban-card-text { font-size: 13.5px; line-height: 1.4; margin-bottom: 6px; }
.kanban-card-meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.kanban-card-ops { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.monitor-panel { margin: 0 0 12px; padding: 10px 14px; background: #fff; border: 1px solid var(--line); border-radius: 14px; border-top: 3px solid var(--coral); }
.monitor-panel.active { box-shadow: 0 8px 24px rgba(30,77,140,.08); }
.monitor-panel.stopped { border-top-color: #8a9aac; }
.monitor-panel.compact {
  padding: 8px 12px 10px;
  position: sticky;
  top: 0;
  z-index: 12;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(8px);
}
.monitor-panel.expanded {
  position: relative;
  z-index: 1;
}
.monitor-strip-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.monitor-strip-title { flex: 0 0 auto; color: var(--deep-blue); font-size: 14px; }
.monitor-current { color: var(--muted); font-size: 12px; text-align: right; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.monitor-progress { height: 8px; background: #e6eef6; border-radius: 999px; overflow: hidden; }
.monitor-progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--coral), var(--gold)); transition: width .35s ease; }
.monitor-progress-label { font-size: 12px; color: var(--muted); margin: 6px 0 0; min-height: 16px; }
.monitor-details { margin-top: 10px; }
.monitor-details.collapsed,
.monitor-details[hidden] { display: none !important; }
.monitor-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 8px; }
.monitor-log-bar { display: flex; justify-content: flex-end; margin: 8px 0 6px; }
.mon-batches { margin: 4px 0 0; }
.mon-batches-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; margin-bottom: 8px; }
.mon-batches-empty { margin: 4px 0 8px; }
.mon-party { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; background: var(--soft); }
.mon-party.current { border-color: rgba(30,77,140,.35); background: #f3f7fc; }
.mon-party-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 6px; }
.mon-party-title { font-weight: 700; color: var(--deep-blue); font-size: 13px; }
.mon-party-meta { font-size: 12px; color: var(--muted); }
.mon-party-bar { height: 6px; background: #dbe6f2; border-radius: 999px; overflow: hidden; margin-bottom: 8px; }
.mon-party-fill { height: 100%; background: linear-gradient(90deg, var(--sky), var(--deep-blue)); transition: width .3s ease; }
.mon-src-list { display: grid; gap: 4px; max-height: 180px; overflow: auto; }
.mon-src { display: grid; grid-template-columns: 10px minmax(0, 1.2fr) auto minmax(0, 1fr); gap: 8px; align-items: center; font-size: 12px; padding: 4px 6px; border-radius: 8px; background: #fff; }
.mon-src-dot { width: 8px; height: 8px; border-radius: 50%; background: #c5d0dc; }
.mon-src-done .mon-src-dot { background: var(--green); }
.mon-src-active .mon-src-dot { background: var(--coral); box-shadow: 0 0 0 3px rgba(232, 112, 88, .2); }
.mon-src-error .mon-src-dot { background: #b42318; }
.mon-src-pending .mon-src-dot { background: #c5d0dc; }
.mon-src-name { font-weight: 600; color: var(--deep-blue); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mon-src-st { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .02em; }
.mon-src-n { color: var(--muted); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-row.on { border-color: rgba(46,125,82,.35); background: #f4fbf6; }
.field textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; font: inherit; resize: vertical; min-height: 140px; }
.parser-tabs .chip-count { opacity: .75; font-weight: 500; margin-left: 4px; }
.sources-list { max-height: 52vh; overflow: auto; margin-top: 8px; }
.source-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: #fff; }
.source-toggle { display: flex; align-items: center; }
.source-u { font-weight: 600; }
.source-u a { color: var(--deep-blue); text-decoration: none; }
.source-u a:hover { text-decoration: underline; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--soft); font-size: 12px; font-weight: 600; }
.badge.on { background: #eaf7ef; color: var(--green); }
.badge.off { background: #eceff3; color: var(--muted); }
.logbox { white-space: pre-wrap; background: #0f1b2a; color: #d7e3f0; border-radius: 12px; padding: 10px 12px;
  font-family: ui-monospace, Consolas, monospace; font-size: 12px; margin-bottom: 12px; max-height: 140px; overflow: auto; }
@media (min-width: 1100px) {
  .monitor-stats { grid-template-columns: repeat(8, 1fr); }
}
.monitor-stat { background: var(--soft); border-radius: 10px; padding: 8px 10px; }
.monitor-stat-k { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; }
.monitor-stat-v { font-weight: 700; color: var(--deep-blue); }
.monitor-stat-btn {
  appearance: none; border: 0; font: inherit; text-align: left; cursor: pointer;
  width: 100%;
}
.monitor-stat-btn:disabled { cursor: default; opacity: .85; }
.monitor-stat-btn.has-errors {
  background: #fdecec;
  box-shadow: inset 0 0 0 1px rgba(180,35,24,.18);
}
.monitor-stat-btn.has-errors .monitor-stat-v { color: #b42318; }
.monitor-stat-btn.open {
  background: #f8d7da;
}
.monitor-errors {
  grid-column: 1 / -1;
  max-height: 160px;
  overflow: auto;
  background: #2a1214;
  color: #ffd6d0;
  border-radius: 12px;
  padding: 10px 12px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
}
.monitor-error-line { padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.monitor-error-line:last-child { border-bottom: 0; }
.monitor-error-line.muted { color: #c9a8a4; }
.monitor-log { max-height: 160px; overflow: auto; background: #0f1b2a; color: #d7e3f0; border-radius: 12px; padding: 10px 12px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; line-height: 1.45; }
.monitor-log.collapsed,
.monitor-log[hidden] { display: none !important; }
.monitor-line { opacity: .95; }
.monitor-line-error { color: #ffb4a8; }
.monitor-line-t { color: #7f96b0; margin-right: 8px; }
@media (max-width: 1100px) {
  .kanban { grid-template-columns: repeat(5, minmax(180px, 1fr)); }
  .monitor-stats { grid-template-columns: repeat(2, 1fr); }
}

/* —— leads dashboard / cards (desktop parity) —— */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.toolbar h2 { margin: 0; color: var(--deep-blue); font-size: 22px; display: flex; align-items: center; gap: 10px; }
.toolbar-count { color: var(--muted); font-size: 18px; font-weight: 600; }
.live-pill { background: var(--green); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; }
.lead-search-wrap { display: flex; gap: 8px; margin-bottom: 12px; }
.lead-search { flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; font: inherit; }
.search-hl { background: rgba(240,192,64,.45); border-radius: 2px; padding: 0 1px; }
.dash-s { font-size: 12px; color: var(--muted); margin-top: 4px; }
.dash-card.wide { grid-column: 1 / -1; }
.dash-card--total::before { background: var(--deep-blue); }
.dash-card--biz::before { background: var(--sky); }
.dash-card--local::before { background: var(--gold); }
.dash-card--comp::before { background: #c45c3e; }
.dash-card--day::before { background: #e8a07a; }
.dash-card--sources::before { background: linear-gradient(180deg, var(--coral), var(--deep-blue)); }
.dash-list { margin-top: 8px; }
.dash-source-row { display: grid; grid-template-columns: 140px 1fr auto; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.dash-source-row:last-child { border-bottom: 0; }
.dash-source-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-source-bar { height: 8px; background: #e6eef6; border-radius: 999px; overflow: hidden; }
.dash-source-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--coral), var(--gold)); }
.dash-warn { background: #fff7ed; border: 1px solid rgba(232,93,42,.25); color: var(--coral-deep); border-radius: 12px; padding: 10px 12px; margin: 0 0 12px; }
.subtabs { display: flex; gap: 8px; margin-bottom: 10px; }
.leads { display: grid; gap: 10px; }
.lead { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: grid; grid-template-columns: 1fr auto; gap: 10px 16px; }
.lead .dir { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; color: #b8860b; }
.lead .text { margin: 6px 0; white-space: pre-wrap; word-break: break-word; line-height: 1.45; }
.lead .ops { display: flex; flex-direction: column; gap: 6px; align-items: stretch; min-width: 160px; }
.lead-main { min-width: 0; }
.status-select-label { font-size: 11px; color: var(--muted); display: grid; gap: 4px; }
.btn.danger { background: #b42318; border-color: #b42318; color: #fff; }
.btn.danger:hover { filter: brightness(1.05); }
.chip.sm { padding: 5px 10px; font-size: 12px; }
.country-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.reply-box { margin-top: 10px; padding: 10px 12px; background: var(--soft); border-radius: 12px; border: 1px solid var(--line); }
.reply-label { font-size: 11px; text-transform: uppercase; font-weight: 700; color: #b8860b; margin-bottom: 6px; }
.reply-pre { margin: 0; white-space: pre-wrap; font: inherit; font-size: 13px; }
.compose-muted { opacity: .75; }
.empty { color: var(--muted); padding: 24px; text-align: center; border: 1px dashed var(--line); border-radius: 14px; }
.badge.on { background: #e7f6ec; color: var(--green); }
.badge.off { background: var(--soft); color: var(--muted); }

/* —— broadcasts —— */
.bc-intro { color: var(--muted); margin: 0 0 14px; }
.bc-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 14px; }
@media (max-width: 1100px) { .bc-grid { grid-template-columns: 1fr; } }
.bc-card { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.bc-card h3 { margin: 0 0 12px; color: var(--deep-blue); font-size: 16px; }
.bc-templates { display: grid; gap: 8px; margin-top: 12px; }
.bc-template { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; background: #fff; }
.bc-template.on { border-color: var(--coral); background: #fff7f3; }
.bc-settings { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.bc-settings label { display: grid; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.bc-settings input { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; }
.bc-leads { max-height: 420px; overflow: auto; display: grid; gap: 6px; }
.bc-lead { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.bc-lead span { display: grid; gap: 2px; min-width: 0; }
.bc-preview { margin-top: 12px; display: grid; gap: 8px; }
.bc-preview-msg { background: var(--soft); border-radius: 12px; padding: 10px 12px; }
.bc-preview-msg pre { margin: 6px 0 0; white-space: pre-wrap; font: inherit; font-size: 13px; }
.bc-progress { font-size: 14px; }
@media (max-width: 700px) {
  .lead { grid-template-columns: 1fr; }
  .bc-settings { grid-template-columns: 1fr; }
  .dash-source-row { grid-template-columns: 1fr; }
}

/* —— confirm modal —— */
.modal-overlay {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(16, 28, 48, 0.48);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 18px;
  padding: 22px 20px 18px;
  box-shadow: 0 20px 50px rgba(16,28,48,.25);
  border: 1px solid var(--line);
}
.modal-card h3 {
  margin: 0 0 8px;
  color: var(--deep-blue);
  font-size: 18px;
}
.modal-card p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}
.modal-actions {
  display: flex; gap: 8px; justify-content: flex-end;
}

/* —— lead more menu —— */
.lead-links-desktop { display: flex; flex-direction: column; gap: 6px; }
.lead-more { display: none; position: relative; }
.lead-more-toggle {
  min-width: 40px;
  font-size: 18px;
  line-height: 1;
  letter-spacing: 1px;
}
.lead-more-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 160px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(30,77,140,.14);
  padding: 6px;
  z-index: 20;
}
.lead-more-menu.open { display: grid; gap: 2px; }
.lead-more-item {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}
.lead-more-item:hover { background: var(--soft); color: var(--deep-blue); }
.agreement-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: linear-gradient(155deg, #1E4D8C 0%, #163a6b 40%, #2a3d52 100%);
  display: flex; align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}
.agreement-panel {
  width: min(640px, 100%);
  background: #fff;
  border-radius: 18px;
  padding: 24px 22px 20px;
  box-shadow: 0 24px 60px rgba(0,0,0,.28);
  max-height: 92vh;
  overflow: auto;
}
.agreement-logo {
  width: 72px; height: 72px; border-radius: 50%;
  object-fit: cover; display: block; margin: 0 auto 16px;
  border: 3px solid var(--gold);
}
.agreement-panel h1 {
  font-size: 20px; margin: 0 0 14px; text-align: center; color: var(--deep-blue); line-height: 1.3;
}
.agreement-body { color: var(--ink); font-size: 14px; line-height: 1.55; }
.agreement-body ul { padding-left: 1.2em; margin: 10px 0; }
.agreement-body li { margin: 6px 0; }
.agreement-accept { width: 100%; margin-top: 18px; }

/* —— PWA install banner —— */
.pwa-banner {
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  margin: 10px 16px 0; padding: 12px 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 8px 24px rgba(30,77,140,.08);
}
.pwa-banner-text { display: grid; gap: 2px; min-width: 0; }
.pwa-banner-text strong { color: var(--deep-blue); }
.pwa-banner-text span { color: var(--muted); font-size: 13px; }
.pwa-banner-actions { display: flex; gap: 8px; }

/* —— mobile / PWA shell —— */
.brand-inline { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-inline img { width: 28px; height: 28px; border-radius: 50%; }
.brand-inline strong { color: var(--deep-blue); font-size: 15px; white-space: nowrap; }
.mobile-subtabs { display: flex; gap: 8px; margin-bottom: 12px; }
.bottom-nav {
  display: none;
  position: sticky; bottom: 0; z-index: 40;
  flex: 0 0 auto;
  align-self: stretch;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 6px 4px max(6px, env(safe-area-inset-bottom));
  /* не давать ряду/кнопкам растягиваться на пустое место экрана */
  height: auto;
  max-height: calc(64px + env(safe-area-inset-bottom));
  align-items: center;
}
.bottom-nav-btn {
  appearance: none; border: 0; background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 6px 4px; border-radius: 12px; cursor: pointer;
  color: var(--muted); font: inherit;
  width: 100%;
  height: 48px;
  max-height: 48px;
  min-height: 48px;
  align-self: center;
  box-sizing: border-box;
}
.bottom-nav-btn.on { color: var(--coral); background: rgba(232,93,42,.1); }
.bottom-nav-btn.locked { opacity: .45; }
.bottom-nav-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  line-height: 0;
}
.bottom-nav-icon .nav-svg {
  width: 22px;
  height: 22px;
  display: block;
}
.bottom-nav-btn.on .nav-svg {
  filter: drop-shadow(0 1px 0 rgba(232,93,42,.15));
  transform: translateY(-0.5px);
}
.bottom-nav-label { font-size: 11px; font-weight: 700; line-height: 1.1; letter-spacing: .01em; }

@media (max-width: 900px) {
  .shell, .shell-mobile {
    display: flex;
    flex-direction: column;
    grid-template-columns: unset;
    height: 100%;
    min-height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }
  .side { display: none !important; }
  .shell-mobile .main,
  .shell .main {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .topbar {
    padding: 10px 12px;
    padding-top: max(10px, env(safe-area-inset-top));
    position: sticky; top: 0; z-index: 30;
    flex: 0 0 auto;
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(10px);
  }
  .content {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .bottom-nav { display: grid; flex: 0 0 auto; }
  .dash { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-card.wide { grid-column: 1 / -1; }
  .kanban {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 12px;
  }
  .kanban-col {
    flex: 0 0 calc(100vw - 28px);
    width: calc(100vw - 28px);
    max-width: calc(100vw - 28px);
    min-height: 60vh;
    scroll-snap-align: start;
  }
  .lead .ops { min-width: 0; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .lead-links-desktop { display: none; }
  .lead-more { display: inline-block; }
  .lead {
    grid-template-columns: 1fr;
  }
  .lead .ops {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
  }
  .lead .ops .status-select-label { grid-column: 1 / -1; }
  .lead .ops [data-open-chat],
  .lead .ops [data-ai],
  .lead .ops [data-lead-delete] { width: 100%; }
  .lead .ops .lead-more { justify-self: end; grid-column: 2; grid-row: 2; }
  .lead .ops [data-open-chat] { grid-column: 1; grid-row: 2; }
  .lead .ops [data-ai] { grid-column: 1; grid-row: 3; }
  .lead .ops [data-lead-delete] { grid-column: 2; grid-row: 3; }
  .monitor-panel { margin: 0 0 10px; }
  .monitor-stats { grid-template-columns: repeat(2, 1fr); }
  .monitor-log { max-height: 120px; }
  .monitor-strip-top { flex-wrap: wrap; }
  .monitor-current { white-space: normal; text-align: left; max-height: 2.6em; overflow: hidden; }
  .mon-src { grid-template-columns: 10px 1fr auto; }
  .mon-src-n { grid-column: 2 / -1; text-align: left; }
  .toolbar { flex-wrap: wrap; }
  .toolbar h2 { font-size: 18px; }
  .chat-overlay { justify-content: stretch; }
  .chat-panel {
    width: 100%;
    max-width: none;
    border-radius: 0;
    height: 100%;
    max-height: 100%;
  }
  .login-wrap { padding: 16px; padding-top: max(16px, env(safe-area-inset-top)); }
  .login-card { padding: 22px 18px; }
  .country-chips { max-height: 120px; overflow: auto; }
  .bc-leads { max-height: 280px; }
  .pwa-banner { margin: 8px 12px 0; }
}

/* installed PWA */
html.is-pwa body {
  background: #eef4f9;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
html.is-pwa-mobile body {
  user-select: none;
  -webkit-user-select: none;
}
html.is-pwa .content,
html.is-pwa .lead .text,
html.is-pwa textarea,
html.is-pwa input {
  user-select: text;
  -webkit-user-select: text;
}

/* телефон: фиксированный viewport + safe areas */
html.is-pwa-mobile .shell-pwa {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}
html.is-pwa-mobile .shell-pwa .main {
  min-height: 0;
  overflow: hidden;
}
html.is-pwa-mobile .shell-pwa .content {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
html.is-pwa-mobile .topbar .meta { display: none; }

/* ПК-приложение: полный десктопный shell, без мобильного обрезания */
html.is-pwa-desktop,
html.is-pwa-desktop body,
html.is-pwa-desktop #app {
  height: 100%;
  min-height: 100%;
}
html.is-pwa-desktop .shell-pwa {
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  max-height: none;
  overflow: hidden;
  grid-template-columns: 220px 1fr;
}
html.is-pwa-desktop .shell-pwa .side {
  display: flex !important;
  overflow: auto;
}
html.is-pwa-desktop .shell-pwa .main {
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
html.is-pwa-desktop .shell-pwa .content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 20px;
}
html.is-pwa-desktop .bottom-nav { display: none !important; }
html.is-pwa-desktop .topbar .meta { display: block; }
html.is-pwa-desktop .kanban {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  overflow: visible;
}
html.is-pwa-desktop .kanban-col {
  flex: none;
  width: auto;
  max-width: none;
  min-height: 40vh;
}

