/* Лидогенератор «как раз»: плотный рабочий интерфейс на каждый день. */

:root {
  --ink: #14171c;
  --bg: #f1f3f6;
  --card: #ffffff;
  --line: #e2e6ec;
  --line-soft: #eef1f5;
  --muted: #5b616b;
  --faint: #878d97;
  --accent: #3a5bd9;
  --accent-ink: #ffffff;
  --danger: #c62b31;

  --slate: #616873;
  --green: #14784c;
  --amber: #a96500;
  --indigo: #4a4fd0;
  --orange: #a8501c;
  --red: #c62b31;
  --deep: #0d5c3a;

  --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --head: 54px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14.5px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
ol,
ul,
dl,
dd,
figure {
  margin: 0;
  padding: 0;
}

ol,
ul {
  list-style: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent);
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

/* иначе display у .btn перебивает скрытие атрибутом hidden */
[hidden] {
  display: none !important;
}

/* ---------- Базовые элементы ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.14s;
}

.btn:hover {
  background: color-mix(in oklab, var(--accent) 86%, #000);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-quiet {
  background: transparent;
  color: var(--muted);
}

.btn-quiet:hover {
  background: var(--line-soft);
  color: var(--ink);
}

.btn-outline {
  background: var(--card);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.btn-outline:hover {
  background: var(--line-soft);
}

.btn-sm {
  min-height: 28px;
  padding: 0 10px;
  font-size: 13.5px;
}

.btn-wide {
  width: 100%;
  min-height: 42px;
}

.control {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  width: 100%;
  transition: border-color 0.14s;
}

.control:focus {
  border-color: var(--accent);
}

select.control {
  cursor: pointer;
}

.control-sm {
  min-height: 30px;
  font-size: 13.5px;
}

textarea.control {
  line-height: 1.45;
  resize: vertical;
}

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.err {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
}

.hint {
  color: var(--faint);
  font-size: 13px;
  line-height: 1.4;
}

code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--line-soft);
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  font-size: 13px;
}

/* ---------- Шапка ---------- */
.top {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--head);
  padding: 0 14px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.top-mark {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  white-space: nowrap;
}

.mark-dots {
  display: inline-flex;
  gap: 3px;
}

.mark-dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9aa0a6;
}

.mark-dots i:nth-child(2) {
  background: #5f6368;
}

.mark-dots i:nth-child(3) {
  background: var(--accent);
}

.field-inline {
  display: block;
}

.top .control {
  width: auto;
  min-width: 150px;
}

.search {
  position: relative;
  flex: 1;
  max-width: 340px;
}

.search svg {
  position: absolute;
  top: 50%;
  left: 10px;
  width: 16px;
  height: 16px;
  translate: 0 -50%;
  fill: none;
  stroke: var(--faint);
  stroke-width: 1.8;
  stroke-linecap: round;
  pointer-events: none;
}

.search .control {
  width: 100%;
  padding-left: 32px;
}

.top-stats {
  display: flex;
  gap: 16px;
  margin-left: auto;
  color: var(--muted);
  font-size: 13.5px;
  white-space: nowrap;
}

.top-stats b {
  color: var(--ink);
  font-weight: 600;
}

.top-stats .is-red b {
  color: var(--danger);
}

/* ---------- Рабочая область ---------- */
.work {
  display: grid;
  grid-template-columns: 384px minmax(0, 1fr);
  height: calc(100vh - var(--head));
}

.side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--card);
  border-right: 1px solid var(--line);
}

.filters {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 27px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font-size: 13px;
  cursor: pointer;
  transition:
    background-color 0.14s,
    border-color 0.14s;
}

.chip:hover {
  border-color: var(--faint);
}

.chip b {
  color: var(--faint);
  font-weight: 500;
}

.chip.is-on {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.chip.is-on b {
  color: rgb(255 255 255 / 0.65);
}

.chip i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tone, var(--slate));
}

.filters-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 9px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
}

.toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.filters-row .field-inline {
  margin-left: auto;
}

.filters-row .control {
  width: auto;
}

/* Список */
.leads {
  flex: 1;
  overflow: auto;
  outline: none;
}

.lead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}

.lead:hover {
  background: var(--line-soft);
}

.lead.is-on {
  background: color-mix(in oklab, var(--accent) 9%, var(--card));
  box-shadow: inset 3px 0 0 var(--accent);
}

.lead-name {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-weight: 500;
}

.lead-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.no-site {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 5px;
  background: color-mix(in oklab, var(--danger) 14%, #fff);
}

.no-site svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: var(--danger);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lead-meta {
  grid-column: 1;
  color: var(--faint);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-side {
  grid-row: 1 / 3;
  grid-column: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--tone) 12%, #fff);
  color: var(--tone);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.lead-when {
  color: var(--faint);
  font-size: 12px;
  white-space: nowrap;
}

.lead-when.is-due {
  color: var(--danger);
  font-weight: 500;
}

.side-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 13px;
}

/* ---------- Карточка ---------- */
.detail {
  min-height: 0;
  overflow: auto;
  padding: 18px 22px 60px;
}

.empty {
  max-width: 420px;
  margin: 12vh auto 0;
  text-align: center;
  color: var(--muted);
}

.empty h2 {
  font-size: 19px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--ink);
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px 16px;
}

.card-title {
  min-width: 0;
  flex: 1;
}

