:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --brand: #1d4ed8;
  --brand-ink: #ffffff;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120; --surface: #111827; --surface-2: #0f172a; --text: #e5e7eb;
    --muted: #94a3b8; --border: #1f2937; --brand: #3b82f6;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
}
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 20px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* topo */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; letter-spacing: -.01em; }
.brand span { color: var(--brand); }
.spacer { flex: 1; }
.clock { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); }
.clock b { color: var(--text); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 6px; vertical-align: 1px; }
.dot.off { background: var(--muted); }

main { max-width: 1200px; margin: 0 auto; padding: 16px; }

/* componentes */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 12px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.stat { padding: 12px 14px; }
.stat .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); padding: 8px 14px; border-radius: 8px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
button:disabled { opacity: .55; cursor: default; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 5px 12px;
  font-size: 13px; cursor: pointer; white-space: nowrap;
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .n { opacity: .7; margin-left: 4px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap; }

/* tabela / lista */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

.lead-list { display: grid; gap: 8px; }
.lead {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 14px; cursor: pointer;
}
.lead:hover { border-color: var(--muted); }
.lead .name { font-weight: 600; }
.lead .meta { font-size: 13px; color: var(--muted); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(2, 6, 23, .55); display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; overflow-y: auto; z-index: 50; }
.modal { width: 100%; max-width: 560px; }
.modal header { display: flex; justify-content: space-between; align-items: start; gap: 12px; padding: 16px; border-bottom: 1px solid var(--border); }
.modal .body { padding: 16px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.x { border: none; background: none; font-size: 22px; line-height: 1; padding: 0 4px; color: var(--muted); }

.status-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.status-pick button { justify-content: flex-start; border-width: 2px; }
.status-pick button.on { color: #fff; }

.history { list-style: none; padding: 0; margin: 0; }
.history li { padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }

.phone-link { font-size: 18px; font-weight: 700; text-decoration: none; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 10px 14px; color: var(--muted); }
.tabs button.on { color: var(--text); border-bottom-color: var(--brand); font-weight: 600; }

.bars { display: grid; gap: 6px; }
.bar { display: grid; grid-template-columns: 140px 1fr 36px; gap: 8px; align-items: center; font-size: 13px; }
.bar .track { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 5px; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 360px; padding: 24px; }

/* relatório */
.report h1 { margin-bottom: 4px; }
@media print {
  .topbar, .no-print, .modal-bg footer { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #ccc; }
  .modal-bg { position: static; background: none; padding: 0; }
  .modal { max-width: none !important; }
  body:has(.modal-bg) > main { display: none; }
}
@media (max-width: 640px) {
  .bar { grid-template-columns: 100px 1fr 30px; }
  .hide-sm { display: none; }
}
