:root {
  --bg: #f5f6f8; --card: #fff; --text: #111827; --muted: #6b7280; --line: #e5e7eb; --line-strong: #d1d5db;
  --brand: #4f46e5; --brand-dark: #4338ca; --brand-weak: #eef2ff;
  --green: #15803d; --green-bg: #dcfce7; --amber: #b45309; --amber-bg: #fef3c7;
  --red: #b91c1c; --red-bg: #fee2e2; --blue: #1d4ed8; --blue-bg: #dbeafe; --purple: #6d28d9; --purple-bg: #ede9fe;
  --gray: #4b5563; --gray-bg: #f3f4f6;
  --side: #111827; --radius: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif; color: var(--text);
  background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; letter-spacing: -.02em; }
h2 { font-size: 17px; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hide { display: none !important; }

/* ---------- estrutura ---------- */
.shell { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }
.side { background: var(--side); color: #e5e7eb; display: flex; flex-direction: column; padding: 22px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 26px; font-weight: 700; font-size: 18px; color: #fff; letter-spacing: -.01em; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: #cbd5e1; font-weight: 500; font-size: 15px; }
.nav a svg { width: 21px; height: 21px; flex: none; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.on { background: var(--brand); color: #fff; }
.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; cursor: pointer; background: rgba(255,255,255,.06); border: 0; width: 100%; text-align: left; color: #e5e7eb; }
.me:hover { background: rgba(255,255,255,.1); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #374151; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; }
.me b { display: block; font-size: 14px; line-height: 1.2; color: #fff; }
.me span { font-size: 12px; color: #9ca3af; }
.main { padding: 30px 36px 60px; min-width: 0; max-width: 1400px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; }
.tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- componentes ---------- */
.card { min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card h2 { margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-strong); background: #fff; color: var(--text);
  padding: 9px 16px; border-radius: 10px; font-weight: 600; cursor: pointer; font-size: 14.5px; white-space: nowrap; }
.btn:hover { background: var(--gray-bg); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--red); border-color: #fecaca; }
.btn.danger:hover { background: var(--red-bg); }
.btn.green { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn.green:hover { background: #15803d; }
.btn.small { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: wait; }
.btn svg { width: 17px; height: 17px; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px; background: #fff; outline: none; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
textarea.input { min-height: 84px; resize: vertical; }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.search .input { padding-left: 38px; min-width: 260px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; white-space: nowrap; background: var(--gray-bg); color: var(--gray); }
.badge.green { background: var(--green-bg); color: var(--green); } .badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.red { background: var(--red-bg); color: var(--red); } .badge.blue { background: var(--blue-bg); color: var(--blue); }
.badge.purple { background: var(--purple-bg); color: var(--purple); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-strong); background: #fff; padding: 6px 14px; border-radius: 99px; cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--gray); }
.chip.on { background: var(--text); border-color: var(--text); color: #fff; }
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty h3 { color: var(--text); font-size: 18px; margin-bottom: 6px; }
.empty .btn { margin-top: 18px; }

/* ---------- dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi { display: block; color: inherit; transition: transform .12s, box-shadow .12s; }
a.kpi:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(16,24,40,.08); }
.kpi .label { color: var(--muted); font-weight: 600; font-size: 13.5px; }
.kpi .value { font-size: 32px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; }
.kpi .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.todo { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.todo:first-of-type { border-top: 0; padding-top: 0; }
.todo .dot { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--amber-bg); color: var(--amber); font-weight: 700; }
.todo .txt { flex: 1; min-width: 0; }
.todo .txt b { display: block; }
.ok-all { display: flex; align-items: center; gap: 12px; color: var(--green); font-weight: 600; padding: 8px 0; }
.bars .row { display: grid; grid-template-columns: 110px 1fr 34px; align-items: center; gap: 12px; padding: 6px 0; font-size: 14px; }
.bar { height: 10px; background: var(--gray-bg); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; }
.rows .r { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.rows .r:first-child { border-top: 0; padding-top: 0; }
.rows .grow { flex: 1; min-width: 0; }
.rows .grow b, .rows .grow span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.money { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- pipeline ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(262px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 14px; align-items: start; }
.col { background: #eceef2; border-radius: var(--radius); padding: 12px; min-height: 200px; }
.col.over { outline: 2px dashed var(--brand); background: var(--brand-weak); }
.col-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 12px; font-weight: 700; }
.col-head .tag { display: flex; align-items: center; gap: 8px; }
.col-head .sw { width: 10px; height: 10px; border-radius: 50%; }
.col-head .n { background: #fff; border-radius: 99px; padding: 0 9px; font-size: 13px; color: var(--muted); }
.opp { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; cursor: grab; box-shadow: var(--shadow); }
.opp:active { cursor: grabbing; }
.opp.drag { opacity: .45; }
.opp b { display: block; line-height: 1.3; cursor: pointer; }
.opp b:hover { color: var(--brand); }
.opp .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.opp .prod { margin-top: 8px; font-size: 12.5px; background: var(--gray-bg); border-radius: 8px; padding: 3px 8px; display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp .foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.opp .foot select { flex: 1; min-width: 0; font-size: 13px; padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; }
.wa { display: inline-flex; align-items: center; gap: 6px; background: #dcfce7; color: #15803d; font-weight: 600; font-size: 13px; padding: 5px 10px; border-radius: 8px; }
.wa:hover { background: #bbf7d0; }
.wa svg { width: 15px; height: 15px; flex: none; }
.score { font-size: 12px; font-weight: 700; color: var(--brand); background: var(--brand-weak); border-radius: 99px; padding: 1px 8px; float: right; }

/* ---------- contatos ---------- */
.list { padding: 0; overflow: hidden; }
.item { display: grid; grid-template-columns: minmax(200px, 2fr) minmax(130px, 1.2fr) minmax(170px, 1.4fr) 150px; gap: 14px; align-items: center;
  padding: 14px 20px; border-top: 1px solid var(--line); cursor: pointer; }
.item:first-child { border-top: 0; }
.item:hover { background: #fafbff; }
.item.head { cursor: default; background: #fafafa; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding-top: 10px; padding-bottom: 10px; }
.item.head:hover { background: #fafafa; }
.item .nm b { display: block; }
.item .nm span { color: var(--muted); font-size: 13px; }
.item > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* ---------- produtos ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.pcard { padding: 0; overflow: hidden; cursor: pointer; transition: transform .12s, box-shadow .12s; }
.pcard:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(16,24,40,.1); }
.photo { aspect-ratio: 3 / 2; background: linear-gradient(135deg, #e0e7ff, #f3f4f6); display: grid; place-items: center; color: #a5b4fc; overflow: hidden; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo svg { width: 56px; height: 56px; }
.pbody { padding: 14px 16px 16px; }
.pbody h3 { font-size: 16px; line-height: 1.3; margin: 8px 0 4px; }
.pbody .line { color: var(--muted); font-size: 13.5px; }
.pbody .price { margin-top: 8px; font-weight: 700; font-size: 17px; }

/* ---------- janelas (modal) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(17,24,39,.55); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto; z-index: 50; }
.dialog { background: #fff; border-radius: 18px; width: 100%; max-width: 560px; box-shadow: 0 24px 60px rgba(0,0,0,.3); animation: pop .14s ease-out; }
.dialog.wide { max-width: 760px; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.dialog header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px 6px; }
.dialog header h2 { font-size: 20px; }
.x { border: 0; background: var(--gray-bg); border-radius: 50%; width: 32px; height: 32px; cursor: pointer; font-size: 18px; color: var(--muted); }
.dialog .body { padding: 14px 24px 8px; }
.dialog footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px 22px; flex-wrap: wrap; }
.dialog footer .left { margin-right: auto; display: flex; gap: 10px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field.full { grid-column: 1 / -1; }
.field label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 5px; }
.field .hint { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.field .check { display: flex; align-items: center; gap: 10px; font-weight: 600; padding-top: 4px; }
.field .check input { width: 20px; height: 20px; }
.req { color: #dc2626; }
.photo-edit { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.photo-edit .photo { width: 120px; border-radius: 12px; flex: none; }
.pick { max-height: 280px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; margin-top: 10px; }
.pick label { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); cursor: pointer; }
.pick label:first-child { border-top: 0; }
.pick label:hover { background: #fafbff; }
.pick input { width: 18px; height: 18px; }
.callout { background: var(--brand-weak); border-radius: 12px; padding: 12px 14px; font-size: 14px; margin-top: 12px; }
.secret { font: 600 20px/1.2 ui-monospace, Menlo, monospace; background: var(--gray-bg); padding: 14px; border-radius: 10px; text-align: center; letter-spacing: .04em; user-select: all; margin: 10px 0; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #111827, #312e81); }
.login .box { background: #fff; border-radius: 20px; padding: 34px; width: 100%; max-width: 390px; box-shadow: 0 30px 70px rgba(0,0,0,.35); }
.login .brand { padding: 0 0 22px; color: var(--text); }
.login h1 { font-size: 24px; margin-bottom: 4px; }
.login .field { margin-top: 14px; }
.login .btn { width: 100%; margin-top: 22px; padding: 12px; font-size: 16px; }
.error { color: var(--red); background: var(--red-bg); border-radius: 10px; padding: 9px 12px; font-size: 14px; margin-top: 14px; }

/* ---------- avisos ---------- */
#toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center; }
.toast { background: #111827; color: #fff; padding: 11px 18px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-weight: 600; animation: pop .15s ease-out; max-width: 90vw; }
.toast.err { background: #b91c1c; }
.loading { padding: 80px; text-align: center; color: var(--muted); }

/* ---------- celular ---------- */
@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto; flex-direction: row; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); z-index: 40; border-top: 1px solid #1f2937; }
  .brand, .me > div { display: none; }
  .me { margin: 0; width: auto; padding: 6px; background: none; }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 3px; font-size: 11.5px; padding: 7px 10px; }
  .main { padding: 20px 16px 110px; }
  h1 { font-size: 22px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi { padding: 16px; }
  .kpi .value { font-size: 21px; overflow-wrap: anywhere; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .board { grid-auto-columns: 82%; scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; }
  .item { grid-template-columns: 1fr auto; gap: 4px 10px; }
  .item.head, .item .hide-m { display: none; }
  .search .input { min-width: 0; width: 100%; }
  .search { flex: 1; min-width: 180px; }
  .fields { grid-template-columns: 1fr; }
  .overlay { padding: 0; align-items: flex-end; }
  .dialog { border-radius: 20px 20px 0 0; max-width: none; }
}

/* ---------- prospecção ---------- */
.sources { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.src { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.src.on { border-color: #c7d2fe; }
.src.soon { background: #fafafa; box-shadow: none; color: var(--muted); }
.src-top { display: flex; justify-content: space-between; align-items: center; gap: 4px 8px; flex-wrap: wrap; }
.src p { font-size: 13.5px; color: var(--muted); flex: 1; }
.src .btn { align-self: flex-start; }
.res { display: grid; grid-template-columns: 22px minmax(180px, 2fr) minmax(200px, 2fr) 110px; gap: 14px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--line); cursor: pointer; }
.res:first-child { border-top: 0; }
.res:hover { background: #fafbff; }
.res input[type=checkbox] { width: 18px; height: 18px; }
.res .info b { display: block; }
.res .ctt { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; min-width: 0; }
.res .links { display: flex; gap: 10px; flex-wrap: wrap; }
.res .links a { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spin { width: 38px; height: 38px; border: 4px solid var(--brand-weak); border-top-color: var(--brand); border-radius: 50%; animation: giro .9s linear infinite; margin: 0 auto 16px; }
@keyframes giro { to { transform: rotate(360deg); } }
@media (max-width: 880px) {
  .sources { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .res { grid-template-columns: 22px 1fr; padding: 14px 16px; }
  .res .ctt, .res .tags { grid-column: 2; }
}

/* ---------- análise da IA no produto ---------- */
.ia { background: #f8f9ff; border: 1px solid #c7d2fe; border-radius: 12px; padding: 14px 16px; margin-bottom: 18px; font-size: 14.5px; }
.ia p { margin: 8px 0 0; }
.ia ul { margin: 4px 0 0; padding-left: 20px; }
.ia-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ia-foot { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.ia details { margin-top: 8px; }
