/* ============================================================
 * Radar de Leads — sistema visual
 *
 * Direção ("cartógrafo digital"):
 *  - superfície de papel, tinta grafite, pin vermelho-Maps
 *  - sidebar com malha de grade pontilhada (mapa)
 *  - assinatura: pin-mark em CSS puro + radar de varredura (login/vazio)
 *  - dados em JetBrains Mono (coordenadas, notas, scores)
 * ============================================================ */

:root {
  --paper:  #FAF9F6;
  --ink:    #1B212E;
  --pin:    #E8452F;
  --pin-soft: #FEF2F0;
  --trail:  #1E9E6A;
  --steel:  #6B7280;
  --line:   #E5E2DA;
  --card:   #FFFFFF;
  --warning:#F5A623;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body:    'Inter', sans-serif;
  --font-data:    'JetBrains Mono', monospace;

  --sidebar-w: 232px;
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.5;
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

/* ---------- pin-mark (assinatura) ---------- */
.pin-mark {
  width: 30px; height: 30px; flex: none;
  background: var(--pin);
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: grid; place-items: center;
  position: relative;
  box-shadow: 0 3px 0 rgba(27,33,46,.18);
}
.pin-mark::after {
  content: '';
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--paper);
}

/* ============ LOGIN ============ */
#login-screen {
  min-height: 100vh;
  display: grid; place-items: center;
  background:
    radial-gradient(circle, rgba(27,33,46,.10) 1.2px, transparent 1.2px) 0 0 / 26px 26px,
    var(--paper);
  position: relative;
  overflow: hidden;
}
.radar {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  pointer-events: none;
}
.radar-ring {
  position: absolute; border: 1px solid rgba(27,33,46,.14); border-radius: 50%;
}
.radar-ring.r1 { width: 34vmin; height: 34vmin; }
.radar-ring.r2 { width: 62vmin; height: 62vmin; }
.radar-ring.r3 { width: 90vmin; height: 90vmin; }
.radar-sweep {
  position: absolute; width: 90vmin; height: 90vmin; border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(232,69,47,.28), transparent 70deg, transparent);
  animation: sweep 6s linear infinite;
}
.radar-pin {
  position: absolute;
  width: 12px; height: 12px; border-radius: 50% 50% 50% 0;
  background: var(--pin); transform: rotate(-45deg);
  translate: 22vmin -14vmin;
}
@keyframes sweep { to { transform: rotate(360deg); } }