.card-title h2 {
  font-size: 21px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.card-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13.5px;
}

.card-cols {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(300px, 0.95fr);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.block {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

.block + .block {
  margin-top: 14px;
}

.block h3 {
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

/* Статусы */
.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.status-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  font-size: 13.5px;
  cursor: pointer;
  transition:
    border-color 0.14s,
    background-color 0.14s;
}

.status-btn i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tone);
}

.status-btn kbd {
  color: var(--faint);
  font: inherit;
  font-size: 11.5px;
}

.status-btn:hover {
  border-color: var(--faint);
}

.status-btn.is-on {
  border-color: var(--tone);
  background: color-mix(in oklab, var(--tone) 11%, #fff);
  font-weight: 500;
}

/* Контакты */
.rows {
  display: grid;
  gap: 1px;
}

.row {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
}

.row:last-child {
  border-bottom: 0;
}

.row dt {
  color: var(--faint);
  font-size: 13px;
}

.row dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

.row dd a {
  text-decoration: none;
}

.row dd a:hover {
  text-decoration: underline;
}

.phone-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.phone-line + .phone-line {
  margin-top: 4px;
}

.phone-line a {
  font-weight: 500;
  font-size: 15px;
}

.copy {
  border: 0;
  background: none;
  color: var(--faint);
  font-size: 12.5px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.copy:hover {
  color: var(--ink);
}

.flag-no-site {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--danger);
  font-weight: 500;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-grid label {
  display: block;
  font-size: 13px;
  color: var(--faint);
  margin-bottom: 4px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.note-add {
  display: grid;
  gap: 8px;
}

.note-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.note-quick button {
  min-height: 27px;
  padding: 0 9px;
  border: 1px dashed var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
}

.note-quick button:hover {
  border-style: solid;
  border-color: var(--faint);
  color: var(--ink);
}

.notes {
  display: grid;
  gap: 0;
  margin-top: 12px;
}

.note {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  padding: 9px 0;
  border-top: 1px solid var(--line-soft);
}

.note p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.note.is-status p {
  color: var(--muted);
  font-size: 13.5px;
}

.note-when {
  color: var(--faint);
  font-size: 12.5px;
  white-space: nowrap;
}

.note-del {
  grid-column: 2;
  border: 0;
  background: none;
  color: var(--faint);
  font-size: 12.5px;
  cursor: pointer;
  justify-self: end;
}

.note-del:hover {
  color: var(--danger);
}

.raw {
  margin-top: 14px;
}

.raw summary {
  color: var(--muted);
  font-size: 13.5px;
  cursor: pointer;
}

.raw pre {
  margin: 10px 0 0;
  max-height: 320px;
  overflow: auto;
  padding: 12px;
  border-radius: 10px;
  background: var(--line-soft);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* ---------- Окно сбора ---------- */
.sheet {
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 22px 24px 26px;
  border: 0;
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
}

.sheet::backdrop {
  background: rgb(14 18 24 / 0.45);
}

.sheet h2 {
  font-size: 20px;
  font-weight: 600;
}

.sheet-close {
  float: right;
}

.sheet-close .x {
  border: 0;
  background: none;
  color: var(--faint);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.sheet-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.steps {
  counter-reset: step;
  margin-top: 18px;
}

.steps li {
  position: relative;
  padding: 0 0 18px 34px;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 1px;
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: var(--line-soft);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

.steps h3 {
  font-size: 15px;
  font-weight: 600;
}

.steps p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

.bookmarklet {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 15px;
  border-radius: 9px;
  background: var(--ink);
  color: #fff;
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  cursor: grab;
}

.paste {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.paste-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.more {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.more summary {
  color: var(--muted);
  font-size: 13.5px;
  cursor: pointer;
}

.more-body {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.platform-add {
  display: flex;
  gap: 8px;
}

/* ---------- Вход ---------- */
.login-page {
  display: grid;
  place-items: center;
  background: var(--bg);
}

.login {
  width: min(340px, calc(100vw - 32px));
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}

.login h1 {
  margin: 16px 0 14px;
  font-size: 20px;
  font-weight: 600;
}

.login label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 13.5px;
}

.login .err {
  margin: 8px 0;
}

/* ---------- Всплывашка ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  translate: -50% 0;
  z-index: 60;
  padding: 9px 16px;
  border-radius: 9px;
  background: var(--ink);
  color: #fff;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}

.toast.is-on {
  opacity: 1;
}

/* ---------- Узкие экраны ---------- */
@media (max-width: 1100px) {
  .card-cols {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .top {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 12px;
    gap: 8px;
  }

  .top .field-inline {
    flex: 1;
    min-width: 0;
  }

  .top .control {
    width: 100%;
    min-width: 0;
  }

  .top-stats {
    order: 5;
    width: 100%;
    margin-left: 0;
    gap: 14px;
    overflow-x: auto;
  }

  .row {
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 10px;
  }

  .phone-line {
    flex-wrap: wrap;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .search {
    max-width: none;
    flex-basis: 100%;
    order: 4;
  }

  .work {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
  }

  .side {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .leads {
    max-height: 56vh;
  }

  .detail {
    padding: 14px 14px 40px;
  }

  body.has-detail .side {
    display: none;
  }

  body.has-detail .back-to-list {
    display: inline-flex;
  }
}

.back-to-list {
  display: none;
  margin-bottom: 12px;
}
