:root {
  --bg: #f6faf8;
  --card: #ffffff;
  --card-2: #f1f7f4;
  --line: #e1ebe6;
  --ink: #0f241b;
  --muted: #5d6e66;
  --primary: #0e9f6e;
  --primary-dark: #0a7a54;
  --primary-soft: #8eeeb0;
  --primary-tint: #e3f8ec;
  --red: #ef6461;
  --red-tint: #fde4e3;
  --yellow: #f3f07c;
  --orange: #fca65f;
  --blue: #4b8de8;
  --shadow: 0 1px 2px rgba(16, 40, 30, .06), 0 4px 14px rgba(16, 40, 30, .06);
  --radius: 18px;
  --nav-h: 76px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body { -webkit-font-smoothing: antialiased; font-size: 16px; line-height: 1.4; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary-dark); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Estrutura ---------- */
.shell { min-height: 100vh; }
.view { padding: 16px 14px calc(var(--nav-h) + 96px); max-width: 760px; margin: 0 auto; }
.nav {
  position: fixed; left: 8px; right: 8px; bottom: 8px; height: var(--nav-h); z-index: 20;
  display: flex; justify-content: space-around; align-items: center;
  background: #f4f9f6; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
  padding: 0 4px;
}
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--primary); min-width: 0; height: 100%; border-radius: 14px;
}
.nav a svg { width: 28px; height: 28px; }
.nav a span { display: none; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.1; }
.nav a.ativo { color: var(--muted); }
.nav a.ativo span { display: block; }
.nav .marca { display: none; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 248px 1fr; }
  .nav {
    position: sticky; top: 0; left: auto; right: auto; bottom: auto; height: 100vh; border-radius: 0;
    flex-direction: column; justify-content: flex-start; align-items: stretch; gap: 4px; padding: 20px 14px;
    border-width: 0 1px 0 0; box-shadow: none; background: #fff;
  }
  .nav .marca { display: flex; margin: 0 6px 18px; }
  .nav a { flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 12px; height: 46px; padding: 0 12px; }
  .nav a span { display: block; font-size: 15px; color: var(--ink); }
  .nav a svg { width: 22px; height: 22px; }
  .nav a.ativo { background: var(--primary-tint); color: var(--primary-dark); }
  .nav a.ativo span { color: var(--primary-dark); font-weight: 600; }
  .nav a:hover:not(.ativo) { background: var(--card-2); }
  .view { padding: 28px 32px 120px; }
  .fabs { left: calc(124px + 50%) !important; transform: translateX(-50%); }
}

.marca { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--primary-dark); font-size: 18px; }
.marca img { width: 36px; height: 36px; }

