/* CRM бота: сводка, воронка, люди, казна. Одна светлая тема, плотные таблицы, цифры моноширинным. */
:root {
  --paper: #f5f3ee;
  --card: #fffdf9;
  --ink: #1d1c1a;
  --soft: #6f6b62;
  --faint: #a39e93;
  --line: #e4dfd4;
  --line-strong: #cfc8ba;
  --money: #0f6b4f;
  --money-soft: #e3f1ea;
  --warn: #a8690f;
  --warn-soft: #f8ecd4;
  --bad: #b3372f;
  --bad-soft: #f8e2df;
  --blue: #2b5fa8;
  --blue-soft: #e3ecf8;
  --violet: #6a4aa5;
  --violet-soft: #ece6f6;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html,
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14px / 1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a {
  color: inherit;
  text-decoration: none;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

.app {
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr);
  min-height: 100vh;
}
.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 22px 14px 18px;
  border-right: 1px solid var(--line);
  background: #efece5;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
}
.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, transparent 46%, #fffdf9 46%, #fffdf9 54%, transparent 54%),
    var(--money);
}
.brand-name {
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.1;
}
.brand-name small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: var(--soft);
  letter-spacing: 0;
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav a {
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--soft);
  font-weight: 500;
}
.nav a:hover {
  background: #e6e2d8;
  color: var(--ink);
}
.nav a.on {
  background: var(--ink);
  color: #fffdf9;
}
.rail-foot {
  margin-top: auto;
  padding: 0 8px;
  font-size: 12px;
  color: var(--soft);
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}
.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link:hover {
  color: var(--ink);
}

.main {
  padding: 26px 32px 60px;
  max-width: 1280px;
  width: 100%;
}
.head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.01em;
}
h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--soft);
}
.muted {
  color: var(--soft);
}
.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.right {
  text-align: right;
}

/* Полоса ключевых цифр: одна строка, четыре числа. */
.strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 22px;
}
.figure {
  padding: 16px 18px 14px;
  border-left: 1px solid var(--line);
  min-width: 0;
}
.figure:first-child {
  border-left: 0;
}
.figure .label {
  font-size: 12px;
  color: var(--soft);
}
.figure .value {
  font: 600 26px / 1.15 var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  margin: 4px 0 3px;
}
.figure .value.money {
  color: var(--money);
}
.figure .sub {
  font-size: 12px;
  color: var(--soft);
}
.figure .sub b {
  color: var(--ink);
  font-weight: 600;
}
.sub .bad {
  color: var(--bad);
}

.grid {
  display: grid;
  align-items: start;
  gap: 22px;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  margin-bottom: 22px;
}
.grid.cash {
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
}
.block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  min-width: 0;
}
.block.flush {
  padding: 16px 0 6px;
}
.block.flush h2,
.block.flush .note {
  padding: 0 18px;
}
.note {
  font-size: 12px;
  color: var(--soft);
  margin: 0 0 10px;
}

