/* KnockD2D pipeline. Light, dense, readable on a phone. */
:root {
  --bg: #f6f7f9; --card: #fff; --ink: #0f172a; --ink-2: #475569; --ink-3: #94a3b8; --line: #e2e8f0; --line-2: #cbd5e1;
  --head: #0b0f1a; --head-ink: #e5e7eb; --accent: #f59e0b; --accent-ink: #1a1200; --accent-soft: #fef3c7;
  --blue: #2563eb; --blue-soft: #dbeafe; --green: #059669; --green-soft: #d1fae5; --purple: #7c3aed; --purple-soft: #ede9fe;
  --red: #dc2626; --red-soft: #fee2e2; --orange: #ea580c; --amber-soft: #fef3c7; --gray-soft: #f1f5f9;
  --r: 10px; --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 18px 0 8px; }
h3 { font-size: .95rem; margin: 14px 0 6px; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { background: #fff; border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 9px; min-height: 36px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
textarea { width: 100%; resize: vertical; }
.muted { color: var(--ink-2); } .dim { color: var(--ink-3); font-size: .85em; } .nowrap { white-space: nowrap; }
.loading, .empty { color: var(--ink-3); text-align: center; padding: 40px 16px; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: #fff; border-radius: 8px; padding: 7px 12px; cursor: pointer; font-weight: 600; min-height: 36px; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.dark { background: var(--head); border-color: var(--head); color: #fff; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 4px 9px; min-height: 28px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--blue); cursor: pointer; font-weight: 600; }

/* top bar */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px; padding: 0 16px; height: 52px; background: var(--head); color: var(--head-ink); }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 800; font-size: 1.02rem; }
.brand:hover { text-decoration: none; }
.brand svg { width: 20px; height: 20px; color: var(--accent); }
.brand em { font-style: normal; color: var(--accent); }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { color: #cbd5e1; padding: 8px 10px; border-radius: 8px; font-weight: 600; white-space: nowrap; }
.tabs a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.tabs a.on { background: rgba(255,255,255,.12); color: #fff; }
.badge { background: var(--red); color: #fff; border-radius: 999px; font-size: .72rem; padding: 1px 6px; margin-left: 2px; }
.who .link { color: #cbd5e1; white-space: nowrap; }
@media (max-width: 760px) {
  .top { flex-wrap: wrap; height: auto; padding: 8px 12px 0; gap: 8px; }
  .brand span { display: none; }
  .tabs { order: 3; flex-basis: 100%; padding-bottom: 6px; }
  .who { margin-left: auto; }
}

.view { padding: 16px; max-width: 1900px; margin: 0 auto; }
.head-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; }
.help { color: var(--ink-2); max-width: 75em; margin: 4px 0 12px; }

/* stage counters */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(6, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; text-align: center; cursor: pointer; }
.stat:hover { border-color: var(--line-2); }
.stat.on { outline: 2px solid var(--accent); }
.stat b { display: block; font-size: 1.45rem; line-height: 1.1; }
.stat span { color: var(--ink-2); font-size: .8rem; }
.st-new b { color: var(--blue); } .st-working b { color: var(--orange); } .st-interested b { color: var(--green); }
.st-activated b { color: #047857; } .st-parked b { color: var(--purple); } .st-dead b { color: var(--ink-3); }
details.stages { color: var(--ink-2); margin: 4px 0 8px; }
details.stages summary { cursor: pointer; font-weight: 600; }
details.stages ul { margin: 6px 0 0; padding-left: 18px; }
.types { color: var(--ink-2); margin: 0 0 10px; }
.types b { color: var(--ink); }

/* filters */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; }
.filters label { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: .85rem; }
.filters input[type=search] { min-width: 220px; flex: 1; }
.filters .spacer { flex: 1; }
.filters .count { color: var(--ink-2); font-weight: 600; }

/* table */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); margin-top: 10px; overflow-x: auto; }
table.pl { width: 100%; border-collapse: collapse; min-width: 1400px; }
table.pl th { background: var(--head); color: #e5e7eb; text-align: left; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; padding: 9px 8px; white-space: nowrap; position: sticky; top: 0; }
table.pl th[data-sort] { cursor: pointer; }
table.pl th[data-sort]:hover { color: #fff; }
table.pl th.sorted::after { content: " ▾"; } table.pl th.sorted.asc::after { content: " ▴"; }
table.pl td { padding: 9px 8px; border-top: 1px solid var(--line); vertical-align: top; }
table.pl tbody tr { cursor: pointer; }
table.pl tbody tr:hover td { background: #fafbfc; }
table.pl tbody tr.fresh td { background: #fffbeb; }
table.pl .name { font-weight: 700; color: var(--ink); }
.phone { color: var(--orange); font-weight: 700; white-space: nowrap; }
.chip { display: inline-block; font-size: .75rem; background: var(--gray-soft); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; margin: 1px 2px 1px 0; white-space: nowrap; color: var(--ink-2); font-weight: 600; }
.chip.text { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.chips { max-width: 260px; }
.score { font-weight: 800; white-space: nowrap; }
.tier-A { color: var(--orange); } .tier-B { color: #b45309; } .tier-C { color: var(--ink-3); } .tier-AGENCY { color: var(--purple); }
.pill { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.ty-rep { background: var(--green-soft); color: #065f46; } .ty-blitz { background: #ffedd5; color: #9a3412; } .ty-agency { background: var(--purple-soft); color: #5b21b6; }
.pl-new { background: var(--head); color: #fff; } .pl-working { background: #fbbf24; color: #422006; } .pl-interested { background: #10b981; color: #fff; }
.pl-activated { background: #047857; color: #fff; } .pl-parked { background: var(--purple-soft); color: #5b21b6; } .pl-dead { background: var(--gray-soft); color: var(--ink-3); }
.oc { font-size: .75rem; background: #fff; border: 1px solid var(--line-2); border-radius: 999px; padding: 2px 8px; margin: 1px 2px 1px 0; cursor: pointer; white-space: nowrap; }
.oc:hover { border-color: var(--accent); background: var(--accent-soft); }
td input[type=date] { min-height: 30px; padding: 3px 5px; font-size: .82rem; }

/* phone: table becomes cards */
@media (max-width: 900px) {
  table.pl { min-width: 0; }
  table.pl thead { display: none; }
  table.pl, table.pl tbody, table.pl tr, table.pl td { display: block; width: 100%; }
  table.pl tr { border-top: 1px solid var(--line); padding: 10px 12px; }
  table.pl td { border: 0; padding: 2px 0; }
  table.pl td[data-l]::before { content: attr(data-l) ": "; color: var(--ink-3); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
  table.pl td.hide-m { display: none; }
  table.pl td.row-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 1rem; }
  .chips { max-width: none; }
}

/* drawer */
.scrim { position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(100%, 620px); background: var(--bg); z-index: 50; overflow-y: auto; box-shadow: -10px 0 30px rgba(0,0,0,.15); }
.dr-head { position: sticky; top: 0; background: var(--head); color: #fff; padding: 14px 16px; z-index: 2; }
.dr-head h2 { margin: 0; font-size: 1.25rem; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dr-head .close { position: absolute; right: 12px; top: 10px; background: none; border: 0; color: #cbd5e1; font-size: 1.6rem; cursor: pointer; line-height: 1; }
.dr-head .sub { color: #cbd5e1; margin-top: 4px; }
.dr-body { padding: 14px 16px 40px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin-bottom: 12px; }
.card h3:first-child { margin-top: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: var(--ink-2); font-weight: 600; }
.field select, .field input { width: 100%; color: var(--ink); font-weight: 400; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
dl.kv dt { color: var(--ink-3); } dl.kv dd { margin: 0; word-break: break-word; }
.parts { display: flex; flex-wrap: wrap; gap: 6px; }
.parts span { background: var(--gray-soft); border-radius: 6px; padding: 3px 8px; font-size: .8rem; }
.log { list-style: none; padding: 0; margin: 0; }
.log li { padding: 8px 0; border-top: 1px solid var(--line); }
.log li:first-child { border-top: 0; }
.log small { color: var(--ink-3); display: block; }
.log .k-sms_in { color: var(--blue); font-weight: 600; } .log .k-alert { color: var(--ink-3); }
.tpl { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }

/* call list */
.cl-section { margin-bottom: 22px; }
.cl-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.cl-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; }
.cl-card:hover { border-color: var(--line-2); }
.cl-card .row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.cl-card .name { font-weight: 700; font-size: 1rem; }
.age { font-size: .78rem; font-weight: 700; border-radius: 6px; padding: 1px 7px; background: var(--gray-soft); color: var(--ink-2); }
.age.hot { background: var(--red-soft); color: var(--red); }

/* partners / team / sources */
.list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.item { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.item h3 { margin: 0 0 4px; display: flex; justify-content: space-between; gap: 8px; }
.item.off { opacity: .55; }
table.simple { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
table.simple th, table.simple td { padding: 8px 10px; text-align: left; border-top: 1px solid var(--line); }
table.simple th { background: var(--gray-soft); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); border-top: 0; }
table.simple td.n { text-align: right; font-variant-numeric: tabular-nums; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 110px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; margin-bottom: 12px; }
.bars div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bars div:hover::after { content: attr(data-t); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--head); color: #fff; font-size: .75rem; padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
.secret { font: 600 1.15rem ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--accent-soft); border: 1px dashed var(--accent); padding: 10px; border-radius: 8px; text-align: center; letter-spacing: .04em; user-select: all; }

/* auth screens */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--head); }
.auth form { background: var(--card); border-radius: 14px; padding: 26px; width: min(100%, 400px); display: flex; flex-direction: column; gap: 12px; }
.auth h1 { display: flex; align-items: center; gap: 8px; }
.auth h1 svg { width: 22px; height: 22px; color: var(--accent); }
.auth .field input { min-height: 42px; font-size: 1rem; }
.auth .btn { justify-content: center; min-height: 44px; font-size: 1rem; }
.err { color: var(--red); min-height: 1.2em; margin: 0; font-weight: 600; }

dialog { border: 0; border-radius: 14px; padding: 20px; width: min(94vw, 520px); max-height: 90vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15,23,42,.45); }
dialog h2 { margin-top: 0; }
dialog form { display: flex; flex-direction: column; gap: 10px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--head); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 80; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.err { background: var(--red); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 4px 10px; }
.checks label { display: flex; gap: 6px; align-items: center; font-weight: 400; color: var(--ink); }
.checks input { min-height: 0; }
.only-m { display: none; }
@media (max-width: 900px) { .only-m { display: inline; } }
.only-m-flex { display: none; }
@media (max-width: 760px) {
  .hide-m-block { display: none; }
  .only-m-flex { display: inline-flex; margin: 4px 0 8px; }
  .filters { display: none; }
  .filters.open { display: flex; }
  .filters label, .filters input[type=search] { flex: 1 1 100%; }
  .filters label select, .filters label input { flex: 1; }
  details.stages { display: none; }
}
table.simple th.n { text-align: right; }
