[hidden] { display: none !important; }
:root {
  --bg: #0b0b0c;
  --panel: #141416;
  --panel-2: #1b1b1f;
  --line: #2a2a30;
  --text: #f2f2f3;
  --muted: #9a9aa3;
  --accent: #f26b1d;
  --accent-2: #ff8a45;
  --ok: #22c55e;
  --bad: #ef4444;
  --warn: #eab308;
  --blue: #3b82f6;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 Inter, system-ui, -apple-system, Segoe UI, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
small, .muted { color: var(--muted); }
code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: 12.5px; word-break: break-all; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: #0f0f11; border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand img { width: 34px; height: 34px; border-radius: 8px; }
.brand b { font-size: 15px; display: block; }
.brand small { font-size: 11px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--muted); font-weight: 600; text-decoration: none; position: relative; }
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.on { background: rgba(242,107,29,.12); color: var(--accent-2); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .count { margin-left: auto; background: var(--accent); color: #fff; font-size: 11px; border-radius: 99px; padding: 0 7px; line-height: 18px; }
.side .me { margin-top: auto; padding: 12px; border-top: 1px solid var(--line); font-size: 13px; }
.main { min-width: 0; padding: 22px 26px 60px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; flex-direction: row; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); z-index: 40; border-right: 0; border-top: 1px solid var(--line); }
  .side .brand, .side .me { display: none; }
  .nav { display: flex; width: 100%; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 2px; font-size: 10.5px; padding: 6px 8px; }
  .nav .count { position: absolute; top: 0; right: 4px; margin: 0; }
  .main { padding: 16px 16px 90px; }
  h1 { font-size: 19px; }
}