/* Воронка: ступени сужаются, справа видно, сколько людей на ступени остановилось. */
.funnel {
  display: grid;
  gap: 7px;
}
.step {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 150px;
  align-items: center;
  gap: 14px;
}
.step .name {
  font-weight: 500;
}
.step .track {
  position: relative;
  height: 30px;
  background: #efece5;
  border-radius: 6px;
  overflow: hidden;
}
.step .fill {
  position: absolute;
  inset: 0 auto 0 0;
  min-width: 2px;
  border-radius: 6px;
  background: linear-gradient(90deg, #17805f, #0f6b4f);
  transition: width 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.step .inside {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.step .inside b {
  font-size: 15px;
}
.step .inside span {
  font-size: 12px;
  color: var(--soft);
}
.step.wide .inside b,
.step.wide .inside span {
  color: #fffdf9;
}
.step .lost {
  font-size: 12px;
  color: var(--soft);
  white-space: nowrap;
}
.step .lost a {
  color: var(--bad);
  font-weight: 600;
  border-bottom: 1px dashed currentColor;
}
.step .lost.end a {
  color: var(--money);
}
.drop {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 150px;
  gap: 14px;
  font-size: 11px;
  color: var(--faint);
  font-family: var(--mono);
  margin: -3px 0;
}
.funnel.compact .step {
  grid-template-columns: 170px minmax(0, 1fr);
}
.funnel.compact .track {
  height: 24px;
}
.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--soft);
}
.facts b {
  color: var(--ink);
  font-family: var(--mono);
}

/* Переключатели: источник и период. */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  border: 1px solid var(--line-strong);
  background: transparent;
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12.5px;
  color: var(--soft);
  cursor: pointer;
}
.chip:hover {
  color: var(--ink);
}
.chip.on {
  background: var(--ink);
  border-color: var(--ink);
  color: #fffdf9;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  margin-bottom: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  padding: 8px 10px;
  text-align: left;
  border-top: 1px solid var(--line);
  vertical-align: top;
  white-space: nowrap;
}
td.wrap {
  white-space: normal;
  min-width: 130px;
}
th {
  border-top: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--faint);
  white-space: nowrap;
}
td.num,
th.num {
  text-align: right;
}
.flush th:first-child,
.flush td:first-child {
  padding-left: 18px;
}
.flush th:last-child,
.flush td:last-child {
  padding-right: 18px;
}
tr.total td {
  font-weight: 600;
  border-top: 1px solid var(--line-strong);
}
tr.go {
  cursor: pointer;
}
tr.go:hover td {
  background: #f3efe6;
}
tr.void td {
  color: var(--faint);
  text-decoration: line-through;
}
.scroll {
  overflow-x: auto;
}
.who b {
  font-weight: 600;
}
.who small {
  display: block;
  color: var(--soft);
  font-size: 12px;
}
.empty {
  padding: 22px 18px;
  color: var(--faint);
  text-align: center;
}

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #ebe7dd;
  color: var(--soft);
  white-space: nowrap;
}
.tag.s5 {
  background: var(--warn-soft);
  color: var(--warn);
}
.tag.s6,
.tag.good {
  background: var(--money-soft);
  color: var(--money);
}
.tag.s4,
.tag.s3 {
  background: var(--blue-soft);
  color: var(--blue);
}
.tag.bad {
  background: var(--bad-soft);
  color: var(--bad);
}
.tag.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

/* График по дням: столбики — новые люди, точки — приход. */
.chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 6px;
  align-items: end;
  height: 150px;
  padding-top: 18px;
}
.day {
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  justify-items: center;
  gap: 3px;
}
.day .area {
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.day .bar {
  width: 100%;
  max-width: 34px;
  border-radius: 4px 4px 0 0;
  background: #d9d3c5;
  min-height: 2px;
  position: relative;
}
.day .bar.has {
  background: #8a8477;
}
.day .cash {
  position: absolute;
  left: 50%;
  transform: translate(-50%, -100%);
  top: -3px;
  font: 600 10.5px var(--mono);
  color: var(--money);
  white-space: nowrap;
}
.day .count {
  font: 11px var(--mono);
  color: var(--soft);
}
.day .date {
  font-size: 10.5px;
  color: var(--faint);
  white-space: nowrap;
}
.legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--soft);
  margin-top: 8px;
}
.legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  margin-right: 5px;
  background: #8a8477;
}
.legend i.cash {
  background: var(--money);
}

