:root {
  --navy: #12304a;
  --teal: #0e7c86;
  --teal-d: #0a5f67;
  --bg: #f3f6f8;
  --card: #ffffff;
  --line: #d9e2e7;
  --txt: #1d2730;
  --mut: #5a6670;
  --ok: #1f8a4c;
  --warn: #b7791f;
  --bad: #c0392b;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--txt); background: var(--bg); }
a { color: var(--teal-d); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.4rem; margin: 0 0 .6rem; color: var(--navy); }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; color: var(--navy); }
h3 { font-size: .95rem; margin: .8rem 0 .3rem; color: var(--teal-d); }
small, .mut { color: var(--mut); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 14px; }

/* topo */
.top { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 20; }
.top .in { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 6px; padding: 8px 14px; flex-wrap: wrap; }
.brand { font-weight: 700; letter-spacing: .2px; margin-right: 10px; color: #fff; }
.brand span { color: #7fd1d9; }
.top nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.top nav a { color: #cfe3e8; padding: 7px 11px; border-radius: 7px; font-size: .92rem; }
.top nav a:hover, .top nav a.on { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.top .who { font-size: .85rem; color: #cfe3e8; display: flex; gap: 8px; align-items: center; }
.top .who form { margin: 0; }
.linkbtn { background: none; border: 0; color: #cfe3e8; cursor: pointer; font: inherit; padding: 4px; text-decoration: underline; }

/* mensagens */
.flash { padding: 10px 12px; border-radius: 8px; margin: 0 0 10px; border: 1px solid; font-size: .93rem; }
.flash.ok { background: #e7f5ec; border-color: #b6e0c5; color: #14532d; }
.flash.erro { background: #fdeceb; border-color: #f2c1bc; color: #7a1d14; }
.flash.info { background: #eaf3f5; border-color: #bcd9de; color: #0a4a52; }

/* cartões e grades */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.card.tight { padding: 10px 12px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.kpi b { display: block; font-size: 1.7rem; color: var(--navy); line-height: 1.1; }
.kpi span { font-size: .82rem; color: var(--mut); }
.kpi.alert b { color: var(--bad); }
.kpi a { color: inherit; display: block; }
.kpi a:hover { text-decoration: none; }

/* formulários */
label { display: block; font-size: .82rem; color: var(--mut); margin: 8px 0 3px; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid #bccbd2; border-radius: 8px; font: inherit; background: #fff; color: var(--txt); }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #8fd0d6; border-color: var(--teal); }
.row { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.row > div { min-width: 0; }
.btn { display: inline-block; background: var(--teal); color: #fff; border: 0; padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-align: center; }
.btn:hover { background: var(--teal-d); text-decoration: none; color: #fff; }
.btn.sec { background: #e6eef1; color: var(--navy); }
.btn.sec:hover { background: #d6e4e9; color: var(--navy); }
.btn.bad { background: #fff; color: var(--bad); border: 1px solid #e7b9b4; }
.btn.bad:hover { background: #fdeceb; color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: .82rem; font-weight: 500; }
.btn.wa { background: #1fa855; }
.btn.wa:hover { background: #168443; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; margin: 0; }
.right { margin-left: auto; }

/* tabelas e listas */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .3px; color: var(--mut); border-bottom: 2px solid var(--line); padding: 6px 8px; }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:hover td { background: #f8fbfc; }
.tablewrap { overflow-x: auto; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 9px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
.list li:last-child { border-bottom: 0; }
.list .main { flex: 1; min-width: 0; }
.list .main small { display: block; }
.empty { color: var(--mut); padding: 6px 0; font-size: .92rem; }

/* selos */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .74rem; font-weight: 600; background: #e6eef1; color: var(--navy); white-space: nowrap; }
.b-novo { background: #e6eef1; }
.b-em_contato { background: #dbeafe; color: #1e3a8a; }
.b-necessidade { background: #ccfbf1; color: #115e59; }
.b-visita { background: #fef3c7; color: #92400e; }
.b-proposta { background: #ede9fe; color: #5b21b6; }
.b-ganho { background: #dcfce7; color: #14532d; }
.b-perdido { background: #fee2e2; color: #7f1d1d; }
.b-sem_perfil { background: #eceff1; color: #546e7a; }
.p-A { background: #fde8d8; color: #9a3412; }
.p-B { background: #e6eef1; }
.p-C { background: #f1f5f9; color: #64748b; }
.late { color: var(--bad); font-weight: 600; }

/* funil e gráfico */
.bar { display: flex; align-items: center; gap: 8px; margin: 5px 0; font-size: .88rem; }
.bar .lbl { width: 150px; flex: none; }
.bar .track { flex: 1; background: #e9eff2; border-radius: 6px; height: 18px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--teal); min-width: 2px; }
.bar .n { width: 46px; text-align: right; font-weight: 600; }
.cols { display: flex; align-items: flex-end; gap: 4px; height: 110px; }
.cols .c { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; font-size: .68rem; color: var(--mut); }
.cols .c i { display: block; width: 100%; background: var(--teal); border-radius: 3px 3px 0 0; min-height: 2px; }
.cols .c b { font-size: .72rem; color: var(--navy); }

/* filtros */
.filters { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); align-items: end; }
.filters .q { grid-column: span 2; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: center; margin: 12px 0; flex-wrap: wrap; }

/* ficha */
.head { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.head .t { flex: 1; min-width: 240px; }
.head h1 { margin-bottom: 2px; }
.anchors { display: flex; gap: 4px; flex-wrap: wrap; margin: 0 0 12px; position: sticky; top: 46px; z-index: 10; background: var(--bg); padding: 6px 0; }
.anchors a { background: #fff; border: 1px solid var(--line); padding: 5px 11px; border-radius: 999px; font-size: .85rem; color: var(--navy); }
.person { border: 1px solid var(--line); border-radius: 9px; padding: 10px; margin-bottom: 8px; }
.person h4 { margin: 0 0 2px; font-size: .98rem; }
details > summary { cursor: pointer; color: var(--teal-d); font-weight: 600; font-size: .9rem; }
details[open] > summary { margin-bottom: 6px; }
.timeline { border-left: 3px solid var(--line); margin-left: 6px; padding-left: 14px; }
.timeline .ev { position: relative; padding-bottom: 14px; }
.timeline .ev::before { content: ""; position: absolute; left: -21px; top: 4px; width: 11px; height: 11px; background: var(--teal); border-radius: 50%; border: 2px solid #fff; }
.script { background: #f1f8f9; border-left: 3px solid var(--teal); padding: 8px 12px; border-radius: 0 8px 8px 0; font-size: .9rem; }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.tabs button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 12px; cursor: pointer; font: inherit; }
.tabs button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
#gmap, #omap, #mapa { width: 100%; border: 1px solid var(--line); border-radius: 9px; }
#gmap { height: 340px; }
#omap { height: 340px; }
#mapa { height: calc(100vh - 250px); min-height: 380px; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: .82rem; margin-top: 6px; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }

/* login */
.loginbox { max-width: 360px; margin: 9vh auto; }
.loginbox .card { padding: 22px; }

@media (max-width: 640px) {
  .top .in { gap: 2px 6px; }
  .brand { flex: 1; margin-right: 0; }
  .top nav { order: 3; flex: 1 1 100%; overflow-x: auto; flex-wrap: nowrap; }
  .top nav a { white-space: nowrap; }
  .top nav a { padding: 6px 8px; font-size: .86rem; }
  .filters .q { grid-column: span 1; }
  .bar .lbl { width: 105px; }
  .hide-sm { display: none; }
  .wrap { padding: 10px; }
}

/* envio de material */
.matlist { border: 1px solid var(--line); border-radius: 9px; max-height: 280px; overflow-y: auto; }
.mat { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.mat:last-child { border-bottom: 0; }
.mat label { display: flex; gap: 8px; align-items: flex-start; margin: 0; font-weight: 400; cursor: pointer; flex: 1; }
.mat input[type=checkbox] { width: auto; margin-top: 3px; }
.chips { margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-block; background: #e8f5ee; color: #14683a; border: 1px solid #bfe3cf; border-radius: 999px; padding: 1px 10px; font-size: .8rem; font-weight: 600; }
.chip.off { background: #eee; color: #777; border-color: #ddd; text-decoration: line-through; }
