:root {
  --bg: #f5f4f0; --surface: #ffffff; --surface-2: #f0eee8; --fg: #1c1d1b; --muted: #6b6a64;
  --line: #e2dfd6; --brand: #1f2a24; --brand-fg: #f5f1e6; --accent: #a8823f; --accent-soft: #f3ead8;
  --ok: #2f7d4f; --ok-soft: #e3f2e8; --bad: #b4412f; --bad-soft: #f8e4df; --info: #2d5f8a; --info-soft: #e2edf6;
  --warn: #9a6a12; --warn-soft: #f7ecd4; --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121412; --surface: #1b1e1b; --surface-2: #232723; --fg: #ecebe6; --muted: #a09e96;
    --line: #2f332f; --brand: #0d100e; --brand-fg: #efe7d4; --accent: #d1ad6b; --accent-soft: #2e2818;
    --ok: #6cc28f; --ok-soft: #1a2c21; --bad: #e6826f; --bad-soft: #321d19; --info: #7fb0dc; --info-soft: #17242f;
    --warn: #e0b45c; --warn-soft: #2f2614; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121412; --surface: #1b1e1b; --surface-2: #232723; --fg: #ecebe6; --muted: #a09e96;
  --line: #2f332f; --brand: #0d100e; --brand-fg: #efe7d4; --accent: #d1ad6b; --accent-soft: #2e2818;
  --ok: #6cc28f; --ok-soft: #1a2c21; --bad: #e6826f; --bad-soft: #321d19; --info: #7fb0dc; --info-soft: #17242f;
  --warn: #e0b45c; --warn-soft: #2f2614; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px 16px; text-align: center; color: var(--muted); }

/* topo */
.top { background: var(--brand); color: var(--brand-fg); position: sticky; top: 0; z-index: 10; }
.top-in { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { font-weight: 700; letter-spacing: .08em; display: flex; align-items: center; gap: 8px; text-decoration: none; }
.brand svg { width: 26px; height: 26px; }
.brand small { font-weight: 500; letter-spacing: .02em; opacity: .7; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { text-decoration: none; padding: 7px 12px; border-radius: 8px; opacity: .8; white-space: nowrap; }
.nav a.on, .nav a:hover { opacity: 1; background: rgba(255,255,255,.1); }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; opacity: .9; }
.who button { background: transparent; border: 1px solid rgba(255,255,255,.25); color: var(--brand-fg); border-radius: 8px; padding: 5px 10px; cursor: pointer; }

main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 64px; }
h1 { font-size: 1.35rem; margin: 0 0 16px; }
h2 { font-size: 1rem; margin: 0 0 12px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* cartões */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpi .v { font-size: 1.7rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 13px; }
.two { grid-template-columns: 1fr; }
@media (min-width: 900px) { .two { grid-template-columns: 1fr 1fr; } .detail { grid-template-columns: 1.3fr 1fr; } }

/* formulários */
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; width: 100%; min-height: 40px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
textarea { min-height: 84px; resize: vertical; }
.password-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.password-field input { border-radius: 9px 0 0 9px; }
.password-field button { border: 1px solid var(--line); border-left: 0; border-radius: 0 9px 9px 0; background: var(--surface-2); padding: 0 12px; cursor: pointer; font-size: 13px; }
.password-field button:hover { color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 9px 14px; min-height: 40px; cursor: pointer; text-decoration: none; font-weight: 500; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-fg); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #1b160c; }
.btn.danger { color: var(--bad); border-color: var(--bad-soft); }
.btn.small { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.filters { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; margin-bottom: 14px; }
.filters .q { grid-column: 1 / -1; }
@media (min-width: 900px) { .filters { grid-template-columns: 2fr repeat(5, 1fr) auto; align-items: end; } .filters .q { grid-column: auto; } }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 7px 12px; cursor: pointer; }
.seg button.on { background: var(--brand); color: var(--brand-fg); }

/* chips de etapa */
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.st-novo { background: var(--info-soft); color: var(--info); }
.st-tentativa_contato, .st-em_atendimento { background: var(--warn-soft); color: var(--warn); }
.st-qualificado, .st-visita_agendada, .st-proposta { background: var(--accent-soft); color: var(--accent); }
.st-venda { background: var(--ok-soft); color: var(--ok); }
.st-perdido { background: var(--bad-soft); color: var(--bad); }

/* lista de leads */
.list { display: grid; gap: 8px; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; }
.item:hover { border-color: var(--accent); }
.item .n { font-weight: 600; }
.item .meta { color: var(--muted); font-size: 13px; grid-column: 1 / -1; display: flex; gap: 6px 14px; flex-wrap: wrap; }
@media (min-width: 900px) {
  .item { grid-template-columns: 1.4fr 1fr 1.3fr .9fr .8fr auto; align-items: center; }
  .item .meta { display: contents; }
  .item .meta span { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

/* detalhe */
.detail { display: grid; gap: 14px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.stages { display: flex; flex-wrap: wrap; gap: 6px; }
.stages button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.stages button.on { background: var(--brand); color: var(--brand-fg); border-color: var(--brand); }
.answers { display: grid; gap: 10px; }
.answers div { border-left: 3px solid var(--accent); padding-left: 10px; }
.answers b { display: block; font-weight: 500; color: var(--muted); font-size: 13px; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.timeline li { border-left: 2px solid var(--line); padding: 0 0 0 12px; }
.timeline .t { font-size: 12px; color: var(--muted); }
.timeline .b { white-space: pre-wrap; overflow-wrap: anywhere; }

/* barras */
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 140px 1fr 40px; gap: 10px; align-items: center; font-size: 13px; }
.bar .track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent); border-radius: 999px; }
.bar .num { text-align: right; font-variant-numeric: tabular-nums; }
.days { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 8px; }
.days div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; padding: 28px 24px; }
.login .brand { color: var(--fg); justify-content: center; margin-bottom: 18px; font-size: 1.1rem; }
.login form { display: grid; gap: 12px; }

/* avisos */
.alert { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }
.alert.err { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.info { background: var(--accent-soft); color: var(--fg); }
.secret { font: 600 1.1rem ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .05em; user-select: all; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--brand); color: var(--brand-fg); padding: 10px 16px; border-radius: 10px; z-index: 50; max-width: calc(100% - 32px); }
