/* Lead Hunter — панель. Палитра как у CRM AiPP. */
:root {
  --bg:#f1f5f9; --card:#fff; --ink:#0f172a; --muted:#64748b; --line:#e2e8f0;
  --accent:#2563eb; --accent-ink:#fff; --accent-soft:#eff4ff;
  --ok:#059669; --ok-soft:#ecfdf5; --warn:#d97706; --warn-soft:#fffbeb; --bad:#dc2626; --bad-soft:#fef2f2;
  --soft:#f8fafc; --bar:#0f172a; --bar-ink:#fff; --bar-dim:#94a3b8; --bar-hover:#1e293b;
  --hot:#dc2626; --warm:#d97706; --cold:#2563eb;
  --radius:14px; --shadow:0 1px 2px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.05);
  --safe-b:env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:#0b1220; --card:#131c2e; --ink:#e6edf7; --muted:#93a4bd; --line:#22304a;
    --accent:#4f8cff; --accent-ink:#0b1220; --accent-soft:#16233d;
    --ok:#22c55e; --ok-soft:#10241b; --warn:#f59e0b; --warn-soft:#2a2111; --bad:#f87171; --bad-soft:#2c1618;
    --soft:#18233a; --bar:#0a101d; --bar-ink:#e6edf7; --bar-dim:#8296b4; --bar-hover:#1b2740;
    --hot:#f87171; --warm:#f59e0b; --cold:#4f8cff;
    --shadow:0 1px 2px rgba(0,0,0,.35), 0 6px 18px rgba(0,0,0,.28);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
code, .mono { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; }
code { background: var(--soft); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ── каркас ─────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--bar); color: var(--bar-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 17px; }
.brand img { width: 28px; height: 28px; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--bar-dim); padding: 10px 12px; border-radius: 10px; font-weight: 500; }
.nav a:hover { background: var(--bar-hover); color: var(--bar-ink); text-decoration: none; }
.nav a.on { background: var(--bar-hover); color: var(--bar-ink); }
.nav .ico { width: 20px; text-align: center; }
.nav .dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.side .foot { margin-top: auto; padding: 10px 12px; font-size: 13px; color: var(--bar-dim); display: flex; justify-content: space-between; align-items: center; }
.side .foot button { color: var(--bar-dim); }

main { padding: 24px 28px 48px; max-width: 1080px; width: 100%; }
#main > * + * { margin-top: 14px; }
#main > .head + * { margin-top: 0; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.head .sub { color: var(--muted); margin-top: 4px; }

@media (max-width: 899px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; flex-direction: row; padding: 6px 6px calc(6px + var(--safe-b)); z-index: 20; overflow-x: auto; gap: 2px; }
  .brand, .side .foot { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav a { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 4px; min-width: 58px; text-align: center; }
  .nav .dot { position: absolute; margin: 0 0 0 22px; }
  .nav a { position: relative; }
  main { padding: 16px 16px calc(96px + var(--safe-b)); }
  h1 { font-size: 20px; }
}

