:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f2f2f4;
  --line: #e4e4e8;
  --text: #17171c;
  --muted: #6b6b76;
  --accent: #5656d0;
  --accent-hover: #4b4bc4;
  --on-accent: #ffffff;
  /* Fills under white text (primary and danger buttons): ≥ 4.5:1 in both themes */
  --accent-fill: var(--accent);
  --accent-fill-hover: var(--accent-hover);
  --danger: #c93434;
  --danger-fill: #c93434;
  --on-danger: #ffffff;
  --ok: #1f9d55;
  --wa: #1fa855;
  --tg: #2a9bd8;
  --vk: #3f6fd8;
  --owner: #b7791f;
  /* Statuses of a lead («Сохранённые лиды») and a client («Клиенты»): good, waiting, active, warm, bad */
  --st-good: #1f9d55;
  --st-wait: #a88400;
  --st-active: #2b6fd6;
  --st-warm: #dd6b20;
  --st-bad: #d93f3f;
  --prio-cold: #3b82f6;
  --prio-hot: #e03131;
  --prio-tint: 12%;
  --shadow: 0 1px 2px rgba(16, 16, 24, .04), 0 8px 24px rgba(16, 16, 24, .06);
  --shadow-lg: 0 24px 64px rgba(16, 16, 24, .18);
  --radius: 12px;
  color-scheme: light;
}
/* Dark: follows the system unless the user picked a theme in Настройки (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0f11;
    --surface: #16171a;
    --surface-2: #1d1e22;
    --line: #2a2b31;
    --text: #ececf1;
    --muted: #8e8e99;
    --accent: #7c7cf0;
    --accent-hover: #8d8df5;
    --accent-fill: #5b5bd6;
    --accent-fill-hover: #6262de;
    --danger: #f06060;
    --owner: #e3b341;
    --st-good: #3fbf74;
    --st-wait: #e6c33a;
    --st-active: #5c9df2;
    --st-warm: #f2913d;
    --st-bad: #f06060;
    --prio-cold: #4f8ff7;
    --prio-hot: #f25f5f;
    --prio-tint: 16%;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0f11;
  --surface: #16171a;
  --surface-2: #1d1e22;
  --line: #2a2b31;
  --text: #ececf1;
  --muted: #8e8e99;
  --accent: #7c7cf0;
  --accent-hover: #8d8df5;
  --accent-fill: #5b5bd6;
  --accent-fill-hover: #6262de;
  --danger: #f06060;
  --owner: #e3b341;
  --st-good: #3fbf74;
  --st-wait: #e6c33a;
  --st-active: #5c9df2;
  --st-warm: #f2913d;
  --st-bad: #f06060;
  --prio-cold: #4f8ff7;
  --prio-hot: #f25f5f;
  --prio-tint: 16%;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
/* Focus scrolled into view stays clear of the sticky page header (and of the bottom menu on phones) */
html { scroll-padding-top: 80px; -webkit-tap-highlight-color: color-mix(in srgb, var(--accent) 14%, transparent); }
button, a, label, input, select, summary { touch-action: manipulation; }
.skip-link { position: fixed; left: 12px; top: -48px; z-index: 40; padding: 8px 14px; border-radius: 9px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); text-decoration: none; font-weight: 550; }
.skip-link:focus { top: 12px; }
.main:focus { outline: none; }
body {
  font: 14px/1.45 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.app { min-height: 100vh; }

/* Shell: side menu + page */
.workspace { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.main { width: 100%; max-width: 1280px; padding: 0 28px 64px; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; padding: 18px 12px;
  background: var(--surface); border-right: 1px solid var(--line); z-index: 6; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-right: 2px; }
.side .brand { padding: 4px 10px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 11px; height: 38px; padding: 0 10px; border-radius: 9px;
  color: var(--muted); text-decoration: none; font-weight: 550; transition: background .15s, color .15s; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-short { display: none; }
.nav-item.on { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.nav-item .icon { width: 18px; height: 18px; }
.side-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 6px 0 10px; border-top: 1px solid var(--line); }
.me { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none;
  border-radius: 9px; padding: 4px; margin-left: -4px; }
.me:hover, .me.on { background: var(--surface-2); }
.side-user .user { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.avatar { width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 13px;
  font-weight: 650; color: var(--on-accent); background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #000)); }
.avatar.lg { width: 52px; height: 52px; font-size: 20px; }
.icon-btn { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 8px; background: none;
  color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
/* Lucide icons from vendor/icons.svg: <svg class="icon"><use href="…#name"/></svg> */
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .icon { width: 18px; height: 18px; }

/* Profile and settings pages */
.page { max-width: 640px; padding-top: 22px; display: flex; flex-direction: column; gap: 14px; }
.page h1 { margin: 0 0 4px; font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px; }
.panel h2 { margin: 0; font-size: 14px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.profile-head { flex-direction: row; align-items: center; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 10px; }
.segmented button { height: 30px; padding: 0 14px; border: 0; border-radius: 8px; background: none; cursor: pointer; white-space: nowrap;
  color: var(--muted); font-weight: 550; transition: background .15s, color .15s; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.field input:disabled { opacity: .6; cursor: not-allowed; }
.panel > .btn { align-self: flex-start; }

/* Header */
.top { display: flex; align-items: center; gap: 16px; padding: 18px 0; position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
@keyframes pulse { 50% { opacity: .3; } }
.top-title { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -.01em; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface); cursor: pointer; font-weight: 550;
  text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-fill-hover); border-color: var(--accent-fill-hover); }
.btn.danger { background: var(--danger-fill); border-color: var(--danger-fill); color: var(--on-danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.badge { font-size: 11.5px; padding: 1px 7px; border-radius: 999px; background: rgba(255, 255, 255, .22); font-variant-numeric: tabular-nums; }
.link { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-weight: 500; }
.link:disabled { color: var(--muted); cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Search */
.search { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); }
.spheres { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent;
  cursor: pointer; color: var(--muted); font-weight: 500; transition: color .15s, border-color .15s, background .15s; }
.chip:hover:not(:disabled) { color: var(--text); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.chip.on { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent); }
.chip:disabled { cursor: not-allowed; }
.bar { display: flex; gap: 10px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.field.grow { flex: 1; }
.field.city { width: 210px; }
.field.limit { width: 120px; }
.field input, .field select, .path-row input, .filter {
  height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); outline: none;
  transition: border-color .15s, box-shadow .15s; width: 100%; }
.field input:focus, .field select:focus, .path-row input:focus, .filter:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.field.grow input { font-size: 15px; }
.btn.go { height: 40px; min-width: 140px; }
.field.city { position: relative; }
.select { height: 40px; padding: 0 10px 0 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg);
  text-align: left; cursor: pointer; display: flex; align-items: center; gap: 8px; min-width: 0; }
.select > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select .icon { color: var(--muted); }
.select:disabled { opacity: .6; cursor: not-allowed; }
.field input[aria-invalid="true"], .path-row input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--danger); }
.search > .field-error { margin: 8px 0 0 !important; }
.popover { position: absolute; top: calc(100% + 6px); left: 0; width: 280px; z-index: 10; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 8px; }
.popover input[type=search] { height: 34px; }
.city-list { max-height: 280px; overflow-y: auto; margin: 6px 0; }
.check { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 7px; cursor: pointer; }
.check:hover { background: var(--surface-2); }
.check input, .pick input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.popover-foot { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 2px;
  border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
th.pick, td.pick { width: 1%; padding-right: 0; }
.subbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; margin-top: 10px; font-size: 12.5px;
  color: var(--muted); }
.subbar .toggle { margin-left: auto; white-space: nowrap; }
.toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.toggle input { accent-color: var(--accent); cursor: pointer; }

.alert { margin-top: 14px; padding: 11px 14px; border-radius: 10px; color: var(--danger);
  background: color-mix(in srgb, var(--danger) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); }

/* Results */
.results { margin-top: 18px; }
/* Search run: status, progress and the run's parameters, right above the table it fills */
.run-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 12px; font-size: 13px;
  color: var(--muted); }
.run-bar b { color: var(--text); font-weight: 600; }
.run-bar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.run-bar.running .dot { background: var(--accent); animation: pulse 1.1s infinite; }
.run-bar.done .dot { background: var(--ok); }
.run-bar.error .dot { background: var(--danger); }
.run-bar + .alert { margin: 0 0 12px; }
.results-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 12px;
  margin-bottom: 10px; min-height: 36px; }
.counters { display: flex; align-items: center; gap: 16px; color: var(--muted); min-width: 0; }
.counters b { color: var(--text); font-variant-numeric: tabular-nums; }
.counters > span:first-child, .counters > .worked { white-space: nowrap; }
.toggle-skipped, .undo-link { display: inline-flex; align-items: center; gap: 4px; }
.undo-link .icon { width: 14px; height: 14px; }
.toggle-skipped b { color: inherit; }
.toggle-skipped .icon { width: 14px; height: 14px; transition: transform .15s; }
.toggle-skipped[aria-expanded="true"] .icon { transform: rotate(180deg); }
.results-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; margin-left: auto; }
.run-label { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 460px; }
.run-label.stale { color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, var(--surface)); }
.log { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 520px; }
.filter { width: 260px; max-width: 100%; height: 36px; background: var(--surface); }

/* «Ещё» menu */
.more { position: relative; }
.more > .icon-btn { width: 36px; height: 36px; border: 1px solid var(--line); background: var(--surface); }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; min-width: 240px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); }
.menu-item { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
  background: none; text-align: left; cursor: pointer; font-weight: 500; }
