/* Layout: ferramenta de uma coluna — barra de funil clicável, filtros, tabela densa; painel lateral para editar uma lead. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --line: #dde1e8;
  --fg: #1a1f2b;
  --muted: #5d6576;
  --accent: #2f4fd0;
  --accent-soft: #e4e9fb;
  --on-accent: #ffffff;
  --st-novo: #6b7385;
  --st-contactado: #2f7fc1;
  --st-reuniao: #8a5cc8;
  --st-proposta: #c98a14;
  --st-ganho: #2e8a57;
  --st-perdido: #c04a4a;
  --danger: #c04a4a;
  --shadow: 0 10px 40px rgba(20, 28, 50, .18);
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "Figtree", "Segoe UI", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151c; --surface: #1a1e27; --surface-2: #232835; --line: #2e3443;
    --fg: #e6e9f0; --muted: #9aa2b4; --accent: #7d95f5; --accent-soft: #252e52; --on-accent: #0f1430;
    --st-novo: #9aa2b4; --st-contactado: #5fa8e6; --st-reuniao: #b38ef0; --st-proposta: #e5ad45;
    --st-ganho: #5cc28a; --st-perdido: #ec7b7b; --danger: #ec7b7b; --shadow: 0 10px 40px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12151c; --surface: #1a1e27; --surface-2: #232835; --line: #2e3443;
  --fg: #e6e9f0; --muted: #9aa2b4; --accent: #7d95f5; --accent-soft: #252e52; --on-accent: #0f1430;
  --st-novo: #9aa2b4; --st-contactado: #5fa8e6; --st-reuniao: #b38ef0; --st-proposta: #e5ad45;
  --st-ganho: #5cc28a; --st-perdido: #ec7b7b; --danger: #ec7b7b; --shadow: 0 10px 40px rgba(0,0,0,.5);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--f-body); font-size: 14px; line-height: 1.45; }
.wrap { max-width: 1240px; margin: 0 auto; padding-inline: 20px; padding-block: 24px 48px; display: flex; flex-direction: column; gap: 18px; }
@media (max-width: 600px) { .wrap { padding-inline: 16px; } }
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; margin: 0; }
h1 { font-size: 1.75rem; letter-spacing: -.01em; }
.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.top p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions form { margin: 0; }
button, .btn { font: inherit; font-weight: 600; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); padding: 8px 14px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, tr:focus-visible, .stage:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* funil */
.funnel { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 820px) { .funnel { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.stage { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; position: relative; overflow: hidden; }
.stage::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.stage .lbl { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.stage .n { font-family: var(--f-display); font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.stage .v { font-family: var(--f-mono); font-size: .72rem; color: var(--muted); }
.stage[aria-pressed="true"] { border-color: var(--c); background: var(--surface-2); }

/* filtros */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters input[type=search] { flex: 1 1 240px; min-width: 0; }
input, select, textarea { font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
.filters select { width: auto; max-width: 100%; }
.count { color: var(--muted); font-size: .85rem; margin-left: auto; font-variant-numeric: tabular-nums; }

/* tabela */
.tablebox { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 860px; }
th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
th.sorted::after { content: " ↓"; }
th.sorted.asc::after { content: " ↑"; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
.co { font-weight: 600; }
.sub { color: var(--muted); font-size: .82rem; }
.mono { font-family: var(--f-mono); font-size: .8rem; }
.site { color: var(--accent); text-decoration: none; word-break: break-all; }
.site:hover { text-decoration: underline; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--c); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.score { display: inline-flex; gap: 2px; }
.score i { width: 8px; height: 14px; border-radius: 2px; background: var(--line); }
.score i.on { background: var(--accent); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: .72rem; background: var(--accent-soft); color: var(--fg); padding: 1px 7px; border-radius: 4px; }
.due { font-family: var(--f-mono); font-size: .78rem; }
.due.late { color: var(--danger); font-weight: 600; }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.empty h3 { color: var(--fg); font-size: 1.15rem; }
.note { font-size: .82rem; color: var(--muted); }
.banner { background: var(--accent-soft); border-radius: 8px; padding: 10px 14px; font-size: .88rem; }

/* painel */
.scrim { position: fixed; inset: 0; background: rgba(10, 14, 24, .4); z-index: 10; }
.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--surface); box-shadow: var(--shadow); z-index: 11; display: flex; flex-direction: column; }
.panel header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel header h2 { font-size: 1.2rem; min-width: 0; overflow-wrap: anywhere; }
.panel .body { overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.panel footer { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; padding: 12px 18px; border-top: 1px solid var(--line); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }
.full { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; color: var(--muted); font-weight: 600; min-width: 0; }
textarea { min-height: 72px; resize: vertical; }
fieldset { border: 0; padding: 0; margin: 0; }
.sect { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; border-top: 1px solid var(--line); padding-top: 12px; }
.log { display: flex; flex-direction: column; gap: 8px; }
.log .row { display: grid; grid-template-columns: 92px 1fr auto; gap: 10px; align-items: start; font-size: .88rem; }
.log .row .mono { color: var(--muted); }
.addlog { display: flex; gap: 8px; }
.addlog input { flex: 1; min-width: 0; }
.confirm { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .85rem; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 8px 16px; border-radius: 8px; font-weight: 600; z-index: 20; }
@media (prefers-reduced-motion: no-preference) { .panel { animation: slide .18s ease-out; } @keyframes slide { from { transform: translateX(24px); opacity: .6; } } }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.login .err { color: var(--danger); font-size: .85rem; }

/* tenants */
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.card h2 { font-size: 1.2rem; }
.tenant-user { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 0; }
.tenant-user form, .inline-form { margin: 0; }
.inline-form { display: flex; gap: 6px; flex-wrap: wrap; }
.inline-form input { width: auto; flex: 1 1 120px; min-width: 0; }
.banner.err { color: var(--danger); }

/* settings */
.wrap.narrow { max-width: 860px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: .85rem; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.tabs a:hover { color: var(--fg); border-color: var(--accent); }
.logo-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.logo-row .grow { flex: 1 1 240px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.logo-preview { width: 160px; height: 80px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 6px; }
.empty-logo { display: grid; place-items: center; color: var(--muted); font-size: .8rem; background: var(--surface-2); }
label.check { flex-direction: row; align-items: center; gap: 8px; }
label.check input { width: auto; }
table.plain { min-width: 0; }
table.plain th { cursor: default; }
table.plain td form { margin: 0; }
.token { display: inline-block; margin-top: 6px; word-break: break-all; user-select: all; }
.placeholders { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: .85rem; margin: 8px 0 0; }
.placeholders dd { margin: 0; color: var(--muted); }
.apidoc { display: flex; flex-direction: column; gap: 10px; font-size: .88rem; margin-top: 8px; }
.apidoc p { margin: 0; }
.apidoc pre { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; overflow-x: auto; margin: 0; }
.apidoc td.mono { white-space: nowrap; }
summary { cursor: pointer; }

/* email no painel da lead */
.mailbox { display: flex; flex-direction: column; gap: 10px; }
.mailbox textarea { min-height: 220px; }
