/* Avokado — кабинет клиента. Как сайт: кремовый фон, оливковый акцент, коричневые кнопки, Inter + Instrument Serif. */
@font-face { font-family: "Inter"; src: url("/assets/inter-latin-var.woff2") format("woff2"); font-weight: 100 900; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; src: url("/assets/inter-latin-ext-var.woff2") format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+0100-017F; }
@font-face { font-family: "Inter"; src: url("/assets/inter-cyrillic-var.woff2") format("woff2"); font-weight: 100 900; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Instrument Serif"; src: url("/assets/instrument-serif-latin-italic.woff2") format("woff2"); font-style: italic; font-weight: 400; font-display: swap; }

:root {
  --bg: #FBFAF3;
  --tint: #F4F2E6;
  --surface: #FFFFFF;
  --ink: #1D1A12;
  --ink-2: #4F493B;
  --ink-3: #6F6754;
  --line: rgba(46, 38, 16, .09);
  --line-2: rgba(46, 38, 16, .16);
  --olive: #5F7015;
  --olive-ink: #586710;
  --lime: #ACC14C;
  --lime-soft: #EEF0D8;
  --pit: #553003;
  --warn: #A5560B;
  --bad: #B3261E;
  --r: 20px;
  --shadow-s: 0 1px 2px rgba(40, 32, 10, .05), 0 2px 8px -2px rgba(40, 32, 10, .06);
  --shadow: 0 1px 2px rgba(40, 32, 10, .04), 0 14px 32px -16px rgba(40, 32, 10, .22);
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.025em; }
h1 { font-size: clamp(26px, 3vw, 34px); line-height: 1.1; letter-spacing: -0.035em; }
h2 { font-size: 17px; }
h3 { color: var(--ink-3); font-size: 12px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; }
h1 em, .serif { color: var(--olive-ink); font-family: "Instrument Serif", ui-serif, Georgia, serif; font-size: 1.1em; font-style: italic; font-weight: 400; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--olive-ink); }
button { font: inherit; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--olive); outline-offset: 2px; border-radius: 8px; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.empty { padding: 32px 16px; color: var(--ink-3); text-align: center; }
.boot { display: grid; place-items: center; min-height: 100vh; opacity: .55; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  padding: 0 20px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .2s, border-color .2s, transform .2s;
}
.btn:hover { border-color: rgba(46, 38, 16, .3); }
.btn.primary { border-color: var(--pit); background: var(--pit); color: #FBF4DF; box-shadow: 0 10px 22px -12px rgba(85, 48, 3, .7); }
.btn.primary:hover { background: #6C3E07; transform: translateY(-1px); }
.btn.small { height: 34px; padding: 0 14px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.link { padding: 0; border: 0; background: none; color: var(--ink-2); cursor: pointer; }
.link:hover { color: var(--ink); }
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; background: var(--tint); color: var(--ink-2); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.chip.warn { background: rgba(165, 86, 11, .12); color: var(--warn); }
.chip.lime { background: rgba(172, 193, 76, .26); color: #47550A; }
.toast { position: fixed; left: 50%; bottom: 32px; z-index: 30; padding: 11px 18px; border-radius: 14px; background: var(--ink); color: #fff; transform: translateX(-50%); box-shadow: var(--shadow); }
.toast.bad { background: var(--bad); }

/* ---------- вход ---------- */
.login-wrap {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px 16px;
  background: radial-gradient(60% 45% at 50% 0%, rgba(215, 216, 123, .5), transparent 72%), linear-gradient(180deg, #F2F1DA, var(--bg) 60%);
}
.login-card { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 400px; padding: 34px 30px 26px; border: 1px solid var(--line); border-radius: 28px; background: var(--surface); box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 20px; font-weight: 650; letter-spacing: -0.045em; }
.login-card h1 { font-size: 30px; }
label { display: flex; flex-direction: column; gap: 6px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
input, textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 400;
}
input:focus, textarea:focus { border-color: var(--olive); outline: none; box-shadow: 0 0 0 4px rgba(95, 112, 21, .12); }
.form-err { min-height: 1.2em; color: var(--bad); font-size: 13px; }
.lang { display: inline-flex; align-self: center; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.lang button { height: 28px; padding: 0 11px; border: 0; border-radius: 999px; background: none; color: var(--ink-3); font-size: 12px; font-weight: 650; cursor: pointer; }
.lang button.on { background: var(--ink); color: #fff; }

/* ---------- оболочка ---------- */
.shell { display: flex; flex-direction: column; min-height: 100vh; }
.top { position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--line); background: rgba(251, 250, 243, .86); backdrop-filter: saturate(1.4) blur(14px); }
.top-in { display: flex; align-items: center; gap: 16px; max-width: 1200px; height: 64px; margin: 0 auto; padding: 0 20px; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font-size: 19px; font-weight: 650; letter-spacing: -0.045em; text-decoration: none; }
.biz { overflow: hidden; max-width: 220px; padding: 5px 12px; border-radius: 999px; background: var(--tint); color: var(--ink-2); font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.tabs { display: flex; gap: 2px; margin: 0 auto; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, .7); }
.tabs a { display: inline-flex; align-items: center; gap: 7px; padding: 7px 16px; border-radius: 999px; color: var(--ink-2); font-size: 14px; font-weight: 550; text-decoration: none; }
.tabs a svg { width: 17px; height: 17px; }
.tabs a:hover { background: var(--tint); color: var(--ink); }
.tabs a.on { background: var(--ink); color: #fff; }
.badge-n { min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--pit); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.top-right { display: flex; align-items: center; gap: 10px; }
.me { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #D7D87B, #ACC14C); color: var(--pit); font-size: 13px; font-weight: 700; text-decoration: none; }
.me.on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--olive); }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { color: var(--ink); border-color: var(--line-2); }
.icon-btn svg { width: 17px; height: 17px; }
.view { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 32px 20px 56px; }
.page-head { margin-bottom: 22px; }
.page-head p { margin-top: 6px; }
.card { padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow-s); }
.card + .card { margin-top: 16px; }
.card-head { margin-bottom: 6px; }
.narrow { display: flex; flex-direction: column; gap: 14px; max-width: 460px; }

/* ---------- обзор ---------- */
.callout {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  padding: 16px 18px;
  border: 1px solid rgba(85, 48, 3, .14);
  border-radius: var(--r);
  background: linear-gradient(120deg, #F8EBDA, #FBF4E9);
  color: var(--pit);
}
.callout-ic { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--pit); color: #FBF4DF; }
.callout-ic svg { width: 20px; height: 20px; }
.callout strong { display: block; font-size: 16px; letter-spacing: -0.01em; }
.callout .btn { margin-left: auto; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { display: flex; flex-direction: column; gap: 4px; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: inherit; text-decoration: none; box-shadow: var(--shadow-s); }
a.kpi:hover { border-color: rgba(95, 112, 21, .45); }
.kpi-ic { display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: 10px; border-radius: 11px; background: var(--lime-soft); color: var(--olive); }
.kpi-ic svg { width: 18px; height: 18px; }
.kpi-v { font-size: 32px; font-weight: 600; letter-spacing: -0.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-l { color: var(--ink-3); font-size: 13px; line-height: 1.35; }
.budget { display: flex; align-items: center; gap: 16px; }
.budget .bar { flex: 1; }
.bar { height: 8px; overflow: hidden; border-radius: 999px; background: var(--tint); }
.bar i { display: block; width: 2%; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--lime), var(--olive)); }

/* ---------- список диалогов ---------- */
.list { display: flex; flex-direction: column; gap: 2px; }
.conv { display: flex; gap: 12px; padding: 12px; border-radius: 14px; color: inherit; text-decoration: none; }
.conv:hover { background: var(--tint); }
.conv.on { background: var(--lime-soft); }
.avatar { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%; background: #E6E9C3; color: #4D5C0B; font-size: 13px; font-weight: 700; }
.conv.paused .avatar { background: #F3E2CC; color: var(--pit); }
.conv-main { display: flex; flex: 1; flex-direction: column; gap: 3px; min-width: 0; }
.conv-top { display: flex; align-items: center; gap: 8px; }
.conv-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-top .small { flex: none; white-space: nowrap; }
.conv-prev { overflow: hidden; font-size: 13.5px; text-overflow: ellipsis; white-space: nowrap; }
.conv-tags { display: flex; gap: 6px; }
.conv-tags:empty { display: none; }

.split { display: grid; grid-template-columns: 370px minmax(0, 1fr); height: calc(100vh - 64px - 88px); min-height: 480px; overflow: hidden; border: 1px solid var(--line); border-radius: 26px; background: var(--surface); box-shadow: var(--shadow); }
.side { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.side-head { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-bottom: 1px solid var(--line); }
.seg { display: flex; gap: 4px; padding: 3px; border-radius: 999px; background: var(--tint); }
.seg button { flex: 1; height: 32px; border: 0; border-radius: 999px; background: none; color: var(--ink-2); font-size: 13px; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-s); }
.scroll { flex: 1; min-height: 0; padding: 8px; overflow-y: auto; }

.detail { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: linear-gradient(180deg, #FDFCF7, #FAF8EF); }
.detail > .empty { margin: auto; max-width: 260px; }
.detail-head { padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.detail-title { display: flex; align-items: center; gap: 12px; }
.detail-name { display: flex; flex-direction: column; min-width: 0; }
.back { display: none; padding: 4px 8px; color: var(--ink); font-size: 20px; text-decoration: none; }
.status { display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--surface); font-size: 13.5px; font-weight: 550; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: #4CAF50; box-shadow: 0 0 0 4px rgba(76, 175, 80, .15); }
.status.paused { background: #FBF3E6; color: var(--warn); }
.status.paused .dot { background: var(--warn); box-shadow: 0 0 0 4px rgba(165, 86, 11, .15); }
.detail-body { display: grid; flex: 1; grid-template-columns: minmax(0, 1fr) 270px; min-height: 0; }
.detail-body:has(.lead[hidden]) { grid-template-columns: minmax(0, 1fr); }
.thread { display: flex; flex-direction: column; gap: 10px; min-height: 0; padding: 20px; overflow-y: auto; }
.msg { display: flex; flex-direction: column; gap: 3px; max-width: 76%; }
.msg.client { align-self: flex-start; }
.msg.assistant, .msg.team { align-self: flex-end; align-items: flex-end; }
.bubble { padding: 10px 14px; border-radius: 18px; font-size: 14.5px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.client .bubble { border: 1px solid var(--line); border-bottom-left-radius: 6px; background: var(--surface); }
.msg.assistant .bubble { border-bottom-right-radius: 6px; background: var(--olive); color: #FBF8E8; }
.msg.team .bubble { border-bottom-right-radius: 6px; background: #2B2822; color: #fff; }
.msg-who { color: var(--ink-3); font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; }
.pic { max-width: 220px; border-radius: 14px; }
.lead { min-height: 0; padding: 18px; overflow-y: auto; border-left: 1px solid var(--line); background: var(--surface); }
.lead dl { display: grid; gap: 8px; margin: 12px 0 0; }
.lead dt { color: var(--ink-3); font-size: 12px; }
.lead dd { margin: 0 0 4px; font-weight: 550; overflow-wrap: anywhere; }
.reply { display: flex; flex-direction: column; gap: 8px; padding: 12px 18px 14px; border-top: 1px solid var(--line); background: var(--surface); }
.reply textarea { min-height: 64px; resize: vertical; }

/* ---------- лиды ---------- */
.table-card { padding: 0; overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 13px 18px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { background: var(--tint); color: var(--ink-3); font-size: 11.5px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #FBFAF0; }
tbody tr:last-child td { border-bottom: 0; }

/* ---------- нижние вкладки (телефон) ---------- */
.bottom-tabs { display: none; }

@media (max-width: 1100px) {
  .detail-body { display: flex; flex-direction: column; }
  .thread { flex: 1; }
  .lead { order: -1; max-height: 30vh; padding: 12px 18px; border-bottom: 1px solid var(--line); border-left: 0; }
  .lead dl { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 16px; margin-top: 8px; }
}
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  body { padding-bottom: 72px; }
  .top-in { height: 58px; padding: 0 14px; gap: 10px; }
  .top .tabs, .top .me, .top .icon-btn { display: none; }
  .biz { max-width: 150px; margin-right: auto; }
  .view { padding: 20px 14px 28px; }
  .callout { flex-wrap: wrap; }
  .callout .btn { width: 100%; margin-left: 0; }
  .kpi { padding: 14px 16px; }
  .kpi-v { font-size: 26px; }
  .split { grid-template-columns: minmax(0, 1fr); height: calc(100vh - 58px - 72px - 40px); border-radius: 20px; }
  .split .detail { display: none; }
  .split.has-detail .side { display: none; }
  .split.has-detail .detail { display: flex; }
  .back { display: inline-block; }
  .msg { max-width: 88%; }
  .bottom-tabs {
    position: fixed;
    inset: auto 0 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, .94);
    backdrop-filter: blur(14px);
  }
  .bottom-tabs a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; border-radius: 12px; color: var(--ink-3); font-size: 11px; font-weight: 600; text-decoration: none; }
  .bottom-tabs a svg { width: 22px; height: 22px; }
  .bottom-tabs a.on { background: var(--lime-soft); color: var(--olive-ink); }
  .bottom-tabs .badge-n { position: absolute; top: 2px; left: calc(50% + 6px); }
  .toast { bottom: 88px; }
  /* лиды — карточками */
  table thead { display: none; }
  table, tbody, tr { display: block; }
  tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  td { display: flex; gap: 12px; padding: 3px 0; border: 0; white-space: normal; }
  td::before { content: attr(data-label); flex: none; width: 92px; color: var(--ink-3); font-size: 12px; }
}
.tg-chats { list-style: none; margin: 0 0 12px; padding: 0; }
.tg-chats li { padding: 6px 0; border-top: 1px solid var(--line); }
