/* Datoo Prospect — tokens derivados de datoo.com.br */
:root {
  --navy: #0b1220;
  --navy2: #0f1f3d;
  --blue: #0066ff;
  --blue-dark: #0052cc;
  --cyan: #00d2ff;
  --grad: linear-gradient(135deg, #0066ff, #00d2ff);

  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5fb;
  --ink: #0b1220;
  --muted: #64748b;
  --line: #dce6f2;
  --ice: #e6f0ff;
  --ok: #10b981;
  --err: #ef4444;
  --warn: #f59e0b;
  --accent: #8b5cf6;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(11, 18, 32, .04), 0 6px 20px rgba(11, 18, 32, .05);
  --sidebar-w: 236px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0f1a;
    --surface: #111a2c;
    --surface-2: #16223a;
    --ink: #e6edf7;
    --muted: #94a3b8;
    --line: #22314d;
    --ice: #13274a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 600; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy2) 100%);
  color: #cbd8e9;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: block; padding: 4px 10px 22px; }
.brand img { display: block; height: 30px; width: auto; }
.brand small { display: block; margin-top: 6px; font-weight: 600; font-size: 11px; color: #a3b8d6; letter-spacing: .08em; text-transform: uppercase; }
.auth-logo { display: block; height: 44px; width: auto; margin: 0 auto 6px; }
.auth-sub { text-align: center; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; margin: 0 0 20px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: #cbd8e9; font-weight: 500;
}
.nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(0, 102, 255, .22); color: #fff; box-shadow: inset 3px 0 0 var(--cyan); }
.nav .soon { margin-left: auto; font-size: 10px; color: #7b8fb0; border: 1px solid rgba(255, 255, 255, .12); border-radius: 99px; padding: 0 6px; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #7b8fb0; padding: 14px 12px 4px; }
.sidebar-foot { margin-top: auto; font-size: 12px; color: #a3b8d6; padding: 8px 12px; }
.sidebar-foot button { background: none; border: 0; color: #a3b8d6; padding: 0; cursor: pointer; font: inherit; text-decoration: underline; }

.main { flex: 1; min-width: 0; padding: 28px 32px 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 0; }

/* Superfícies */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi.alert .value { color: var(--err); }

/* Funil */
.funnel { display: grid; gap: 6px; }
.funnel-row { display: grid; grid-template-columns: 220px 1fr 48px; gap: 10px; align-items: center; font-size: 13px; }
.funnel-bar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.funnel-bar span { display: block; height: 100%; background: var(--grad); border-radius: 99px; min-width: 2px; }

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

/* Badges */
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 500; background: var(--ice); color: var(--blue-dark); white-space: nowrap; }
.badge.ok { background: rgba(16, 185, 129, .14); color: #047857; }
.badge.err { background: rgba(239, 68, 68, .12); color: #b91c1c; }
.badge.warn { background: rgba(245, 158, 11, .16); color: #b45309; }
.badge.gray { background: var(--surface-2); color: var(--muted); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge { color: #a8c7f5; }
  :root:not([data-theme="light"]) .badge.ok { color: #6ee7b7; }
  :root:not([data-theme="light"]) .badge.err { color: #fca5a5; }
  :root:not([data-theme="light"]) .badge.warn { color: #fcd34d; }
}

/* Formulários */
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=number], input[type=url], input[type=search], input[type=password], input[type=file], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(0, 102, 255, .35); border-color: var(--blue); }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: end; }
.field { margin-bottom: 12px; }
.field-check { display: flex; align-items: center; gap: 8px; }
.field-check label { margin: 0; }
.errorlist { color: var(--err); margin: 4px 0 0; padding: 0; list-style: none; font-size: 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--blue); text-decoration: none; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { color: var(--err); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
form.inline { display: inline; }

/* Mensagens */
.messages { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.messages li { padding: 10px 14px; border-radius: 8px; background: var(--ice); border: 1px solid var(--line); }
.messages .success { background: rgba(16, 185, 129, .12); }
.messages .error { background: rgba(239, 68, 68, .1); }
.messages .warning { background: rgba(245, 158, 11, .12); }

dl.props { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; margin: 0; }
dl.props dt { color: var(--muted); font-size: 13px; }
dl.props dd { margin: 0; }

.evidence-field { font-weight: 600; margin-top: 10px; }
.evidence-item { font-size: 13px; padding: 4px 0 4px 12px; border-left: 2px solid var(--line); }
.timeline { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.pagination { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; }
.htmx-request .loading { opacity: 1; }
.loading { opacity: 0; transition: opacity .2s; color: var(--muted); font-size: 12px; }

/* Análise da IA */
.score-ring {
  flex-shrink: 0; width: 76px; height: 76px; border-radius: 50%;
  display: grid; place-content: center; text-align: center;
  color: #fff; background: var(--grad); box-shadow: 0 6px 18px rgba(0, 102, 255, .25);
}
.score-ring .num { font-size: 26px; font-weight: 800; line-height: 1; }
.score-ring small { font-size: 11px; opacity: .85; }
.criteria { display: grid; gap: 10px; margin-bottom: 8px; }
.criterion-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.subhead { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 16px 0 6px; }
.plain-list { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 13px; }
.row-check { width: 16px; height: 16px; }
pre.json { white-space: pre-wrap; word-break: break-word; max-height: 560px; overflow: auto; background: var(--surface-2); border-radius: 8px; padding: 12px; margin: 0; font-size: 12px; }
.bulk-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }

/* Abordagens */
.draft { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-top: 10px; }
.draft-pending { border-color: var(--warn); }
.draft-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.draft-warnings { margin: 0 0 10px; padding: 8px 12px 8px 28px; border-radius: 8px; background: rgba(245, 158, 11, .12); font-size: 13px; }
.draft-body { white-space: pre-wrap; margin: 6px 0; font-size: 13px; }
.nav .count { margin-left: auto; font-size: 11px; font-weight: 700; color: #0b1220; background: var(--cyan); border-radius: 99px; padding: 0 7px; }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #0b1220 0%, #0f1f3d 60%, #0066ff 150%); padding: 16px; }
.auth .card { width: 100%; max-width: 380px; }

/* Responsivo */
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 16px; }
  .brand { padding: 0 12px 0 0; }
  .brand img { height: 24px; }
  .brand small { display: none; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav-section, .nav a[aria-disabled], .sidebar-foot { display: none; }
  .main { padding: 20px 16px 40px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi .value { font-size: 22px; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
  .funnel-row { grid-template-columns: 1fr 80px 36px; }
  dl.props { grid-template-columns: 1fr; }
}
.email-preview summary { cursor: pointer; color: var(--blue); font-size: 13px; font-weight: 600; }
.email-preview iframe { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: 10px; margin-top: 8px; background: #eef3f9; }

/* Funil (Kanban) */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: 250px; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.kanban-col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 160px; }
.kanban-col header { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-bottom: 8px; }
.kanban-won { border-top: 3px solid var(--ok); }
.kanban-lost { border-top: 3px solid var(--err); }
.kanban-cards { display: grid; gap: 8px; min-height: 80px; border-radius: 8px; transition: background .15s; }
.kanban-cards.drop-target { background: var(--ice); outline: 2px dashed var(--blue); }
.kanban-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font-size: 13px; cursor: grab; box-shadow: var(--shadow); }
.kanban-card.dragging { opacity: .5; }
.kanban-meta { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }

/* Tarefas */
.task { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.task:last-child { border-bottom: 0; }
.task-check { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--line); background: var(--surface); color: var(--ok); font-weight: 800; cursor: pointer; line-height: 1; padding: 0; margin-top: 1px; }
.task-check:hover { border-color: var(--ok); }
.task-done strong { text-decoration: line-through; color: var(--muted); }
.text-err { color: var(--err); font-weight: 600; }
.text-warn { color: #b45309; font-weight: 600; }
.link-summary { cursor: pointer; color: var(--blue); font-size: 13px; font-weight: 600; }

/* Conversa */
.msg { border-radius: 10px; padding: 10px 12px; margin-top: 8px; border: 1px solid var(--line); }
.msg-in { background: var(--surface-2); margin-right: 40px; }
.msg-out { background: var(--ice); margin-left: 40px; }

/* ===== Funil v2: cores por etapa, cartões, arrastar (mouse/toque), painel lateral ===== */
.kanban-filters { margin-bottom: 14px; }
.kanban { grid-auto-columns: 272px; gap: 14px; scroll-snap-type: x proximity; scroll-padding: 0 4px; -webkit-overflow-scrolling: touch; padding: 2px 2px 16px; }
.kanban-col { --stage: var(--muted); scroll-snap-align: start; border-top: 3px solid var(--stage); display: flex; flex-direction: column; max-height: calc(100vh - 230px); }
.kanban-col header { position: sticky; top: 0; z-index: 1; background: var(--surface-2); padding-bottom: 6px; }
.kanban-col .stage-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--stage); flex-shrink: 0; }
.kanban-col .stage-name { flex: 1; }
.kanban-cards { overflow-y: auto; padding: 2px; align-content: start; }
.stage-identificada { --stage: #94a3b8; } .stage-enriquecimento { --stage: #64748b; }
.stage-qualificada { --stage: #0066ff; } .stage-aguardando_aprovacao { --stage: #8b5cf6; }
.stage-contatada { --stage: #00a3d9; } .stage-respondeu { --stage: #00d2ff; }
.stage-interessada { --stage: #f59e0b; } .stage-reuniao { --stage: #f97316; }
.stage-proposta { --stage: #a855f7; } .stage-negociacao { --stage: #6366f1; }
.stage-cliente { --stage: #10b981; } .stage-perdida { --stage: #ef4444; }
.kanban-won, .kanban-lost { border-top-width: 3px; }

.kanban-card { cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; transition: box-shadow .15s, transform .15s, border-color .15s; }
.kanban-card:hover { border-color: var(--stage, var(--blue)); box-shadow: 0 6px 18px rgba(11, 18, 32, .1); }
.kanban-card:focus-visible { outline: 2px solid var(--blue); }
.kanban-card.selected { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(0, 102, 255, .25); }
.kanban-card.dragging { opacity: .35; }
.kanban-card.just-moved { animation: kc-pop .9s ease; }
@keyframes kc-pop { 0% { box-shadow: 0 0 0 3px var(--cyan); } 100% { box-shadow: var(--shadow); } }
.kanban-ghost { position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none; opacity: .95; box-shadow: 0 18px 40px rgba(11, 18, 32, .25); cursor: grabbing; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }
.kanban-cards.drop-target { background: color-mix(in srgb, var(--stage) 12%, transparent); outline: 2px dashed var(--stage); }
.kanban-empty { text-align: center; font-size: 12px; padding: 18px 0; border: 1px dashed var(--line); border-radius: 8px; margin: 0; }

.kc-top { display: flex; gap: 8px; align-items: flex-start; }
.kc-avatar { flex-shrink: 0; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff; background: var(--grad); }
.kc-avatar-lg { width: 42px; height: 42px; font-size: 14px; border-radius: 10px; }
.kc-title { flex: 1; min-width: 0; }
.kc-title strong { display: block; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.3; }
.kc-score { flex-shrink: 0; font-size: 12px; font-weight: 800; padding: 1px 7px; border-radius: 99px; font-variant-numeric: tabular-nums; }
.kc-score.hi { background: rgba(16, 185, 129, .15); color: #047857; }
.kc-score.mid { background: rgba(245, 158, 11, .16); color: #b45309; }
.kc-score.lo { background: var(--surface-2); color: var(--muted); }
.kc-when { font-size: 11px; }

/* Painel lateral */
.drawer { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(11, 18, 32, .35); opacity: 0; transition: opacity .2s; }
.drawer-sheet { position: absolute; top: 0; right: 0; height: 100%; width: min(440px, 100%); background: var(--surface); border-left: 1px solid var(--line); box-shadow: -10px 0 40px rgba(11, 18, 32, .15); padding: 22px 22px 40px; overflow-y: auto; transform: translateX(100%); transition: transform .25s cubic-bezier(.22, 1, .36, 1); }
.drawer.open { pointer-events: auto; }
.drawer.open .drawer-backdrop { opacity: 1; }
.drawer.open .drawer-sheet { transform: translateX(0); }
.drawer-close { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; }
.panel-alert { margin: 12px 0; padding: 10px 12px; border-radius: 8px; background: rgba(245, 158, 11, .14); font-size: 13px; display: grid; gap: 8px; }
.props-compact { grid-template-columns: 1fr 1.2fr; font-size: 13px; }

/* Mensagens como no celular */
.phone { background: #e9eef5; border-radius: 14px; padding: 10px; display: grid; gap: 6px; }
.bubble { max-width: 85%; padding: 7px 10px 16px; border-radius: 10px; font-size: 13px; line-height: 1.4; position: relative; white-space: pre-wrap; word-break: break-word; }
.bubble.in { background: #fff; color: #222; justify-self: start; border-top-left-radius: 3px; }
.bubble.out { background: #d9fdd3; color: #222; justify-self: end; border-top-right-radius: 3px; }
.bubble-time { position: absolute; right: 8px; bottom: 3px; font-size: 10px; color: #6b7280; }

.lost-dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; width: min(440px, calc(100% - 32px)); background: var(--surface); color: var(--ink); }
.lost-dialog::backdrop { background: rgba(11, 18, 32, .45); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .phone { background: #0f1a2b; }
  :root:not([data-theme="light"]) .bubble.in { background: #1c2a40; color: #e6edf7; }
  :root:not([data-theme="light"]) .bubble.out { background: #134d3a; color: #e6edf7; }
  :root:not([data-theme="light"]) .bubble-time { color: #94a3b8; }
}

/* Celular: colunas quase da largura da tela, encaixando ao deslizar */
@media (max-width: 860px) {
  .kanban { grid-auto-columns: 86vw; scroll-snap-type: x mandatory; gap: 10px; }
  .kanban-col { max-height: calc(100vh - 170px); }
  .kanban-filters { grid-template-columns: 1fr 1fr; }
  .drawer-sheet { width: 100%; border-left: 0; }
}

/* Resumo "o que mostrar no material" (qualificação pelo WhatsApp) */
.callout{border:1px solid var(--blue);border-left-width:4px;border-radius:10px;padding:10px 12px;margin:0 0 12px;background:color-mix(in srgb, var(--blue) 7%, transparent);font-size:14px;line-height:1.45}
.callout strong{display:block;font-size:12px;text-transform:uppercase;letter-spacing:.04em;color:var(--blue);margin-bottom:4px}