/* ── карточки ───────────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card, .stack > * + * { margin-top: 14px; }
.card .card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card .card-head p { color: var(--muted); font-size: 14px; margin-top: 3px; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.four { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.grid > .card + .card { margin-top: 0; }

.stat { padding: 16px; }
.stat .n { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 13px; }
.stat.hot .n { color: var(--hot); } .stat.warm .n { color: var(--warm); } .stat.cold .n { color: var(--cold); }

.status-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.status-row:first-of-type { border-top: 0; }
.status-row .k { width: 120px; color: var(--muted); flex-shrink: 0; }
.status-row .v { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--soft); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.HOT { background: var(--bad-soft); color: var(--hot); border-color: transparent; }
.badge.WARM { background: var(--warn-soft); color: var(--warm); border-color: transparent; }
.badge.COLD { background: var(--accent-soft); color: var(--cold); border-color: transparent; }

/* ── шаги настройки ─────────────────────────────────────── */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.steps li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.steps li:first-child { border-top: 0; }
.steps .num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--soft); border: 1px solid var(--line); flex-shrink: 0; }
.steps li.done .num { background: var(--ok); color: #fff; border-color: var(--ok); }
.steps li.done .t { color: var(--muted); text-decoration: line-through; }
.howto { margin: 6px 0 12px; padding-left: 20px; color: var(--muted); font-size: 14px; }
.howto li + li { margin-top: 3px; }

/* ── формы ──────────────────────────────────────────────── */
label.f { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
input[type=text], input[type=password], input[type=tel], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; outline: none; min-height: 40px;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 180px; }
.field + .field { margin-top: 12px; }
.secret-line { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px; flex-wrap: wrap; }

button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border-radius: 10px; font-weight: 600; background: var(--soft); color: var(--ink); border: 1px solid var(--line); white-space: nowrap; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); padding: 6px 10px; min-height: 32px; }
.btn.ghost:hover { color: var(--ink); }
.btn.sm { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.big { min-height: 48px; font-size: 16px; padding: 10px 22px; }

.seg { display: inline-flex; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { padding: 8px 14px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.switch { position: relative; display: inline-block; vertical-align: middle; width: 40px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(16px); }

/* ── таблицы ────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.off td { color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 6px 5px 12px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; font-size: 14px; font-weight: 500; }
.chip button { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; line-height: 1; }
.chip button:hover { background: var(--card); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.filters button { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 13px; font-weight: 600; color: var(--muted); }
.filters button.on { background: var(--ink); color: var(--card); border-color: var(--ink); }

/* ── география ──────────────────────────────────────────── */
details.district { border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
details.district + details.district { margin-top: 8px; }
details.district summary { list-style: none; cursor: pointer; padding: 12px 14px; display: flex; align-items: center; gap: 10px; font-weight: 600; }
details.district summary::-webkit-details-marker { display: none; }
details.district summary::before { content: "›"; font-size: 20px; color: var(--muted); transition: transform .15s; width: 12px; }
details.district[open] summary::before { transform: rotate(90deg); }
details.district summary .badge { margin-left: auto; }
.regions { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 2px 12px; padding: 0 14px 12px; }
.regions label { display: flex; align-items: center; gap: 10px; padding: 7px 4px; cursor: pointer; border-radius: 8px; }
.regions label:hover { background: var(--soft); }
.regions input { width: 18px; height: 18px; accent-color: var(--accent); }
.district-actions { display: flex; gap: 6px; padding: 0 14px 12px; }
.dim { opacity: .55; }

/* ── лиды ───────────────────────────────────────────────── */
.lead .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 13px; }
.lead blockquote { margin: 10px 0; padding: 10px 14px; background: var(--soft); border-left: 3px solid var(--line); border-radius: 0 10px 10px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.lead .draft { margin-top: 10px; padding: 10px 14px; background: var(--accent-soft); border-radius: 10px; white-space: pre-wrap; }
.lead .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }

.result { margin-top: 12px; padding: 12px 14px; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
.result pre { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.alert { padding: 12px 14px; border-radius: 10px; font-size: 14px; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--accent-soft); color: var(--ink); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 6px; }

/* ── вход ───────────────────────────────────────────────── */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 380px; padding: 28px; }
.auth .brand { color: var(--ink); padding: 0 0 18px; }
.auth h1 + p { margin: 6px 0 18px; }
.auth form > h1:last-of-type { margin-bottom: 14px; }
.auth .btn { width: 100%; margin-top: 16px; }
.err { color: var(--bad); font-size: 14px; margin-top: 10px; min-height: 20px; }

.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--card); padding: 10px 18px; border-radius: 12px; font-weight: 500; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.bad { background: var(--bad); color: #fff; }
@media (max-width: 899px) { .toast { bottom: calc(84px + var(--safe-b)); } }
.lead .actions select { width: auto; min-width: 170px; }
