:root {
  --vinho: #7a1f1f;
  --vinho-2: #9b2c2c;
  --vinho-claro: #fbeaea;
  --tinta: #1f2328;
  --texto: #3b4048;
  --sutil: #6b7280;
  --borda: #e3e5e8;
  --fundo: #f6f5f3;
  --card: #ffffff;
  --ok: #1f7a4d;
  --ok-bg: #e7f5ee;
  --aviso: #8a5a00;
  --aviso-bg: #fff4dc;
  --erro: #b42318;
  --erro-bg: #fdecea;
  --destaque: #7a1f1f;
  --raio: 14px;
  --sombra: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  --foco: 0 0 0 3px rgba(155,44,44,.25);
  --mix-0:#9b2c2c; --mix-1:#d98a2b; --mix-2:#c75b7a; --mix-3:#2b7bb9; --mix-4:#e0b93a; --mix-5:#7a5c99; --mix-6:#3f9a5f;
}
@media (prefers-color-scheme: dark) {
  :root {
    --tinta:#f1f2f4; --texto:#d4d7dc; --sutil:#9aa1ab; --borda:#30343b; --fundo:#141518; --card:#1d1f23;
    --vinho-claro:#3a1f1f; --ok-bg:#15301f; --aviso-bg:#33280f; --erro-bg:#3a1a17;
    --ok:#5fd09a; --aviso:#f0c060; --erro:#ff8a80; --destaque:#f0a3a3;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--texto); background: var(--fundo); line-height: 1.5; font-size: 16px;
}
h1, h2, h3, h4 { color: var(--tinta); line-height: 1.25; margin: 0 0 .5rem; }
h2 { font-size: 1.35rem; }
h2:focus { outline: none; }
h3 { font-size: 1.05rem; margin-top: 1.5rem; }
[hidden] { display: none !important; }
small { color: var(--sutil); }

/* ---------- topo ---------- */
.topo { background: var(--vinho); color: #fff; position: sticky; top: 0; z-index: 20; }
.topo-inner { max-width: 1180px; margin: 0 auto; padding: .7rem 16px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.marca { display: flex; align-items: center; gap: .6rem; }
.marca .logo { font-size: 1.6rem; }
.marca strong { display: block; font-size: 1rem; }
.marca small { color: #f3d6d6; font-size: .78rem; }
.topo-acoes { display: flex; align-items: center; gap: .5rem; }
.status-salvo { font-size: .8rem; color: #f3d6d6; white-space: nowrap; }
.status-salvo.erro { color: #ffd0cc; font-weight: 600; }
.topo .btn-ghost { color: #fff; border-color: rgba(255,255,255,.35); }
.topo .btn-ghost:hover { background: rgba(255,255,255,.12); }

/* ---------- botões ---------- */
.btn {
  font: inherit; font-weight: 600; border-radius: 10px; padding: .65rem 1.1rem; cursor: pointer;
  border: 1px solid transparent; transition: background .15s, transform .05s; text-decoration: none;
  display: inline-flex; align-items: center; gap: .35rem; min-height: 44px;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: none; box-shadow: var(--foco); }
.btn-primario { background: var(--vinho); color: #fff; }
.btn-primario:hover { background: var(--vinho-2); }
.btn-primario:disabled { opacity: .6; cursor: wait; }
.btn-secundario { background: var(--card); color: var(--destaque); border-color: var(--destaque); }
.btn-secundario:hover { background: var(--vinho-claro); }
.btn-ghost { background: transparent; color: var(--destaque); border-color: var(--borda); }
.btn-ghost:hover { background: var(--vinho-claro); }
.btn-grande { font-size: 1.1rem; padding: .9rem 1.6rem; }
.btn-peq { min-height: 34px; padding: .35rem .7rem; font-size: .85rem; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio); box-shadow: var(--sombra); padding: 1.5rem; }

/* ---------- início ---------- */
.inicio { max-width: 720px; margin: 2.5rem auto; padding: 0 16px; }
.hero h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
.lead { font-size: 1.08rem; }
.beneficios { list-style: none; padding: 0; margin: 1.2rem 0 1.6rem; display: grid; gap: .45rem; }
.continuar { margin-top: 1.2rem; padding: .9rem 1rem; background: var(--vinho-claro); border-radius: 10px; display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; }
.privacidade { font-size: .82rem; color: var(--sutil); margin-top: 1.5rem; }

/* ---------- layout do formulário ---------- */
.layout {
  max-width: 1180px; margin: 0 auto; padding: 1.25rem 16px 6rem;
  display: grid; grid-template-columns: minmax(0, 1fr) 260px; grid-template-areas: "step step" "form painel"; gap: 1.25rem;
}
.stepper { grid-area: step; }
#form { grid-area: form; min-width: 0; }
.painel { grid-area: painel; }

.stepper ol { list-style: none; padding: 0; margin: 0 0 .6rem; display: flex; gap: .4rem; overflow-x: auto; scrollbar-width: none; }
.stepper ol::-webkit-scrollbar { display: none; }
.stepper li {
  flex: 1 0 auto; display: flex; align-items: center; gap: .45rem; font-size: .88rem; font-weight: 500; color: var(--sutil);
  padding: .5rem .75rem; border-radius: 999px; cursor: pointer; white-space: nowrap; user-select: none;
}
.stepper li span {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; font-weight: 700;
  background: var(--borda); color: var(--texto);
}
.stepper li:hover { background: var(--card); }
.stepper li.atual { background: var(--card); color: var(--destaque); box-shadow: var(--sombra); }
.stepper li.atual span { background: var(--vinho); color: #fff; }
.stepper li.feito span { background: var(--ok); color: #fff; }
.progresso { height: 4px; background: var(--borda); border-radius: 4px; overflow: hidden; }
#barra-progresso { height: 100%; width: 0; background: var(--vinho); transition: width .3s ease; }

.etapa { animation: entra .25s ease; }
@keyframes entra { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .etapa { animation: none; } #barra-progresso { transition: none; } }
.ajuda { color: var(--sutil); margin-top: 0; }
.dica { font-size: .88rem; color: var(--sutil); background: var(--fundo); padding: .6rem .8rem; border-radius: 8px; }

/* ---------- campos ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.1rem; margin-top: 1rem; }
.col-2 { grid-column: 1 / -1; }
.campo { display: flex; flex-direction: column; gap: .35rem; font-weight: 500; font-size: .92rem; color: var(--tinta); border: 0; padding: 0; margin: 1.2rem 0 0; min-width: 0; }
.grid .campo { margin: 0; }
.campo legend { font-weight: 600; margin-bottom: .5rem; padding: 0; }
.obg { color: var(--erro); }
input[type=text], input[type=email], input[type=tel], input[type=number], select, textarea {
  font: inherit; font-size: 16px; color: var(--tinta); background: var(--card); border: 1px solid var(--borda); border-radius: 10px;
  padding: .6rem .75rem; min-height: 44px; width: 100%; transition: border-color .15s;
}
textarea { resize: vertical; min-height: 70px; }
input:hover, select:hover, textarea:hover { border-color: #c9ccd1; }
input:focus, select:focus, textarea:focus { border-color: var(--vinho-2); }
.invalido { border-color: var(--erro) !important; background: var(--erro-bg) !important; }
input[type=number] { -moz-appearance: textfield; }

/* ---------- tabela público ---------- */
.tabela-publico { border: 1px solid var(--borda); border-radius: 12px; overflow: hidden; margin-top: 1rem; }
.tp-head, .tp-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr .8fr; gap: .6rem; align-items: center; padding: .6rem .8rem; }
.tp-head { background: var(--fundo); font-size: .8rem; font-weight: 600; color: var(--sutil); text-transform: uppercase; letter-spacing: .03em; }
.tp-row { border-top: 1px solid var(--borda); }
.tp-row.inativo input[type=number] { opacity: .55; }
.tp-check { display: flex; align-items: center; gap: .55rem; font-weight: 600; color: var(--tinta); cursor: pointer; }
.tp-check input { width: 20px; height: 20px; accent-color: var(--vinho); }
.tp-kg { font-weight: 700; color: var(--destaque); text-align: right; font-variant-numeric: tabular-nums; }
.sr-mob { display: none; }

.totais-destaque, .resumo-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-top: 1.25rem; }
.totais-destaque > div, .resumo-kpis > div { background: var(--vinho-claro); border-radius: 12px; padding: .8rem 1rem; }
.totais-destaque small, .resumo-kpis small { display: block; font-size: .78rem; }
.totais-destaque strong, .resumo-kpis strong { font-size: 1.35rem; color: var(--destaque); font-variant-numeric: tabular-nums; }

/* ---------- mix ---------- */
.glossario { background: var(--fundo); border-radius: 10px; padding: .6rem .9rem; margin: .5rem 0 1rem; font-size: .9rem; }
.glossario summary { cursor: pointer; font-weight: 600; color: var(--destaque); }
.mix-lista { display: grid; gap: .6rem; }
.mix-item { border: 1px solid var(--borda); border-radius: 12px; padding: .75rem .9rem; transition: border-color .15s, background .15s; }
.mix-item.ativo { border-color: var(--vinho-2); background: var(--vinho-claro); }
.mix-topo { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.mix-nome { font-weight: 600; color: var(--tinta); }
.mix-pct { display: flex; align-items: center; gap: .6rem; flex: 1; justify-content: flex-end; min-width: 220px; }
.mix-pct input[type=range] { flex: 1; max-width: 260px; accent-color: var(--vinho); height: 28px; }
.pct-num { display: flex; align-items: center; gap: .25rem; font-weight: 600; }
.pct-num input { width: 80px; text-align: right; }
.mix-detalhe { display: none; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: center; margin-top: .6rem; }
.mix-item.ativo .mix-detalhe, .mix-item:focus-within .mix-detalhe { display: grid; }
.mix-cortes { min-height: 38px !important; padding: .4rem .6rem !important; font-size: .9rem !important; }
.mix-kg { font-size: .82rem; color: var(--sutil); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mix-kg b { color: var(--tinta); }

.mix-soma { position: sticky; bottom: 0; margin: 1rem -1.5rem 0; padding: .8rem 1.5rem; background: var(--card); border-top: 1px solid var(--borda); z-index: 5; }
.mix-barra { height: 10px; border-radius: 6px; background: var(--borda); display: flex; overflow: hidden; }
.mix-barra span { height: 100%; transition: width .2s; }
.seg-0{background:var(--mix-0)} .seg-1{background:var(--mix-1)} .seg-2{background:var(--mix-2)} .seg-3{background:var(--mix-3)} .seg-4{background:var(--mix-4)} .seg-5{background:var(--mix-5)} .seg-6{background:var(--mix-6)}
.mix-soma-txt { display: flex; align-items: center; gap: .8rem; margin-top: .5rem; flex-wrap: wrap; font-size: .92rem; }
.mix-soma.ok #mix-msg { color: var(--ok); font-weight: 600; }
.mix-soma.aviso #mix-msg { color: var(--aviso); font-weight: 600; }
.mix-soma.erro #mix-msg { color: var(--erro); font-weight: 600; }

/* ---------- segmentado / chips / rating ---------- */
.seg { display: inline-flex; border: 1px solid var(--borda); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.seg label { cursor: pointer; position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: .45rem .85rem; font-size: .88rem; font-weight: 500; border-right: 1px solid var(--borda); min-height: 38px; line-height: 1.6; background: var(--card); }
.seg label:last-child span { border-right: 0; }
.seg input:checked + span { background: var(--vinho); color: #fff; }
.seg input:focus-visible + span { box-shadow: inset var(--foco); }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: .5rem .9rem; border: 1px solid var(--borda); border-radius: 999px; cursor: pointer; font-size: .9rem; font-weight: 500;
  background: var(--card); color: var(--texto); transition: all .15s; min-height: 40px;
}
.chip span:hover { border-color: var(--vinho-2); }
.chip input:checked + span { background: var(--vinho); border-color: var(--vinho); color: #fff; }
.chip input:checked + span::before { content: "✓ "; }
.chip input:focus-visible + span { box-shadow: var(--foco); }

.ratings { display: grid; gap: .35rem; }
.rating { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .4rem 0; border-bottom: 1px dashed var(--borda); flex-wrap: wrap; }
.rating-label { font-weight: 500; font-size: .92rem; }
.rating-opts { display: flex; gap: .3rem; }
.rating-opts button {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--borda); background: var(--card); color: var(--texto);
  font: inherit; font-weight: 600; cursor: pointer; transition: all .12s;
}
.rating-opts button:hover { border-color: var(--vinho-2); }
.rating-opts button[aria-pressed=true] { background: var(--vinho); color: #fff; border-color: var(--vinho); }

/* ---------- navegação ---------- */
.nav-etapas { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1rem; }

/* ---------- painel ---------- */
.painel { position: sticky; top: 80px; align-self: start; background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio); padding: 1.1rem; box-shadow: var(--sombra); }
.painel h3 { margin: 0 0 .6rem; font-size: .95rem; }
.painel dl { display: grid; grid-template-columns: 1fr auto; gap: .45rem .5rem; margin: 0; }
.painel dt { color: var(--sutil); font-size: .88rem; }
.painel dd { margin: 0; font-weight: 700; color: var(--tinta); text-align: right; font-variant-numeric: tabular-nums; }
.painel dd.ok { color: var(--ok); }
.painel dd.aviso { color: var(--aviso); }
.painel-nota { font-size: .75rem; color: var(--sutil); margin: .8rem 0 0; }

/* ---------- resumo ---------- */
.resumo-bloco { border-top: 1px solid var(--borda); padding: 1rem 0 .3rem; margin-top: 1rem; }
.resumo-bloco h4 { display: flex; justify-content: space-between; align-items: center; }
.link-editar { background: none; border: 0; color: var(--destaque); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; text-decoration: underline; }
.tabela-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--borda); }
th { color: var(--sutil); font-weight: 600; font-size: .8rem; }
td.ok, th.ok { color: var(--ok); } td.erro, th.erro { color: var(--erro); }
.nota { font-size: .82rem; color: var(--sutil); }
.alerta { border-radius: 10px; padding: .8rem 1rem; margin: 1rem 0; }
.alerta.erro { background: var(--erro-bg); color: var(--erro); }
.alerta ul { margin: .4rem 0 0; padding-left: 1.2rem; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal-card { background: var(--card); border-radius: 18px; padding: 2rem 1.5rem; max-width: 520px; width: 100%; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.sucesso-icone { width: 64px; height: 64px; margin: 0 auto 1rem; border-radius: 50%; background: var(--ok-bg); color: var(--ok); display: grid; place-items: center; font-size: 2rem; font-weight: 700; }
.link-box { display: flex; gap: .5rem; margin: 1rem 0; }
.link-box input { flex: 1; font-size: .85rem !important; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--tinta); color: var(--card); padding: .75rem 1.1rem; border-radius: 10px; font-size: .92rem; z-index: 60;
  transition: all .25s; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: #1f7a4d; color: #fff; }
.toast.erro { background: #b42318; color: #fff; }

/* ---------- responsivo ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; grid-template-areas: "step" "painel" "form"; }
  .painel { position: sticky; top: 62px; z-index: 10; padding: .6rem .9rem; }
  .painel h3, .painel-nota { display: none; }
  .painel dl { grid-template-columns: repeat(4, auto); gap: 0 .9rem; }
  .painel dt { font-size: .7rem; grid-row: 1; }
  .painel dd { grid-row: 2; text-align: left; font-size: .95rem; }
}
@media (max-width: 640px) {
  .card { padding: 1.1rem; }
  .mix-soma { margin: 1rem -1.1rem 0; padding: .8rem 1.1rem; }
  .grid { grid-template-columns: 1fr; }
  .topo-acoes .btn span { display: none; }
  .status-salvo { font-size: .72rem; }
  .marca small { display: none; }
  .tp-head { display: none; }
  .tp-row { grid-template-columns: 1fr 1fr 1fr; gap: .5rem; }
  .tp-check { grid-column: 1 / 3; }
  .tp-kg { grid-column: 3; grid-row: 1; }
  .tp-kg::after { content: " kg/dia"; font-weight: 500; font-size: .75rem; color: var(--sutil); }
  .sr-mob { display: block; font-size: .72rem; color: var(--sutil); }
  .totais-destaque, .resumo-kpis { gap: .4rem; }
  .totais-destaque > div, .resumo-kpis > div { padding: .6rem; }
  .totais-destaque strong, .resumo-kpis strong { font-size: 1.05rem; }
  .mix-pct { min-width: 0; width: 100%; }
  .mix-detalhe { grid-template-columns: 1fr; }
  .rating { flex-direction: column; align-items: flex-start; gap: .3rem; }
  .rating-opts button { width: 48px; }
  .nav-etapas .btn { flex: 1; justify-content: center; }
  .stepper li { font-size: 0; gap: 0; padding: .4rem; justify-content: center; }
  .stepper li.atual { font-size: .82rem; gap: .4rem; }
}

/* ---------- admin ---------- */
.admin { max-width: 1280px; margin: 1.5rem auto; padding: 0 16px; }
.admin-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin: 1rem 0; }
.admin-kpis div { background: var(--card); border: 1px solid var(--borda); border-radius: 12px; padding: .8rem 1rem; }
.admin-kpis strong { display: block; font-size: 1.4rem; color: var(--destaque); }
.admin-acoes { display: flex; gap: .5rem; flex-wrap: wrap; margin: .5rem 0 1rem; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge.enviado { background: var(--ok-bg); color: var(--ok); }
.badge.rascunho { background: var(--aviso-bg); color: var(--aviso); }
