:root {
  --orange: #FF6A13;
  --orange-soft: #FFF1E8;
  --purple: #6B2FD6;
  --purple-dark: #4C1D95;
  --purple-soft: #F3EDFF;
  --ink: #17132B;
  --ink-2: #4B4766;
  --muted: #8C88A3;
  --line: #ECEAF3;
  --bg: #F8F7FB;
  --card: #FFFFFF;
  --danger: #E5484D;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23,19,43,.05), 0 4px 16px rgba(23,19,43,.05);
  --accent: var(--orange);
}
* { box-sizing: border-box; }
html, body, #app { margin: 0; height: 100%; }
body { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: var(--purple); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }

/* ---------- Botões / campos ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: #d7d3e6; background: #fbfaff; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(.95); }
.btn.purple { background: var(--purple); border-color: var(--purple); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 12px; outline: none; transition: .15s; }
.input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-soft); }
label.f { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 0 0 6px; }
.field { margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.45; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
pre.code { background: #17132B; color: #EDE7FF; padding: 14px 16px; border-radius: 12px; overflow: auto; font-size: 12.5px; line-height: 1.55; margin: 0; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100%; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: linear-gradient(145deg, var(--purple-dark), var(--purple) 55%, #8B4CF0); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art::after { content: ''; position: absolute; width: 420px; height: 420px; border-radius: 50%; background: var(--orange); filter: blur(120px); opacity: .45; right: -120px; bottom: -140px; }
.login-art h1 { font-size: 40px; line-height: 1.1; max-width: 460px; position: relative; z-index: 1; }
.login-art p { opacity: .8; max-width: 420px; line-height: 1.6; position: relative; z-index: 1; }
.login-box { display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand-logo { height: 56px; max-width: 220px; object-fit: contain; margin-bottom: 24px; }
.login-card h2 { font-size: 24px; margin-bottom: 6px; }
.login-card .sub { color: var(--muted); margin-bottom: 26px; }
.wordmark { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -.03em; }
.wordmark .dot { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--orange), var(--purple)); display: grid; place-items: center; color: #fff; font-size: 13px; }
.powered { font-size: 12px; color: var(--muted); margin-top: 28px; display: flex; align-items: center; gap: 6px; }
.powered b { background: linear-gradient(90deg, var(--orange), var(--purple)); -webkit-background-clip: text; color: transparent; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; height: 100%; }
.side { background: #fff; border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; }
.side .client { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.side .client img { width: 40px; height: 40px; object-fit: contain; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.side .client .ph { width: 40px; height: 40px; border-radius: 10px; background: var(--orange-soft); color: var(--orange); display: grid; place-items: center; font-weight: 800; }
.side .client b { display: block; font-size: 14px; line-height: 1.2; }
.side .client small { color: var(--muted); font-size: 11.5px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 600; }
.nav a:hover { background: var(--bg); }
.nav a.on { background: var(--purple-soft); color: var(--purple); }
.nav a svg { width: 18px; height: 18px; }
.nav .sep { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 16px 12px 6px; font-weight: 700; }
.side .foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
.side .foot .me { font-size: 13px; padding: 4px 8px 10px; }
.side .foot .me small { color: var(--muted); display: block; }
.main { overflow: auto; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 28px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.85); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 20px; }
.topbar .sp { flex: 1; }
.content { padding: 24px 28px; flex: 1; min-height: 0; }
.acting { background: linear-gradient(90deg, var(--orange), var(--purple)); color: #fff; font-size: 12.5px; padding: 7px 28px; display: flex; gap: 10px; align-items: center; }
.acting a { color: #fff; text-decoration: underline; font-weight: 700; }

/* ---------- Kanban ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.tab.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; height: calc(100vh - 170px); align-items: stretch; }
.col { flex: 0 0 258px; background: #F1EFF7; border-radius: var(--radius); display: flex; flex-direction: column; max-height: 100%; }
.col-h { padding: 12px 14px 10px; display: flex; align-items: center; gap: 8px; }
.col-h .bar { width: 10px; height: 10px; border-radius: 3px; }
.col-h b { font-size: 13.5px; }
.col-h .n { background: #fff; border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.col-h .sum { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 600; }
.col-h .ev { font-size: 10.5px; font-weight: 700; color: var(--purple); background: var(--purple-soft); padding: 2px 6px; border-radius: 6px; }
.col-b { padding: 4px 10px 12px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.col.over { outline: 2px dashed var(--purple); outline-offset: -4px; }
.lcard { background: #fff; border-radius: 12px; padding: 12px; box-shadow: var(--shadow); cursor: grab; border: 1px solid transparent; transition: .12s; }
.lcard:hover { border-color: #DCD5F2; }
.lcard.drag { opacity: .45; }
.lcard .t { font-weight: 700; margin-bottom: 3px; }
.lcard .p { color: var(--muted); font-size: 12.5px; }
.lcard .row { display: flex; align-items: center; gap: 6px; margin-top: 9px; flex-wrap: wrap; }
.lcard .v { margin-left: auto; font-weight: 700; font-size: 12.5px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: var(--bg); color: var(--ink-2); }
.badge.meta { background: var(--purple-soft); color: var(--purple); }
.badge.google { background: var(--orange-soft); color: #C2410C; }
.badge.ref { background: #F4F4F5; color: #3F3F46; font-family: ui-monospace, monospace; }
.badge.won { background: var(--purple-dark); color: #fff; }

/* ---------- Cards / tabelas ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card h3 { font-size: 15px; margin-bottom: 4px; }
.card .desc { color: var(--muted); font-size: 13px; margin-bottom: 16px; line-height: 1.5; }
.stack > * + * { margin-top: 18px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; position: relative; overflow: hidden; }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--orange); }
.kpi:nth-child(even)::before { background: var(--purple); }
.kpi small { color: var(--muted); font-weight: 600; font-size: 12px; }
.kpi b { display: block; font-size: 26px; margin-top: 6px; letter-spacing: -.03em; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #FBFAFE; }
.hbar { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.hbar .lbl { width: 190px; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar .track { flex: 1; height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.hbar .fill { height: 100%; background: linear-gradient(90deg, var(--orange), var(--purple)); border-radius: 99px; }
.hbar .num { width: 40px; text-align: right; font-weight: 700; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters .input { width: auto; min-width: 160px; }
.empty { text-align: center; color: var(--muted); padding: 40px; }

/* ---------- Drawer / modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(23,19,43,.35); z-index: 50; display: flex; justify-content: flex-end; animation: fade .15s; }
.overlay.center { justify-content: center; align-items: center; }
@keyframes fade { from { opacity: 0; } }
.drawer { width: 560px; max-width: 100%; height: 100%; background: #fff; overflow-y: auto; animation: slide .2s ease-out; display: flex; flex-direction: column; }
@keyframes slide { from { transform: translateX(40px); opacity: .5; } }
.drawer-h { padding: 20px 24px 0; border-bottom: 1px solid var(--line); }
.drawer-h .top { display: flex; align-items: flex-start; gap: 10px; }
.drawer-h h2 { font-size: 20px; }
.drawer-h .meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.dtabs { display: flex; gap: 18px; margin-top: 16px; }
.dtabs a { padding: 10px 0; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; cursor: pointer; }
.dtabs a.on { color: var(--purple); border-color: var(--purple); }
.drawer-b { padding: 22px 24px; flex: 1; }
.drawer-f { padding: 14px 24px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: #fff; position: sticky; bottom: 0; }
.modal { background: #fff; border-radius: 18px; width: 520px; max-width: calc(100% - 32px); max-height: calc(100% - 40px); overflow: auto; padding: 24px; animation: pop .15s ease-out; }
@keyframes pop { from { transform: scale(.97); opacity: .6; } }
.modal h2 { font-size: 19px; margin-bottom: 18px; }
.trk { display: grid; grid-template-columns: 150px 1fr; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.trk div { padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 13px; word-break: break-all; }
.trk div:nth-child(odd) { background: var(--bg); font-weight: 600; color: var(--ink-2); font-family: ui-monospace, monospace; font-size: 12px; }
.trk div.empty-v { color: #C4C1D4; }
.trk .grp { grid-column: 1 / -1; background: var(--purple-soft) !important; color: var(--purple) !important; font-family: inherit !important; font-size: 11.5px !important; text-transform: uppercase; letter-spacing: .06em; font-weight: 800 !important; }
.timeline { border-left: 2px solid var(--line); margin-left: 6px; padding-left: 18px; }
.timeline .it { position: relative; padding-bottom: 16px; }
.timeline .it::before { content: ''; position: absolute; left: -24px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--purple); border: 2px solid #fff; }
.timeline .it.stage::before { background: var(--orange); }
.timeline .it small { color: var(--muted); display: block; font-size: 12px; }
.stage-row { display: grid; grid-template-columns: 22px 1fr 44px 150px 110px 34px; gap: 8px; align-items: center; margin-bottom: 8px; }
.stage-row .handle { color: var(--muted); cursor: grab; text-align: center; }
.stage-row input[type=color] { width: 44px; height: 38px; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: #fff; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row .input { font-family: ui-monospace, monospace; font-size: 12.5px; }
.logo-drop { display: flex; align-items: center; gap: 16px; }
.logo-drop .prev { width: 88px; height: 88px; border-radius: 16px; border: 1px dashed #D5D0E5; display: grid; place-items: center; background: var(--bg); overflow: hidden; }
.logo-drop .prev img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pill-status { font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 6px; }
.pill-status.on { background: var(--purple-soft); color: var(--purple); }
.pill-status.off { background: #F4F4F5; color: #71717A; }
.pill-status.warn { background: var(--orange-soft); color: #C2410C; }
.pill-status.err { background: #FDECEC; color: var(--danger); }
.cfg-nav { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; font-weight: 600; opacity: 0; transition: .2s; pointer-events: none; z-index: 99; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--danger); }

@media (max-width: 900px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .kpis, .two, .grid3 { grid-template-columns: 1fr 1fr; }
}

/* ---------- IA / vendedores ---------- */
.badge.ia { background: linear-gradient(90deg, var(--orange-soft), var(--purple-soft)); color: var(--purple); }
.badge.seller { background: var(--ink); color: #fff; }
.aibar { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: var(--bg); }
.aibar b { font-size: 13px; display: block; }
.aibar small { color: var(--muted); font-size: 12px; }
.switch { position: relative; width: 42px; height: 24px; flex: 0 0 42px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #D4D1E0; border-radius: 99px; cursor: pointer; transition: .2s; }
.switch span::after { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: linear-gradient(90deg, var(--orange), var(--purple)); }
.switch input:checked + span::after { transform: translateX(18px); }
.flow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; color: var(--muted); font-weight: 700; }
.flow span { padding: 7px 12px; border-radius: 10px; background: var(--bg); color: var(--ink-2); font-size: 12.5px; }
.flow span.o { background: var(--orange); color: #fff; }
.flow span.p { background: var(--purple); color: #fff; }
.warnbox { background: var(--orange-soft); color: #9A3412; padding: 12px 14px; border-radius: 10px; }

.origem-box { background: var(--purple-soft); color: var(--purple-dark); padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; font-size: 13px; }
.okcheck { width: 56px; height: 56px; margin: 0 auto; border-radius: 50%; background: linear-gradient(135deg, var(--orange), var(--purple)); color: #fff; font-size: 28px; font-weight: 800; display: grid; place-items: center; }
