/* Live Leads
   Layout: one screen. Desktop = lead list (left) + details (right). Phone = list, details slide over it.
   A cool neutral board with one cobalt accent; amber marks a lead that just arrived; green marks a
   lead you can contact. Numbers and times in a mono face so they line up and read like data. */
:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --panel-2: #f7f9fb;
  --line: #e1e6ed;
  --ink: #142030;
  --ink-2: #4a5768;
  --ink-3: #7c8898;
  --accent: #2448c5;
  --accent-ink: #ffffff;
  --accent-soft: #e8edfc;
  --fresh: #b8740a;
  --fresh-soft: #fff4dc;
  --ok: #157347;
  --ok-soft: #e3f4ea;
  --danger: #b42318;
  --shadow: 0 1px 2px rgba(20, 32, 48, 0.06), 0 8px 24px rgba(20, 32, 48, 0.06);
  --font: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d131c; --panel: #131b26; --panel-2: #172130; --line: #243142; --ink: #e8edf4; --ink-2: #a8b4c4; --ink-3: #74829a;
    --accent: #7d9bff; --accent-ink: #0b1220; --accent-soft: #1a2747; --fresh: #f0b44c; --fresh-soft: #2f2412;
    --ok: #4fc98a; --ok-soft: #12291f; --danger: #ff8a7a; --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d131c; --panel: #131b26; --panel-2: #172130; --line: #243142; --ink: #e8edf4; --ink-2: #a8b4c4; --ink-3: #74829a;
  --accent: #7d9bff; --accent-ink: #0b1220; --accent-soft: #1a2747; --fresh: #f0b44c; --fresh-soft: #2f2412;
  --ok: #4fc98a; --ok-soft: #12291f; --danger: #ff8a7a; --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ── App shell ───────────────────────────────────────────────────────────────────────── */
.app { height: 100%; display: grid; grid-template-rows: auto 1fr; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--panel); }

.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding-block: 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
}
.brand h1 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; }
.live { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); animation: pulse 2s infinite; }
.dot.bad { background: var(--danger); }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.top .spacer { flex: 1; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-2);
}
.icon-btn:hover { color: var(--ink); background: var(--panel-2); }
.icon-btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.icon-btn svg { width: 18px; height: 18px; }

/* ── Board ───────────────────────────────────────────────────────────────────────────── */
.board { min-height: 0; display: grid; grid-template-columns: minmax(340px, 440px) 1fr; }
.list-pane { min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--panel); }

.tools { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.stats { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.stats b { font: 600 22px/1 var(--font); color: var(--ink); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-right: 4px; }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; translate: 0 -50%; width: 16px; height: 16px; color: var(--ink-3); pointer-events: none; }
.search input {
  width: 100%; height: 40px; padding: 0 12px 0 34px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2);
}
.search input::placeholder { color: var(--ink-3); }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); align-self: flex-start; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 7px; font-size: 13px; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }

