:root {
  --paper: #f1f5f4;
  --surface: #ffffff;
  --ink: #10262b;
  --ink-2: #41565c;
  --ink-3: #6f8388;
  --line: #dbe4e3;
  --line-2: #c9d6d5;
  --petrol: #0b3540;
  --petrol-2: #124a58;
  --signal: #d4f26a;
  --wa: #1fa855;
  --wa-d: #178a45;
  --none: #0b8a5f;
  --none-bg: #e0f5ec;
  --social: #9a6600;
  --social-bg: #fbefcf;
  --site: #2b62c4;
  --site-bg: #e3ecfb;
  --unk: #5f7076;
  --unk-bg: #e8eded;
  --danger: #b8332a;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.5 var(--font-body);
}
h1, h2, h3 { font-family: var(--font-head); margin: 0; line-height: 1.15; letter-spacing: -0.01em; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--petrol-2); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #5aa9ff; outline-offset: 2px; border-radius: 6px; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--petrol); color: #d9e7e8;
  padding: 22px 14px; display: flex; flex-direction: column; gap: 26px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; padding: 0 8px; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-name { font: 700 19px/1 var(--font-head); letter-spacing: -0.01em; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px;
  border-radius: 10px; color: #c2d6d8; text-decoration: none; font-weight: 500;
  border-left: 3px solid transparent;
}
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: rgba(255,255,255,.11); color: #fff; border-left-color: var(--signal); }
.nav-ico { font-size: 17px; width: 22px; text-align: center; }
.nav-count {
  margin-left: auto; background: var(--signal); color: var(--petrol);
  font-size: 12px; font-weight: 700; border-radius: 999px; padding: 1px 8px;
}
.side-note { margin-top: auto; font-size: 12.5px; line-height: 1.45; color: #8fb0b4; padding: 0 8px; }

.content { padding: 30px clamp(16px, 3vw, 40px) 60px; max-width: 1320px; width: 100%; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 30px; }
.page-head p { color: var(--ink-2); margin-top: 6px; max-width: 62ch; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  padding: 9px 14px; border-radius: 10px; font-weight: 600; font-size: 14px;
  text-decoration: none; line-height: 1.2; white-space: nowrap;
  transition: background-color .15s, border-color .15s;
}
.btn:hover { background: #f4f8f7; border-color: #a9bcbb; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--petrol); border-color: var(--petrol); color: #fff; }
.btn-primary:hover { background: var(--petrol-2); border-color: var(--petrol-2); }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn-wa:hover { background: var(--wa-d); border-color: var(--wa-d); }
.btn-lg { padding: 13px 20px; font-size: 15px; border-radius: 12px; }
.btn-danger { color: var(--danger); }
.btn-saved { background: var(--none-bg); border-color: #a9dcc6; color: var(--none); }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }

/* ---------- Search form ---------- */
.searchbox {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px; display: grid; gap: 14px;
  grid-template-columns: 150px minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1.2fr);
  align-items: end;
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field label i { font-style: normal; font-weight: 400; color: var(--ink-3); }
.input, .select {
  width: 100%; height: 44px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line-2); background: #fbfdfc;
}
.input:focus, .select:focus { border-color: var(--petrol-2); background: #fff; }
.searchbox .custom { grid-column: 4; }
.searchbox .go { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.go-hint { color: var(--ink-3); font-size: 13px; }

.notice {
  border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; font-size: 14px;
  background: var(--social-bg); border: 1px solid #ecd28f; color: #5a3d00;
}
.notice a { color: inherit; font-weight: 700; }
.notice.error { background: #fbe4e1; border-color: #efb4ad; color: #7a1f18; }

/* ---------- Results summary ---------- */
.summary { margin: 22px 0 14px; display: grid; gap: 14px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.stat b { display: block; font: 700 28px/1.1 var(--font-head); }
.stat span { display: block; margin-top: 4px; color: var(--ink-2); font-size: 13.5px; }
.stat small { display: block; margin-top: 2px; color: var(--ink-3); font-size: 12px; }
.stat.hot { background: var(--petrol); border-color: var(--petrol); }
.stat.hot b { color: var(--signal); }
.stat.hot span { color: #d6e6e7; }
.stat.hot small { color: #9dbcc0; }

.spectrum { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.spectrum-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--unk-bg); gap: 2px; }
.spectrum-bar i { display: block; min-width: 4px; }
.spectrum-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: 13px; color: var(--ink-2); }
.spectrum-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.c-none { background: var(--none); }
.c-instagram { background: #d9a21b; }
.c-linktree { background: #e07b2c; }
.c-site { background: var(--site); }
.c-unk { background: #97a5a9; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px;
  padding: 6px 12px; font-size: 13.5px; font-weight: 500; color: var(--ink-2);
}
.chip:hover { border-color: #97aead; }
.chip[aria-pressed="true"] { background: var(--petrol); border-color: var(--petrol); color: #fff; }
.chip em { font-style: normal; opacity: .7; margin-left: 4px; font-size: 12.5px; }
.toolbar .select { height: 38px; width: auto; font-size: 13.5px; padding-right: 8px; }
.toolbar .sep { flex: 1; }
.tb-group { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-3); }

/* ---------- Cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 16px 16px 14px 20px; display: flex; flex-direction: column; gap: 10px;
  overflow: hidden;
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--edge, var(--line-2)); }
.card.p-sem_site { --edge: var(--none); }
.card.p-instagram { --edge: #d9a21b; }
.card.p-linktree { --edge: #e07b2c; }
.card.p-possui_site { --edge: var(--site); }
.card.p-nao_identificado { --edge: #97a5a9; }
.card-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.card h3 { font-size: 18px; }
.cat { color: var(--ink-2); font-size: 14px; margin-top: 3px; }
.badge {
  flex: none; font-size: 12.5px; font-weight: 700; border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
.b-sem_site { background: var(--none-bg); color: var(--none); }
.b-instagram, .b-linktree { background: var(--social-bg); color: var(--social); }
.b-possui_site { background: var(--site-bg); color: var(--site); }
.b-nao_identificado { background: var(--unk-bg); color: var(--unk); }
.facts { display: grid; gap: 4px; font-size: 14px; color: var(--ink); }
.facts div { display: flex; gap: 8px; align-items: baseline; }
.facts .ic { width: 20px; flex: none; text-align: center; }
.muted { color: var(--ink-3); }
.wa-status { font-size: 12.5px; font-weight: 600; border-radius: 6px; padding: 1px 7px; }
.wa-ok { background: #dcf5e5; color: #11713a; }
.wa-maybe { background: #e5f4ea; color: #2c7a48; }
.wa-no { background: var(--unk-bg); color: var(--unk); }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 4px; }
.card-actions .btn { flex: 1 1 auto; }
.card-actions .btn-wa { flex-basis: 100%; }

.skeleton { height: 250px; border-radius: 16px; background: linear-gradient(100deg, #e6ecea 30%, #f3f7f6 50%, #e6ecea 70%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.empty { background: var(--surface); border: 1px dashed var(--line-2); border-radius: 16px; padding: 34px 24px; text-align: center; color: var(--ink-2); }
.empty h3 { font-size: 20px; color: var(--ink); margin-bottom: 8px; }
.empty p { max-width: 58ch; margin: 0 auto; }
.empty .btn { margin-top: 16px; }
.steps { text-align: left; max-width: 640px; margin: 18px auto 0; display: grid; gap: 8px; }
.steps div { display: flex; gap: 10px; align-items: baseline; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(8, 28, 34, .55); }
.modal-panel {
  position: relative; background: var(--surface); border-radius: 18px; width: min(680px, 100%);
  max-height: calc(100vh - 40px); overflow: auto; padding: 24px;
  animation: pop .18s ease-out;
}
@keyframes pop { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.modal-head h2 { font-size: 24px; }
.x { border: 0; background: #edf2f1; width: 34px; height: 34px; border-radius: 50%; font-size: 18px; line-height: 1; flex: none; }
.x:hover { background: #dfe8e6; }
.presence-box { border-radius: 12px; padding: 12px 14px; margin: 12px 0 4px; font-size: 14px; }
.presence-box.b-sem_site { background: var(--none-bg); color: #075c40; }
.presence-box.b-instagram, .presence-box.b-linktree { background: var(--social-bg); color: #5f3f00; }
.presence-box.b-possui_site { background: var(--site-bg); color: #1d4590; }
.presence-box.b-nao_identificado { background: var(--unk-bg); color: #3e4d52; }
.presence-box small { display: block; margin-top: 4px; opacity: .85; }
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 10px 14px; margin: 16px 0; font-size: 14.5px; }
.dl dt { color: var(--ink-3); font-weight: 500; }
.dl dd { margin: 0; word-break: break-word; }
.hours { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.modal-actions .btn-wa { flex: 1 1 100%; }

/* ---------- Leads ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 600; font-size: 13px; color: var(--ink-3); padding: 12px 14px; border-bottom: 1px solid var(--line); background: #f8fbfa; white-space: nowrap; }
.tbl td { padding: 12px 14px; border-bottom: 1px solid #ebf1f0; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .nm { font-weight: 600; }
.tbl .nm small { display: block; font-weight: 400; color: var(--ink-3); }
.tbl .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.status-sel { height: 36px; border-radius: 8px; border: 1px solid var(--line-2); padding: 0 8px; background: #fff; font-weight: 600; }
.st-novo { border-left: 4px solid #6a8bd6; }
.st-contatado { border-left: 4px solid #d9a21b; }
.st-respondeu { border-left: 4px solid #8a63d2; }
.st-interessado { border-left: 4px solid #1fa855; }
.st-nao_interessado { border-left: 4px solid #9aa6a9; }
.st-cliente { border-left: 4px solid #0b3540; }
.search-in { max-width: 260px; height: 38px; }

/* ---------- Dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.kpi b { font: 700 30px/1.1 var(--font-head); display: block; }
.kpi span { color: var(--ink-2); font-size: 13.5px; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.chart { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.chart h3 { font-size: 18px; margin-bottom: 14px; }
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut-wrap svg { width: 150px; height: 150px; flex: none; }
.legend { display: grid; gap: 7px; font-size: 14px; }
.legend div { display: flex; align-items: center; gap: 8px; }
.legend b { margin-left: auto; padding-left: 14px; }
.hbar { display: grid; grid-template-columns: 110px 1fr 34px; gap: 10px; align-items: center; font-size: 14px; margin: 9px 0; }
.hbar .track { height: 14px; background: #edf2f1; border-radius: 999px; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 999px; background: var(--petrol-2); }
.hbar b { text-align: right; }
.footnote { margin-top: 16px; font-size: 13px; color: var(--ink-3); max-width: 80ch; }

/* ---------- Settings ---------- */
.stack { display: grid; gap: 16px; max-width: 760px; }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; display: grid; gap: 12px; }
.box h3 { font-size: 19px; }
.box p, .box li { color: var(--ink-2); font-size: 14.5px; }
.box ol { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.pill { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border-radius: 999px; font-weight: 600; font-size: 13px; }
.pill.ok { background: var(--none-bg); color: var(--none); }
.pill.off { background: #fbe4e1; color: var(--danger); }
code { background: #edf2f1; padding: 1px 6px; border-radius: 6px; font-size: 13px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--petrol); color: #fff; padding: 11px 18px; border-radius: 12px; font-weight: 600; font-size: 14px;
  transition: opacity .2s, transform .2s; z-index: 80; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .searchbox { grid-template-columns: 140px minmax(0, 1fr) minmax(0, 1fr); }
  .searchbox .segment { grid-column: 1 / -1; }
  .searchbox .custom { grid-column: 1 / -1; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 40; left: 0; right: 0; top: auto; bottom: 0; height: auto;
    flex-direction: row; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); gap: 0;
    box-shadow: 0 -6px 20px rgba(8, 28, 34, .18);
  }
  .brand, .side-note { display: none; }
  .nav { flex-direction: row; width: 100%; gap: 2px; }
  .nav a { flex: 1; flex-direction: column; gap: 2px; padding: 7px 4px; font-size: 11.5px; border-left: 0; border-top: 3px solid transparent; border-radius: 10px; text-align: center; position: relative; }
  .nav a.active { border-top-color: var(--signal); }
  .nav-count { position: absolute; top: 2px; right: 14%; margin: 0; font-size: 10.5px; padding: 0 6px; }
  .content { padding: 20px 14px 96px; }
  .page-head h1 { font-size: 25px; }
  .modal { align-items: flex-end; padding: 0; }
  .modal-panel { border-radius: 18px 18px 0 0; max-height: 92vh; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dd { margin-bottom: 8px; }
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .tbl td { border: 0; padding: 4px 0; }
  .tbl td[data-label]::before { content: attr(data-label) ": "; color: var(--ink-3); font-size: 13px; }
  .tbl td.nm::before { content: none; }
}
@media (max-width: 560px) {
  .searchbox { grid-template-columns: 1fr 1fr; padding: 14px; }
  .searchbox .field.uf { grid-column: 1 / -1; }
  .searchbox .field.city { grid-column: 1 / -1; }
  .searchbox .field.hood { grid-column: 1 / -1; }
  .grid { grid-template-columns: 1fr; }
  .stats { gap: 8px; }
  .stat { padding: 12px; }
  .stat b { font-size: 24px; }
  .hbar { grid-template-columns: 92px 1fr 30px; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton, .modal-panel { animation: none; }
  .toast { transition: none; }
}