/* ---------- componentes ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 14px; }
.card h2 { margin-bottom: 12px; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .g2 { grid-template-columns: 1fr; } }
.stat { padding: 14px 16px; }
.stat small { display: block; font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .04em; }
.stat b { font-size: 26px; font-weight: 800; display: block; margin-top: 4px; }
.stat span { font-size: 12px; color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 9px; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: #3a3a42; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.fb { background: #1877f2; border-color: #1877f2; color: #fff; }
.btn.wa { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn.danger { color: #fca5a5; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 16px; height: 16px; }

label.f { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
label.f > input, label.f > select, label.f > textarea { margin-top: 5px; }
input, select, textarea { width: 100%; background: #0f0f11; border: 1px solid var(--line); color: var(--text); font: inherit; padding: 9px 11px; border-radius: 9px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
input[type=color] { padding: 2px; height: 36px; width: 48px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 10px; cursor: pointer; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { min-width: 0; }
.fields2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 560px) { .fields2 { grid-template-columns: 1fr; } }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.ok { color: #86efac; border-color: #14532d; background: #0d2416; }
.pill.bad { color: #fca5a5; border-color: #7f1d1d; background: #2a1010; }
.pill.warn { color: #fde68a; border-color: #713f12; background: #2a1f0b; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 6px; background: rgba(242,107,29,.13); color: var(--accent-2); }

table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--panel-2); }
.table-wrap { overflow-x: auto; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 6px; }

/* ---------- filtros ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input[type=search] { flex: 1 1 220px; max-width: 340px; }
.filters select { width: auto; flex: 0 1 auto; max-width: 220px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { background: transparent; border: 0; color: var(--muted); font: inherit; font-weight: 600; padding: 7px 12px; cursor: pointer; }
.seg button.on { background: var(--panel-2); color: var(--text); }

/* ---------- kanban ---------- */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; scroll-snap-type: x proximity; }
.col { flex: 0 0 280px; background: #101012; border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 210px); scroll-snap-align: start; }
.col-h { padding: 12px 12px 10px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.col-h b { font-size: 13px; }
.col-h .n { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 600; }
.col-h .v { display: block; font-size: 11.5px; color: var(--muted); padding: 0 12px 8px; }
.col-b { padding: 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 80px; }
.col.over { border-color: var(--accent); background: #17110d; }
.lc { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; cursor: pointer; position: relative; }
.lc:hover { border-color: #3a3a42; }
.lc.dragging { opacity: .4; }
.lc.unread::before { content: ''; position: absolute; left: -1px; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--accent); }
.lc .nm { font-weight: 700; font-size: 13.5px; display: flex; gap: 6px; align-items: center; }
.lc .nm .new { font-size: 10px; background: var(--accent); color: #fff; border-radius: 5px; padding: 0 5px; }
.lc .meta { font-size: 12px; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc .foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 11.5px; color: var(--muted); }
.lc .foot .av { margin-left: auto; }
.av { width: 22px; height: 22px; border-radius: 50%; background: #2c2c33; color: #ddd; font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.lc .due { color: var(--warn); }
.lc .due.late { color: #fca5a5; }
@media (max-width: 860px) { .col { flex-basis: 84vw; max-height: none; } }

/* ---------- drawer (ficha do lead) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50; display: flex; justify-content: flex-end; animation: fade .15s; }
.drawer { width: min(620px, 100%); height: 100%; background: var(--bg); border-left: 1px solid var(--line); overflow-y: auto; animation: slide .2s ease-out; display: flex; flex-direction: column; }
.drawer-h { position: sticky; top: 0; background: rgba(11,11,12,.96); backdrop-filter: blur(6px); padding: 16px 18px; border-bottom: 1px solid var(--line); z-index: 2; }
.drawer-h .top { display: flex; align-items: flex-start; gap: 10px; }
.drawer-h h2 { font-size: 19px; }
.drawer-h .x { margin-left: auto; }
.drawer-b { padding: 16px 18px 40px; }
.contact { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
@media (max-width: 560px) { .kv { grid-template-columns: 1fr; } .kv dd { margin-bottom: 6px; } }
.stages-bar { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 12px; }
.stages-bar button { flex: 1 1 auto; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.stages-bar button.on { color: #fff; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.timeline .ic { width: 28px; height: 28px; border-radius: 50%; background: var(--panel-2); display: flex; align-items: center; justify-content: center; flex: none; font-size: 13px; }
.timeline .tx { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; }
.timeline small { display: block; font-size: 11.5px; }
.note-types { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .15s; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: min(520px, 100%); max-height: 90vh; overflow-y: auto; padding: 20px; box-shadow: var(--shadow); }
.modal h2 { margin-bottom: 14px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ---------- gráficos ---------- */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding-top: 10px; }
.bars div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; opacity: .85; }
.bars div:hover { opacity: 1; }
.bars-x { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; }
.hbar { margin-bottom: 10px; }
.hbar .l { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; margin-bottom: 4px; }
.hbar .l span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--accent); border-radius: 99px; }
.funnel .hbar .fill { background: var(--c, var(--accent)); }

/* ---------- integrações ---------- */
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps > li { counter-increment: s; position: relative; padding: 0 0 18px 42px; }
.steps > li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.steps > li.done::before { content: '✓'; background: #0d2416; border-color: #14532d; color: #86efac; }
.steps > li > b:first-child { display: block; margin-bottom: 4px; }
.copy { display: flex; gap: 6px; align-items: center; margin: 6px 0; }
.copy code { flex: 1; padding: 7px 10px; }
.page-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.page-row img { width: 38px; height: 38px; border-radius: 50%; background: var(--panel-2); }
.page-row .info { flex: 1; min-width: 160px; }
.alert { border-radius: 10px; padding: 10px 12px; font-size: 13px; border: 1px solid; margin-bottom: 12px; }
.alert.warn { background: #2a1f0b; border-color: #713f12; color: #fde68a; }
.alert.bad { background: #2a1010; border-color: #7f1d1d; color: #fca5a5; }
.alert.ok { background: #0d2416; border-color: #14532d; color: #86efac; }
.alert.info { background: #0c1a2e; border-color: #1e3a5f; color: #bfdbfe; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: radial-gradient(circle at 30% 20%, rgba(242,107,29,.14), transparent 50%), var(--bg); }
.login .card { width: min(380px, 100%); padding: 26px; }
.login .brand { padding: 0 0 18px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow); animation: up .2s; max-width: 360px; cursor: default; }
.toast.err { border-left-color: var(--bad); }
.toast.lead { border-left-color: var(--ok); cursor: pointer; }
@media (max-width: 860px) { #toasts { bottom: 86px; } }

@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
@keyframes up { from { transform: translateY(10px); opacity: 0; } }
.spin { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: rot .7s linear infinite; display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }
.loading { display: flex; justify-content: center; padding: 50px; }

.f-toggle { display: none; }
@media (max-width: 860px) {
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
  .filters input[type=search] { max-width: none; grid-column: 1; }
  .f-toggle { display: inline-flex; }
  .filters select, .filters input[type=date] { max-width: none; width: 100%; }
  .filters.collapsed .adv { display: none; }
}
