:root {
  --background: 0 0% 100%;
  --foreground: 222.2 84% 4.9%;
  --card: 0 0% 100%;
  --primary: 222.2 47.4% 11.2%;
  --primary-foreground: 210 40% 98%;
  --muted: 210 40% 96.1%;
  --muted-foreground: 215.4 16.3% 46.9%;
  --accent: 210 40% 96.1%;
  --destructive: 0 84.2% 60.2%;
  --border: 214.3 31.8% 91.4%;
  --input: 214.3 31.8% 91.4%;
  --radius: 0.5rem;
  --emerald: 142 71% 45%;
  --amber: 32 95% 44%;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.page { min-height: 100vh; }
.container {
  max-width: 42rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 2.5rem;
}
@media (min-width: 768px) {
  .container { padding-top: 2.5rem; }
}

.hidden { display: none !important; }

/* Header */
.header { text-align: center; margin-bottom: 2rem; }
.header-logo { display: flex; justify-content: center; margin-bottom: 0.75rem; }
.logo { height: 2.5rem; }
@media (min-width: 768px) { .logo { height: 3rem; } }
.header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
}
@media (min-width: 768px) {
  .header h1 { font-size: 1.875rem; }
}
.subtitle {
  color: hsl(var(--muted-foreground));
  margin-top: 0.5rem;
  font-size: 0.875rem;
}
@media (min-width: 768px) {
  .subtitle { font-size: 1rem; }
}
.byline {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.25rem;
}

/* Segmentos */
.segmentos { margin-bottom: 2rem; }
.segmentos h2 {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}
@media (min-width: 768px) {
  .segmentos h2 { font-size: 1.5rem; }
}
.segmentos-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}
@media (min-width: 640px) {
  .segmentos-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 768px) {
  .segmentos-grid { grid-template-columns: repeat(4, 1fr); }
}

.seg-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  border-radius: 0.75rem;
  border: 2px solid hsl(var(--border));
  background: hsl(var(--card));
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  font: inherit;
  color: inherit;
}
.seg-btn:hover {
  border-color: hsl(var(--primary) / 0.5);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.seg-btn.active {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.1);
  box-shadow: 0 4px 6px rgba(0,0,0,0.08);
  transform: scale(1.03);
}
.seg-btn .icon { font-size: 1.875rem; line-height: 1; }
.seg-btn .label {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
}

/* Calculadora */
.calculadora { display: flex; flex-direction: column; gap: 1.5rem; }

.card {
  border: 1px solid hsl(var(--border));
  border-radius: 0.5rem;
  background: hsl(var(--card));
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.card-header { padding: 1.5rem 1.5rem 0.75rem; }
.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.card-body { padding: 0 1.5rem 1.5rem; }
.card-body > .field + .field { margin-top: 0.75rem; }

.step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 0.875rem;
  font-weight: 700;
  flex-shrink: 0;
}

.field { margin-bottom: 0; }
.field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
}
.input-wrap { position: relative; }
.input-wrap .prefix,
.input-wrap .suffix {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  pointer-events: none;
}
.input-wrap .prefix { left: 0.75rem; }
.input-wrap .suffix { right: 0.75rem; }
.input-wrap input {
  width: 100%;
  height: 2.5rem;
  border: 1px solid hsl(var(--input));
  border-radius: 0.375rem;
  background: hsl(var(--background));
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  color: inherit;
}
.input-wrap .prefix + input { padding-left: 2.5rem; }
.input-wrap input:has(+ .suffix),
.input-wrap:has(.suffix) input { padding-right: 2.5rem; }
.input-wrap input:focus {
  outline: none;
  box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--primary) / 0.35);
}
.hint {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.25rem;
}

.resumo-box {
  margin-top: 0.75rem;
  background: hsl(var(--muted));
  border-radius: 0.5rem;
  padding: 0.75rem;
  text-align: center;
  font-size: 0.875rem;
}
.resumo-box span { color: hsl(var(--muted-foreground)); }
.resumo-box strong { margin-left: 0.5rem; }

