/* IP-Partner CRM — сдержанный документный стиль: тёмно-синий, тёплый бумажный фон, бронзовый акцент */
:root {
  --navy: #17365d; --navy-2: #1f4675; --navy-soft: #e8eef6;
  --bronze: #a67c52; --bronze-soft: #f6eee4; --bronze-ink: #7a5630;
  --paper: #f7f4ef; --surface: #ffffff; --surface-2: #fbfaf7;
  --ink: #1d2433; --muted: #667085; --line: #e3e0d8; --line-2: #eeebe4;
  --red: #b42318; --red-soft: #fdecea; --green: #087443; --green-soft: #e5f4ec; --gold-soft: #fbf1df; --gold-ink: #8a5a12;
  --radius: 10px; --shadow: 0 1px 2px rgba(23, 54, 93, .06), 0 4px 16px rgba(23, 54, 93, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--navy-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; color: var(--navy); line-height: 1.25; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--bronze); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, Consolas, monospace; word-break: break-all; }
.nowrap { white-space: nowrap; }
.bad-text { color: var(--red); }
.good-text { color: var(--green); }
.danger-text { color: var(--red) !important; }
.clip { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.stack > * + * { margin-top: 12px; }

/* ---------- кнопки ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface);
  color: var(--navy); border-radius: 8px; padding: 8px 14px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--navy-soft); border-color: #cfd9e6; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.accent { background: var(--bronze); border-color: var(--bronze); color: #fff; }
.btn.accent:hover { background: #94693f; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--navy-soft); }
.btn.link { background: none; border: 0; padding: 0; color: var(--navy-2); font-weight: 600; font-size: 12.5px; }
.btn.link:hover { text-decoration: underline; background: none; }
.btn.sm { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.block { width: 100%; padding: 11px; }
.icon-btn { border: 0; background: none; font-size: 16px; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--line-2); }

/* ---------- вход ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(circle at 20% 10%, #fff 0, var(--paper) 55%); }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 32px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 22px 0 6px; font-size: 20px; }
.auth-card .stack { margin-top: 18px; }
.auth-install { margin-top: 14px; text-align: center; }
.auth-install:empty { display: none; }
.brand-lg { font-size: 24px; font-weight: 800; color: var(--navy); letter-spacing: -.02em; }
.brand-lg small { display: block; font-size: 13px; font-weight: 600; color: var(--bronze); letter-spacing: 0; }

/* ---------- каркас ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex: none; background: var(--navy); color: #dbe5f1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { padding: 22px 20px 18px; font-size: 19px; font-weight: 800; color: #fff; letter-spacing: -.01em; }
.brand small { color: #e5c9a5; font-size: 12px; font-weight: 600; margin-left: 6px; }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #dbe5f1; font-weight: 500; margin: 1px 0; }
.nav-item:hover { background: rgba(255, 255, 255, .07); text-decoration: none; }
.nav-item.active { background: rgba(255, 255, 255, .13); color: #fff; box-shadow: inset 3px 0 0 #e5c9a5; }
.nav-icon { width: 18px; text-align: center; color: #e5c9a5; font-size: 13px; }
.me { padding: 14px 20px 18px; border-top: 1px solid rgba(255, 255, 255, .1); }
.me-name { color: #fff; font-weight: 600; }
.me-role { font-size: 12px; color: #aebdd0; }
.me-actions { display: flex; gap: 14px; margin-top: 6px; }
.me-actions .btn.link { color: #e5c9a5; }
.me-actions:empty { display: none; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main { flex: 1; min-width: 0; padding: 28px 32px 60px; }
.impersonation { position: sticky; top: 0; z-index: 10; display: flex; gap: 12px; align-items: center; justify-content: space-between;
  flex-wrap: wrap; padding: 10px 32px; background: var(--bronze); color: #fff; font-size: 13.5px; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); }
.impersonation .btn { background: #fff; color: var(--bronze-ink); border-color: #fff; }
.impersonation .btn:hover { background: var(--bronze-soft); }
.view { max-width: 1440px; margin: 0 auto; }
.loading { padding: 60px; text-align: center; color: var(--muted); }

/* ---------- заголовки страниц ---------- */
.page-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; max-width: 760px; }
.actions { display: flex; gap: 8px; align-items: center; }
.actions.wrap { flex-wrap: wrap; justify-content: flex-end; }
.card-head h1 { font-size: 26px; }
.head-pills { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: 10px; color: var(--muted); font-size: 13px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar select, .toolbar input { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 10px; }
.search { min-width: 280px; flex: 1; max-width: 420px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); margin-left: auto; }
.seg button { border: 0; background: none; padding: 7px 14px; cursor: pointer; color: var(--muted); font-weight: 600; }
.seg button.active { background: var(--navy-soft); color: var(--navy); }
.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