.menu-item .icon { margin-top: 2px; color: var(--muted); }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-item.danger, .menu-item.danger .icon { color: var(--danger); }
.menu-item:disabled { opacity: .5; cursor: not-allowed; }
.menu-item small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.skipped { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill b { color: var(--text); margin-left: 4px; }

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; font-weight: 550; color: var(--muted); padding: 10px 14px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
td { padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { cursor: pointer; transition: background .12s; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover, tbody tr.active { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; width: 1%; white-space: nowrap; }
.name { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.title { font-weight: 550; }
.row-open { border: 0; background: none; padding: 0; text-align: left; cursor: pointer; border-radius: 4px; }
.row-open:hover { color: var(--accent); }
/* The row checkbox: the whole cell is the hit area, not the 15px box */
.pick-hit { display: grid; place-items: center; min-width: 32px; min-height: 32px; margin: -6px -4px; cursor: pointer; }
.thumb { position: relative; width: 34px; height: 34px; border-radius: 8px; overflow: hidden; flex: none; background: var(--surface-2);
  display: grid; place-items: center; font-size: 11px; font-weight: 650; color: var(--muted); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
/* Crown on the photo: filled — 2GIS names a director/owner contact, outline — a likely owner's mobile */
.thumb-crown { position: absolute; right: 1px; bottom: 1px; display: grid; place-items: center; width: 15px; height: 15px;
  border-radius: 5px; background: var(--surface); color: var(--owner); box-shadow: 0 0 0 1px color-mix(in srgb, var(--owner) 45%, transparent); }
.thumb-crown .crown { width: 11px; height: 11px; }
.thumb-crown.maybe .crown { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linejoin: round; }
.thumb-crown.owner { background: var(--owner); color: var(--surface); box-shadow: none; }
.owner-sort { margin-left: 6px; vertical-align: middle; color: var(--muted); }
.owner-sort .crown { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.owner-sort.on { color: var(--owner); }
.owner-sort.on .crown { fill: currentColor; }
.rating { font-weight: 600; }
.rating::before { content: "★ "; color: #f5a524; }
.channel { --c: var(--muted); display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; color: color-mix(in srgb, var(--c) 75%, var(--text));
  background: color-mix(in srgb, var(--c) 13%, transparent); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); }
.channel.wa { --c: var(--wa); }
.channel.tg { --c: var(--tg); }
.channel.vk { --c: var(--vk); }
.prices { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.results > .empty { text-align: center; padding: 72px 24px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.results > .empty h2 { color: var(--text); font-size: 17px; font-weight: 600; margin: 0 0 6px; }
.results > .empty p { margin: 0 auto; max-width: 520px; }
.results > .empty .btn { margin-top: 16px; }

/* Card drawer */
.scrim { position: fixed; inset: 0; background: rgba(10, 10, 14, .35); z-index: 20; }
.card { position: fixed; top: 0; right: 0; bottom: 0; width: min(540px, 100vw); background: var(--surface); z-index: 21;
  box-shadow: var(--shadow-lg); overflow-y: auto; overscroll-behavior: contain; border-left: 1px solid var(--line); outline: none; }
.slide-in { animation: slide-in .28s cubic-bezier(.2, .8, .2, 1); }
.slide-out { animation: slide-in .2s ease-in reverse; }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }
.card-loading { padding: 40px; color: var(--muted); }
.hero { position: relative; height: 230px; background-size: cover; background-position: center; color: #fff; display: flex; align-items: flex-end; }
.hero-text { padding: 20px 24px; }
.hero h2 { margin: 0; font-size: 22px; letter-spacing: -.01em; line-height: 1.2; }
.hero p { margin: 6px 0 0; opacity: .85; font-size: 13px; }
.close { position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(0, 0, 0, .45); color: #fff; backdrop-filter: blur(6px); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px 24px; border-bottom: 1px solid var(--line); }
.block { padding: 16px 24px; border-bottom: 1px solid var(--line); }
.block h3 { margin: 0; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  display: flex; justify-content: space-between; font-weight: 600; }
.block h3 .link { text-transform: none; letter-spacing: 0; font-size: 12.5px; }
.block p { margin: 0; }
.block .sec-body { margin-top: 8px; }
.message { white-space: pre-wrap; background: var(--surface-2); padding: 12px 14px; border-radius: 10px; }
.kv { margin: 0; display: grid; gap: 7px; }
.kv > div { display: grid; grid-template-columns: 116px 1fr; gap: 10px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.kv a { color: var(--accent); text-decoration: none; }
.kv a:hover { text-decoration: underline; }
.prices-list { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 6px; }
.prices-list li { display: flex; justify-content: space-between; gap: 16px; }
.prices-list b { white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }
details.block summary { cursor: pointer; color: var(--muted); }
.assumed { margin: 10px 0 0; padding-left: 18px; color: var(--muted); }
.card > .card-body > p.small { padding: 14px 24px 28px; margin: 0; }
.block h3 .count { font-weight: 600; color: var(--muted); letter-spacing: 0; }

/* Lead card contacts: every 2GIS contact with its label, the owner's highlighted */
.contacts { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 4px; }
.contact { display: grid; grid-template-columns: 116px 1fr; gap: 10px; padding: 7px 10px; margin: 0 -10px; border-radius: 9px;
  border-left: 3px solid transparent; }
.contact.owner { border-left-color: var(--owner); background: color-mix(in srgb, var(--owner) 10%, transparent); }
.contact-type { color: var(--muted); }
.contact-main { min-width: 0; word-break: break-word; }
.contact-main a { color: var(--accent); text-decoration: none; }
.contact-main a:hover { text-decoration: underline; }
.contact-label { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 2px; font-size: 12.5px; }
.contact-label .default { color: var(--muted); font-style: italic; }
.contact-label .default-note { color: var(--muted); font-size: 11.5px; }
.probe { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 4px; font-size: 12.5px; }
.probe .link { color: var(--muted); }
.probe .link:hover, .probe .link[aria-expanded="true"] { color: var(--text); }
.probe-links { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.probe-links a { color: var(--accent); text-decoration: none; font-weight: 500; }
.probe-links a:hover { text-decoration: underline; }
.owner-badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px 1px 6px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; color: var(--owner); background: color-mix(in srgb, var(--owner) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--owner) 35%, transparent); white-space: nowrap; }
.owner-badge.maybe { font-weight: 550; background: transparent; border-style: dashed;
  border-color: color-mix(in srgb, var(--owner) 55%, transparent); }
.owner-badge.maybe .crown { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.crown { width: 13px; height: 13px; fill: currentColor; }
.legal-owner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Docs page */
.page.docs { max-width: 780px; }
.page.docs > p { margin: -6px 0 0; }
.docs-toc { gap: 6px; }
.docs-toc a { color: var(--accent); text-decoration: none; font-weight: 550; }
.docs-toc a:hover { text-decoration: underline; }
.docs article { gap: 10px; scroll-margin-top: 16px; line-height: 1.6; }
.docs article h2 { font-size: 16px; }
.docs article p, .docs article ul, .docs article ol { margin: 0; }
.docs article ul, .docs article ol { padding-left: 20px; display: grid; gap: 5px; }

/* Export modal */
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px; z-index: 21; box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 32px); overflow-y: auto; overscroll-behavior: contain; }
.modal h2 { margin: 0 0 8px; font-size: 18px; text-wrap: balance; }
.modal > .field { margin-bottom: 5px; }
.modal p { margin: 0 0 16px; }
.modal .save-target { margin-top: 14px; }
.path-row { display: flex; flex-wrap: wrap; gap: 8px; }
.path-row input { flex: 1 1 220px; min-width: 0; }
.path-row input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30; max-width: calc(100vw - 32px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 500; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 28px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.login-card h1 { margin: 4px 0 2px; font-size: 19px; font-weight: 650; letter-spacing: -.01em; }
.login-card .alert { margin-top: 0; }
.login-card .btn { height: 40px; margin-top: 4px; }
/* «Сохранённые лиды» and «Клиенты»: the work on a saved lead — status, priority, contacted channels, demo app, comment */
.st { --c: var(--muted); display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--c);
  background: color-mix(in srgb, var(--c) 13%, transparent); border: 1px solid color-mix(in srgb, var(--c) 30%, transparent); }
.st::before, .st-btn .dot { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
/* Lead: not_written stays muted. Client: ok, question, bug. */
.st.written, .st-btn.written, .st.question, .st-btn.question { --c: var(--st-wait); }
.st.in_progress, .st-btn.in_progress { --c: var(--st-active); }
.st.almost, .st-btn.almost { --c: var(--st-warm); }
.st.bought, .st-btn.bought, .st.ok, .st-btn.ok { --c: var(--st-good); }
.st.refused, .st-btn.refused, .st.bug, .st-btn.bug { --c: var(--st-bad); }
/* Priority 0–5: one mark right before the photo (no gap to it) — big flame 5, flame 4, sun 3, cloud 2, snowflake 1,
   dashed circle 0 — in the same heat colour as the row tint. */
.prio-col { width: 1%; white-space: nowrap; }
td.prio-col, th.prio-col { padding-right: 0; }
/* Even gaps: checkbox, number, mark and photo all ~18px apart (the mark's own side bearing makes up the rest) */
.num:has(+ .prio-col) { padding-right: 7px; }
.num + .prio-col { padding-left: 7px; }
.prio-mark { display: inline-grid; place-items: center; vertical-align: middle;
  color: color-mix(in oklch shorter hue, var(--prio-hot) var(--heat), var(--prio-cold)); }
.prio-mark.p-0 { color: var(--muted); }
.prio-mark .icon { width: 17px; height: 17px; }
/* Rows coloured by priority (toggle «Раскрасить по приоритету»): a smooth heat scale from cold blue (1) to hot
   red (5), the short way round the hue circle; the colour fades from the left edge to nothing before the photo;
   none for 0. */
table { --prio-fade: 100px; }
tbody tr[class*="tint-"] {
  --tint: color-mix(in srgb, color-mix(in oklch shorter hue, var(--prio-hot) var(--heat), var(--prio-cold)) var(--prio-tint), transparent);
  --fade: linear-gradient(to right, var(--tint), transparent var(--prio-fade));
  background: var(--fade);
}
tbody tr.tint-1, .prio-mark.p-1 { --heat: 0%; }
tbody tr.tint-2, .prio-mark.p-2 { --heat: 25%; }
tbody tr.tint-3, .prio-mark.p-3 { --heat: 50%; }
tbody tr.tint-4, .prio-mark.p-4 { --heat: 75%; }
tbody tr.tint-5, .prio-mark.p-5 { --heat: 100%; }
tbody tr[class*="tint-"]:hover, tbody tr[class*="tint-"].active { background: var(--fade), var(--surface-2); }
.prio-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.assess { margin-bottom: 14px; }
.assess p { margin: 0; }
.assess .prio-mark { margin-right: 4px; }
.sort-btn { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; white-space: nowrap; }
.sort-btn:hover { color: var(--text); }
.sort-btn { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; }
.sort-mark { width: 13px; height: 13px; color: var(--accent); }

.sub-label { font-size: 11.5px; color: var(--muted); font-weight: 500; margin: 2px 0 6px; }
.sub-label:not(:first-child) { margin-top: 14px; }
.status-pick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.st-btn { --c: var(--muted); display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; cursor: pointer; font-weight: 550; color: var(--muted);
  transition: background .15s, border-color .15s, color .15s; }
.st-btn:hover:not(:disabled) { color: var(--text); border-color: color-mix(in srgb, var(--c) 50%, var(--line)); }
.st-btn.on { color: var(--c); border-color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); }
.st-btn:disabled, .segmented button:disabled { cursor: progress; }
.block .row.to-client { justify-content: flex-start; flex-wrap: wrap; gap: 6px 12px; margin: 10px 0 2px; }
.nowrap-col { white-space: nowrap; }
.contacted { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 2px; }
.contacted .check { margin: 0 -8px; word-break: break-word; }
.contacted .contact-type { width: 100px; flex: none; }
.demo-saved { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 8px; }
.demo-saved .btn { height: 30px; padding: 0 10px; }
.field-error { color: var(--danger); font-size: 12.5px; margin-top: 6px !important; }
.field-note { margin-top: 6px !important; overflow-wrap: anywhere; }  /* a hint under a field, e.g. the link it gives */
.path-row input[type=url] { height: 36px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); padding: 0 12px;
  width: 100%; outline: none; }
.comment-field { width: 100%; min-height: 96px; resize: vertical; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); outline: none; line-height: 1.45; }
.comment-field:focus, .path-row input[type=url]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.message-field { min-height: 200px; }
.message-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 10px; }
.message-actions { flex-wrap: wrap; }
.sec-tools { display: inline-flex; gap: 2px; }  /* icon buttons side by side at the end of a sub-section heading */
.message-actions .reset { margin-right: auto; }  /* «Вернуть стандартное» stands apart from Отмена / Сохранить */
.block .row { margin-top: 8px; }
.delete-zone { border-bottom: 0; padding-bottom: 28px; }
.btn.danger-ghost { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); background: transparent; }
.btn.danger-ghost:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 9%, transparent); }

/* Foldable card sections; «Работа с клиентом» has foldable sub-sections */
.sec-btn { all: unset; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; text-transform: inherit;
  letter-spacing: inherit; font: inherit; color: inherit; border-radius: 4px; }
.sec-btn:not(:disabled):hover { color: var(--text); }
.sec-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chev { width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg); margin: -3px 2px 0 1px; transition: transform .15s; }
.sec-btn[aria-expanded="false"] .chev { transform: rotate(-45deg); margin-top: 0; }
.sub-sec { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.work-head + .sub-sec { margin-top: 16px; }
.sub-sec:first-of-type { margin-top: 4px; padding-top: 0; border-top: 0; }  /* search page: Сообщение comes first */
.sub-sec h4 { margin: 0; display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--text); }
.sub-sec h4 .count { color: var(--muted); font-weight: 600; }
.sub-sec h4 .link { font-size: 12.5px; }
.sub-sec h4 .icon-btn { width: 28px; height: 28px; margin: -6px 0; }  /* copy the message from its heading */
.sub-sec .sec-btn:hover { color: var(--accent); }
.close { display: grid; place-items: center; }
.close.fold-all { right: 54px; }
.actions-note { flex-basis: 100%; margin: 0; overflow-wrap: anywhere; }
.scrim.over-card { z-index: 22; }
.modal.over-card { z-index: 23; }

@media (max-width: 760px) {
  html { scroll-padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .workspace { display: block; }
  .main { padding: 0 16px 88px; }
  .side { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line); z-index: 15; }
  .side { flex-direction: row; align-items: center; gap: 8px; }
  .side .brand, .side-user .user, .side-user .logout-btn { display: none; }
  /* Phones: the bottom bar is full, the theme button sits at the top right of the page title row */
  .theme-btn { position: fixed; top: calc(14px + env(safe-area-inset-top)); right: 12px; z-index: 16;
    width: 40px; height: 40px; background: var(--surface); border: 1px solid var(--line); }
  .nav { flex: 1; }
  .side-user { margin: 0; padding: 0; border: 0; }
  .nav { flex-direction: row; }
  .nav-item { flex: 1; flex-direction: column; justify-content: center; gap: 3px; height: 52px; font-size: 11px; }
  .nav-item { min-width: 0; padding: 0 2px; }
  .nav-full { display: none; }
  .nav-short { display: inline; }
  .panel .row { flex-wrap: wrap; }
  .toast { bottom: 84px; }
  .bar { flex-wrap: wrap; }
  .field.grow { flex-basis: 100%; }
  .field.city, .field.limit { flex: 1; width: auto; }
  .btn.go { flex-basis: 100%; }
  .subbar { flex-direction: column; }
  .col-extra { display: none; }
  table { --prio-fade: 64px; }
  /* Phone: filter and «Ещё» on the first row, the two actions share the second */
  .counters { flex-wrap: wrap; gap: 4px 16px; }
  .counters > .muted { flex-basis: 100%; order: 3; font-size: 12.5px; }
  .results-actions { width: 100%; margin-left: 0; display: grid; gap: 8px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px; grid-template-areas: "filter filter more" "save export export"; }
  .results-actions .filter { grid-area: filter; width: 100%; }
  .results-actions .btn { grid-area: save; padding: 0 8px; gap: 6px; }
  .results-actions .btn.primary { grid-area: export; }
  .results-actions .more { grid-area: more; }
  /* No «Сохранить лиды» (the saved leads page, past searches): export takes the whole row */
  .results-actions .btn[style*="display: none"] + .btn.primary { grid-column: 1 / -1; }
  .name { min-width: 150px; }
  .subbar .toggle { margin-left: 0; }
  .log { white-space: normal; }
}

/* Reduced motion: state still changes, only the movement goes (the running dot stays lit, the card just appears) */
@media (prefers-reduced-motion: reduce) {
  .run-bar.running .dot { animation: none; }
  .slide-in, .slide-out { animation: none; }
  .btn:active:not(:disabled) { transform: none; }
  .toggle-skipped .icon, .chev { transition: none; }
}
