:root {
  --bg: #0E0F12;
  --panel: #16181D;
  --panel-2: #1D2027;
  --line: #2A2E37;
  --line-soft: #22252D;
  --text: #F4F1EC;
  --muted: #9A9FAB;
  --faint: #6B7180;
  --accent: #FF6B3D;
  --accent-soft: rgba(255, 107, 61, .14);
  --green: #3DD68C;
  --green-soft: rgba(61, 214, 140, .13);
  --yellow: #F5C451;
  --yellow-soft: rgba(245, 196, 81, .14);
  --red: #FF5C6C;
  --red-soft: rgba(255, 92, 108, .13);
  --blue: #6CA8FF;
  --blue-soft: rgba(108, 168, 255, .13);
  --violet: #B892FF;
  --violet-soft: rgba(184, 146, 255, .14);
  --radius: 14px;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 'Manrope', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid var(--line-soft);
  padding: 22px 14px; display: flex; flex-direction: column; gap: 4px;
  background: linear-gradient(180deg, #121419, var(--bg));
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; }
.brand img { width: 30px; height: 30px; }
.brand b { display: block; font-size: 15px; letter-spacing: -.01em; }
.brand span { display: block; font-size: 11px; color: var(--faint); }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px;
  text-decoration: none; color: var(--muted); font-weight: 600;
}
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.on { background: var(--panel-2); color: var(--text); }
.nav a.on svg { color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .count { margin-left: auto; font: 500 11px var(--mono); color: var(--faint); }
.side .spacer { flex: 1; }
.main { min-width: 0; padding: 28px 32px 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

.mobile-bar { display: none; }

/* ---------- componentes ---------- */
.card { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 15px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font-weight: 700; cursor: pointer; white-space: nowrap;
  text-decoration: none; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: #3a3f4b; background: #232630; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #160904; }
.btn.primary:hover { background: #ff7d55; }
.btn.green { background: var(--green); border-color: var(--green); color: #04150c; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); }
.btn.sm { height: 31px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn svg { width: 16px; height: 16px; }

.input, .select, textarea.input {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: #111318; outline: none; transition: border-color .15s;
}
textarea.input { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.55; }
.input:focus, .select:focus { border-color: var(--accent); }
.select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239A9FAB' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
label.f small { font-weight: 500; color: var(--faint); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 99px;
  border: 1px solid var(--line); background: transparent; cursor: pointer; font-weight: 600; font-size: 12.5px; color: var(--muted);
}
.chip:hover { color: var(--text); }
.chip.on { background: var(--accent-soft); border-color: rgba(255,107,61,.5); color: var(--accent); }
.chip svg { width: 14px; height: 14px; }

.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-novo { background: var(--blue-soft); color: var(--blue); }
.st-contatado { background: var(--yellow-soft); color: var(--yellow); }
.st-respondeu { background: var(--violet-soft); color: var(--violet); }
.st-reuniao { background: var(--accent-soft); color: var(--accent); }
.st-fechado { background: var(--green-soft); color: var(--green); }
.st-perdido { background: #23262d; color: var(--faint); }

.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--panel-2); color: var(--muted); }
.tag.good { background: var(--green-soft); color: var(--green); }
.tag.warn { background: var(--yellow-soft); color: var(--yellow); }
.tag.bad { background: var(--red-soft); color: var(--red); }
.tag.hot { background: var(--accent-soft); color: var(--accent); }

/* stats */
.stat { padding: 16px 18px; }
.stat .k { color: var(--muted); font-size: 12px; font-weight: 700; }
.stat .v { font: 500 30px/1.2 var(--mono); margin-top: 6px; letter-spacing: -.03em; }
.stat .s { color: var(--faint); font-size: 12px; margin-top: 2px; }

.funnel { display: flex; flex-direction: column; gap: 9px; }
.funnel .fr { display: grid; grid-template-columns: 100px 1fr 44px; align-items: center; gap: 12px; font-size: 13px; }
.funnel .bar { height: 10px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.funnel .bar i { display: block; height: 100%; border-radius: 99px; }
.funnel .n { font-family: var(--mono); text-align: right; color: var(--muted); }

.integ { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.integ:last-child { border-bottom: 0; }
.integ .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); flex: none; }
.integ .dot.ok { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.integ .dot.mid { background: var(--yellow); box-shadow: 0 0 0 4px var(--yellow-soft); }
.integ b { display: block; }
.integ span { font-size: 12px; color: var(--muted); }

/* tabela de leads */
.filters { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.filters .top { display: grid; grid-template-columns: minmax(180px, 1fr) 160px 170px 150px; gap: 10px; }
.table-wrap { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 700; padding: 11px 14px; border-bottom: 1px solid var(--line-soft); background: #14161b; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; transition: background .1s; }
tbody tr:hover { background: #1a1d23; }
tbody tr.sel { background: rgba(255,107,61,.06); }
td.cb, th.cb { width: 40px; padding-right: 0; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.lead-name b { display: block; font-weight: 700; }
.lead-name span { font-size: 12px; color: var(--muted); }
.icons { display: flex; gap: 6px; }
.ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--panel-2); color: #4a4f5c; }
.ic svg { width: 15px; height: 15px; }
.ic.on { color: var(--green); background: var(--green-soft); }
.ic.mid { color: var(--yellow); background: var(--yellow-soft); }
.ic.off { color: var(--red); background: var(--red-soft); }
.rating { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.rating small { color: var(--faint); }
.score { font: 500 13px var(--mono); display: inline-grid; place-items: center; min-width: 38px; height: 26px; border-radius: 7px; background: var(--panel-2); }
.score.hi { background: var(--accent-soft); color: var(--accent); }
.score.md { background: var(--yellow-soft); color: var(--yellow); }

.bulk {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 30;
  display: flex; gap: 8px; align-items: center; padding: 10px; border-radius: 16px;
  background: #1f2229; border: 1px solid #343946; box-shadow: 0 18px 50px rgba(0,0,0,.5);
  max-width: calc(100vw - 32px); flex-wrap: wrap; justify-content: center;
}
.bulk .n { font-weight: 800; padding: 0 8px; }
.bulk .select { height: 31px; width: auto; font-size: 12.5px; border-radius: 8px; }

.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 4px; color: var(--muted); font-size: 13px; }

/* drawer */
.overlay { position: fixed; inset: 0; background: rgba(5,6,8,.6); z-index: 40; animation: fade .15s; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw); z-index: 41;
  background: var(--bg); border-left: 1px solid var(--line); overflow-y: auto;
  animation: slide .2s cubic-bezier(.2,.8,.2,1);
}
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.drawer-head { position: sticky; top: 0; z-index: 2; background: rgba(14,15,18,.92); backdrop-filter: blur(10px); padding: 20px 24px 16px; border-bottom: 1px solid var(--line-soft); }
.drawer-body { padding: 20px 24px 60px; display: flex; flex-direction: column; gap: 16px; }
.x { position: absolute; top: 16px; right: 16px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.ai-box { border: 1px solid rgba(255,107,61,.3); background: linear-gradient(160deg, rgba(255,107,61,.07), transparent 60%), var(--panel); }
.ai-box ul { margin: 8px 0 0; padding-left: 18px; color: var(--text); }
.ai-box li { margin: 3px 0; }
.msg-card textarea { min-height: 150px; }
.hist { display: flex; flex-direction: column; gap: 8px; }
.hist .h { padding: 10px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line-soft); font-size: 13px; }
.hist .h.in { border-color: rgba(184,146,255,.35); background: rgba(184,146,255,.06); }
.hist .h header { display: flex; justify-content: space-between; color: var(--faint); font-size: 11.5px; margin-bottom: 4px; gap: 10px; }
.hist .h p { margin: 0; white-space: pre-wrap; }

/* serviços */
.svc { display: flex; flex-direction: column; gap: 10px; }
.svc header { display: flex; align-items: center; gap: 10px; }
.svc header .input { font-weight: 700; }

/* busca */
.search-hero { padding: 24px; background: radial-gradient(120% 140% at 100% 0%, rgba(255,107,61,.12), transparent 50%), var(--panel); }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--line-soft); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item b { display: block; }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: rot .7s linear infinite; display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty svg { width: 36px; height: 36px; color: var(--faint); margin-bottom: 10px; }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-soft); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; color: var(--muted); font-weight: 700; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(60% 50% at 50% 0%, rgba(255,107,61,.16), transparent 70%), var(--bg); }
.login .card { width: min(380px, 100%); padding: 30px; display: flex; flex-direction: column; gap: 16px; }
.login img { width: 48px; }

#toast { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
#toast div { background: #23262e; border: 1px solid #383d4a; padding: 10px 16px; border-radius: 10px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: fade .2s; max-width: 90vw; }
#toast div.err { border-color: rgba(255,92,108,.5); color: #ffb3bb; }

/* ---------- responsivo ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .top { grid-template-columns: 1fr 1fr; }
  .hide-md { display: none; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 20; flex-direction: row;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line);
    background: rgba(14,15,18,.95); backdrop-filter: blur(12px);
  }
  .side .brand, .side .spacer, .side .logout { display: none; }
  .nav { display: flex; flex: 1; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 3px; font-size: 10.5px; padding: 6px 4px; }
  .nav .count { display: none; }
  .main { padding: 18px 16px 120px; }
  .mobile-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
  .mobile-bar img { width: 26px; }
  .g2, .g4 { grid-template-columns: 1fr 1fr; }
  .g2 { grid-template-columns: 1fr; }
  h1 { font-size: 22px; }
  .filters .top { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  td, th { padding: 10px; }
  .bulk { bottom: 84px; left: 12px; right: 12px; transform: none; max-width: none; }
  .bulk .select { flex: 1; }
  .kv { grid-template-columns: 90px 1fr; }
  .drawer-head, .drawer-body { padding-left: 16px; padding-right: 16px; }
}

/* integrações */
.dot-s { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #3a3f4b; margin-right: 7px; vertical-align: 1px; }
.dot-s.ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
details.keys { border-top: 1px solid var(--line-soft); padding-top: 12px; }
details.keys summary { cursor: pointer; font-weight: 700; list-style: none; }
details.keys summary::before { content: '▸ '; color: var(--faint); }
details.keys[open] summary::before { content: '▾ '; }
.save-bar { position: sticky; bottom: 12px; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px 12px 18px; border-radius: 14px; background: rgba(29,32,39,.94); border: 1px solid var(--line); backdrop-filter: blur(10px); }
@media (max-width: 760px) { .save-bar { bottom: 80px; } }

.test-box { padding: 12px; border-radius: 10px; background: #121419; border: 1px dashed var(--line); gap: 8px; }
