/* Identidade: claro e legível, laranja como destaque, verde reservado ao investimento. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f5f6f8;
  --surface-3: #e7e9ee;
  --input: #ffffff;
  --border: #d9dde3;
  --text: #14171c;
  --muted: #5a6270;
  --accent: #f26a0d;
  --accent-hover: #d95b06;
  --accent-text: #c2410c;
  --accent-ink: #ffffff;
  --accent-soft: #fff3ea;
  --accent-line: #fbc49d;
  --money: #15803d;
  --money-ink: #ffffff;
  --money-soft: #e7f6ec;
  --danger: #b91c1c;
  --danger-soft: #fdecec;
  --warn: #8a5300;
  --warn-soft: #fff6dd;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.07);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.55 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 26px; letter-spacing: -.02em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.hl { color: var(--accent-text); }
.money { color: var(--money); }

/* Formulários */
label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #9aa1ad; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.invalid { border-color: var(--danger); }
textarea { resize: vertical; min-height: 72px; }
.field { margin-bottom: 16px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.input-affix { position: relative; }
.input-affix span { position: absolute; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; pointer-events: none; }
.input-affix .pre { left: 13px; }
.input-affix .suf { right: 13px; }
.input-affix input.has-pre { padding-left: 40px; }
.input-affix input.has-suf { padding-right: 32px; }
.input-lg input { font-size: 22px; font-weight: 700; padding-top: 14px; padding-bottom: 14px; }
.input-lg .pre { font-size: 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 14px;
  border-radius: 10px; padding: 10px 16px;
  border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.green { background: var(--money); border-color: var(--money); color: var(--money-ink); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.lg { padding: 13px 22px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: default; }

.alert { padding: 11px 13px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.info { background: var(--accent-soft); color: var(--accent-text); border: 1px solid var(--accent-line); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.hidden { display: none !important; }

/* Marca */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.01em; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 16px; font-weight: 900; }

/* Login */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(600px 300px at 50% 0%, rgba(255,122,26,.12), transparent 70%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px; }

/* Topo */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 8px; }
.topbar .spacer { flex: 1; }
.user-chip { font-size: 13px; color: var(--muted); margin-right: 4px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.step-label { font-size: 12px; font-weight: 700; color: var(--accent-text); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; }

.grid { display: grid; gap: 0 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ---------- Questionário ---------- */
.wizard { max-width: 760px; margin: 0 auto; padding: 24px 16px 120px; }

.stepper { display: flex; gap: 6px; margin-bottom: 26px; }
.stepper button { flex: 1; min-width: 0; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; color: var(--muted); font: inherit; }
.stepper button:disabled { cursor: default; }
.stepper .bar { height: 4px; border-radius: 99px; background: var(--surface-3); margin-bottom: 8px; transition: background .2s; }
.stepper .name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.stepper .done .bar { background: var(--accent); }
.stepper .done { color: var(--text); }
.stepper .current .bar { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.stepper .current { color: var(--accent-text); }

.q-head { margin-bottom: 22px; }
.q-head h1 { margin-bottom: 8px; }
.q-head p { margin: 0; color: var(--muted); }

.step-panel { animation: fadeIn .2s ease both; }
@keyframes fadeIn { from { transform: translateY(6px); } to { transform: none; } }

.nav-bar { box-shadow: 0 -2px 10px rgba(16,24,40,.05); position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: rgba(255,255,255,.95); backdrop-filter: blur(10px); border-top: 1px solid var(--border); }
.nav-inner { max-width: 760px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 10px; }
.nav-inner .spacer { flex: 1; }
.nav-inner .count { font-size: 13px; color: var(--muted); }

/* Caixa "O que é?" */
.explain { display: flex; gap: 12px; background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 12px; padding: 14px 16px; margin: 4px 0 18px; font-size: 14px; }
.explain .i { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-size: 13px; font-style: italic; font-family: Georgia, serif; }
.explain strong { color: var(--accent-text); }
.explain p { margin: 0; }
.explain p + p { margin-top: 6px; }

/* Termo com tooltip */
.term { border-bottom: 1px dashed var(--accent); cursor: help; position: relative; }
.info-btn { display: inline-grid; place-items: center; width: 17px; height: 17px; margin-left: 5px; border-radius: 50%; border: 1px solid var(--accent-line); color: var(--accent-text); background: transparent; font: italic 800 11px Georgia, serif; cursor: pointer; vertical-align: 1px; padding: 0; }
.info-btn:hover, .info-btn[aria-expanded=true] { background: var(--accent); color: var(--accent-ink); }
.info-pop { font-weight: 400; font-size: 13px; color: var(--text); background: var(--surface-3); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-top: 6px; }

/* Feedback ao vivo */
.live { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-top: 6px; }
.live .row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 14px; }
.live .row + .row { border-top: 1px dashed var(--border); }
.live .row b { font-variant-numeric: tabular-nums; }

/* Cartões de produto */
.prod-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; margin-bottom: 12px; }
.prod-card .prod-top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.prod-card .prod-top .badge-n { width: 26px; height: 26px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-text); font-weight: 800; display: grid; place-items: center; font-size: 13px; flex: none; }
.prod-card .prod-top input { font-weight: 700; }
.prod-card .prod-result { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.pill { font-size: 13px; padding: 5px 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); }
.pill b { color: var(--accent-text); }
.pill.money-pill b { color: var(--money); }
.add-prod { width: 100%; border: 1px dashed var(--accent-line); background: transparent; color: var(--accent-text); padding: 14px; border-radius: 14px; font: inherit; font-weight: 700; cursor: pointer; }
.add-prod:hover { background: var(--accent-soft); }

/* Opções em chip */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip { background: var(--input); border: 1px solid var(--border); color: var(--text); font: inherit; font-weight: 700; padding: 10px 16px; border-radius: 10px; cursor: pointer; font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--accent-line); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip small { display: block; font-weight: 500; font-size: 11px; opacity: .8; }

/* ---------- Resultado ---------- */
.hero { background: linear-gradient(135deg, #15803d, #16a34a); color: var(--money-ink); border-radius: 18px; padding: 26px; }
.hero .label { font-size: 14px; font-weight: 600; opacity: .85; }
.hero .value { font-size: 44px; font-weight: 900; letter-spacing: -.03em; line-height: 1.1; margin: 4px 0; }
.hero .sub { font-size: 14px; font-weight: 500; opacity: .9; }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 22px; font-weight: 800; color: var(--accent-text); }
.kpi .value.white { color: var(--text); }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 9px 6px; border-bottom: 1px solid var(--border); text-align: right; }
.table th:first-child, .table td:first-child { text-align: left; }
.table th { font-size: 12px; font-weight: 600; color: var(--muted); }
.table tfoot td { font-weight: 800; border-bottom: 0; }
.table td.inv { color: var(--money); font-weight: 700; }

.memoria { font-size: 14px; }
.memoria h3 { margin: 18px 0 6px; color: var(--accent-text); }
.memoria .line { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.memoria .line span:last-child { font-weight: 700; text-align: right; white-space: nowrap; }
.memoria .line.inv span:last-child { color: var(--money); }
.memoria .formula { color: var(--muted); font-size: 13px; }

.bar-track { height: 10px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.bar-track > div { height: 100%; background: var(--money); border-radius: 99px; }
.bar-track.low > div { background: var(--accent); }

.glossary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.glossary div { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; font-size: 13px; color: var(--muted); }
.glossary b { display: block; color: var(--text); font-size: 14px; margin-bottom: 2px; }

.result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* Painel de simulações */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 100%); background: var(--surface); border-left: 1px solid var(--border); z-index: 41; padding: 18px; overflow: auto; }
.sim-list { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 6px; }
.sim-list li button { width: 100%; text-align: left; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; font: inherit; color: var(--text); cursor: pointer; }
.sim-list li button:hover { border-color: var(--accent-line); }
.sim-list li button.active { border-color: var(--accent); }
.sim-list .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 2px; }
.sim-list .meta b { color: var(--money); }

.badge { display: inline-block; white-space: nowrap; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.off { background: var(--danger-soft); color: var(--danger); }
.badge.neutral { background: var(--surface-3); color: var(--muted); }
.badge.orange { background: var(--accent-soft); color: var(--accent-text); }

.toast { position: fixed; bottom: 86px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; z-index: 60; }

.print-only { display: none; }

@media (max-width: 640px) {
  h1 { font-size: 22px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .glossary { grid-template-columns: 1fr; }
  .stepper .name { display: none; }
  .user-chip { display: none; }
  .hero .value { font-size: 34px; }
  .nav-inner .count { display: none; }
  .brand-name { display: none; }
  .topbar-inner { gap: 4px; }
  .topbar .btn.sm { padding: 6px 8px; }
  .kpi .value { font-size: 18px; }
}

@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #f4f4f5; --surface-3: #e4e4e7; --text: #111; --muted: #555; --border: #ddd; color-scheme: light; }
  .topbar, .stepper, .nav-bar, .no-print, .btn, .drawer, .drawer-backdrop { display: none !important; }
  .wizard { padding: 0; max-width: none; }
  .card { break-inside: avoid; }
  .print-only { display: block; }
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Divisão do lucro (etapa 4) */
.split { padding: 14px 0; border-top: 1px solid var(--border); }
.split-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.split-bar { display: flex; height: 26px; border-radius: 8px; overflow: hidden; background: var(--surface-3); }
.split-bar .ads { background: var(--accent); }
.split-bar .keep { background: #cfd5dd; }
.split-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; font-size: 14px; }
.split-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }
.dot.ads { background: var(--accent); }
.dot.keep { background: #cfd5dd; }
.split-legend b { font-variant-numeric: tabular-nums; }

/* Como calcular (etapa 5) */
.how { background: var(--surface); }
.formula-box { background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--accent-text); font-weight: 700; border-radius: 10px; padding: 12px 14px; margin: 4px 0 10px; text-align: center; }

/* Empresa travada */
.locked-field { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; font-weight: 600; min-height: 46px; }
.locked-field .lock { font-size: 14px; opacity: .7; }

/* Rodapé de licença no PDF */
@media print {
  #license { position: fixed; bottom: 0; left: 0; right: 0; font-size: 10px; color: #555; text-align: center; border-top: 1px solid #ddd; padding-top: 4px; }
}

/* Aviso de trava (etapa 1, primeiro preenchimento) */
.lock-warning { display: flex; gap: 12px; background: #fff7ed; border: 1px solid var(--accent-line); border-left: 4px solid var(--accent); border-radius: 12px; padding: 14px 16px; margin-bottom: 18px; font-size: 14px; }
.lock-warning .lock-ico { font-size: 20px; line-height: 1; }
.lock-warning strong { color: var(--accent-text); font-size: 15px; }
.lock-warning p { margin: 4px 0 0; }

/* "Como calcular" recolhível (etapa 5) */
details.how { padding: 0; }
details.how summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; font-size: 15px; }
details.how summary::-webkit-details-marker { display: none; }
details.how summary b { color: var(--accent-text); }
details.how summary:hover { background: var(--surface-2); border-radius: var(--radius); }
details.how .chev { color: var(--accent-text); font-size: 20px; line-height: 1; transition: transform .2s; }
details.how[open] .chev { transform: rotate(180deg); }
details.how[open] summary { border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
details.how .how-body { padding: 16px 22px 20px; }
