:root {
  --red: #ED3237; --red-d: #c9242a; --red-l: #fdecec;
  --gray: #727376; --ink: #1f2124; --muted: #6b6e73; --line: #e3e4e7; --bg: #f4f5f7; --card: #fff;
  --ok: #1f8a4c; --ok-l: #e5f4ea; --warn: #b26a00; --warn-l: #fff3df; --blue: #2563eb; --blue-l: #e8efff;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--red-d); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; }
h2 { font-size: 18px; } h3 { font-size: 15px; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(237,50,55,.25); border-color: var(--red); }
textarea { resize: vertical; min-height: 64px; width: 100%; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
label > input, label > select, label > textarea { font-weight: 400; color: var(--ink); font-size: 14px; }
.btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 12px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: #c9cbd0; }
.btn.pri { background: var(--red); border-color: var(--red); color: #fff; }
.btn.pri:hover { background: var(--red-d); }
.btn.sm { padding: 4px 8px; font-size: 12px; }
.btn.link { border: 0; background: none; color: var(--red-d); padding: 0; }
.btn:disabled { opacity: .55; cursor: default; }

/* topo */
header.top { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 3px solid var(--red); display: flex; align-items: center; gap: 18px; padding: 8px 18px; }
header.top img { height: 34px; }
header.top .marca { font-weight: 700; color: var(--gray); letter-spacing: .5px; font-size: 13px; }
nav.abas { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
nav.abas a { padding: 8px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; text-decoration: none; }
nav.abas a.on { background: var(--red-l); color: var(--red-d); }
nav.abas a:hover { background: #f1f2f4; }
.usuario { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; white-space: nowrap; }
main { padding: 16px 18px 40px; max-width: 1700px; margin: 0 auto; }

.barra { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 14px; }
.barra .cresce { flex: 1; }
.barra input[type=search] { min-width: 220px; }
.chk { flex-direction: row; align-items: center; gap: 6px; font-weight: 600; padding-bottom: 6px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.vazio { color: var(--muted); padding: 18px; text-align: center; }
.muted { color: var(--muted); }
.peq { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* funil */
.funil { display: grid; grid-template-columns: repeat(6, minmax(230px, 1fr)); gap: 10px; overflow-x: auto; align-items: start; padding-bottom: 8px; }
.coluna { background: #eceef1; border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 170px); min-height: 200px; }
.coluna.alvo { outline: 2px dashed var(--red); }
.coluna > .cab { padding: 10px 12px 8px; display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.coluna > .cab b { font-size: 13px; letter-spacing: .3px; }
.coluna > .cab span { font-size: 12px; color: var(--muted); }
.coluna > .lista { overflow-y: auto; padding: 0 8px 8px; display: flex; flex-direction: column; gap: 7px; }
.cartao { background: #fff; border-radius: 8px; padding: 9px 10px; border: 1px solid var(--line); cursor: pointer; border-left: 4px solid var(--gray); }
.cartao:hover { border-color: #c9cbd0; }
.cartao .nome { font-weight: 700; }
.cartao .tit { color: var(--muted); font-size: 12.5px; margin: 2px 0 6px; }
.cartao .rod { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 12px; flex-wrap: wrap; }
.cartao.venc { border-left-color: var(--red); }
.cartao[draggable=true]:active { cursor: grabbing; }
.et-NOVO { --c: #727376; } .et-CONTATO { --c: #2563eb; } .et-NEGOCIANDO { --c: #b26a00; } .et-AGENDADO { --c: #7c3aed; } .et-GANHO { --c: #1f8a4c; } .et-PERDIDO { --c: #9aa0a6; }
.coluna > .cab b { color: var(--c); }

.chip { display: inline-block; padding: 1px 7px; border-radius: 99px; font-size: 11px; font-weight: 700; background: #eef0f2; color: var(--muted); white-space: nowrap; }
.chip.o-DECLINADO { background: var(--red-l); color: var(--red-d); }
.chip.o-OLEO { background: var(--warn-l); color: var(--warn); }
.chip.o-ALINHAMENTO { background: var(--blue-l); color: var(--blue); }
.chip.o-PNEUS { background: #efe7ff; color: #6d28d9; }
.chip.o-PJ_INATIVO { background: #e6f6f7; color: #0f766e; }
.chip.o-ANIVERSARIO { background: #fde9f4; color: #be185d; }
.chip.s-CONFIRMADO, .chip.s-COMPARECEU, .chip.e-GANHO { background: var(--ok-l); color: var(--ok); }
.chip.s-CANCELADO, .chip.s-FALTOU, .chip.e-PERDIDO { background: #eceef0; color: #80858b; }
.chip.s-AGENDADO, .chip.e-AGENDADO { background: #efe7ff; color: #6d28d9; }
.chip.venc { background: var(--red); color: #fff; }
.chip.auto { background: var(--ok); color: #fff; }

/* tabelas */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 7px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 700; background: #fafafb; position: sticky; top: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: #fafafb; }

/* agenda */
.agenda { display: grid; grid-template-columns: 1fr 360px; gap: 14px; align-items: start; }
.dia { margin-bottom: 12px; }
.dia > h3 { font-size: 13px; text-transform: capitalize; margin: 0 0 6px; color: var(--muted); }
.dia.hoje > h3 { color: var(--red-d); }
.ag { display: grid; grid-template-columns: 62px 1fr auto; gap: 10px; align-items: start; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; margin-bottom: 6px; }
.ag .hora { font-weight: 800; font-size: 15px; }
.ag.CANCELADO { opacity: .55; } .ag.CANCELADO .hora { text-decoration: line-through; }
.ag .acoes { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; max-width: 280px; }

/* gaveta e modal */
.fundo { position: fixed; inset: 0; background: rgba(20,22,25,.35); z-index: 40; }
.gaveta { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--bg); z-index: 41; overflow-y: auto; box-shadow: -4px 0 18px rgba(0,0,0,.12); }
.gaveta > .cab { position: sticky; top: 0; background: #fff; padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; z-index: 2; }
.gaveta > .corpo { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.modal { position: fixed; z-index: 51; left: 50%; top: 6vh; transform: translateX(-50%); width: min(620px, calc(100vw - 24px)); max-height: 88vh; overflow-y: auto; background: #fff; border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.modal > .cab { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal > .corpo { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.modal > .rod { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.fundo.m { z-index: 50; }
.x { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.linha { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.erro { background: var(--red-l); color: var(--red-d); border-radius: 8px; padding: 8px 10px; font-weight: 600; }
.ok-msg { background: var(--ok-l); color: var(--ok); border-radius: 8px; padding: 8px 10px; font-weight: 600; }

.timeline { display: flex; flex-direction: column; gap: 8px; }
.timeline .it { border-left: 3px solid var(--line); padding: 2px 0 2px 10px; }
.timeline .it.t-LIGACAO, .timeline .it.t-WHATSAPP { border-left-color: var(--blue); }
.timeline .it.t-NOTA { border-left-color: var(--warn); }
.timeline .it.t-AGENDAMENTO { border-left-color: #7c3aed; }
.timeline .it .q { font-size: 11.5px; color: var(--muted); }
.timeline .it .tx { white-space: pre-wrap; }

.ficha { display: grid; grid-template-columns: 360px 1fr; gap: 14px; align-items: start; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 5px 10px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.subabas { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 10px; flex-wrap: wrap; }
.subabas button { border: 0; background: none; padding: 8px 10px; font-weight: 700; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.subabas button.on { color: var(--red-d); border-bottom-color: var(--red); }

.metricas { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.metrica { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.metrica .r { font-size: 12px; color: var(--muted); font-weight: 600; }
.metrica .v { font-size: 22px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* WhatsApp */
.zap { background: #efeae2; border-radius: 8px; padding: 10px; max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.msg { max-width: 80%; padding: 6px 9px; border-radius: 8px; background: #fff; align-self: flex-start; white-space: pre-wrap; word-break: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.msg.eu { background: #d9fdd3; align-self: flex-end; }
.msg .h { font-size: 10.5px; color: var(--muted); text-align: right; margin-top: 2px; }

.sugestoes { border: 1px solid var(--line); border-radius: 8px; max-height: 220px; overflow-y: auto; }
.sugestoes div { padding: 7px 10px; cursor: pointer; border-bottom: 1px solid var(--line); }
.sugestoes div:hover { background: var(--red-l); }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 60; font-weight: 600; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(360px, 100%); background: #fff; border-radius: 14px; padding: 28px 24px; box-shadow: var(--shadow); border-top: 5px solid var(--red); display: flex; flex-direction: column; gap: 12px; }
.login img { width: 180px; align-self: center; margin-bottom: 4px; }
.login h1 { font-size: 15px; text-align: center; color: var(--gray); letter-spacing: 1px; }

@media (max-width: 1000px) {
  .agenda, .ficha, .grid2 { grid-template-columns: 1fr; }
  header.top { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  main { padding: 12px 12px 40px; }
  .usuario .nome-u { display: none; }
}