/* ---------- панели ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.panel + .panel, .col > * + * { margin-top: 16px; }
.view > .panel { margin-bottom: 16px; }
.panel-title { margin-bottom: 12px; font-size: 14px; text-transform: none; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; margin-bottom: 16px; }
.grid-card { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 12px; }
.note { padding: 11px 14px; border-radius: 8px; background: var(--navy-soft); border-left: 3px solid var(--navy); margin: 0 0 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.note.warn { background: var(--gold-soft); border-color: var(--bronze); }
.note.bad { background: var(--red-soft); border-color: var(--red); }
.note > div { flex-basis: 100%; }

/* ---------- метки ---------- */
.pill { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--navy-soft); color: var(--navy); }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.gold { background: var(--gold-soft); color: var(--gold-ink); }
.pill.muted { background: var(--line-2); color: var(--muted); }
.pill.blue { background: var(--navy-soft); color: var(--navy); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px; }
button.chip { cursor: pointer; font-size: 13px; color: var(--ink); }
button.chip:hover { border-color: #c5d1e0; }
button.chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.filter-chips { margin-bottom: 12px; }

/* ---------- этапы ---------- */
.progress { list-style: none; display: flex; padding: 0; margin: 0 0 18px; gap: 4px; counter-reset: s; overflow-x: auto; }
.progress li { flex: 1; min-width: 110px; position: relative; padding: 8px 10px 8px 12px; font-size: 12px; color: var(--muted); background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px; counter-increment: s; }
.progress li::before { content: counter(s); font-weight: 700; margin-right: 6px; color: #b3b8c2; }
.progress li.done { background: var(--navy-soft); color: var(--navy); border-color: #d3deeb; }
.progress li.done::before { content: "✓"; color: var(--navy); }
.progress li.current { background: var(--navy); color: #fff; border-color: var(--navy); font-weight: 600; }
.progress li.current::before { color: #e5c9a5; }
.progress.dim { opacity: .55; }

/* ---------- доска ---------- */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.column { flex: 1 0 196px; max-width: 300px; background: #efebe3; border-radius: var(--radius); padding: 10px; }
.column-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; color: var(--navy); font-size: 13px; padding: 2px 4px 10px; }
.count { background: rgba(23, 54, 93, .1); color: var(--navy); border-radius: 99px; padding: 0 8px; font-size: 11.5px; font-weight: 700; margin-left: 6px; }
.column-body { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.column-empty { color: #b3b0a8; text-align: center; padding: 10px; }
.card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 11px 12px; color: var(--ink); box-shadow: 0 1px 2px rgba(23, 54, 93, .05); }
.card:hover { border-color: #c5d1e0; text-decoration: none; box-shadow: var(--shadow); }
.card.on_hold { border-left: 3px solid var(--bronze); }
.card.declined, .card.closed { opacity: .65; }
.card.escalated { border-left: 3px solid var(--red); }
.card .pill { margin-top: 6px; }
.card-title { font-weight: 600; color: var(--navy); }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.card-next { font-size: 12px; margin-top: 7px; color: #475467; }
.card-next.bad-text { color: var(--red); }
.card-foot { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 8px; gap: 8px; }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table select.sm { padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.view > .table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- табы ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: -6px -4px 16px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.tab { border: 0; background: none; padding: 9px 14px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--navy); }
.tab.active { color: var(--navy); border-bottom-color: var(--bronze); }
.tab-actions { display: flex; justify-content: flex-end; margin-bottom: 10px; }

/* ---------- задачи ---------- */
.task-list { list-style: none; margin: 0; padding: 0; }
.task { display: flex; gap: 12px; align-items: flex-start; padding: 10px 2px; border-bottom: 1px solid var(--line-2); }
.task:last-child { border-bottom: 0; }
.task.closed { opacity: .7; }
.check-btn { flex: none; width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid #b9c3d0; background: var(--surface); cursor: pointer; margin-top: 1px;
  display: grid; place-items: center; font-size: 12px; color: #fff; }
.check-btn:hover { border-color: var(--green); background: var(--green-soft); }
.check-btn.done { background: var(--green); border-color: var(--green); cursor: default; }
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 500; }
.task.overdue .task-title { color: var(--red); }
.task-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 2px; align-items: center; }
.task-desc { font-size: 12.5px; color: #475467; margin-top: 4px; }
.auto { font-size: 10.5px; font-weight: 700; color: var(--bronze-ink); background: var(--bronze-soft); padding: 0 6px; border-radius: 4px; margin-left: 6px; vertical-align: 1px; }

/* ---------- лента ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.timeline li:last-child { border-bottom: 0; }
.tl-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.tl-head time { margin-left: auto; color: var(--muted); font-size: 12px; }
.tl-text { white-space: pre-wrap; margin-top: 6px; }
.tl-msg .tl-text { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line-2); max-width: 760px; }
.tl-msg.out .tl-text { background: var(--navy-soft); border-color: #d6e0ed; }
.tl-event .tl-head { color: #475467; }
.tl-event .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bronze); }
.tl-event .tl-text { font-size: 12.5px; margin-left: 16px; }

/* ---------- эскалации ---------- */
.esc-list { list-style: none; margin: 0; padding: 0; }
.esc { padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.esc:last-child { border-bottom: 0; }
.esc.overdue { box-shadow: inset 3px 0 0 var(--red); padding-left: 10px; }
.esc-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.esc-reason { margin-top: 6px; font-weight: 500; white-space: pre-wrap; }
.esc-resolution { margin-top: 6px; padding: 8px 10px; background: var(--green-soft); border-radius: 8px; font-size: 13px; }
.esc-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; gap: 10px; }

/* ---------- мелкие списки, kv ---------- */
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.mini-list li:last-child { border-bottom: 0; }
.mini-list li .btn { margin-left: auto; }
.mini-list li.col-item { display: block; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; margin: 0; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.quote { background: var(--surface-2); border-left: 3px solid var(--bronze); padding: 9px 12px; border-radius: 0 8px 8px 0; margin: 8px 0; white-space: pre-wrap; }
.risky { font-size: 13px; text-decoration: line-through; text-decoration-color: rgba(180, 35, 24, .5); color: #7a2a22; }
.code-box { display: flex; align-items: baseline; gap: 10px; margin: 8px 0; }
.code-box b { font-family: ui-monospace, Consolas, monospace; font-size: 20px; letter-spacing: .1em; color: var(--navy); }

/* ---------- библиотека ---------- */
.cards-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }
.lib-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: var(--surface); }
.lib-card.retired { opacity: .6; }
.lib-card.needs_review { border-color: #ecd6b3; background: #fffcf6; }
.lib-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.lib-head h3 { flex-basis: 100%; margin-top: 6px; }
.rules h3 { margin: 18px 0 8px; }
.rules h3:first-child { margin-top: 0; }
.rules li { margin: 4px 0; }

.big-num { font-size: 22px; color: var(--navy); }

/* ---------- доходы ---------- */
.income-top { margin-bottom: 0; }
.totals .totals-net { margin: 2px 0 12px; }
.net-num { font-size: 32px; font-weight: 800; color: var(--green); letter-spacing: -.02em; }
.totals.secondary { background: var(--surface-2); }
.totals.secondary .net-num { font-size: 24px; color: var(--navy); }
.money-line { display: flex; justify-content: space-between; padding: 6px 0; border-top: 1px solid var(--line-2); font-size: 13.5px; }
.money-line.minus b { color: #8a3a2e; font-weight: 600; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.income-card { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 14px 16px;
  cursor: pointer; display: flex; flex-direction: column; gap: 3px; box-shadow: var(--shadow); font: inherit; color: inherit; }
.income-card:hover { border-color: #c5d1e0; box-shadow: 0 6px 20px rgba(23, 54, 93, .1); }
.income-name { font-weight: 700; color: var(--navy); }
.income-amount { font-size: 24px; font-weight: 800; color: var(--navy); margin-top: 6px; letter-spacing: -.01em; }
.income-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.income-current { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 6px; }
.month-block { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-top: 12px; }
.month-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.month-head .btn { margin-left: auto; }
.table.compact td, .table.compact th { padding: 6px 8px; }
tr.details td { background: var(--surface-2); padding-top: 0; }
details summary { cursor: pointer; color: var(--navy-2); margin: 6px 0; }

/* ---------- Telegram ---------- */
.tg-account { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; }
.tg-account .btn { margin-left: auto; }
.tg-connect { max-width: 640px; margin-bottom: 16px; }
.tg-connect form input { flex: 1; min-width: 220px; border: 1px solid #d5d1c8; border-radius: 8px; padding: 9px 11px; }
.tg-steps { padding-left: 20px; color: var(--muted); }
.tg-steps li.current { color: var(--navy); font-weight: 700; }
.tg-steps li.done { text-decoration: line-through; }
.tg-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 14px; height: calc(100vh - 230px); min-height: 460px; }
.tg-side { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; }
.tg-side-head { padding: 10px; border-bottom: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 8px; }
.tg-side-head select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.tg-tabs { margin: 0; width: 100%; display: flex; }
.tg-tabs button { flex: 1; }
.tg-list { overflow-y: auto; flex: 1; }
.tg-item { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line-2); background: none; padding: 10px 12px; cursor: pointer; font: inherit; color: inherit; }
.tg-item:hover { background: var(--surface-2); }
.tg-item.active { background: var(--navy-soft); }
.tg-item-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.tg-unread { background: var(--navy); color: #fff; border-radius: 99px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.tg-chat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-height: 0; display: flex; flex-direction: column; }
.tg-chat > .empty { margin: auto; }
.tg-pane { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.tg-pane.compact { height: 460px; border: 1px solid var(--line-2); border-radius: var(--radius); }
.tg-chat-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line-2); }
.tg-pane > .note { margin: 10px 14px 0; }
.tg-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: #f4f1ea; min-height: 0; }
.tg-msg { max-width: 72%; padding: 8px 11px; border-radius: 12px; background: #fff; box-shadow: 0 1px 1px rgba(0, 0, 0, .06); align-self: flex-start; }
.tg-msg.outgoing { align-self: flex-end; background: #e2ecf7; }
.tg-text { white-space: pre-wrap; word-break: break-word; }
.tg-meta { font-size: 11px; color: var(--muted); margin-top: 3px; text-align: right; }
.tg-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line-2); align-items: flex-end; }
.tg-input textarea { flex: 1; border: 1px solid #d5d1c8; border-radius: 10px; padding: 8px 10px; resize: none; }
.tg-card-chat + .tg-card-chat { margin-top: 14px; }
@media (max-width: 900px) {
  .tg-layout { grid-template-columns: 1fr; height: auto; }
  .tg-side { max-height: 300px; }
  .tg-chat { height: 520px; }
}

/* ---------- журнал ---------- */
.journal { list-style: none; margin: 0; padding: 0; }
.journal li { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: start; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.journal li:last-child { border-bottom: 0; }
.journal time { color: var(--muted); font-size: 12.5px; padding-top: 1px; }

/* ---------- скрипты ---------- */
.branch-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-bottom: 16px; }
.branch { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 12px 14px; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); }
.branch:hover { border-color: #c5d1e0; }
.branch.active { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy), var(--shadow); }
.branch-num { font-size: 11.5px; font-weight: 700; color: var(--bronze-ink); text-transform: uppercase; letter-spacing: .04em; }
.branch-title { font-weight: 600; color: var(--navy); }
.branch-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.branch-head p { margin-top: 4px; max-width: 760px; }
.steps-tools { margin: 10px 0 4px; }
.steps { list-style: none; margin: 0; padding: 0; }
.step { border: 1px solid var(--line); border-radius: var(--radius); margin-top: 8px; background: var(--surface); }
.step.open { border-color: #c5d1e0; }
.step-head { width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 14px; border: 0; background: none; cursor: pointer; text-align: left; }
.step-head:hover { background: var(--surface-2); border-radius: var(--radius); }
.step-num { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--navy-soft); color: var(--navy); font-weight: 700; font-size: 12px; display: grid; place-items: center; }
.step.guide .step-num { background: var(--line-2); color: var(--muted); }
.step-title { flex: 1; font-weight: 600; }
.step-arrow { color: var(--muted); }
.step-body { padding: 0 14px 14px 48px; }
.step-body .note { margin: 0 0 8px; }
.script-text { white-space: pre-wrap; line-height: 1.6; }
.script-text.guide { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 12px 14px; }

/* ---------- сводка ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat-num { font-size: 28px; font-weight: 800; color: var(--navy); letter-spacing: -.02em; }
.stat-label { font-size: 12.5px; color: var(--muted); }
.stat.good .stat-num { color: var(--green); }
.stat.bad .stat-num { color: var(--red); }
.stat.warn .stat-num { color: var(--bronze-ink); }
.funnel { margin: 12px 0; }
.funnel-row { display: grid; grid-template-columns: 150px 1fr 60px; gap: 10px; align-items: center; padding: 4px 0; font-size: 13px; }
.funnel-bar { height: 10px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.funnel-bar span { display: block; height: 100%; background: var(--navy); border-radius: 99px; min-width: 2px; }
.funnel-bar.alt span { background: var(--bronze); }
.funnel-num { text-align: right; font-weight: 700; color: var(--navy); }
.conv { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; border-top: 1px solid var(--line-2); padding-top: 12px; }
.conv-num { font-size: 20px; font-weight: 800; color: var(--navy); }

/* ---------- модальные окна и формы ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(16, 28, 45, .45); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .12s ease-out; }
.modal { background: var(--surface); border-radius: 14px; width: min(520px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal.wide { width: min(760px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px 0; }
.modal-body { padding: 14px 22px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .full, .form-grid .form-error, .form-grid .check { grid-column: 1 / -1; }
.form-intro { color: #475467; background: var(--surface-2); border: 1px solid var(--line-2); padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: #475467; margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid #d5d1c8; border-radius: 8px; padding: 8px 10px; background: var(--surface); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--navy-2); outline: none; box-shadow: 0 0 0 3px rgba(31, 70, 117, .12); }
.field textarea { resize: vertical; }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.req { color: var(--red); }
.form-error { color: var(--red); font-size: 13px; min-height: 0; white-space: pre-wrap; }
.form-error:empty { display: none; }

/* ---------- меню ---------- */
.menu { position: relative; }
.menu-list { display: none; position: absolute; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .12); min-width: 250px; padding: 6px; z-index: 20; }
.menu.open .menu-list { display: block; }
.menu-list button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.menu-list button:hover { background: var(--navy-soft); }

/* ---------- уведомления ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: min(420px, calc(100vw - 36px)); }
.toast { background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 9px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); transition: opacity .4s, transform .4s; animation: up .18s ease-out; }
.toast.warn { background: var(--bronze-ink); }
.toast.bad { background: var(--red); }
.toast.hide { opacity: 0; transform: translateY(6px); }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { opacity: 0; transform: translateY(8px); } }

/* ---------- адаптив ---------- */
@media (max-width: 1100px) {
  .grid-card, .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .brand { padding: 14px 16px 8px; }
  .nav { display: flex; overflow-x: auto; padding: 0 8px 8px; }
  .nav-item { white-space: nowrap; }
  .nav-item.active { box-shadow: none; }
  .me { display: flex; gap: 12px; align-items: center; padding: 8px 16px 12px; }
  .me-actions { margin: 0 0 0 auto; }
  .main { padding: 18px 16px 50px; }
  .impersonation { padding: 10px 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .search { min-width: 0; max-width: none; flex-basis: 100%; }
  .seg { margin-left: 0; }
  .conv { grid-template-columns: repeat(2, 1fr); }
  .funnel-row { grid-template-columns: 110px 1fr 50px; }
  .cards-list { grid-template-columns: 1fr; }
  .actions.wrap { justify-content: flex-start; }
}