.margem-status {
  font-size: 0.875rem;
  font-weight: 600;
  margin: 0.5rem 0;
}
.margem-status.apertada { color: hsl(var(--amber)); }
.margem-status.saudavel { color: hsl(var(--emerald)); }
.margem-status.forte { color: hsl(var(--primary)); }

/* Resultado */
.resultado {
  border-color: hsl(var(--primary) / 0.3);
  background: hsl(var(--primary) / 0.05);
}
.resultado.erro {
  border-color: hsl(var(--destructive) / 0.5);
  background: hsl(var(--destructive) / 0.05);
}
.resultado .card-body { padding: 1.5rem; }
.preco-ideal { text-align: center; margin-bottom: 1rem; }
.preco-ideal .label {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin-bottom: 0.25rem;
}
.preco-ideal .valor {
  font-size: 2.5rem;
  font-weight: 800;
  color: hsl(var(--primary));
  line-height: 1.1;
}
@media (min-width: 768px) {
  .preco-ideal .valor { font-size: 3rem; }
}
.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  text-align: center;
}
.metric {
  background: hsl(var(--card));
  border-radius: 0.5rem;
  padding: 0.75rem;
}
.metric .label {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}
.metric .valor {
  font-size: 1.125rem;
  font-weight: 700;
}
.metric .valor.lucro { color: hsl(var(--emerald)); }
.erro-msg {
  text-align: center;
  color: hsl(var(--destructive));
  font-weight: 600;
  padding: 1.5rem;
}

/* Simuladores */
.sim-box {
  margin-top: 0.75rem;
  border-radius: 0.5rem;
  padding: 1rem;
  text-align: center;
  background: hsl(var(--muted));
}
.sim-box.prejuizo {
  background: hsl(var(--destructive) / 0.1);
  border: 1px solid hsl(var(--destructive) / 0.3);
}
.sim-box .alerta {
  color: hsl(var(--destructive));
  font-weight: 700;
  font-size: 1.125rem;
  margin-bottom: 0.25rem;
}
.sim-row {
  display: flex;
  justify-content: space-around;
}
.sim-row .label {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}
.sim-row .valor { font-weight: 700; }
.sim-row .valor.ok { color: hsl(var(--emerald)); }
.sim-row .valor.bad { color: hsl(var(--destructive)); }

.btn-outline {
  width: 100%;
  margin-top: 0.75rem;
  height: 2.5rem;
  border: 1px solid hsl(var(--input));
  border-radius: 0.375rem;
  background: hsl(var(--background));
  cursor: pointer;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: inherit;
}
.btn-outline:hover { background: hsl(var(--accent)); }

