/* CRM de Leads — tokens: temperatura do lead é a única paleta com significado;
   tudo o mais é neutro. Tira de KPIs com divisórias, painéis com borda fina
   (sem sombra difusa), tipografia com algarismos tabulares nas tabelas. */

:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-hover: #f6f8fa;
  --border: #dce1e7;
  --ink: #161a22;
  --ink-muted: #5b6472;
  --ink-faint: #8891a0;
  --brand: #0e7c74;
  --brand-hover: #0b655f;
  --brand-soft: #e3f3f1;
  --frio: #4c7fe0;
  --frio-soft: #e8eefc;
  --morno: #b9661c;
  --morno-strong: #e8963c;
  --morno-soft: #fbeedd;
  --quente: #c93a33;
  --quente-strong: #e2473f;
  --quente-soft: #fbe4e2;
  --ganho: #1f9e6d;
  --ganho-soft: #e2f5ec;
  --perdido: #8691a0;
  --radius: 10px;
  --radius-sm: 7px;
  --font-display: "Archivo", sans-serif;
  --font-body: "IBM Plex Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); margin: 0; letter-spacing: -0.01em; }
p { margin: 0 0 0.6em; }
a { color: var(--brand); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
[x-cloak] { display: none !important; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 252px;
  flex-shrink: 0;
  background: #141820;
  color: #c7ced9;
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  color: #fff;
  padding: 2px 10px 22px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.sidebar .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--quente-strong); box-shadow: 0 0 0 3px rgba(226,71,63,.25); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 8px;
  color: #c7ced9; text-decoration: none;
  font-size: 0.93rem; font-weight: 500;
}
.sidebar nav a svg { flex-shrink: 0; opacity: .85; }
.sidebar nav a:hover { background: #1c222c; color: #fff; }
.sidebar nav a.active { background: #232a36; color: #fff; }
.sidebar nav a.active svg { color: var(--quente-strong); opacity: 1; }
.sidebar .meta {
  margin-top: auto; padding-top: 16px; border-top: 1px solid #262c38;
  font-size: 0.78rem; color: #78818f;
}
.sidebar .meta strong { color: #c7ced9; font-size: 1.05rem; display: block; font-family: var(--font-display); }

.menu-toggle { display: none; }

.main { flex: 1; min-width: 0; padding: 30px 38px 60px; max-width: 1360px; }

.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-head h1 { font-size: 1.6rem; font-weight: 800; }
.page-head .sub { color: var(--ink-muted); font-size: 0.9rem; margin-top: 4px; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- scoreboard (KPIs) ---------- */
.stat-strip {
  display: flex; flex-wrap: wrap;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); margin-bottom: 22px; overflow: hidden;
}
.stat-item { flex: 1 1 140px; padding: 16px 20px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.stat-item:last-child { border-right: none; }
.stat-value { font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; font-variant-numeric: tabular-nums; line-height: 1.05; }
.stat-label { font-size: 0.78rem; color: var(--ink-muted); margin-top: 5px; }
.stat-sub { font-size: 0.72rem; margin-top: 3px; color: var(--ink-faint); }
.stat-strip.section-title { border: none; background: transparent; padding: 0; margin: 28px 0 10px; }

h3.section-title { font-size: 0.95rem; color: var(--ink-muted); font-weight: 700; margin: 26px 0 12px; }

/* ---------- panels / grid ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.panel h2 { font-size: 0.98rem; font-weight: 700; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 980px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.chart-box { position: relative; height: 260px; }
.chart-box.short { height: 200px; }
.muted-note { color: var(--ink-faint); font-size: 0.85rem; padding: 10px 0; }

/* ---------- pills / badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px; font-size: 0.76rem; font-weight: 700; white-space: nowrap; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; }
.pill.frio { background: var(--frio-soft); color: var(--frio); }
.pill.frio .dot { background: var(--frio); }
.pill.morno { background: var(--morno-soft); color: var(--morno); }
.pill.morno .dot { background: var(--morno-strong); }
.pill.quente { background: var(--quente-soft); color: var(--quente); }
.pill.quente .dot { background: var(--quente-strong); }
.pill.neutro { background: #eef0f3; color: var(--ink-muted); }

.stage { font-size: 0.76rem; font-weight: 700; padding: 3px 9px; border-radius: 6px; background: #eef0f3; color: var(--ink-muted); }
.stage.ganho { background: var(--ganho-soft); color: var(--ganho); }
.stage.perdido { background: #f1f0ee; color: var(--perdido); }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
table.data th { text-align: left; font-weight: 700; color: var(--ink-muted); font-size: 0.74rem; text-transform: none; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
table.data tbody tr:hover { background: var(--surface-hover); }
table.data .num { font-variant-numeric: tabular-nums; text-align: right; }
table.data .lead-name { font-weight: 600; white-space: normal; }
table.data .lead-sub { color: var(--ink-faint); font-size: 0.78rem; }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font-body); font-weight: 600; font-size: 0.86rem;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none; line-height: 1;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-hover); }
.btn-danger { background: #fff; border-color: #f0c6c3; color: var(--quente); }
.btn-danger:hover { background: var(--quente-soft); }
.btn-sm { padding: 6px 11px; font-size: 0.78rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 0.78rem; font-weight: 700; color: var(--ink-muted); }
.field input, .field select, .field textarea {
  font-family: var(--font-body); font-size: 0.88rem; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--ink);
}
.field textarea { resize: vertical; min-height: 64px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.toolbar .field { margin-bottom: 0; min-width: 150px; }
.search-input { min-width: 240px; }

.alert { padding: 11px 14px; border-radius: 8px; font-size: 0.86rem; margin-bottom: 14px; }
.alert.ok { background: var(--ganho-soft); color: #176b4c; }
.alert.err { background: var(--quente-soft); color: var(--quente); }

/* ---------- contato page ---------- */
.contato-layout { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
@media (max-width: 980px) { .contato-layout { grid-template-columns: 1fr; } }
.lead-pick { max-height: 72vh; overflow-y: auto; }
.lead-pick-item { display: block; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); margin-bottom: 2px; }
.lead-pick-item:hover { background: var(--surface-hover); }
.lead-pick-item.active { background: var(--brand-soft); }
.lead-pick-item .name { font-weight: 600; font-size: 0.88rem; }
.lead-pick-item .sub { font-size: 0.76rem; color: var(--ink-faint); }

.lead-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.lead-header h2 { font-size: 1.25rem; }
.lead-links { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.85rem; margin-top: 8px; }
.kv-row { display: flex; gap: 22px; flex-wrap: wrap; margin: 14px 0; }
.kv-row .kv .v { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; }
.kv-row .kv .k { font-size: 0.75rem; color: var(--ink-muted); }

.history-item { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.history-item:last-child { border-bottom: none; }
.history-item .when { color: var(--ink-faint); font-size: 0.76rem; }

/* ---------- follow-ups ---------- */
.fu-section { margin-bottom: 26px; }
.fu-section h3 { display: flex; align-items: center; gap: 8px; font-size: 1rem; margin-bottom: 10px; }
.fu-count { background: #eef0f3; color: var(--ink-muted); border-radius: 999px; padding: 1px 9px; font-size: 0.78rem; font-weight: 700; }

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  .sidebar {
    position: fixed; z-index: 30; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: 0 0 0 100vmax rgba(0,0,0,0);
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 0 100vmax rgba(10,12,16,.45); }
  .main { padding: 18px 16px 48px; }
  .menu-toggle {
    display: inline-flex; align-items: center; gap: 8px; margin-bottom: 14px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 12px; font-weight: 600; font-size: 0.85rem; cursor: pointer;
  }
}
@media (min-width: 861px) { .menu-toggle { display: none; } }