.login-card {
  position: relative;
  width: min(380px, 92vw);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 36px 32px 28px;
  box-shadow: 0 24px 60px rgba(27,33,46,.12);
}
.login-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 24px; }
.login-brand h1 { font-family: var(--font-display); font-size: 24px; margin: 0; letter-spacing: -.01em; }
.login-brand p { margin: 2px 0 0; color: var(--steel); font-size: 13px; }
.login-card label { display: block; font-weight: 600; font-size: 12.5px; margin: 14px 0 5px; }
.login-card input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 9px; background: var(--paper); font-size: 14.5px;
}
.login-card input:focus-visible { outline: 2px solid var(--pin); outline-offset: 1px; }
.login-card button {
  width: 100%; margin-top: 22px; padding: 12px;
  background: var(--pin); color: #fff; border: 0; border-radius: 9px;
  font-weight: 600; font-size: 15px;
}
.login-card button:hover { filter: brightness(.95); }
.form-error { color: var(--pin); font-size: 13px; margin: 12px 0 0; font-weight: 500; }
.credit { margin: 14px 0 0; font-size: 10px; color: var(--steel); text-align: center; letter-spacing: .04em; }
.sidebar-foot .credit { color: #5F6675; text-align: left; padding: 8px 12px 0; margin: 0; }

/* ============ SHELL ============ */
#app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: none;
  background:
    radial-gradient(circle, rgba(250,249,246,.07) 1px, transparent 1px) 0 0 / 22px 22px,
    var(--ink);
  color: var(--paper);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { display: flex; gap: 12px; align-items: center; padding: 20px 18px 16px; }
.sidebar .brand strong { font-family: var(--font-display); font-size: 16px; display: block; }
.sidebar .brand small { color: #98A0AF; font-size: 11.5px; display: block; margin-top: 2px; }

.menu { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; flex: 1; }
.menu button {
  text-align: left; background: none; border: 0; color: #C6CBD6;
  padding: 10px 12px; border-radius: 9px; font-size: 13.5px; font-weight: 500;
}
.menu button:hover { background: rgba(250,249,246,.07); color: var(--paper); }
.menu button.active { background: var(--pin); color: #fff; }
.sidebar-foot { padding: 14px 10px; }
.ghost { background: none; border: 1px solid rgba(250,249,246,.25); color: inherit; padding: 8px 12px; border-radius: 9px; font-size: 13px; width: 100%; }
.ghost:hover { background: rgba(250,249,246,.08); }

main { flex: 1; padding: 28px 30px; min-width: 0; }

/* ---------- cabeçalho de visão ---------- */
.view-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; margin-bottom: 20px; flex-wrap: wrap; }
.view-title { font-family: var(--font-display); font-size: 26px; margin: 0; letter-spacing: -.01em; }
.view-sub { margin: 3px 0 0; color: var(--steel); font-size: 13px; }
.view-head select { padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }

/* ============ KANBAN ============ */
.board { display: flex; gap: 14px; align-items: flex-start; overflow-x: auto; padding-bottom: 14px; }
.kcol {
  width: 268px; flex: none; background: #F2F0EA; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px;
}
.kcol-head {
  display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px;
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
}
.kcol-head .dot { width: 10px; height: 10px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); flex: none; }
.kcol-head .count { margin-left: auto; font-family: var(--font-data); font-size: 12px; color: var(--steel); }
.kcol-body { display: flex; flex-direction: column; gap: 8px; min-height: 44px; }

.lead-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; cursor: grab; position: relative;
  border-left: 4px solid var(--pin);
  box-shadow: 0 1px 2px rgba(27,33,46,.05);
}
.lead-card:hover { box-shadow: 0 4px 14px rgba(27,33,46,.10); }
.lead-card:active { cursor: grabbing; }
.lead-card h4 { margin: 0 0 2px; font-size: 13.5px; font-weight: 600; }
.lead-card .cat { font-size: 11.5px; color: var(--steel); }
.lead-card .row { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 11.5px; }
.rating { font-family: var(--font-data); color: var(--warning); font-weight: 600; }
.score-badge {
  margin-left: auto; font-family: var(--font-data); font-size: 10.5px; font-weight: 600;
  padding: 2px 7px; border-radius: 20px; background: var(--pin-soft); color: var(--pin);
}
.score-badge.low { background: #EDF9F3; color: var(--trail); }
.lead-card .who { display:block; margin-top: 6px; font-size: 10.5px; color: var(--steel); }

/* ============ TIMELINE ============ */
.timeline { list-style: none; margin: 0; padding: 0 0 0 8px; max-width: 720px; }
.timeline li { position: relative; padding: 0 0 22px 28px; border-left: 1px solid var(--line); }
.timeline li::before {
  content: ''; position: absolute; left: -7px; top: 3px;
  width: 11px; height: 11px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--steel);
}
.timeline li.t-call::before    { background: var(--warning); }
.timeline li.t-whatsapp::before{ background: var(--trail); }
.timeline li.t-status::before  { background: #4A6FA5; }
.timeline li.t-capture::before { background: var(--pin); }
.timeline .t-head { font-size: 12.5px; color: var(--steel); }
.timeline .t-head b { color: var(--ink); font-weight: 600; }
.timeline .t-body { margin-top: 2px; font-size: 13.5px; }
.timeline .t-time { font-family: var(--font-data); font-size: 11px; color: var(--steel); }

/* ============ TABELA DE LEADS ============ */
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input, .filters select { padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.filters input { min-width: 260px; }

.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
.leads-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.leads-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--steel); padding: 12px 14px; border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.leads-table td { padding: 10px 14px; border-bottom: 1px solid #F0EEE7; vertical-align: middle; }
.leads-table tr:last-child td { border-bottom: 0; }
.leads-table tr:hover td { background: #FBFAF7; }
.leads-table .name-cell b { display: block; font-weight: 600; }
.leads-table .name-cell small { color: var(--steel); font-family: var(--font-data); font-size: 11px; }
.mono { font-family: var(--font-data); font-size: 12px; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; color: #fff; }
.chip-off { background: #EDF0F4; color: var(--steel); }

/* ============ LISTAS / USUÁRIOS ============ */
.btn-primary { background: var(--pin); color: #fff; border: 0; border-radius: 9px; padding: 10px 16px; font-weight: 600; }
.btn-secondary { background: var(--ink); color: #fff; border: 0; border-radius: 9px; padding: 9px 14px; font-weight: 600; font-size: 13px; }
.btn-link { background: none; border: 0; color: var(--pin); font-weight: 600; font-size: 12.5px; padding: 4px 6px; }

.list-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.list-card h3 { font-family: var(--font-display); margin: 0 0 4px; font-size: 17px; }
.list-card .cols { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.col-pill { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 30px; padding: 5px 6px 5px 12px; font-size: 12.5px; }
.col-pill .dot { width: 9px; height: 9px; border-radius: 50%; }
.col-pill button { background: none; border: 0; color: var(--steel); font-size: 12px; padding: 2px 5px; border-radius: 50%; }
.col-pill button:hover { color: var(--pin); }

.token-cell code {
  font-family: var(--font-data); font-size: 11px; background: var(--paper);
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px;
  display: inline-block; max-width: 170px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle;
}

/* ============ FORMULÁRIO EMBUTIDO ============ */
.inline-form {
  background: var(--card); border: 1px dashed #CBC6B8; border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
}
.inline-form label { font-size: 11.5px; font-weight: 600; display: block; margin-bottom: 4px; color: var(--steel); }
.inline-form input, .inline-form select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.inline-form .field { display: flex; flex-direction: column; }

/* ============ DRAWER DO LEAD ============ */
.drawer { position: fixed; inset: 0; z-index: 60; background: rgba(27,33,46,.38); display: flex; justify-content: flex-end; }
.drawer-panel {
  width: min(460px, 94vw); background: var(--paper); height: 100%;
  overflow-y: auto; padding: 0 0 30px;
  box-shadow: -18px 0 50px rgba(27,33,46,.25);
  animation: slide-in .18s ease-out;
}
@keyframes slide-in { from { transform: translateX(40px); opacity: .4; } }
.drawer-head {
  position: sticky; top: 0; background: var(--ink); color: var(--paper);
  padding: 18px 20px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.drawer-head h3 { font-family: var(--font-display); margin: 0; font-size: 19px; }
.drawer-meta { margin: 5px 0 0; font-size: 12px; color: #A9B0BE; }
.drawer-head .ghost { width: auto; border-color: rgba(250,249,246,.3); }
.drawer-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 18px; }

.d-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.d-item { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.d-item small { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--steel); font-weight: 600; }
.d-item .val { font-size: 13.5px; font-weight: 500; margin-top: 3px; word-break: break-word; }
.d-item .val.mono { font-family: var(--font-data); font-size: 12px; }

.score-meter { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.score-meter .bar { height: 8px; border-radius: 6px; background: #EFEDE6; margin-top: 8px; overflow: hidden; }
.score-meter .bar i { display: block; height: 100%; border-radius: 6px; }
.score-meter .lbl { display: flex; justify-content: space-between; font-size: 12px; }
.score-meter .lbl b { font-family: var(--font-data); }

.d-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.d-actions a, .d-actions button {
  flex: 1; text-align: center; text-decoration: none;
  padding: 10px; border-radius: 9px; font-weight: 600; font-size: 13px; border: 0;
  min-width: 130px;
}
.a-call { background: var(--ink); color: #fff; }
.a-wa { background: var(--trail); color: #fff; }
.a-maps { background: var(--pin-soft); color: var(--pin); border: 1px solid var(--pin) !important; }
.a-site { background: #EDF0F4; color: var(--ink); }

.d-feed h4, .d-add h4 { font-family: var(--font-display); font-size: 14px; margin: 0 0 10px; }
.feed-item { border-left: 2px solid var(--line); padding: 0 0 12px 12px; font-size: 13px; }
.feed-item small { display: block; color: var(--steel); font-size: 11px; font-family: var(--font-data); margin-top: 2px; }
.d-add textarea { width: 100%; min-height: 64px; border: 1px solid var(--line); border-radius: 9px; padding: 10px; resize: vertical; }
.d-add .row2 { display: flex; gap: 8px; margin-top: 8px; }

/* ============ ESTADO VAZIO / TOAST ============ */
.empty {
  text-align: center; padding: 60px 20px; color: var(--steel); position: relative;
}
.empty .radar-mini {
  width: 74px; height: 74px; margin: 0 auto 18px; position: relative; border-radius: 50%;
  border: 1px solid var(--line);
  background: radial-gradient(circle, var(--paper) 30%, #F2F0EA);
  overflow: hidden;
}
.empty .radar-mini::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(rgba(232,69,47,.35), transparent 90deg, transparent);
  animation: sweep 3.5s linear infinite;
}
.empty p { margin: 0; font-size: 14px; }
.empty b { color: var(--ink); }

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 11px 18px;
  border-radius: 10px; font-size: 13.5px; font-weight: 500; z-index: 90;
  box-shadow: 0 10px 30px rgba(27,33,46,.30);
  border-left: 4px solid var(--trail);
}
#toast.err { border-left-color: var(--pin); }

/* ============ RESPONSIVO ============ */
@media (max-width: 860px) {
  #app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; }
  .menu { flex-direction: row; overflow-x: auto; }
  .sidebar-foot { margin-left: auto; }
  main { padding: 18px 14px; }
  .view-head { align-items: stretch; }
  .filters input { min-width: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .radar-sweep, .empty .radar-mini::after { animation: none; }
  .drawer-panel { animation: none; }
}

/* ---------- plano da assinatura (Usuários) ---------- */
.plan-sel {
  font-family: var(--font-b); font-size: 13.5px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--paper);
  color: var(--ink); cursor: pointer;
}
