[hidden] { display: none !important; }
:root {
  --red: #dd0000;
  --red-dark: #b00000;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f7f7f8;
  --card: #fff;
  --hot: #dd0000;
  --warm: #d97706;
  --cool: #6b7280;
  --ok: #15803d;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.45;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--red-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

header {
  display: flex; align-items: center; gap: 1.5rem;
  padding: .6rem 1.25rem; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--ink); }
.brand img { width: 26px; height: 26px; }
nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
nav a { padding: .35rem .7rem; border-radius: 6px; color: var(--ink); }
nav a.on { background: #fdecec; color: var(--red-dark); font-weight: 600; }
nav a:hover { text-decoration: none; background: #f1f1f3; }
.me { display: flex; gap: .75rem; align-items: center; color: var(--muted); font-size: .9rem; }

main { max-width: 1240px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.spread { justify-content: space-between; }
.grow { flex: 1; }
.cols { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: .9rem; }
.card.link { cursor: pointer; transition: border-color .1s; color: inherit; display: block; }
.card.link:hover { border-color: var(--red); text-decoration: none; }
.stats { display: flex; gap: 2rem; flex-wrap: wrap; margin: 1rem 0; }
.stat b { display: block; font-size: 1.6rem; }
.stat span { color: var(--muted); font-size: .85rem; }

table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: #fafafa; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fcf6f6; }
.tablewrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
.tablewrap table { border: 0; }

.badge { display: inline-block; padding: .08rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #eef0f3; color: #374151; white-space: nowrap; }
.badge.hot { background: #fde8e8; color: var(--hot); }
.badge.warm { background: #fdf2e2; color: var(--warm); }
.badge.cool { background: #eef0f3; color: var(--cool); }
.badge.sent, .badge.active { background: #e6f4ea; color: var(--ok); }
.badge.draft, .badge.trial { background: #fdf2e2; color: var(--warm); }
.badge.prospect { background: #e8effd; color: #1d4ed8; }
.badge.paused, .badge.churned { background: #eef0f3; color: var(--muted); }

button, .btn {
  font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: .45rem .9rem; border-radius: 7px; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem;
}
button:hover, .btn:hover { border-color: #c7cad1; text-decoration: none; }
button.primary, .btn.primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--red-dark); }
button.danger { color: var(--red-dark); }
button.link { border: 0; background: none; padding: 0; color: var(--red-dark); }
button.small, .btn.small { padding: .2rem .55rem; font-size: .85rem; }
button:disabled { opacity: .5; cursor: default; }

label { display: block; font-size: .85rem; font-weight: 600; margin: .7rem 0 .25rem; }
label .muted { font-weight: 400; }
input, select, textarea {
  font: inherit; width: 100%; padding: .5rem .6rem; border: 1px solid #d1d5db; border-radius: 7px; background: #fff; color: var(--ink);
}
textarea { min-height: 4.5rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #f6b9b9; border-color: var(--red); }
input[type=checkbox] { width: auto; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 1rem; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.login { max-width: 380px; margin: 9vh auto; }
.login .brand { justify-content: center; font-size: 1.3rem; margin-bottom: 1.25rem; }
.login .brand img { width: 40px; height: 40px; }
.qr { display: flex; justify-content: center; margin: .75rem 0; }
.qr img { image-rendering: pixelated; width: 200px; height: 200px; }
code.secret { display: block; word-break: break-all; background: #f3f4f6; padding: .4rem .5rem; border-radius: 6px; font-size: .85rem; }
.error { color: var(--red-dark); margin: .6rem 0 0; min-height: 1.2em; }

.finding { color: #374151; font-size: .9rem; }
.lead-name { font-weight: 600; }
.notes { list-style: none; padding: 0; margin: 0; }
.notes li { padding: .6rem 0; border-bottom: 1px solid var(--line); }
.notes li .meta { font-size: .8rem; color: var(--muted); }
.notes li.kind-email .meta::before { content: "✉ "; }
.notes li.kind-call .meta::before { content: "☎ "; }
.notes li .text { white-space: pre-wrap; }

iframe.preview { width: 100%; height: 520px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.tabs { display: flex; gap: .25rem; margin-bottom: .5rem; }
.tabs button.on { background: #fdecec; border-color: #f6b9b9; color: var(--red-dark); }
pre.plain { white-space: pre-wrap; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; font: .9rem/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; max-height: 520px; overflow: auto; margin: 0; }
.temp-pw { background: #fffbea; border: 1px solid #f5d77a; padding: .75rem; border-radius: 8px; margin: .75rem 0; }
.temp-pw code { font-size: 1.05rem; user-select: all; }

#toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); z-index: 20;
}
#toast.err { background: var(--red-dark); }
.empty { padding: 2rem; text-align: center; color: var(--muted); }
.filters { display: flex; gap: .4rem; flex-wrap: wrap; margin: .5rem 0 1rem; }
.filters button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.hint { font-size: .8rem; color: var(--muted); margin-top: .25rem; }
.phone { font-size: .9rem; font-weight: 600; margin: .1rem 0; }
.phone a { color: var(--ink); }