/* Chart simples */
.chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 0.75rem;
  height: 14rem;
  padding-top: 1rem;
}
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}
.bar-wrap {
  width: 100%;
  max-width: 4.5rem;
  flex: 1;
  display: flex;
  align-items: flex-end;
}
.bar {
  width: 100%;
  border-radius: 6px 6px 0 0;
  min-height: 4px;
  transition: height 0.3s;
}
.bar-label {
  font-size: 0.7rem;
  color: hsl(var(--muted-foreground));
  text-align: center;
  margin-top: 0.5rem;
  white-space: pre-line;
  line-height: 1.3;
}
.bar-value {
  font-size: 0.7rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

/* Dica */
.dica {
  border-color: hsl(var(--accent));
  background: hsl(var(--accent) / 0.5);
}
.dica h3 {
  font-weight: 700;
  margin-bottom: 0.5rem;
  font-size: 1rem;
}
.dica p {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.625;
}

/* CTA */
.cta {
  margin-top: 2.5rem;
  border-radius: 0.75rem;
  border: 1px solid hsl(var(--primary) / 0.2);
  background: hsl(var(--primary) / 0.05);
  padding: 1.5rem;
  text-align: center;
}
.logo-sm { height: 2.5rem; margin: 0 auto 0.75rem; display: block; }
.cta h2 {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.cta p {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  max-width: 28rem;
  margin: 0 auto 1rem;
}
.btn-primary {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  transition: opacity 0.2s;
}
.btn-primary:hover { opacity: 0.9; }

.footer {
  margin-top: 2rem;
  padding: 1.5rem 0;
  text-align: center;
  border-top: 1px solid hsl(var(--border));
}
.footer p {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  font-style: italic;
}
.btn-limpar {
  margin-top: 0.75rem;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  text-decoration: underline;
  padding: 0.25rem;
}
.btn-limpar:hover { color: hsl(var(--foreground)); }

#simuladores { display: flex; flex-direction: column; gap: 1.5rem; }
#simuladores.hidden { display: none !important; }

/* Campos opcionais */
.opcional {
  font-weight: 400;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

/* Mensagem enquanto aguarda o custo */
.aguardando-msg {
  text-align: center;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
  padding: 1.5rem;
}

/* Ajuste fino (accordion) */
.ajuste {
  border: 1px dashed hsl(var(--border));
  border-radius: 0.5rem;
  background: hsl(var(--muted) / 0.4);
}
.ajuste summary {
  cursor: pointer;
  padding: 1rem 1.5rem;
  list-style: none;
  display: block;
  position: relative;
}
.ajuste summary::-webkit-details-marker { display: none; }
.ajuste summary::after {
  content: "▾";
  position: absolute;
  right: 1.25rem;
  top: 1rem;
  color: hsl(var(--muted-foreground));
  transition: transform 0.2s;
}
.ajuste[open] summary::after { transform: rotate(180deg); }
.ajuste-titulo {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
}
.ajuste-sub {
  display: block;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.25rem;
  padding-right: 1.5rem;
}
.ajuste-body { padding: 0 1.5rem 1.5rem; }
.ajuste-body h4 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.ajuste-h4-espaco { margin-top: 1.25rem; }
.ajuste-body .field + .field { margin-top: 0.75rem; }

/* CTA contextual dentro do resultado */
.resultado-cta {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid hsl(var(--primary) / 0.15);
  text-align: center;
}
.resultado-cta p {
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  max-width: 26rem;
  margin: 0 auto 0.75rem;
}
.btn-sm {
  padding: 0.5rem 1.25rem;
  font-size: 0.8125rem;
  margin-top: 0;
}

/* Popup de oferta */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}
body.popup-aberto { overflow: hidden; }
.popup {
  position: relative;
  background: hsl(var(--card));
  border-radius: 0.75rem;
  padding: 2rem 1.5rem 1.5rem;
  max-width: 36rem;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  animation: popup-in 0.25s ease-out;
}
@keyframes popup-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.popup-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  border: none;
  background: none;
  font-size: 1.5rem;
  line-height: 1;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  padding: 0.25rem;
}
.popup-close:hover { color: hsl(var(--foreground)); }
.popup-headline {
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 0.75rem;
}
.popup-screenshot {
  width: 100%;
  height: auto;
  border-radius: 0.375rem;
  border: 1px solid hsl(var(--border));
  margin-bottom: 0.75rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.popup-text {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin-bottom: 1.25rem;
}
.popup-btn {
  display: block;
  width: 100%;
  margin-top: 0;
}
.popup-dismiss {
  display: block;
  width: 100%;
  margin-top: 0.75rem;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  text-decoration: underline;
  padding: 0.25rem;
}
.popup-dismiss:hover { color: hsl(var(--foreground)); }

/* Barra fixa de divulgação */
.sticky-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
}
body.has-sticky { padding-bottom: 3.75rem; }
.sticky-logo {
  height: 1.5rem;
  background: #fff;
  border-radius: 4px;
  padding: 2px 4px;
  flex-shrink: 0;
}
.sticky-text {
  font-size: 0.8125rem;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sticky-btn {
  flex-shrink: 0;
  padding: 0.4rem 0.9rem;
  border-radius: 0.375rem;
  background: hsl(var(--primary-foreground));
  color: hsl(var(--primary));
  font-size: 0.8125rem;
  font-weight: 700;
  text-decoration: none;
}
.sticky-btn:hover { opacity: 0.9; }
.sticky-close {
  flex-shrink: 0;
  border: none;
  background: none;
  color: hsl(var(--primary-foreground));
  opacity: 0.7;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem;
}
.sticky-close:hover { opacity: 1; }