/* ---------- Componentes ---------- */
.topo { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.topo .espaco { flex: 1; }
.titulo { font-size: 22px; font-weight: 700; }
.subtitulo { color: var(--muted); font-size: 14px; margin-top: 2px; }
.voltar { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; cursor: pointer; color: var(--ink); }
.voltar:hover { background: var(--card-2); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.card.tint { background: var(--card-2); }
.card.verde { background: var(--primary-soft); border-color: transparent; }
.card.escuro { background: #1f5a45; color: #fff; border-color: transparent; }
.card h3 { font-size: 17px; }

.secao { margin: 22px 2px 10px; }
.secao h2 { font-size: 22px; font-weight: 700; }
.secao p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  border: 1.5px solid transparent; border-radius: 999px; padding: 10px 18px; min-height: 44px;
  background: var(--primary); color: #fff; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn:hover { background: var(--primary-dark); }
.btn.claro { background: var(--primary-soft); color: #0b2b1d; box-shadow: 0 3px 10px rgba(14, 159, 110, .25); }
.btn.claro:hover { background: #7ae29e; }
.btn.contorno { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn.contorno:hover { background: var(--primary-tint); }
.btn.texto { background: transparent; color: var(--primary); padding: 8px 10px; min-height: 36px; }
.btn.texto:hover { background: var(--primary-tint); }
.btn.perigo { background: transparent; color: #c23b38; border-color: #f0b4b2; }
.btn.perigo:hover { background: var(--red-tint); }
.btn.bloco { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.icone-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); }
.icone-btn:hover { background: var(--card-2); }
.icone-btn svg { width: 26px; height: 26px; }

.chip-vendedor { display: inline-flex; align-items: center; gap: 8px; background: var(--primary); color: #fff; font-weight: 700; border-radius: 999px; padding: 8px 16px; }

.pilula { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; padding: 4px 12px; font-weight: 700; font-size: 14px; white-space: nowrap; }
.pilula.vermelha { background: #f6837f; color: #2b0d0c; }
.pilula.amarela { background: var(--yellow); color: #3a3600; }
.pilula.laranja { background: var(--orange); color: #3b1d00; }
.pilula.verde { background: var(--primary-soft); color: #0b2b1d; }
.pilula.cinza { background: #e5ebe8; color: #33433c; }
.pilula.pequena { font-size: 12px; padding: 2px 9px; font-weight: 600; }

.resumo-chips { display: flex; gap: 12px; overflow-x: auto; padding: 6px 2px 14px; scrollbar-width: none; }
.resumo-chips::-webkit-scrollbar { display: none; }
.resumo-chip { flex: none; text-align: center; cursor: pointer; background: none; border: 0; padding: 0; }
.resumo-chip .pilula { font-size: 20px; padding: 12px 22px; min-width: 150px; }
.resumo-chip .rotulo { display: block; margin-top: 6px; color: var(--muted); font-size: 14px; }
.resumo-chip.ativo .pilula { outline: 3px solid var(--ink); outline-offset: 2px; }

.cabeca-curva { background: #eef3f0; margin: -16px -14px 14px; padding: 16px 14px 18px; border-radius: 0 0 50% 50% / 0 0 28px 28px; }
@media (min-width: 900px) { .cabeca-curva { margin: -28px -32px 18px; padding: 24px 32px; } }

.lista-horizontal { display: flex; gap: 12px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x mandatory; }
.lista-horizontal > * { scroll-snap-align: start; flex: 0 0 78%; max-width: 300px; margin: 0; }

.avatar { flex: none; width: 46px; height: 46px; border-radius: 50%; background: #e4e9e6; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; color: #34443d; }
.linha { display: flex; align-items: center; gap: 12px; }
.linha .cresce { flex: 1; min-width: 0; }
.nome { font-weight: 600; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acoes { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.cliente-card { cursor: pointer; }
.cliente-card .nome { white-space: normal; overflow-wrap: anywhere; }
.cliente-card:hover { border-color: #c8dcd2; }
.saldo-box { display: inline-flex; align-items: center; gap: 10px; background: #f1f4f2; border-radius: 999px; padding: 3px 12px 3px 3px; font-weight: 600; }
.saldo-box.zerado { padding: 6px 12px; }

.total-grande { font-size: 32px; font-weight: 700; }

.fabs { position: fixed; z-index: 15; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 22px); display: flex; gap: 12px; width: max-content; max-width: calc(100vw - 24px); }
.fabs .btn { min-height: 54px; padding: 12px 22px; border-radius: 16px; font-size: 16px; font-weight: 500; }
.fab-unico { position: fixed; z-index: 15; right: 18px; bottom: calc(var(--nav-h) + 22px); }
.fab-unico .btn { min-height: 54px; border-radius: 16px; padding: 12px 22px; font-weight: 500; }
@media (min-width: 900px) { .fab-unico { right: 36px; bottom: 28px; } .fabs { bottom: 28px; } }

.busca { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.campo-busca { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; border: 1.5px solid #8a9690; border-radius: 6px; padding: 0 12px; background: #fff; min-height: 50px; }
.campo-busca input { border: 0; outline: 0; flex: 1; width: 100%; font-size: 17px; background: transparent; min-width: 0; }
.campo-busca:focus-within { border-color: var(--primary); }

.abas { display: flex; border-bottom: 1px solid var(--line); margin: 0 -2px 14px; overflow-x: auto; }
.abas button { flex: 1; background: none; border: 0; padding: 10px 8px 12px; cursor: pointer; color: var(--primary); position: relative; min-width: 96px; }
.abas button b { display: block; font-weight: 500; }
.abas button.ativo { font-weight: 700; }
.abas button.ativo::after { content: ''; position: absolute; left: 30%; right: 30%; bottom: 0; height: 4px; border-radius: 4px 4px 0 0; background: #bfc9c4; }
.abas button.ativo b { font-weight: 700; }

/* ---------- Formulários ---------- */
.form { display: grid; gap: 14px; }
.grade-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .grade-2 { grid-template-columns: 1fr; } }
label.campo { display: grid; gap: 6px; font-size: 14px; color: var(--muted); font-weight: 500; }
.campo input:not([type=radio]):not([type=checkbox]), .campo select, .campo textarea {
  border: 1.5px solid #cbd7d1; border-radius: 12px; padding: 12px 14px; background: #fff; font-size: 16px; color: var(--ink); min-height: 48px; width: 100%;
}
.campo textarea { min-height: 150px; resize: vertical; line-height: 1.45; }
.campo input:not([type=radio]):not([type=checkbox]):focus, .campo select:focus, .campo textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }
.campo .dica { font-size: 12px; color: var(--muted); font-weight: 400; }
.opcoes { display: flex; flex-wrap: wrap; gap: 8px; }
.opcoes label { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid #cbd7d1; border-radius: 999px; padding: 8px 14px; cursor: pointer; font-size: 14px; background: #fff; }
.opcoes input { accent-color: var(--primary); }
.opcoes label:has(input:checked) { border-color: var(--primary); background: var(--primary-tint); color: var(--primary-dark); font-weight: 600; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); margin-top: 1px; flex: none; }

.seletor { position: relative; }
.seletor .resultados { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: 280px; overflow: auto; }
.seletor .resultados button { display: flex; width: 100%; justify-content: space-between; gap: 10px; text-align: left; padding: 12px 14px; border: 0; background: #fff; cursor: pointer; }
.seletor .resultados button:hover, .seletor .resultados button:focus { background: var(--primary-tint); outline: none; }
.selecionado { display: flex; align-items: center; gap: 12px; border: 1.5px solid var(--primary); background: var(--primary-tint); border-radius: 12px; padding: 10px 12px; }

.alerta { border-radius: 14px; padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.alerta svg { width: 22px; height: 22px; flex: none; }
.alerta.aviso { background: #fff6d6; color: #5c4700; border: 1px solid #f3df92; }
.alerta.erro { background: var(--red-tint); color: #7d1f1d; border: 1px solid #f4bcbb; }
.alerta.ok { background: var(--primary-tint); color: #0b4f37; border: 1px solid #b8ebcd; }
.alerta.info { background: #eef4ff; color: #1d3f7a; border: 1px solid #cfdcf7; }

table.tabela { width: 100%; border-collapse: collapse; font-size: 15px; }
.tabela th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tabela td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tabela tr:last-child td { border-bottom: 0; }
.tabela .dir { text-align: right; }
.tabela tfoot td { font-weight: 700; border-top: 2px solid var(--line); }

.item { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .cresce { flex: 1; min-width: 0; }

/* ---------- Estados ---------- */
.estado { text-align: center; padding: 48px 20px; color: var(--muted); }
.estado svg { width: 56px; height: 56px; color: #a8bab1; margin-bottom: 8px; }
.estado h3 { color: var(--ink); margin-bottom: 6px; }
.carregando { display: grid; gap: 12px; }
.esqueleto { height: 88px; border-radius: var(--radius); background: linear-gradient(90deg, #eef3f0 25%, #f7faf8 50%, #eef3f0 75%); background-size: 200% 100%; animation: brilho 1.2s infinite; }
@keyframes brilho { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.girando { animation: gira 1s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }

/* ---------- Modal e toast ---------- */
.fundo-modal { position: fixed; inset: 0; background: rgba(10, 25, 18, .45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: aparece .15s ease-out; }
@media (min-width: 640px) { .fundo-modal { align-items: center; } }
.modal { background: #fff; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 22px 22px 0 0; padding: 20px 18px 24px; animation: sobe .2s ease-out; }
@media (min-width: 640px) { .modal { border-radius: 22px; } }
.modal .cab { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.modal .cab h2 { flex: 1; font-size: 20px; }
@keyframes aparece { from { opacity: 0; } }
@keyframes sobe { from { transform: translateY(30px); opacity: .6; } }
.toasts { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); top: 14px; display: grid; gap: 8px; width: min(92vw, 420px); }
.toast { background: #0f241b; color: #fff; border-radius: 14px; padding: 12px 16px; box-shadow: var(--shadow); animation: sobe .2s ease-out; font-size: 15px; }
.toast.erro { background: #8f2523; }
.toast.ok { background: #0a7a54; }

.previa-msg { white-space: pre-wrap; background: #e9f7ef; border-radius: 14px 14px 14px 4px; padding: 12px 14px; font-size: 15px; border: 1px solid #cdebd9; word-break: break-word; }

/* Ocultar valores (ícone do olho) */
body.oculto .valor { filter: blur(7px); user-select: none; }

/* Página de login */
.entrada { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.entrada .card { width: 100%; max-width: 420px; padding: 24px; }
.hero { border-radius: 22px; overflow: hidden; margin-bottom: 14px; background: #f1f5f3; }
.hero img { display: block; width: 100%; height: auto; }

.tres-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.tres-chips a { text-decoration: none; text-align: center; min-width: 0; }
.tres-chips .pilula { display: block; font-size: 14px; padding: 7px 4px; overflow: hidden; text-overflow: ellipsis; }
.tres-chips .rotulo { display: block; margin-top: 5px; color: var(--muted); font-size: 13px; }
@media (min-width: 480px) { .tres-chips .pilula { font-size: 16px; } }

.rolagem { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 480px) { .tabela td, .tabela th { padding-left: 5px; padding-right: 5px; } .tabela { font-size: 14px; } }

.nome.quebra { white-space: normal; overflow-wrap: anywhere; }
.card.linha { flex-wrap: wrap; }
