:root {
  --bg: #f5f5f4; --card: #fff; --ink: #1c1917; --muted: #78716c; --line: #e7e5e4;
  --accent: #1c1917; --radius: 12px;
  --new: #2563eb; --contacted: #a16207; --appointment: #7c3aed; --won: #15803d; --lost: #78716c;
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
.top { position: sticky; top: 0; z-index: 2; display: flex; gap: 12px; align-items: center; justify-content: space-between;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); background: var(--ink); color: #fff; }
.brand { font-weight: 700; text-decoration: none; }
.brand span { font-weight: 400; opacity: .7; }
.top select { max-width: 55%; padding: 6px 8px; border-radius: 8px; border: 0; }
main { max-width: 760px; margin: 0 auto; padding: 16px; padding-bottom: 48px; }
h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 16px; margin: 24px 0 8px; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1 1 180px; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
textarea { min-height: 90px; resize: vertical; }
label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.leads { list-style: none; padding: 0; margin: 0; }
.leads li a { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 14px 16px; background: var(--card);
  border-radius: var(--radius); margin-bottom: 8px; text-decoration: none; }
.leads .name { font-weight: 600; }
.leads .sub { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; grid-column: 1 / -1; }
.leads .when { color: var(--muted); font-size: 13px; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; color: #fff; background: var(--muted); }
.badge.new { background: var(--new); } .badge.contacted { background: var(--contacted); }
.badge.appointment { background: var(--appointment); } .badge.won { background: var(--won); } .badge.lost { background: var(--lost); }
.statuses { display: flex; gap: 6px; flex-wrap: wrap; }
.statuses .btn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.meta { color: var(--muted); font-size: 14px; }
.message { white-space: pre-wrap; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .body { white-space: pre-wrap; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.error { background: #fbebeb; color: #7f1d1d; padding: 12px; border-radius: 10px; margin-bottom: 12px; }
.back { display: inline-block; margin-bottom: 8px; color: var(--muted); text-decoration: none; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 0; }
dt { color: var(--muted); } dd { margin: 0; overflow-wrap: anywhere; }
.top { flex-wrap: wrap; row-gap: 8px; }
.topright { display: flex; gap: 10px; align-items: center; min-width: 0; flex-wrap: wrap; justify-content: flex-end; }
.top select { max-width: 60vw; min-width: 120px; }
#nav { display: flex; gap: 12px; align-items: center; font-size: 14px; white-space: nowrap; }
#nav a, #nav button { color: #fff; background: none; border: 0; padding: 4px 0; cursor: pointer; text-decoration: none; opacity: .85; }
#nav a:hover, #nav button:hover { opacity: 1; text-decoration: underline; }
#nav .who { opacity: .7; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.linkbox { margin-top: 12px; padding: 12px; border-radius: 10px; background: #f0fdf4; }
.linkbox p { margin: 0 0 8px; }
.users { list-style: none; padding: 0; margin: 0; }
.users li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.users li:last-child { border-bottom: 0; }
.users .name { font-weight: 600; }
.table-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius); margin-bottom: 12px; }
.overview { width: 100%; border-collapse: collapse; font-size: 15px; }
.overview th, .overview td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); }
.overview th { font-size: 13px; color: var(--muted); font-weight: 600; }
.overview tr:last-child td { border-bottom: 0; }
.overview .num { text-align: right; font-variant-numeric: tabular-nums; }
.code { font: 13px/1.5 ui-monospace, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
