:root {
  --brand: #1e3a5f;
  --brand-hover: #2d5a8e;
  --accent: #c09b2f;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-dark: #cbd5e1;
  --text: #1a202c;
  --muted: #64748b;
  --success-bg: #f0fdf4; --success-text: #166534; --success-border: #86efac;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  font-size: 16px;
  overscroll-behavior-y: contain;
}

/* ── Casca do app: header fixo + conteúdo + barra inferior fixa, sem scroll de página ── */
.app-shell { height: 100dvh; max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; background: var(--bg); }

.topo { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 0.7rem 1rem; }
.topo-passo { display: flex; gap: 0.35rem; }
.topo-passo span { width: 7px; height: 7px; border-radius: 50%; background: var(--border-dark); }
.topo-passo span.atual { background: var(--brand); width: 18px; border-radius: 4px; }
.topo-info { border: none; background: none; color: var(--muted); font-size: 1.2rem; cursor: pointer; padding: 0.3rem; }

.conteudo { flex: 1 1 auto; overflow-y: auto; padding: 0.5rem 1.1rem; display: flex; flex-direction: column; }
.tela { flex: 1; display: flex; flex-direction: column; gap: 0.9rem; }
.tela-centro { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; text-align: center; }
.icone-grande { font-size: 3rem; }

.rodape-nav { flex: 0 0 auto; display: flex; gap: 0.6rem; padding: 0.8rem 1.1rem calc(0.8rem + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--border); }
.rodape-nav .btn { flex: 1; }
.rodape-nav .btn:only-child { margin-left: auto; }

/* ── Botões e campos ── */
.btn { border: none; border-radius: 12px; padding: 0.8rem 1rem; font-size: 1rem; font-weight: 700; cursor: pointer; min-height: 50px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-ghost { background: var(--surface); color: var(--brand); border: 1px solid var(--border-dark); }
.btn-grande { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-icone { border: 1px solid var(--border-dark); background: var(--surface); color: var(--brand); font-size: 1.2rem; width: 48px; height: 48px; border-radius: 12px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.link-discreto { border: none; background: none; color: var(--muted); font-size: 0.85rem; text-decoration: underline; cursor: pointer; padding: 0.4rem; }

input[type="text"], input[type="tel"], select, textarea {
  width: 100%; padding: 0.85rem; border: 1px solid var(--border-dark); border-radius: 12px; font-size: 1.05rem; background: var(--surface); color: var(--text); min-height: 52px;
}
.input-grande { text-align: center; font-size: 1.2rem; }
.select-grande { text-align: center; font-weight: 700; }
.linha-form-inline { display: flex; gap: 0.5rem; }

.toggle-linha { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.toggle-centro { justify-content: center; }
.toggle-pill { padding: 0.6rem 1rem; border-radius: 999px; border: 1px solid var(--border-dark); background: var(--surface); font-size: 0.88rem; font-weight: 700; cursor: pointer; color: var(--muted); min-height: 44px; }
.toggle-pill[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ── Conexão ── */
.conexao-ok { font-size: 1.2rem; font-weight: 800; color: var(--success-text); background: var(--success-bg); border: 1px solid var(--success-border); border-radius: var(--radius); padding: 1rem 1.4rem; }
.codigo-grande { font-size: 2.1rem; font-weight: 800; letter-spacing: 0.12em; color: var(--brand); background: var(--surface); border: 2px solid var(--brand); border-radius: var(--radius); padding: 1rem; font-family: ui-monospace, 'SF Mono', monospace; text-align: center; }
.qr-box { display: flex; justify-content: center; }
.qr-box img { width: 240px; height: 240px; border-radius: 8px; }

/* ── Contatos ── */
.tela-topo-acoes { flex: 0 0 auto; display: flex; gap: 0.4rem; padding-top: 0.3rem; }
.tela-topo-acoes input { flex: 1; }
.tela-topo-acoes select { width: auto; flex: 0 0 90px; }
.lista-contatos { flex: 1; overflow-y: auto; display: grid; gap: 0.5rem; align-content: start; }
.contato-row { display: flex; align-items: center; gap: 0.6rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0.65rem 0.75rem; }
.contato-row .info { flex: 1; min-width: 0; }
.contato-nome { font-weight: 700; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nivel-badge { font-size: 1rem; }
.nivel-quente::before { content: "🔥"; } .nivel-quente { font-size: 0; }
.nivel-morno::before { content: "🌤"; } .nivel-morno { font-size: 0; }
.nivel-frio::before { content: "❄️"; } .nivel-frio { font-size: 0; }

.lista-nomeada-card { display: flex; justify-content: space-between; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 0.6rem 0.8rem; font-size: 0.9rem; margin-bottom: 0.4rem; }

/* ── Mensagem ── */
.previa { flex: 1; white-space: pre-wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem; font-size: 0.92rem; overflow-y: auto; }

/* ── Limites ── */
.limites-form { display: grid; gap: 0.6rem; }
.limite-grupo { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.7rem 0.8rem; display: flex; align-items: center; gap: 0.6rem; }
.limite-grupo .rotulo { font-size: 1.3rem; flex: 0 0 auto; }
.limite-grupo input { width: 70px; text-align: center; min-height: 40px; padding: 0.4rem; }
.limite-grupo .campo { display: flex; align-items: center; gap: 0.3rem; font-size: 0.78rem; color: var(--muted); }

/* ── Revisão / dashboard ── */
.amostra-lote { display: grid; gap: 0.5rem; }
.amostra-item { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 0.7rem 0.8rem; font-size: 0.85rem; white-space: pre-wrap; }
.dashboard { display: grid; gap: 0.6rem; }
.dash-contadores { display: flex; gap: 0.5rem; }
.dash-contadores .stat { flex: 1; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 0.6rem; }
.dash-contadores .stat .n { font-size: 1.3rem; font-weight: 800; color: var(--brand); }
.dash-contadores .stat .l { font-size: 1.1rem; }
.progresso-track { width: 100%; height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.progresso-fill { height: 100%; background: var(--brand); border-radius: 999px; transition: width .2s; }
.dash-controles { display: flex; gap: 0.5rem; justify-content: center; }

/* ── Modais ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; padding: 1.2rem; z-index: 20; }
.modal-box { position: relative; background: var(--surface); border-radius: var(--radius); padding: 1.5rem 1.2rem; width: 100%; max-width: 380px; max-height: 85vh; overflow-y: auto; display: grid; gap: 0.8rem; }
.modal-box-centro { text-align: center; align-items: center; justify-items: center; }
.modal-box p { margin: 0; font-size: 0.92rem; line-height: 1.5; text-align: center; }
.modal-legenda { margin: 0; font-size: 0.8rem; color: var(--muted); text-align: center; }
.modal-fechar { position: absolute; top: 0.6rem; right: 0.6rem; width: 36px; height: 36px; font-size: 1rem; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: girar 0.8s linear infinite; margin: 1rem auto; }
@keyframes girar { to { transform: rotate(360deg); } }
