:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f1f7;
  --border: #e3e5ee;
  --text: #171a2b;
  --muted: #6b7088;
  --accent: #6d5dfc;
  --accent-2: #5a49f0;
  --accent-soft: #eeecff;
  --green: #16a34a;
  --green-soft: #e3f7ea;
  --wa: #25d366;
  --amber: #d97706;
  --amber-soft: #fef3e2;
  --red: #dc2626;
  --red-soft: #fdeaea;
  --blue: #2563eb;
  --blue-soft: #e6eefe;
  --shadow: 0 1px 2px rgba(20, 22, 40, .04), 0 4px 16px rgba(20, 22, 40, .05);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #171a23;
    --surface-2: #1f2330;
    --border: #2a2f3e;
    --text: #e8eaf2;
    --muted: #9095ab;
    --accent: #8b7dff;
    --accent-2: #9d91ff;
    --accent-soft: #25224a;
    --green: #34d399;
    --green-soft: #12332a;
    --amber: #fbbf24;
    --amber-soft: #3a2d10;
    --red: #f87171;
    --red-soft: #3b1a1a;
    --blue: #60a5fa;
    --blue-soft: #16243d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }
h2 { font-size: 18px; margin: 0 0 4px; letter-spacing: -.01em; }
h3 { font-size: 14px; margin: 22px 0 8px; }
.mt0 { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
[hidden] { display: none !important; }

svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ---------- topo ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 12px 28px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 32px; height: 32px; fill: var(--accent); stroke: none; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.brand-sub { font-size: 11.5px; color: var(--muted); margin-top: -2px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs a {
  padding: 8px 14px; border-radius: 9px; text-decoration: none;
  color: var(--muted); font-weight: 500; white-space: nowrap;
}
.tabs a:hover { background: var(--surface-2); color: var(--text); }
.tabs a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.usage { min-width: 170px; }
.usage-text { font-size: 12.5px; font-weight: 600; text-align: right; }
.usage-text small { color: var(--muted); font-weight: 400; }
.usage-bar { height: 5px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 4px; }
#usage-fill { height: 100%; width: 0; background: var(--green); transition: width .4s; }
.usage.warn #usage-fill { background: var(--amber); }
.usage.over #usage-fill { background: var(--red); }

.banner {
  margin: 16px 28px 0; padding: 12px 16px;
  background: var(--accent-soft); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--radius);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.banner .btn { margin-left: auto; }

main { padding: 20px 28px 60px; max-width: 1400px; margin: 0 auto; }

/* ---------- componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 22px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.grid-2.wide-left { grid-template-columns: 1.05fr 1fr; }
.intro { margin-bottom: 20px; }
.intro p { max-width: 820px; margin: 6px 0 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 10px; font: inherit; font-weight: 500;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-lg { padding: 12px 20px; font-size: 15px; width: 100%; margin-top: 8px; }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn-wa:hover { background: #1fbd5b; }
.btn-danger { color: var(--red); }
.icon-btn { padding: 7px; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.link:hover { text-decoration: underline; }
.link-group { font-size: 12.5px; color: var(--muted); }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 11px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { width: 100%; resize: vertical; }
.input-lg { width: 100%; font-size: 15px; padding: 12px 14px; margin-top: 10px; }
.inline { display: flex; gap: 8px; margin: 10px 0; }
.inline input { flex: 1; min-width: 0; }
.inline.narrow { max-width: 280px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--muted); user-select: none; }
.check.block { display: flex; margin-top: 14px; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 5px 11px; border-radius: 99px; cursor: pointer; font: inherit; font-size: 13px;
  transition: all .12s;
}
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.hot::before { content: "🔥 "; font-size: 11px; }

.segmented { display: inline-flex; background: var(--surface-2); padding: 3px; border-radius: 11px; }
.segmented button {
  border: 0; background: transparent; font: inherit; padding: 7px 14px; border-radius: 8px;
  cursor: pointer; color: var(--muted); font-weight: 500;
}
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.estimate {
  margin-top: 16px; padding: 10px 13px; border-radius: 10px;
  background: var(--surface-2); font-size: 13px; color: var(--muted);
}
.estimate b { color: var(--text); }
.estimate.warn { background: var(--amber-soft); color: var(--amber); }
.estimate.warn b { color: inherit; }

.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 12px 0 8px; }
.progress.thin { height: 4px; margin: 8px 0 14px; }
.progress > div { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .3s; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 16px 0; }
.stat { background: var(--surface-2); border-radius: 11px; padding: 11px 13px; }
.stat .n { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.stat .l { font-size: 12px; color: var(--muted); }
.stat.good .n { color: var(--green); }
.stat.mid .n { color: var(--amber); }

.log { list-style: none; padding: 0; margin: 0; max-height: 260px; overflow: auto; font-size: 12.5px; }
.log li { padding: 6px 0; border-bottom: 1px dashed var(--border); color: var(--muted); display: flex; gap: 8px; }
.log li b { color: var(--text); font-weight: 500; }
.log li.err { color: var(--red); }

.alert { padding: 12px 14px; border-radius: 10px; margin-top: 12px; font-size: 13.5px; }
.alert.ok { background: var(--green-soft); color: var(--green); }
.alert.err { background: var(--red-soft); color: var(--red); }
.alert .hint { color: var(--text); margin-top: 4px; }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty svg { width: 42px; height: 42px; stroke-width: 1.5; color: var(--accent); margin-bottom: 8px; }
.empty.small { padding: 30px 10px; }
.empty h3 { color: var(--text); margin: 6px 0; font-size: 16px; }

/* ---------- leads ---------- */
.pipeline { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.pipe {
  flex: 1; min-width: 120px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 14px; cursor: pointer; font: inherit; color: var(--text); box-shadow: var(--shadow);
  transition: border-color .15s;
}
.pipe:hover { border-color: var(--accent); }
.pipe .n { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.pipe .l { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.pipe .dot { width: 8px; height: 8px; border-radius: 50%; }
.pipe.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.filters { display: flex; gap: 8px; padding: 10px; flex-wrap: wrap; align-items: center; }
.field { position: relative; display: flex; }
.field.grow { flex: 1; min-width: 220px; }
.field input { width: 100%; padding-left: 34px; }
.field-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.list-meta { color: var(--muted); font-size: 12.5px; margin: 14px 4px 8px; }

.lead-list { display: flex; flex-direction: column; gap: 8px; }
.lead {
  display: grid; grid-template-columns: 46px minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, 1.1fr) auto;
  align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; cursor: pointer; transition: border-color .15s, transform .1s;
}
.lead:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.lead.dim { opacity: .55; }
.score {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
}
.score.hot { background: var(--green-soft); color: var(--green); }
.score.warm { background: var(--amber-soft); color: var(--amber); }
.score.cold { background: var(--surface-2); color: var(--muted); }
.lead-name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rating { display: flex; align-items: center; gap: 4px; font-weight: 600; }
.rating .star { color: #f5b301; }
.rating small { color: var(--muted); font-weight: 400; }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap;
}
.tag.sem_site { background: var(--green-soft); color: var(--green); }
.tag.rede_social { background: var(--blue-soft); color: var(--blue); }
.tag.site { background: var(--surface-2); color: var(--muted); }
.phone { font-size: 12.5px; color: var(--muted); margin-top: 3px; white-space: nowrap; }
.lead-actions { display: flex; align-items: center; gap: 6px; }
.lead-actions select { padding: 6px 8px; font-size: 12.5px; }
.more { display: block; margin: 16px auto 0; }

.status-novo { --c: #8b8fa3; }
.status-abordado { --c: #3b82f6; }
.status-interessado { --c: #f59e0b; }
.status-fechado { --c: #16a34a; }
.status-descartado { --c: #dc2626; }
.dot { background: var(--c); }

/* ---------- drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(10, 12, 20, .35); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); z-index: 50;
  background: var(--surface); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform .22s ease; overflow-y: auto;
  box-shadow: -10px 0 40px rgba(0, 0, 0, .12);
}
.drawer.open { transform: none; }
.drawer-head { padding: 22px 22px 16px; border-bottom: 1px solid var(--border); position: relative; }
.drawer-head h2 { padding-right: 40px; }
.drawer-close { position: absolute; top: 16px; right: 16px; }
.drawer-body { padding: 18px 22px 30px; display: flex; flex-direction: column; gap: 18px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.drawer label.lbl { font-weight: 600; font-size: 13px; display: block; margin-bottom: 6px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.status-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.status-pick button { display: inline-flex; align-items: center; gap: 6px; }
.status-pick button.on { border-color: var(--c); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 25%, transparent); font-weight: 600; }

/* ---------- nichos ---------- */
.group { margin-top: 14px; }
.group-title { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.group .chips { margin-top: 7px; }
#a-extra { width: 100%; margin-top: 6px; }
.row-end select { min-width: 180px; }

.rank { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.rank th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 0 8px 8px; }
.rank td { padding: 9px 8px; border-top: 1px solid var(--border); vertical-align: middle; }
.rank td.num { text-align: right; font-variant-numeric: tabular-nums; }
.rank .pos { color: var(--muted); width: 24px; }
.bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--surface-2); min-width: 90px; }
.bar .a { background: var(--green); }
.bar .b { background: var(--blue); opacity: .7; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin: 4px 0 10px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.guide ol { padding-left: 20px; margin: 12px 0 0; }
.guide li { margin-bottom: 10px; }
.guide ul { padding-left: 18px; margin-top: 6px; }
.guide ul li { margin-bottom: 6px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px;
  font-weight: 500; box-shadow: 0 8px 30px rgba(0, 0, 0, .2);
}

/* ---------- responsivo ---------- */
@media (max-width: 1050px) {
  .grid-2, .grid-2.wide-left { grid-template-columns: 1fr; }
  .lead { grid-template-columns: 46px minmax(0, 1fr) auto; }
  .lead .col-rating, .lead .col-site { display: none; }
}
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .tabs { order: 3; flex: 1 1 100%; overflow-x: auto; }
  .usage { margin-left: auto; min-width: 130px; }
  main { padding: 16px 16px 60px; }
  .banner { margin: 12px 16px 0; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .lead { grid-template-columns: 42px minmax(0, 1fr); }
  .lead-actions { grid-column: 1 / -1; justify-content: flex-end; }
}
