:root {
  --verde: #00d19a;
  --verde-esc: #00a77b;
  --verde-claro: #e3faf3;
  --navy: #004464;
  --navy-claro: #e6eff4;
  --ciano: #6ad3f1;
  --texto: #323538;
  --texto-2: #5d5d5d;
  --borda: #e4e8ec;
  --fundo: #f4f6f8;
  --card: #ffffff;
  --alerta: #e8833a;
  --alerta-claro: #fdf0e6;
  --risco: #d64545;
  --risco-claro: #fbe9e9;
  --ouro: #e0a526;
  --grad-marca: linear-gradient(90deg, var(--ciano), var(--verde));
  --grad-acao: linear-gradient(135deg, #00c795, #00a77b);
  --raio: 14px;
  --sombra: 0 1px 2px rgba(0, 68, 100, .06), 0 4px 14px rgba(0, 68, 100, .06);
  --abas-h: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Montserrat, system-ui, sans-serif;
  font-size: 15px;
  color: var(--texto);
  background: var(--fundo);
  padding-bottom: calc(var(--abas-h) + 84px + env(safe-area-inset-bottom));
}
h1, h2, h3 { font-family: Quicksand, Montserrat, sans-serif; font-weight: 700; margin: 0; color: var(--navy); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- topo ---------- */
.topo {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--navy); color: #fff;
}
.topo::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--grad-marca); }
.topo-marca { width: 40px; height: 40px; border-radius: 11px; background: #fff; display: grid; place-items: center; flex: none;
  box-shadow: 0 1px 4px rgba(0, 20, 30, .25); }
