/* CRM «Аксиома» — фирменный стиль: brand #1B2F55, wave #E8833A, шрифт Manrope */
:root {
  --brand: #1B2F55; --brand-2: #24396A; --wave: #E8833A; --wave-ink: #A9531A;
  --surface: #FFFFFF; --soft: #F3F6F9; --ink: #1B2F55; --muted: #4A5B78; --line: #D9DEE5;
  --red: #B42318; --red-bg: #FDECEA; --org-bg: #FDF0E6; --ok: #1E6B3F; --ok-bg: #E7F3EC; --blue-bg: #E8EEF7;
  --r-sm: 4px; --r-md: 8px;
  font-family: Manrope, 'Golos Text', Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--soft); color: var(--ink); font-size: 15px; line-height: 1.45; }
a { color: var(--wave-ink); }
a:hover { color: var(--brand); }
h1 { font-size: 28px; line-height: 34px; margin: 0; }
h2 { font-size: 20px; line-height: 26px; margin: 0; }
h3 { font-size: 16px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* каркас */
.layout { min-height: 100vh; display: flex; flex-wrap: wrap; }
.side { flex: 1 1 232px; max-width: 260px; background: var(--brand); padding: 24px 16px; display: flex; flex-direction: column; gap: 4px; }
.logo { padding: 0 14px 24px; display: flex; flex-direction: column; gap: 6px; }
.logo b { font-size: 18px; letter-spacing: .18em; color: #fff; }
.logo i { width: 48px; height: 4px; border-radius: 2px; background: var(--wave); display: block; }
.logo span { font-size: 12px; color: #B9C6D8; }
.side a { display: block; padding: 10px 14px; border-radius: var(--r-sm); color: #D9E2EF; text-decoration: none; }
.side a.on { background: var(--brand-2); color: #fff; font-weight: 600; }
.side a:focus-visible { outline: 2px solid var(--wave); }
.side .me { margin-top: auto; padding: 24px 14px 0; font-size: 13px; color: #B9C6D8; }
.side .me button { margin-top: 8px; background: none; border: 1px solid #4A5B78; color: #D9E2EF; border-radius: var(--r-sm); min-height: 36px; padding: 0 12px; font: inherit; cursor: pointer; }
.main { flex: 999 1 560px; min-width: 0; padding: 32px 40px 48px; display: flex; flex-direction: column; gap: 20px; }
.bottom { display: none; }

.head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.head .grow { flex: 1 1 300px; }
.crumbs { font-size: 13px; color: var(--muted); }

/* элементы */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: var(--r-sm); border: 1px solid var(--brand); background: var(--brand); color: #fff; font: 600 14px Manrope, Arial, sans-serif; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--brand-2); color: #fff; }
.btn.ghost { background: #fff; color: var(--brand); }
.btn.ghost:hover { background: var(--soft); }
.btn.danger { background: #fff; color: var(--red); border-color: var(--red); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--wave); outline-offset: 1px; }

.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; }
.tile.flush { padding: 0; }
.tile .tile-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .val { font-size: 30px; font-weight: 700; margin-top: 4px; }
.kpi .val.red { color: var(--red); }
.kpi .val.org { color: var(--wave-ink); }
.row { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.col-2 { flex: 2 1 520px; min-width: 0; }
.col-1 { flex: 1 1 300px; min-width: 0; }

.tag { display: inline-block; padding: 3px 8px; border-radius: var(--r-sm); font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag.red { background: var(--red-bg); color: var(--red); }
.tag.org { background: var(--org-bg); color: var(--wave-ink); }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.blue { background: var(--blue-bg); color: var(--brand); }
.tag.grey { background: var(--soft); color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.chk { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; color: var(--ink); }
label.chk input { width: 20px; height: 20px; }
.inp, select.inp, textarea.inp { min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; font: 14px Manrope, Arial, sans-serif; color: var(--ink); width: 100%; }
textarea.inp { padding: 10px 12px; min-height: 84px; resize: vertical; }
.filters .inp { width: auto; min-width: 180px; }
.filters input[type=search].inp { min-width: 260px; }

/* таблицы */
.scroll { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); background: var(--soft); padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 12px; white-space: nowrap; }
table.t td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #FAFBFC; }
table.t .num { text-align: right; white-space: nowrap; }
.sub { font-size: 12px; color: var(--muted); }
table.t td.lead-cell { min-width: 190px; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.eq { display: inline-block; min-width: 24px; padding: 2px 4px; margin: 0 2px 2px 0; border-radius: var(--r-sm); font-size: 11px; font-weight: 700; text-align: center; border: 1px solid var(--line); color: var(--muted); }
.eq.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* воронка и полосы */
.bars { display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.bar-top { display: flex; justify-content: space-between; gap: 8px; }
.bar { height: 8px; background: var(--soft); border-radius: 4px; margin-top: 4px; overflow: hidden; }
.bar i { display: block; height: 8px; background: var(--brand); border-radius: 4px; }
.bar i.w { background: var(--wave); }

/* этапы воронки в карточке */
.steps { display: flex; gap: 4px; overflow-x: auto; }
.step { flex: 1 1 0; min-width: 92px; padding: 8px 6px; font: 600 11px Manrope, Arial, sans-serif; text-align: center; border: 0; border-top: 4px solid var(--line); color: var(--muted); background: none; cursor: pointer; min-height: 44px; }
.step.done { border-top-color: var(--brand); color: var(--brand); }
.step.now { border-top-color: var(--wave); color: var(--brand); }
.step.lost.now { border-top-color: var(--red); color: var(--red); }

.fields { display: flex; flex-direction: column; gap: 12px; }
.fv span { display: block; font-size: 12px; color: var(--muted); }
.ev { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.ev:last-child { border-bottom: 0; }
.ev .d { width: 88px; flex: none; color: var(--muted); }
.ev .c { white-space: pre-wrap; margin-top: 4px; }

/* вход */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login .box { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); padding: 32px; display: flex; flex-direction: column; gap: 16px; }
.login .logo { padding: 0; }
.login .logo b { color: var(--brand); }
.login .logo span { color: var(--muted); }

/* окно формы */
dialog#modal { border: 0; border-radius: var(--r-md); padding: 0; width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 32px); color: var(--ink); }
dialog#modal::backdrop { background: rgba(27, 47, 85, .45); }
dialog#modal.wide { width: min(1040px, calc(100vw - 24px)); }
.m-head { position: sticky; top: 0; background: #fff; padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; z-index: 1; }
.m-body { padding: 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.m-body .full { grid-column: 1 / -1; }
.m-body .sect { grid-column: 1 / -1; font-weight: 700; font-size: 15px; padding-top: 8px; border-top: 1px solid var(--line); margin-top: 4px; }
.m-body .sect:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.m-foot { position: sticky; bottom: 0; background: #fff; padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.m-foot .left { margin-right: auto; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.note { background: var(--org-bg); color: var(--wave-ink); border-radius: var(--r-md); padding: 12px; font-size: 13px; font-weight: 600; }
.icon-btn { width: 44px; height: 44px; border: 0; background: none; cursor: pointer; color: var(--brand); border-radius: var(--r-sm); }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--brand); color: #fff; padding: 12px 16px; border-radius: var(--r-md); font-size: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.18); }
.toast.warn { background: #fff; color: var(--wave-ink); border: 2px solid var(--wave); }
.toast.err { background: var(--red); }

.more a { display: flex; align-items: center; min-height: 52px; padding: 0 16px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 600; }

/* телефон */
@media (max-width: 760px) {
  .side { display: none; }
  .main { padding: 16px 12px 96px; gap: 14px; }
  h1 { font-size: 22px; line-height: 28px; }
  .bottom { display: flex; position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); z-index: 50; padding-bottom: env(safe-area-inset-bottom); }
  .bottom a, .bottom button { flex: 1 1 0; display: flex; align-items: center; justify-content: center; min-height: 56px; font: 600 12px Manrope, Arial, sans-serif; color: var(--muted); text-decoration: none; background: none; border: 0; }
  .bottom a.on { color: var(--brand); box-shadow: inset 0 3px 0 var(--wave); }
  .bottom .plus { color: #fff; background: var(--brand); margin: 6px; border-radius: var(--r-md); min-height: 44px; }
  .head .btn { flex: 1 1 auto; }
  .filters .inp, .filters input[type=search].inp { min-width: 0; width: 100%; }
  .filters label.f { flex: 1 1 100%; }
  .m-body { grid-template-columns: 1fr; }
  dialog#modal, dialog#modal.wide { width: 100vw; max-width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; margin: 0; }
  /* таблицы → карточки */
  table.t.cards thead { display: none; }
  table.t.cards, table.t.cards tbody, table.t.cards tr, table.t.cards td { display: block; width: 100%; }
  table.t.cards tr { border-bottom: 1px solid var(--line); padding: 10px 4px; }
  table.t.cards td { border: 0; padding: 3px 8px; }
  table.t.cards td[data-l]::before { content: attr(data-l) ': '; color: var(--muted); font-size: 12px; }
  table.t.cards td.lead-cell { font-size: 16px; font-weight: 700; }
  table.t.cards .num { text-align: left; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  #toasts { bottom: 80px; left: 16px; right: 16px; max-width: none; }
  table.t td.lead-cell { min-width: 0; }
  .kpi .val { font-size: 24px; }
}

/* ---------- этап 3: контакты и календарь ---------- */
.contact { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.contact:first-of-type { border-top: 0; }
.cal { padding: 12px; }
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cal-head h2 { flex: 1; text-align: center; margin: 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-wd { font-size: 12px; color: var(--muted); text-align: center; padding: 4px 0; font-weight: 600; }
.cal-day { min-height: 92px; display: flex; flex-direction: column; gap: 2px; align-items: stretch; text-align: left; padding: 4px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); font: inherit; color: var(--ink); cursor: pointer; overflow: hidden; position: relative; }
.cal-day:hover { border-color: var(--brand); }
.cal-day.out { background: var(--soft); color: var(--muted); }
.cal-day.today .cal-n { background: var(--wave); color: #fff; border-radius: 10px; padding: 0 6px; }
.cal-day.sel { outline: 2px solid var(--brand); outline-offset: -1px; }
.cal-n { font-size: 13px; font-weight: 600; align-self: flex-start; }
.cal-ev { font-size: 11px; line-height: 15px; padding: 1px 4px; border-radius: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--blue-bg); color: var(--brand); }
.cal-more { font-size: 11px; color: var(--muted); }
.cal-dot { display: none; }
.cal-item { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--r-sm); background: var(--surface); font: inherit; color: var(--ink); cursor: pointer; }
.cal-item:hover { border-color: var(--brand); }
.ev-meet { background: var(--org-bg); color: var(--wave-ink); border-left-color: var(--wave) !important; }
.ev-team { background: var(--blue-bg); color: var(--brand); border-left-color: var(--brand) !important; }
.ev-call { background: var(--ok-bg); color: var(--ok); border-left-color: var(--ok) !important; }
.ev-other { background: var(--soft); color: var(--muted); border-left-color: var(--muted) !important; }
.cal-item.ev-meet, .cal-item.ev-team, .cal-item.ev-call, .cal-item.ev-other { background: var(--surface); color: var(--ink); }
.tag.ev-meet, .tag.ev-team, .tag.ev-call, .tag.ev-other { border: 0; }
@media (max-width: 760px) {
  .cal-day { min-height: 48px; padding: 3px; }
  .cal-ev, .cal-more { display: none; }
  .cal-dot { display: block; width: 6px; height: 6px; border-radius: 3px; background: var(--wave); margin: 2px auto 0; }
}

/* ---------- инструкция ---------- */
.help { max-width: 860px; line-height: 1.6; }
.help h2 { margin: 0 0 8px; }
.help p { margin: 0; }
.h-rules { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.h-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.h-step { display: flex; gap: 14px; align-items: flex-start; }
.h-step h3 { margin: 0 0 2px; font-size: 16px; }
.h-n { flex: none; width: 32px; height: 32px; border-radius: 16px; background: var(--brand); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.h-faq { margin: 0; }
.h-faq dt { font-weight: 700; margin-top: 12px; }
.h-faq dt:first-child { margin-top: 0; }
.h-faq dd { margin: 2px 0 0; }