/* Лента и история: время, вид события, что произошло. */
.feed {
  display: grid;
}
.event {
  display: grid;
  grid-template-columns: 46px 12px minmax(0, 1fr);
  gap: 10px;
  padding: 7px 0;
  align-items: start;
}
.event + .event {
  border-top: 1px solid var(--line);
}
.event time {
  font: 12px var(--mono);
  color: var(--faint);
  padding-top: 1px;
}
.event .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-top: 5px;
  background: var(--faint);
}
.dot.k-paid,
.dot.k-access {
  background: var(--money);
}
.dot.k-failed {
  background: var(--bad);
}
.dot.k-bot {
  background: #c9c3b6;
}
.dot.k-button,
.dot.k-view {
  background: var(--blue);
}
.dot.k-order,
.dot.k-request {
  background: var(--warn);
}
.dot.k-start,
.dot.k-phone {
  background: var(--ink);
}
.dot.k-staff,
.dot.k-note {
  background: var(--violet);
}
.event .what small {
  color: var(--soft);
}
.event.k-bot .what {
  color: var(--soft);
}
.event.k-paid .what {
  font-weight: 600;
  color: var(--money);
}
.event.k-failed .what {
  color: var(--bad);
}
.event.k-note .what {
  background: var(--violet-soft);
  border-radius: 6px;
  padding: 4px 8px;
}
.daymark {
  margin: 14px 0 2px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
}
.daymark:first-child {
  margin-top: 0;
}

.todo {
  display: grid;
  gap: 0;
}
.todo a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.todo a:first-child {
  border-top: 0;
}
.todo a:hover b {
  text-decoration: underline;
}
.todo small {
  color: var(--soft);
}

.person-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 18px;
}
.person-head h1 {
  margin-right: 4px;
}
.back {
  color: var(--soft);
  font-size: 13px;
  display: inline-block;
  margin-bottom: 10px;
}
.back:hover {
  color: var(--ink);
}
dl.pairs {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 7px 12px;
  margin: 0;
}
dl.pairs dt {
  color: var(--soft);
}
dl.pairs dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}
.stack {
  display: grid;
  gap: 22px;
  align-content: start;
}

.field,
.form input,
.form select,
.form textarea {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 8px;
  padding: 7px 10px;
  min-width: 0;
}
.field:focus,
.form input:focus,
.form select:focus,
.form textarea:focus {
  outline: 2px solid var(--ink);
  outline-offset: -1px;
}
.form {
  display: grid;
  gap: 8px;
}
.form .row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}
.form textarea {
  resize: vertical;
  min-height: 62px;
}
.btn {
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  background: var(--ink);
  color: #fffdf9;
  font-weight: 600;
  cursor: pointer;
  justify-self: start;
}
.btn:hover {
  background: #000;
}
.btn.ghost {
  background: transparent;
  color: var(--soft);
  border: 1px solid var(--line-strong);
  font-weight: 500;
  padding: 3px 9px;
  font-size: 12px;
}
.btn.ghost:hover {
  color: var(--ink);
  border-color: var(--ink);
}
.error {
  color: var(--bad);
  font-size: 13px;
}
.copy {
  font: 12px var(--mono);
  color: var(--blue);
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  overflow-wrap: anywhere;
}
.copy:hover {
  text-decoration: underline;
}
.copy.done {
  color: var(--money);
}

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate .card {
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
}
.gate h1 {
  margin-bottom: 14px;
}
.gate .card {
  width: 100%;
}
.gate .form {
  margin-bottom: 16px;
}
.gate .btn {
  justify-self: stretch;
  padding: 10px 14px;
}
.gate code {
  font-family: var(--mono);
  background: #efece5;
  padding: 1px 6px;
  border-radius: 5px;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }
  .rail {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .nav {
    flex-direction: row;
  }
  .rail-foot {
    margin: 0 0 0 auto;
    flex-direction: row;
    gap: 10px;
  }
  .brand-name small {
    display: none;
  }
  .main {
    padding: 18px 14px 50px;
  }
  .strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .figure:nth-child(3) {
    border-left: 0;
  }
  .figure:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }
  .grid,
  .grid.cash {
    grid-template-columns: minmax(0, 1fr);
  }
  .step,
  .drop {
    grid-template-columns: 120px minmax(0, 1fr);
  }
  .step .lost,
  .drop span:last-child,
  .day .cash {
    display: none;
  }
}
