/* CRM АСТРА — фирменный цвет #373F89, шрифт Montserrat (если установлен) */
:root {
  --brand: #373F89; --brand-d: #2a3070; --bg: #f4f5f9; --card: #fff; --text: #1d2033;
  --muted: #6b7085; --line: #e2e4ee; --ok: #1f8a4c; --err: #c0392b; --warn: #b7791f;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 Montserrat, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text);
  min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--brand); }
h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.accent { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
code { background: #eef0f7; padding: 1px 6px; border-radius: 4px; font-size: 14px; }

.top { display: flex; align-items: center; gap: 24px; background: var(--brand); color: #fff; padding: 0 20px; height: 54px; flex-wrap: wrap; }
.top a { color: #fff; text-decoration: none; }
.brand { font-size: 18px; letter-spacing: .3px; }
.top nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.top nav a { padding: 6px 12px; border-radius: 6px; opacity: .85; }
.top nav a.on, .top nav a:hover { background: rgba(255,255,255,.15); opacity: 1; }
.me { display: flex; gap: 12px; align-items: center; }
.me form { margin: 0; }
.me .link { color: #fff; opacity: .8; margin-top: 0; }

.page { padding: 24px 20px; max-width: 1200px; width: 100%; margin: 0 auto; flex: 1; }
.narrow { padding: 40px 16px; max-width: 460px; width: 100%; margin: 0 auto; flex: 1; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.grid2 .card { margin-bottom: 0; }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.head-row h1 { margin: 0; }

label { display: block; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
label input, label select, textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; font: inherit; color: var(--text);
  border: 1px solid var(--line); border-radius: 7px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(55,63,137,.35); border-color: var(--brand); }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); }
label.check input { width: auto; margin: 0; }
textarea { margin-bottom: 12px; }
form.inline { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
form.inline label { margin: 0; flex: 1; min-width: 180px; }
.search { display: flex; gap: 8px; }
.search input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; font: inherit; min-width: 240px; }

.btn { display: inline-block; background: var(--brand); color: #fff; border: 0; border-radius: 7px; padding: 10px 18px;
  font: inherit; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--brand-d); }
.btn.light { background: #eef0f7; color: var(--brand); }
.btn.light:hover { background: #e2e5f2; }
.btn.red { background: var(--err); }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns form { margin: 0; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; text-decoration: underline; margin-top: 12px; }

.msg { padding: 10px 14px; border-radius: 7px; margin-bottom: 14px; }
.msg.err { background: #fdecea; color: var(--err); }
.msg.ok { background: #e8f6ee; color: var(--ok); }
.msg.warn { background: #fdf3e1; color: var(--warn); }
.secret-box { background: #fdf3e1; border: 1px solid #f1d9a7; border-radius: 8px; padding: 12px 14px; margin: 12px 0; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-weight: 600; color: var(--muted); font-size: 13px; background: #fafbfd; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.off td { color: var(--muted); }
.tbl tr.bad td { background: #fff6f5; }
.tbl.small td, .tbl.small th { font-size: 13px; padding: 6px 10px; }
.ua { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: #eef0f7; color: var(--brand); margin: 1px 2px 1px 0; }
.tag.gray { background: #eee; color: #777; }
.tag.warn { background: #fdf3e1; color: var(--warn); }
.tag.red { background: #fdecea; color: var(--err); }

.steps { padding-left: 20px; }
.qr { text-align: center; margin: 12px 0; }
.qr svg { width: 280px; height: 280px; max-width: 100%; display: inline-block; background: #fff; }

@media (max-width: 640px) {
  .top { height: auto; padding: 10px 16px; gap: 6px 12px; }
  .top nav { order: 3; width: 100%; flex: none; flex-wrap: nowrap; overflow-x: auto; }
  .top nav a { white-space: nowrap; }
  .me { margin-left: auto; }
  .page { padding: 16px; }
  .search input { min-width: 0; flex: 1; }
}

/* ---- шаг 1: клиенты ---- */
.tiles { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; min-width: 160px;
  text-decoration: none; color: var(--text); display: flex; flex-direction: column; }
.tile b { font-size: 28px; color: var(--brand); }
.tile span { color: var(--muted); font-size: 13px; }
.tile.warn b { color: var(--warn); }
.tile.add { border-style: dashed; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input[name=q] { flex: 1; min-width: 220px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; font: inherit; }
.filters select { padding: 9px 8px; border: 1px solid var(--line); border-radius: 7px; font: inherit; background: #fff; }
.filters label.check { margin: 0; }
.pager { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.lbl { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.multi { margin-bottom: 12px; }
.mi { display: flex; gap: 6px; margin-bottom: 6px; }
.mi input { flex: 1; padding: 9px 11px; font: inherit; border: 1px solid var(--line); border-radius: 7px; }
.mi .x { border: 0; background: #f1f2f7; color: var(--muted); border-radius: 7px; width: 34px; cursor: pointer; font-size: 18px; }
.add-mi { background: none; border: 0; color: var(--brand); cursor: pointer; padding: 2px 0; font: inherit; font-size: 13px; }
.contact { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px 4px; margin-bottom: 12px; background: #fbfbfd; }
.contact .rm-contact { margin: 0 0 10px; font-size: 13px; color: var(--err); }
.inn-row { display: flex; gap: 8px; align-items: end; }
.inn-row label { flex: 1; }
.inn-row .btn { margin-bottom: 12px; white-space: nowrap; }
#dadata-msg { margin: -6px 0 10px; }
#dadata-msg.good { color: var(--ok); }
#dadata-msg.bad { color: var(--err); font-weight: 600; }
.suggest-wrap { position: relative; }
.suggest { position: absolute; left: 0; right: 0; top: 100%; z-index: 10; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.08); max-height: 320px; overflow: auto; }
.suggest button { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line);
  padding: 8px 12px; font: inherit; font-size: 14px; cursor: pointer; color: var(--text); }
.suggest button:hover { background: #f4f5fb; }
.suggest span { color: var(--muted); font-size: 13px; }
details summary { cursor: pointer; color: var(--brand); margin-bottom: 10px; font-size: 14px; }
.src-pick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.pill input { position: absolute; opacity: 0; }
.pill { margin: 0; display: inline-block; position: relative; }
.pill span { display: inline-block; padding: 7px 14px; border: 1px solid var(--line); border-radius: 18px; cursor: pointer; color: var(--text); background: #fff; }
.pill input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.pill input:focus-visible + span { outline: 2px solid rgba(55,63,137,.4); }
.savebar { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 4px 0 20px; }
.savebar label.check { margin: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.person { padding: 8px 0; border-bottom: 1px solid var(--line); }
.person:last-child { border-bottom: 0; }
.pre { white-space: pre-wrap; margin: 0; }
.msg ul { margin: 6px 0; padding-left: 20px; }
@media (max-width: 640px) {
  .row2 { grid-template-columns: 1fr; gap: 0; }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dd { margin-bottom: 8px; }
}
button.link.small-link { margin: 0; font-size: 13px; color: var(--err); }

/* ---- шаг 3: почта ---- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.tabs a b { background: var(--warn); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; }
.nowrap { white-space: nowrap; }
.bad-text { color: var(--err); }
.mail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.mail-subj { font-size: 20px; }
.mail-body { white-space: pre-wrap; word-wrap: break-word; font-size: 14px; line-height: 1.55; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 10px; max-height: 70vh; overflow: auto; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.att { background: #f1f2f7; border-radius: 6px; padding: 5px 10px; text-decoration: none; font-size: 13px;
       display: inline-flex; align-items: center; gap: 5px; }
.clip { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; flex: none;
        background: url(/static/clip.svg) center / contain no-repeat; }
.mt { margin-top: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 5px 12px; cursor: pointer; font: inherit; font-size: 14px; display: inline-flex; gap: 6px; align-items: baseline; }
.chip small { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.chip:hover { border-color: var(--brand); }
.chip.used { background: #e8f6ee; border-color: #b9e2c9; }
.mail-hint { border-color: #c9cdea; background: #f7f8fd; }
aside .card h2 { font-size: 15px; }
@media (max-width: 900px) { .mail-layout { grid-template-columns: 1fr; } }

/* заведение клиента из письма: письмо справа */
.page.wide { max-width: 1600px; }
.with-mail { display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 16px; align-items: start; }
.wm-mail { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; margin: 0; }
.wm-mail .mail-body { max-height: none; overflow: visible; user-select: text; }
@media (max-width: 1100px) { .with-mail { grid-template-columns: 1fr; } .wm-mail { position: static; max-height: none; } }

/* ---------- сделки (шаг 4) ---------- */
.stagebar { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; padding: 0; margin: 4px 0 16px; counter-reset: st; }
.stagebar li { flex: 1 1 90px; font-size: 12px; padding: 6px 8px; background: #eceef4; color: #6b7280; border-radius: 4px;
               counter-increment: st; line-height: 1.25; }
.stagebar li::before { content: counter(st) ". "; }
.stagebar li.done { background: #dbe9dd; color: #2f5f37; }
.stagebar li.cur { background: #2d4a8a; color: #fff; font-weight: 600; }
.stage-tabs { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 12px; font-size: 14px; }
.stage-tabs a { text-decoration: none; color: #374151; padding: 2px 0; border-bottom: 2px solid transparent; }
.stage-tabs a.on { border-color: #2d4a8a; color: #2d4a8a; font-weight: 600; }
.stage-tabs b { background: #eceef4; border-radius: 9px; padding: 0 6px; font-size: 12px; }
.overdue { color: #b42318; font-weight: 600; }
.due { color: #b45309; font-weight: 600; }
.task { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px;
        padding: 8px 0; border-bottom: 1px solid #eceef4; }
.task.done { color: #6b7280; }
.task-done { display: flex; gap: 6px; }
.task-done input { width: 180px; }
.timeline { list-style: none; padding: 0; margin: 10px 0 0; }
.timeline li { padding: 6px 0; border-bottom: 1px solid #eceef4; }
.checklist { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.pill.hint span { outline: 2px dashed #2d4a8a; outline-offset: 1px; }
.narrow-form { max-width: 720px; }
[hidden] { display: none !important; }
.task-done input, form.inline > input, form > select { padding: 8px 10px; font: inherit; color: var(--text);
  border: 1px solid var(--line); border-radius: 7px; background: #fff; }
form.inline > input { flex: 1; min-width: 200px; }
form.row2 > button { justify-self: start; align-self: end; margin-bottom: 14px; }
.mail-body.request { max-height: 420px; overflow: auto; }
label.check.big { font-size: 16px; margin-bottom: 6px; }
.suggest .sug { padding: 8px 11px; cursor: pointer; border-bottom: 1px solid var(--line); }
.suggest .sug:hover { background: #f4f5fb; }

/* воронка этапов в карточке: стрелки */
.chevrons { display: flex; list-style: none; padding: 0; margin: 6px 0 18px; gap: 2px; }
.chevrons li { flex: 1 1 0; min-width: 0; position: relative; background: #e6e8f0; color: #6b7280; font-size: 12px;
  line-height: 1.2; padding: 9px 6px 9px 16px; clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%); }
.chevrons li:first-child { clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%); padding-left: 10px; border-radius: 6px 0 0 6px; }
.chevrons li span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chevrons li.done { background: #3f9b5a; color: #fff; }
.chevrons li.done span::before { content: "✓ "; }
.chevrons li.cur { background: var(--brand); color: #fff; font-weight: 600; }
.chevrons li.cur span { white-space: normal; }
.chevrons.ended li.done, .chevrons.ended li.cur { background: #9aa0ad; }
@media (max-width: 900px) { .chevrons li:not(.cur) span { font-size: 0; } .chevrons li.done span::before { font-size: 12px; } }

/* воронка в списке сделок */
.funnel { display: flex; flex-direction: column; align-items: center; gap: 3px; margin: 4px 0 18px; }
.funnel a { display: flex; justify-content: space-between; align-items: center; gap: 10px; text-decoration: none;
  color: #fff; background: var(--brand); padding: 7px 14px; border-radius: 4px; font-size: 14px; min-height: 34px; }
.funnel a .fn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.funnel a .fc { white-space: nowrap; font-size: 13px; opacity: .95; }
.funnel a.zero { background: #c9cddb; color: #4b5263; }
.funnel a.on { outline: 3px solid #f2b705; outline-offset: 1px; }
.funnel .f0 { width: 100%; } .funnel .f1 { width: 94%; } .funnel .f2 { width: 88%; } .funnel .f3 { width: 82%; }
.funnel .f4 { width: 76%; } .funnel .f5 { width: 70%; } .funnel .f6 { width: 64%; } .funnel .f7 { width: 58%; }
.funnel .f8 { width: 52%; } .funnel .f9 { width: 46%; } .funnel .f10 { width: 40%; }
.funnel .f0, .funnel .f1, .funnel .f2 { background: #4a56a6; } .funnel .f3, .funnel .f4 { background: #3d4a99; }
.funnel .f5, .funnel .f6, .funnel .f7 { background: #2f7d54; } .funnel .f8, .funnel .f9, .funnel .f10 { background: #3f9b5a; }
.funnel a.zero { background: #d5d8e3; }
.funnel-top { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-bottom: 8px; font-size: 14px; }
.funnel-top a { text-decoration: none; }
.funnel-top a.on { font-weight: 700; text-decoration: underline; }

/* расчёт сделки */
.calc { border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 10px; }
.calc .prow { margin-bottom: 6px; }
.calc .prow input { padding: 9px 11px; font: inherit; border: 1px solid var(--line); border-radius: 7px; width: 100%; }
.calc-result { font-weight: 600; margin: 8px 0; }
.ok-text { color: var(--ok); }
.calc-kv dd { text-align: right; }

/* лента событий и писем */
.tl { list-style: none; padding: 0 0 0 26px; margin: 12px 0 0; border-left: 2px solid #e3e6ef; }
.tl-item { position: relative; margin: 0 0 10px; padding: 8px 10px; background: #f8f9fc; border-radius: 6px; }
.tl-ico { position: absolute; left: -37px; top: 8px; width: 20px; height: 20px; border-radius: 50%; background: #fff;
  border: 2px solid #c9cddb; }
.tl-in .tl-ico { border-color: #c35fb5; } .tl-out .tl-ico { border-color: #3b8fd6; } .tl-ev .tl-ico { border-color: #9aa0ad; }
.tl-item summary { cursor: pointer; list-style: none; }
.tl-item summary::-webkit-details-marker { display: none; }
.tl-badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 4px; color: #fff; background: #c35fb5; }
.tl-out .tl-badge { background: #3b8fd6; }
.tl-date { float: right; font-size: 12px; color: var(--muted); }
.tl-subj { margin-top: 4px; }
.tl-prev { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-item details[open] .tl-prev { display: none; }
.tl-body { margin-top: 8px; max-height: 500px; overflow: auto; background: #fff; }

/* этап: подсказка, переход */
.hint-box { background: #f3f6ff; border-left: 3px solid var(--brand); padding: 8px 12px; border-radius: 4px; margin: 0 0 12px; font-size: 14px; }
.hint-box ul { margin: 4px 0 4px 18px; padding: 0; }
.move { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.q { display: inline-block; width: 16px; height: 16px; line-height: 16px; text-align: center; border-radius: 50%;
  background: #e3e6f0; color: #4b5263; font-size: 11px; font-weight: 700; cursor: help; vertical-align: 1px; }
.sum-row { border-bottom: 1px solid var(--line); padding: 8px 0; }
.sum-row > summary { cursor: pointer; }
.stage-card h2 { margin-top: 0; }
tr.alert-row td { background: #fff1f0; }

/* ---------- карточка сделки: иерархия (v0.4.4) ---------- */
main.page.wide { max-width: 1400px; }
.crumbs { margin: 0 0 4px; font-size: 14px; }
.deal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.deal-head h1 { margin: 0 0 10px; font-size: 24px; line-height: 1.25; }
.more { position: relative; flex: none; }
.more > summary { list-style: none; cursor: pointer; }
.more > summary::-webkit-details-marker { display: none; }
.more-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 360px; background: #fff;
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(28, 35, 80, .14); padding: 6px 14px; }
.more-panel > details, .more-panel > form { border-bottom: 1px solid var(--line); padding: 9px 0; }
.more-panel > details:last-child { border-bottom: 0; }
.more-panel summary { cursor: pointer; font-weight: 600; }
.more-panel summary.danger { color: var(--err); }
.more-panel form { margin-top: 8px; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--brand); cursor: pointer; }
.danger-btn { background: var(--err) !important; }

.facts { display: grid; grid-template-columns: 1fr 2fr 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; margin: 0 0 18px; }
.facts > div { background: #fff; padding: 10px 14px; }
.facts span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.facts b { font-size: 15px; }
.inline-edit { display: inline-block; margin-left: 6px; font-size: 13px; }
.inline-edit > summary { cursor: pointer; color: var(--brand); }
.inline-edit form { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.inline-edit input { padding: 6px 8px; font: inherit; border: 1px solid var(--line); border-radius: 6px; }
@media (max-width: 900px) { .facts { grid-template-columns: 1fr 1fr; } }

.deal-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 18px; align-items: start; }
.deal-main > .card, .deal-side > .card { margin-bottom: 18px; }
@media (max-width: 1000px) { .deal-grid { grid-template-columns: 1fr; } }

.stage-card { border-top: 4px solid var(--brand); }
.stage-card .hint-box > summary { cursor: pointer; font-weight: 600; }
.stage-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 6px; }
.btn.big { font-size: 16px; padding: 11px 20px; }
.other-stage { margin-top: 12px; font-size: 14px; }
.other-stage > summary { cursor: pointer; color: var(--muted); }
.other-stage select { margin-top: 6px; padding: 8px; font: inherit; border: 1px solid var(--line); border-radius: 7px; }
.comment-box > summary { cursor: pointer; color: var(--brand); font-size: 14px; margin: 4px 0 8px; }
.comment-box textarea { width: 100%; }
.inline-h { display: inline; font-size: 18px; }
.small-btn { padding: 5px 10px; font-size: 13px; }
.deal-side .tl { margin-left: 4px; }
.note-form { margin-bottom: 4px; }

/* ---------- раздел «Сделки»: сводка, графики, доска (v0.4.5) ---------- */
.dash-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.dash-head h1 { margin: 0; font-size: 26px; }
.dash-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; background: #e9ebf3; border-radius: 8px; padding: 3px; }
.seg a { padding: 6px 14px; border-radius: 6px; text-decoration: none; color: #4b5263; font-size: 14px; }
.seg a.on { background: #fff; color: var(--brand); font-weight: 600; box-shadow: 0 1px 2px rgba(28, 35, 80, .12); }
.seg-form { display: flex; gap: 6px; }
.seg-select { padding: 7px 10px; font: inherit; font-size: 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

.kpis { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; }
.kpi span { display: block; font-size: 13px; color: var(--muted); }
.kpi b { display: block; font-size: 30px; line-height: 1.15; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi em { font-style: normal; font-size: 13px; color: var(--muted); }
.kpi.main { background: var(--brand); border-color: var(--brand); color: #fff; }
.kpi.main span, .kpi.main em { color: rgba(255, 255, 255, .78); }
@media (max-width: 900px) { .kpis { grid-template-columns: 1fr 1fr; } }

.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.dash-grid .card { margin: 0; }
@media (max-width: 1000px) { .dash-grid { grid-template-columns: 1fr; } }
.chart-card svg { width: 100%; height: auto; display: block; }
.chart-card text { font-family: inherit; }
.funnel-svg .fl { font-size: 13px; fill: #3b4155; }
.funnel-svg .fl.on { font-weight: 700; fill: var(--brand); }
.funnel-svg .fp { transition: opacity .15s; }
.funnel-svg .fp.zero { opacity: .28; }
.funnel-svg a:hover .fp, .funnel-svg .fp.on { opacity: 1; stroke: #1d2033; stroke-width: 1.5; }
.funnel-svg .fv { font-size: 13px; font-weight: 700; fill: #fff; font-variant-numeric: tabular-nums; }
.funnel-svg .fv.zero { fill: #4b5263; font-weight: 400; }
.bars-svg .ax { font-size: 10px; fill: var(--muted); }
.bars-svg .bv { font-size: 11px; font-weight: 700; fill: #3b4155; }
.bars-svg .grid { stroke: #eceef4; }
.bars-svg .axis { stroke: #c9cdd8; }
.hbar-svg .fl { font-size: 13px; fill: #3b4155; }
.hbar-svg .bv { font-size: 12px; fill: #3b4155; font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.list-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.status-tabs { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; flex: 1; }
.status-tabs a { text-decoration: none; color: #4b5263; padding: 3px 0; border-bottom: 2px solid transparent; }
.status-tabs a.on { color: var(--brand); border-color: var(--brand); font-weight: 600; }
.status-tabs small { color: var(--muted); }
.search-form input { padding: 8px 12px; font: inherit; font-size: 14px; border: 1px solid var(--line); border-radius: 8px; width: 280px; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto;
  padding-bottom: 10px; margin-bottom: 8px; }
.col { background: #eceef5; border-radius: 10px; padding: 10px; min-height: 140px; }
.col header { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; margin: 2px 4px 10px; }
.col header span { background: #fff; border-radius: 10px; padding: 0 8px; color: var(--muted); font-variant-numeric: tabular-nums; }
.col-empty { color: #9aa0ad; font-size: 13px; text-align: center; margin: 18px 0; }
.dcard { position: relative; display: block; background: #fff; border-radius: 8px; padding: 10px 12px 10px 14px;
  margin-bottom: 8px; text-decoration: none; color: var(--text); border: 1px solid transparent; font-size: 13px; }
.dcard:hover { border-color: var(--brand); }
.dcard:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.dcard.alert { border-left: 4px solid var(--err); background: #fff7f6; }
.dc-src { position: absolute; top: 12px; right: 10px; line-height: 0; }
.dc-client { display: block; font-size: 14px; padding-right: 14px; }
.dc-title { display: block; color: #4b5263; margin: 2px 0 6px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.dc-money { display: inline-block; font-weight: 700; font-variant-numeric: tabular-nums; margin-bottom: 4px; }
.dc-next, .dc-alert, .dc-mgr { display: block; font-size: 12px; color: var(--muted); }
.dc-alert { color: var(--err); font-weight: 600; }
.dash-grid { align-items: start; }

/* пройденные этапы */
.chevrons li a { color: inherit; text-decoration: none; display: block; }
.chevrons li.done:hover { background: #2f8a4c; }
.chevrons li.viewing { background: #1f6b3a; box-shadow: inset 0 -3px 0 #f2b705; }
.viewed-card { border-top: 4px solid #3f9b5a; }
.viewed-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.viewed-head h2 { margin: 0; }
.viewed-events { list-style: none; padding: 0; margin: 0 0 12px; }
.viewed-events li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.sub-h { font-size: 15px; margin: 14px 0 6px; }

/* быстрые кнопки-подсказки */
.quick { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.qchip { font: inherit; font-size: 12px; padding: 3px 10px; border-radius: 12px; border: 1px solid #d5d9e6; background: #f6f7fb;
  color: #3b4155; cursor: pointer; }
.qchip:hover { border-color: var(--brand); color: var(--brand); }
.qchip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.qchip:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.note-form { flex-wrap: wrap; }
.note-form .quick { flex-basis: 100%; order: 3; margin-top: 0; }
.dash-sub { font-size: 18px; margin: 26px 0 12px; }

/* деньги по сделке */
.money-card { border-top: 4px solid #B5652B; }
.money-sum { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.money-sum > div { background: #fff; padding: 8px 12px; }
.money-sum span { display: block; font-size: 12px; color: var(--muted); }
.money-sum b { font-variant-numeric: tabular-nums; }
.money-sum em { display: block; font-style: normal; font-size: 12px; color: var(--muted); }
.money-sum .ms-total { background: #fbf6f1; }
@media (max-width: 700px) { .money-sum { grid-template-columns: 1fr 1fr; } }
.mrow { display: flex; align-items: center; gap: 12px; padding: 5px 0; border-bottom: 1px solid #f0f1f6; font-size: 14px; flex-wrap: wrap; }
.mrow b { font-variant-numeric: tabular-nums; }
.mrow form { margin-left: auto; }
.mrow .x { background: none; border: 0; color: #9aa0ad; font-size: 18px; cursor: pointer; line-height: 1; }
.mrow .x:hover { color: var(--err); }
.mrow-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.mrow-form > input, .mrow.bill input:not([type=checkbox]) { padding: 7px 9px; font: inherit; font-size: 14px; border: 1px solid var(--line); border-radius: 7px; }
.mrow.bill { width: 100%; border: 0; }
.mrow.bill input[name=bill_supplier] { flex: 2; min-width: 140px; }
.mrow.bill input[name=bill_no] { width: 100px; }
.mrow.bill input[name=bill_amount] { width: 120px; }
.mrow-form .check { margin: 0; }
.madd > summary { cursor: pointer; color: var(--brand); font-size: 14px; margin: 6px 0; }
.inline-label { display: flex; align-items: center; gap: 8px; margin: 0; }
.inline-label input { width: auto; margin: 0; }
.mrow-form .quick { flex-basis: 100%; margin-top: 0; }