.topo-icone { width: 24px; height: 28px; display: block; }
.topo-txt { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.topo-ola { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; opacity: .75; }
.topo-txt strong { font-family: Quicksand; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topo-pontos {
  margin-left: auto; display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.12); border-radius: 999px; padding: 6px 12px;
  font-weight: 700; font-size: 14px; white-space: nowrap;
}
.topo-pontos .estrela { color: var(--ouro); }

.tela { max-width: 640px; margin: 0 auto; padding: 16px; }
.secao-tit { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 2px 10px; }
.secao-tit h2 { font-size: 18px; }
.secao-tit small { color: var(--texto-2); font-size: 12px; }

.card { background: var(--card); border-radius: var(--raio); box-shadow: var(--sombra); padding: 16px; }
.card + .card { margin-top: 12px; }
.muted { color: var(--texto-2); font-size: 13px; }

/* ---------- nível ---------- */
.nivel { background: linear-gradient(135deg, var(--navy) 0%, #00607e 60%, #00897a 100%); color: #fff; }
.nivel h1 { color: #fff; font-size: 22px; }
.nivel-linha { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.nivel-selo {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .8px; background: rgba(255,255,255,.15);
  padding: 4px 10px; border-radius: 999px; margin-bottom: 8px;
}
.nivel-barra { height: 8px; background: rgba(255,255,255,.2); border-radius: 99px; overflow: hidden; margin: 14px 0 6px; }
.nivel-barra i { display: block; height: 100%; background: var(--verde); border-radius: 99px; }
.nivel-rodape { display: flex; justify-content: space-between; font-size: 12px; opacity: .85; }
.sequencia { text-align: center; min-width: 64px; }
.sequencia b { display: block; font-family: Quicksand; font-size: 28px; line-height: 1; }
.sequencia span { font-size: 11px; opacity: .8; }

/* ---------- meta do mês ---------- */
.meta { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; }
.anel { --p: 0; width: 96px; height: 96px; border-radius: 50%;
  background: conic-gradient(var(--verde) calc(var(--p) * 1%), var(--navy-claro) 0);
  display: grid; place-items: center; }
.anel div { width: 76px; height: 76px; border-radius: 50%; background: #fff; display: grid; place-items: center; text-align: center; }
.anel b { font-family: Quicksand; font-size: 24px; color: var(--navy); line-height: 1; }
.anel small { font-size: 11px; color: var(--texto-2); }
.meta h3 { font-size: 16px; margin-bottom: 4px; }

/* ---------- missões ---------- */
.missao { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--borda); }
.missao:first-of-type { border-top: 0; padding-top: 4px; }
.missao-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; font-weight: 700; }
.missao-ic.ok { background: var(--verde); color: #fff; }
.missao-ic.pend { background: var(--navy-claro); color: var(--navy); }
.missao-txt { flex: 1; min-width: 0; }
.missao-txt b { display: block; font-size: 14px; }
.missao-pts { font-weight: 700; color: var(--verde-esc); font-size: 13px; white-space: nowrap; }

/* ---------- gráfico ---------- */
.barras { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 8px; position: relative; }
.barras .linha-base { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--alerta); }
.barras .linha-base span { position: absolute; left: 0; top: 2px; font-size: 11px; color: var(--alerta); font-weight: 600; background: #fff; padding: 0 2px; }
.barra { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.barra i { display: block; width: 100%; max-width: 34px; background: var(--ciano); border-radius: 6px 6px 2px 2px; }
.barra.atual i { background: var(--navy); }
.barra b { font-size: 11px; color: var(--texto); }
.barras-rot { display: flex; gap: 6px; margin-top: 6px; }
.barras-rot span { flex: 1; text-align: center; font-size: 11px; color: var(--texto-2); }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.kpi { background: var(--fundo); border-radius: 10px; padding: 10px; }
.kpi small { display: block; font-size: 11px; color: var(--texto-2); }
.kpi b { font-family: Quicksand; font-size: 17px; color: var(--navy); }

/* ---------- carteira ---------- */
.busca { width: 100%; padding: 12px 14px; border: 1px solid var(--borda); border-radius: 12px; background: #fff; font-size: 16px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--borda); background: #fff; border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 500; }
.chip[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip em { font-style: normal; opacity: .65; margin-left: 4px; }

.cli { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: #fff; border: 0;
  border-radius: 12px; padding: 12px 14px; box-shadow: var(--sombra); margin-top: 8px; }
.cli-av { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; background: var(--navy-claro); color: var(--navy); }
.cli-txt { flex: 1; min-width: 0; }
.cli-txt b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cli-txt span { font-size: 12px; color: var(--texto-2); }
.cli-dir { text-align: right; flex: none; }
.cli-dir b { display: block; font-size: 13px; }

.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.st-reativar { background: var(--risco-claro); color: var(--risco); }
.st-esfriando { background: var(--alerta-claro); color: #b35c1c; }
.st-ativo { background: var(--navy-claro); color: var(--navy); }
.st-fiel { background: var(--verde-claro); color: #00805e; }
.st-novo { background: #eef0ff; color: #4a4fb5; }

/* ---------- folha (detalhe/form) ---------- */
.folha { border: 0; padding: 0; width: 100%; max-width: 640px; margin: auto auto 0; border-radius: 20px 20px 0 0;
  max-height: 92vh; max-height: 92dvh; background: var(--fundo); overflow-y: auto; }
.folha::backdrop { background: rgba(0, 30, 45, .45); }
.folha-cab { position: sticky; top: 0; background: var(--fundo); padding: 10px 16px 8px; z-index: 1; }
.folha-cab::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 4px; background: #c9d1d8; margin: 0 auto 10px; }
.folha-cab h2 { font-size: 19px; padding-right: 40px; }
.fechar { position: absolute; right: 12px; top: 18px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: #fff; font-size: 20px; line-height: 1; box-shadow: var(--sombra); }
.folha-corpo { padding: 4px 16px calc(24px + env(safe-area-inset-bottom)); }
.lista-simples { margin: 0; padding: 0; list-style: none; }
.lista-simples li { padding: 9px 0; border-top: 1px solid var(--borda); font-size: 13px; display: flex; justify-content: space-between; gap: 10px; }
.lista-simples li:first-child { border-top: 0; }
.mini-barras { display: flex; align-items: flex-end; gap: 4px; height: 56px; }
.mini-barras i { flex: 1; background: var(--ciano); border-radius: 3px 3px 0 0; min-height: 2px; }
.mini-barras i.zero { background: var(--borda); }

/* ---------- form ---------- */
.campo { margin-top: 14px; }
.campo > label, .campo > .rot { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--navy); }
.campo input[type="text"], .campo input[type="date"], .campo textarea, .campo select {
  width: 100%; padding: 12px; border: 1px solid var(--borda); border-radius: 10px; background: #fff; font-size: 16px; }
.opcoes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opcao { border: 1.5px solid var(--borda); background: #fff; border-radius: 12px; padding: 12px 10px; font-size: 14px; font-weight: 500; text-align: center; }
.opcao[aria-pressed="true"] { border-color: var(--verde); background: var(--verde-claro); color: #00664b; font-weight: 600; }
.check { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--borda); border-radius: 10px; padding: 10px 12px; margin-top: 6px; font-size: 13px; }
.check input { width: 20px; height: 20px; accent-color: var(--verde-esc); flex: none; }
.btn { display: block; width: 100%; border: 0; border-radius: 12px; padding: 15px; font-weight: 600; font-size: 15px;
  text-transform: uppercase; letter-spacing: 1px; background: var(--grad-acao); color: #fff; margin-top: 18px;
  box-shadow: 0 2px 10px rgba(0, 167, 123, .25); }
.btn:disabled { opacity: .45; }
.btn-sec { background: #fff; color: var(--navy); border: 1.5px solid var(--navy); box-shadow: none; }
.sugestao-cli { max-height: 220px; overflow-y: auto; margin-top: 6px; }
.sugestao-cli button { display: block; width: 100%; text-align: left; border: 0; background: #fff; padding: 10px 12px; border-bottom: 1px solid var(--borda); font-size: 14px; }
.selecionado { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--navy-claro); border-radius: 10px; padding: 10px 12px; font-weight: 600; font-size: 14px; }
.selecionado button { border: 0; background: none; color: var(--navy); font-size: 13px; text-decoration: underline; }

/* ---------- visitas ---------- */
.visita { background: #fff; border-radius: 12px; box-shadow: var(--sombra); padding: 12px 14px; margin-top: 8px; }
.visita-topo { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.visita-topo b { font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.visita p { margin: 6px 0 0; font-size: 13px; color: var(--texto-2); }
.vazio { text-align: center; padding: 36px 16px; color: var(--texto-2); }
.vazio b { display: block; color: var(--navy); font-family: Quicksand; font-size: 17px; margin-bottom: 6px; }

/* ---------- fab, abas, toast ---------- */
.fab { position: fixed; right: 16px; bottom: calc(var(--abas-h) + 16px + env(safe-area-inset-bottom)); z-index: 20;
  display: flex; align-items: center; gap: 8px; border: 0; border-radius: 999px; padding: 14px 20px;
  background: var(--grad-acao); color: #fff; font-weight: 600; box-shadow: 0 6px 20px rgba(0, 167, 123, .4); }
.fab svg { width: 20px; height: 20px; }
.abas { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: #fff;
  border-top: 1px solid var(--borda); height: calc(var(--abas-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
.abas a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 600; color: var(--texto-2); text-decoration: none; position: relative; }
.abas a.ativa::before { content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 30px; height: 3px; border-radius: 0 0 3px 3px; background: var(--grad-marca); }
.abas svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.abas a.ativa { color: var(--navy); }
.abas a.ativa svg { stroke: var(--verde-esc); }
.toast { position: fixed; left: 50%; top: 16px; transform: translate(-50%, -140%); z-index: 50; transition: transform .3s;
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: calc(100% - 32px); text-align: center; }
.toast.on { transform: translate(-50%, 0); }
.rodape { text-align: center; font-size: 11px; color: var(--texto-2); margin: 28px 0 0; }

@media (min-width: 900px) {
  .fab { right: calc(50% - 320px + 16px); }
  .abas { max-width: 640px; margin: 0 auto; border: 1px solid var(--borda); border-bottom: 0; border-radius: 16px 16px 0 0; }
}

/* ---------- login ---------- */
body.deslogado .abas, body.deslogado .fab, body.deslogado .topo-pontos:empty { display: none; }
body.deslogado { padding-bottom: 24px; }
.login { max-width: 420px; margin: 24px auto 0; text-align: center; }
.login h1 { font-size: 24px; margin-bottom: 4px; }
.login .campo { text-align: left; }
.login-logo { display: grid; place-items: center; margin: 4px 0 14px; }
.login-logo img { width: 56px; height: 64px; }
.senha { position: relative; }
.senha input { padding-right: 52px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px;
  border: 0; background: none; color: var(--texto-2); display: grid; place-items: center; }
.pw-toggle svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.pw-toggle[aria-pressed="true"] { color: var(--verde-esc); }
.login-erro { color: var(--risco); font-size: 13px; min-height: 18px; margin: 10px 0 0; }
.campo input[type="password"] { width: 100%; padding: 12px; border: 1px solid var(--borda); border-radius: 10px; background: #fff; font-size: 16px; }

/* ---------- rodada 2 ---------- */
body.papel-gestora .fab { display: none; }
body.papel-gestora { padding-bottom: calc(var(--abas-h) + 24px + env(safe-area-inset-bottom)); }

a.missao { color: inherit; text-decoration: none; }

.linhas-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.linha-chip { background: var(--fundo); border-radius: 10px; padding: 10px; text-align: center; }
.linha-chip b { display: block; font-family: Quicksand; font-size: 18px; color: var(--navy); }
.linha-chip span { font-size: 11px; color: var(--texto-2); }

.material-card { display: block; width: 100%; text-align: left; border: 0; }
.material-card b { display: block; color: var(--navy); margin-bottom: 4px; }
.cola { padding: 12px 14px; }
.cola small { display: block; text-transform: uppercase; letter-spacing: .8px; font-size: 10px; color: var(--verde-esc); font-weight: 700; margin-bottom: 4px; }
.cola b { font-family: Quicksand; font-size: 16px; color: var(--navy); }

.rot-item { background: #fff; border-radius: 12px; box-shadow: var(--sombra); padding: 12px 14px; margin-top: 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.rot-item.atendido { opacity: .72; }
.rot-item.nao_atendido { border-left: 3px solid var(--alerta); }
.rot-nome { border: 0; background: none; text-align: left; padding: 0; flex: 1; min-width: 160px; }
.rot-nome b { display: block; font-size: 14px; }
.rot-acoes { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip.ok { background: var(--verde); border-color: var(--verde); color: #fff; font-weight: 600; }

.flag-banner { background: var(--risco-claro); color: #8c2f2f; border-radius: 12px; padding: 12px 14px; margin-bottom: 12px;
  font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.flag-banner .chip { margin-left: auto; background: #fff; }

.opcoes-3 { grid-template-columns: repeat(3, 1fr); }
.opcoes-3 .opcao { padding: 10px 6px; font-size: 13px; }

.kpis-2 { grid-template-columns: repeat(2, 1fr); margin-top: 0; }
.kpi .up { color: var(--verde-esc); font-weight: 700; }
.kpi .down { color: var(--risco); font-weight: 700; }

.ficha-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px solid var(--borda); font-size: 13px; flex-wrap: wrap; }
.ficha-item:first-child { border-top: 0; }
.seg { display: flex; gap: 4px; }
.seg button { width: 34px; height: 34px; border-radius: 8px; border: 1.5px solid var(--borda); background: #fff; font-weight: 600; font-size: 13px; }
.seg button[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.topo-pontos:empty { display: none; }
.toast:empty { display: none; }
.equipe-card .cli-txt span { display: block; }
