:root {
  --bg: #0b0f17;
  --surface: #131a26;
  --surface-2: #1b2434;
  --border: #283348;
  --text: #e6edf7;
  --muted: #93a3ba;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --whatsapp: #16a34a;
  --whatsapp-hover: #15803d;
  --warn: #d97706;
  --danger: #dc2626;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

h1 {
  margin: 0;
  font-size: 1.4rem;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  margin-top: 4px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="search"],
textarea,
select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.92rem;
  font-family: inherit;
}

input[type="search"]::placeholder {
  color: var(--muted);
}

.filter-search-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.filter-search-wrap svg {
  position: absolute;
  left: 11px;
  color: var(--muted);
  pointer-events: none;
}

#lead-search {
  padding-left: 34px;
  min-width: 240px;
  background: var(--surface);
  border-color: var(--border);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

#lead-search:hover {
  border-color: #3a4a66;
}

#lead-search:focus {
  background: var(--surface-2);
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.22);
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--primary);
  border-color: transparent;
}

.grow { flex: 1; min-width: 220px; }

button {
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: var(--primary);
  transition: background 0.15s;
}

button:hover { background: var(--primary-hover); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

button.secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}
button.secondary:hover { background: #243045; }

button.whatsapp { background: var(--whatsapp); }
button.whatsapp:hover { background: var(--whatsapp-hover); }

button.danger {
  background: transparent;
  border: 1px solid #4c2227;
  color: #f87171;
  padding: 7px 10px;
}
button.danger:hover { background: #3b171b; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--muted);
  cursor: pointer;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tab {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
}

.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.lead-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lead-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.lead-info {
  flex: 1;
  min-width: 260px;
}

.lead-toolbar { display:flex; align-items:end; gap:12px; width:100%; padding:12px; background:var(--surface); border:1px solid var(--border); border-radius:12px; }
.toolbar-field { display:flex; flex-direction:column; gap:5px; min-width:190px; color:var(--muted); font-size:.76rem; font-weight:650; }
.toolbar-field select { min-width:190px; }
.filter-search-wrap { flex:1; }
.filter-search-wrap #lead-search { width:100%; min-width:180px; height:40px; }
.list-heading { display:flex; justify-content:space-between; align-items:end; margin:24px 2px 12px; }
.list-heading h2 { margin:0; font-size:1.15rem; }
.list-heading .subtitle { margin:3px 0 0; font-size:.82rem; }
.lead-avatar { display:grid; place-items:center; flex:0 0 44px; height:44px; border-radius:14px; color:#bfdbfe; background:linear-gradient(145deg,#263b5e,#19283e); border:1px solid #344b6e; font-weight:750; font-size:1.1rem; }
.lead-links { display:grid; gap:8px; margin-top:12px; }
.social-stack { display:grid; grid-template-columns:repeat(2,minmax(130px,1fr)); gap:7px; max-width:380px; }
.social-link { display:inline-flex; align-items:center; width:max-content; max-width:100%; padding:6px 10px; border-radius:8px; border:1px solid color-mix(in srgb,var(--social-color,#60a5fa) 38%,transparent); background:color-mix(in srgb,var(--social-color,#60a5fa) 10%,transparent); color:var(--social-color,#93c5fd); text-decoration:none; font-size:.78rem; font-weight:650; }
.social-link:hover { background:color-mix(in srgb,var(--social-color,#60a5fa) 18%,transparent); }
.maps-link { --social-color:#60a5fa; }
.website-link { --social-color:#4ade80; }
.social-missing { color:var(--muted); font-size:.78rem; }
.lead-saved-details { margin-top:10px; color:var(--muted); font-size:.8rem; }
.lead-saved-details summary { width:max-content; cursor:pointer; color:#aab9ce; }
.saved-fields { display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); gap:9px; margin-top:10px; padding:11px; border:1px solid var(--border); border-radius:9px; background:var(--bg); overflow-wrap:anywhere; }
.saved-fields span { display:grid; gap:2px; }
.saved-fields b { color:var(--muted); font-size:.7rem; text-transform:uppercase; letter-spacing:.04em; }
.settings-utilities { display:flex; justify-content:space-between; align-items:center; gap:14px; margin-top:20px; padding:14px; border:1px solid var(--border); border-radius:10px; background:var(--bg); }
.settings-utilities p { margin:3px 0 0; font-size:.8rem; }
.utility-link { display:inline-flex; align-items:center; text-decoration:none; padding:10px 14px; border-radius:10px; font-size:.9rem; font-weight:600; }
.lead-card { transition:border-color .18s, transform .18s, box-shadow .18s; }
.lead-card:hover { border-color:#3a4a66; transform:translateY(-1px); box-shadow:0 10px 28px rgba(0,0,0,.16); }
.lead-actions { margin-left:auto; }
.more-actions { position:relative; isolation:isolate; }
.more-actions[open] { z-index:50; }
.lead-card:has(.more-actions[open]) { z-index:50; }
.more-actions summary { list-style:none; cursor:pointer; padding:10px 12px; border-radius:9px; border:1px solid var(--border); background:var(--surface-2); color:var(--muted); font-size:.86rem; font-weight:650; }
.more-actions summary::-webkit-details-marker { display:none; }
.more-actions[open] summary,.more-actions summary:hover { color:var(--text); border-color:#435573; }
.more-actions-menu { position:absolute; z-index:51; right:0; top:calc(100% + 7px); display:grid; gap:7px; min-width:210px; padding:9px; background:var(--surface); border:1px solid var(--border); border-radius:12px; box-shadow:0 14px 35px rgba(0,0,0,.35); }
.more-actions-menu button { text-align:left; }
.action-status { display:grid; gap:5px; color:var(--muted); font-size:.78rem; }
.modal-heading,.message-footer { display:flex; align-items:center; justify-content:space-between; gap:14px; }
.modal-heading h2 { margin:0; }
.eyebrow { margin:0 0 3px; color:#7aaeff; letter-spacing:.12em; font-size:.68rem; font-weight:750; }
.message-modal { max-width:650px; }
.message-modal > .subtitle { margin:5px 0 18px; }
.message-modal textarea { min-height:190px; line-height:1.55; resize:vertical; }
.message-footer { margin-top:4px; }
.icon-button { width:38px; height:38px; padding:0; border-radius:50%; background:var(--surface-2); border:1px solid var(--border); font-size:1.35rem; }
button { border-radius:10px; padding:10px 15px; font-weight:650; box-shadow:0 1px 1px rgba(0,0,0,.15); }
button:focus-visible,summary:focus-visible { outline:2px solid #60a5fa; outline-offset:2px; }

@media (max-width: 700px) {
  .lead-toolbar { align-items:stretch; flex-direction:column; }
  .toolbar-field,.toolbar-field select { width:100%; }
  .lead-card { align-items:flex-start; }
  .lead-actions { width:100%; margin-left:0; }
  .lead-actions > .whatsapp { flex:1; }
  .message-footer { align-items:flex-start; flex-direction:column; }
  .settings-utilities { align-items:flex-start; flex-direction:column; }
  .social-stack { grid-template-columns:1fr 1fr; max-width:none; }
}

.lead-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 700;
  font-size: 1rem;
}

.badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

.badge.no-site {
  background: #0d2e1b;
  color: #4ade80;
  border-color: #166534;
}

.badge.followup {
  background: #332109;
  color: #fbbf24;
  border-color: #78350f;
}

.lead-meta {
  margin-top: 5px;
  font-size: 0.85rem;
  color: var(--muted);
}

.lead-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.feedback {
  margin-top: 10px;
  font-size: 0.88rem;
  color: var(--muted);
}

.feedback.ok { color: #4ade80; }
.feedback.err { color: #f87171; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-backdrop.hidden { display: none; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 580px;
  padding: 20px;
  max-height: 90vh;
  overflow-y: auto;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 10px;
}

/* Grade de contatos: cada empresa ocupa um card independente. */
.lead-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  align-items: stretch;
  gap: 16px;
}

.lead-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  min-width: 0;
  padding: 0;
  overflow: visible;
  border-radius: 15px;
}

.lead-media {
  position: relative;
  display: grid;
  place-items: center;
  height: 152px;
  overflow: hidden;
  border-radius: 14px 14px 0 0;
  background: linear-gradient(135deg, #1e3558, #172237);
}

.lead-media img { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; }
.lead-media img { animation: photo-arrive .45s ease-out both; }
.lead-initial { color:#bfdbfe; font-size:2rem; font-weight:800; }
.lead-priority { position:absolute; z-index:1; top:10px; left:10px; padding:5px 8px; border:1px solid #5b8fe5; border-radius:999px; background:rgba(11, 28, 55, .88); color:#dbeafe; font-size:.68rem; font-weight:800; letter-spacing:.04em; box-shadow:0 2px 10px rgba(0,0,0,.25); }
.muted-priority { border-color:#55657c; color:#c5d0df; }
.lead-info { display:flex; flex:1; flex-direction:column; min-width:0; padding:14px 15px 0; }
.lead-title { font-size:1.02rem; line-height:1.25; }
.lead-info > .lead-meta { display:none; }
.lead-facts { display:grid; gap:5px; margin-top:12px; padding-top:11px; border-top:1px solid var(--border); }
.fact { display:flex; justify-content:space-between; gap:10px; padding:2px 0; font-size:.78rem; color:var(--muted); }
.fact b { color:var(--text); font-size:.8rem; font-weight:550; text-align:right; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.fact-phone,.fact-rating,.fact-address,.fact-contact { background:transparent; color:var(--muted); }
.fact-address { align-items:flex-start; }
.fact-address b { white-space:normal; }
.lead-links { margin-top:13px; }
.social-stack { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width:none; }
.social-link { width:100%; justify-content:center; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; border-color:var(--border); background:transparent; color:var(--muted); }
.social-link:hover { background:var(--surface-2); color:var(--text); }
.maps-link,.website-link { --social-color:var(--muted); }
.social-dropdown { position:relative; }
.social-dropdown summary { display:flex; align-items:center; justify-content:space-between; cursor:pointer; padding:8px 0; border:0; border-radius:0; color:var(--muted); background:transparent; font-size:.8rem; font-weight:650; list-style:none; }
.social-dropdown summary::-webkit-details-marker { display:none; }
.social-dropdown summary::after { content:"+"; color:var(--muted); font-size:1rem; }
.social-dropdown[open] summary::after { content:"−"; }
.social-dropdown-menu { display:grid; gap:9px; margin-top:7px; padding:10px; border:1px solid var(--border); border-radius:8px; background:var(--surface-2); animation: menu-arrive .18s ease-out both; }
.social-dropdown-menu p { margin:0; color:var(--muted); font-size:.75rem; line-height:1.4; }
.social-searches { display:grid; gap:7px; color:#9bacc4; font-size:.72rem; }
.social-searches > span { font-weight:700; text-transform:uppercase; letter-spacing:.06em; }
.lead-saved-details { margin-top:13px; }
.lead-actions { display:flex; align-items:end; width:100%; margin:0; padding:14px 15px 15px; }
.lead-actions .action-status { flex:1; min-width:0; }
.lead-actions .action-status select { width:100%; }
.lead-actions .whatsapp { white-space:nowrap; }
.more-actions-menu { z-index:51; }
@keyframes photo-arrive { from { opacity:0; transform:scale(1.04); } to { opacity:1; transform:scale(1); } }
@keyframes menu-arrive { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:translateY(0); } }

@media (max-width: 700px) {
  .lead-list { grid-template-columns: 1fr; }
  .lead-card { align-items:stretch; }
  .lead-actions { width:100%; margin:0; }
}