.list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: env(safe-area-inset-bottom, 0px); }
.row {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: start;
  width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none;
  padding: 12px 16px; position: relative;
}
.row:hover { background: var(--panel-2); }
.row[aria-current="true"] { background: var(--accent-soft); }
.row[aria-current="true"]::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.row.fresh { animation: fresh 9s ease-out; }
@keyframes fresh { 0%, 25% { background: var(--fresh-soft); } 100% { background: transparent; } }
.row .when { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--ink-3); padding-top: 1px; white-space: nowrap; }
.row .when .t { color: var(--ink-2); font-weight: 600; font-size: 13px; }
.row .main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row .product { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cc {
  display: inline-block; min-width: 26px; padding: 1px 5px; margin-right: 7px; border-radius: 5px; text-align: center;
  font-size: 11px; font-weight: 600; letter-spacing: 0.03em; line-height: 16px; vertical-align: 1px;
  background: var(--accent-soft); color: var(--accent);
}
.row .meta { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--panel-2); color: var(--ink-3); border: 1px solid var(--line);
}
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.new { background: var(--fresh-soft); color: var(--fresh); border-color: transparent; }
.row .tags { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

.empty { padding: 48px 24px; text-align: center; color: var(--ink-2); display: grid; gap: 6px; justify-items: center; }
.empty b { color: var(--ink); font-size: 16px; }

/* ── Details ─────────────────────────────────────────────────────────────────────────── */
.detail-pane { min-height: 0; overflow-y: auto; }
.detail {
  max-width: 760px; margin: 0 auto; display: grid; gap: 18px;
  padding-block: 24px calc(32px + env(safe-area-inset-bottom, 0px));
  padding-left: max(24px, env(safe-area-inset-left, 0px));
  padding-right: max(24px, env(safe-area-inset-right, 0px));
}
.back { display: none; }
.d-head { display: grid; gap: 8px; }
.d-eyebrow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; color: var(--ink-2); }
.d-head h2 { margin: 0; font-size: clamp(22px, 2.6vw, 30px); line-height: 1.15; letter-spacing: -0.02em; font-weight: 650; text-wrap: balance; }

.contact {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 18px; display: grid; gap: 14px;
}
.contact .who { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.contact .name { font-size: 18px; font-weight: 650; }
.contact .phone { font: 600 clamp(20px, 3vw, 26px)/1.2 var(--mono); letter-spacing: 0.01em; word-break: break-all; user-select: all; }
.contact .no-phone { color: var(--ink-2); font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); text-decoration: none; color: var(--ink); font-weight: 600; font-size: 14px;
}
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn svg { width: 17px; height: 17px; }

.facts { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); margin: 0; }
.facts > div { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.facts > div:last-child { border-bottom: 0; }
.facts dt { color: var(--ink-3); font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; padding-top: 1px; }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.facts dd .sub { color: var(--ink-3); font-size: 13px; }
.section-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 600; margin-bottom: -8px; }

.placeholder { height: 100%; display: grid; place-items: center; color: var(--ink-3); text-align: center; padding: 24px; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); translate: -50% 0; z-index: 50;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow);
}
.banner { padding: 10px 16px; background: var(--fresh-soft); color: var(--ink); font-size: 13px; border-bottom: 1px solid var(--line); }
.banner.bad { color: var(--danger); }

/* ── Phone ───────────────────────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .board { grid-template-columns: 1fr; }
  .list-pane { border-right: 0; }
  .detail-pane {
    position: fixed; inset: 0; z-index: 40; background: var(--bg);
    padding-top: env(safe-area-inset-top, 0px);
    transform: translateX(100%); transition: transform 0.22s ease; visibility: hidden;
  }
  .detail-pane.open { transform: none; visibility: visible; }
  .back {
    display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--accent);
    font-weight: 600; padding: 0; height: 36px; justify-self: start;
  }
  .detail { padding-block: 12px calc(28px + env(safe-area-inset-bottom, 0px)); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); gap: 16px; }
  .facts > div { grid-template-columns: 1fr; gap: 2px; }
  .actions .btn { flex: 1 1 auto; justify-content: center; }
  .live .label { display: none; }
}
@media (max-width: 420px) {
  .brand h1 { font-size: 16px; }
  .row { grid-template-columns: 44px 1fr; }
  .row .tags { grid-column: 2; flex-direction: row; align-items: center; justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ── Sign-in ─────────────────────────────────────────────────────────────────────────── */
.signin { min-height: 100%; display: grid; place-items: center; padding-block: 24px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.signin form {
  width: min(380px, 100%); display: grid; gap: 16px; padding: 28px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.signin h1 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.signin p { margin: 0; color: var(--ink-2); font-size: 14px; }
.signin label { font-size: 13px; font-weight: 600; color: var(--ink-2); display: grid; gap: 6px; }
.signin input { height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); }
.signin button { height: 44px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 650; }
.signin .err { color: var(--danger); font-size: 14px; }
