/* Forja — carvão, brasa e aço. Escuro por padrão; claro quando o aparelho pede. */
:root {
  --bg: #100d0b;
  --bg2: #17120f;
  --card: #1c1612;
  --card2: #241c17;
  --text: #f5eee7;
  --muted: #a8998b;
  --line: #2f2620;
  --primary: #ff6a1a;          /* brasa */
  --primary-2: #ffb347;        /* ouro */
  --primary-ink: #1a0c03;
  --primary-soft: #3a1d0d;
  --aco: #d9cfc4;
  --prot: #5fb2ff;
  --carb: #ffb347;
  --gord: #ff6f9c;
  --ok: #4ade80;
  --ok-soft: #10301d;
  --bad: #ff5a5a;
  --bad-soft: #3d1414;
  --warn: #fbbf24;
  --warn-soft: #3a2a08;
  --radius: 16px;
  --brasa: linear-gradient(135deg, #ff4d0d, #ff8a1f 55%, #ffc94a);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f2ec;
    --bg2: #efe7de;
    --card: #ffffff;
    --card2: #f8f3ee;
    --text: #221a14;
    --muted: #7a6b5e;
    --line: #e6dcd1;
    --primary: #e2550c;
    --primary-2: #c97a10;
    --primary-ink: #ffffff;
    --primary-soft: #ffe7d6;
    --aco: #5b5048;
    --prot: #1f6fd1;
    --carb: #c97a10;
    --gord: #d23d72;
    --ok: #15803d;
    --ok-soft: #dcfce7;
    --bad: #dc2626;
    --bad-soft: #fee2e2;
    --warn: #a16207;
    --warn-soft: #fef3c7;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 800; }
h2 { font-size: 1.05rem; margin: 1.5rem 0 .6rem; font-weight: 700; }
h2.secao { text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; color: var(--muted); }
p { margin: .25rem 0 .75rem; }
small, .muted { color: var(--muted); }
strong.brasa, .brasa-txt { background: var(--brasa); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* topo com a marca */
.topo { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.topo img { width: 34px; height: 34px; border-radius: 10px; }
.topo .marca { font-weight: 900; letter-spacing: .18em; font-size: .95rem; }
.topo .grow { flex: 1; }

.view { max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 14px) 16px calc(96px + env(safe-area-inset-bottom)); }
.loading { padding: 3rem 0; text-align: center; color: var(--muted); }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: center;
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; max-width: 130px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 7px; font-size: .7rem; color: var(--muted); text-decoration: none; font-weight: 600;
}
.tabbar svg { width: 23px; height: 23px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--primary); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.card.destaque { background: linear-gradient(160deg, var(--primary-soft), var(--card) 70%); border-color: color-mix(in srgb, var(--primary) 35%, var(--line)); }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }

button, .btn {
  font: inherit; border: 1px solid var(--line); background: var(--card2); color: var(--text);
  border-radius: 12px; padding: 10px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button.primary, .btn.primary { background: var(--brasa); border-color: transparent; color: #1a0c03; font-weight: 700; }
button.bad { color: var(--bad); border-color: var(--bad-soft); background: transparent; }
button.ok { color: var(--ok); border-color: var(--ok-soft); background: transparent; }
button.ghost { border-color: transparent; background: transparent; color: var(--primary); padding: 6px 8px; font-weight: 600; }
button.small { padding: 6px 10px; font-size: .86rem; }
button.full { width: 100%; }
button:disabled { opacity: .5; cursor: default; }
.iconbtn { width: 40px; height: 40px; padding: 0; border-radius: 50%; font-size: 1.2rem; }

label { display: block; font-size: .85rem; color: var(--muted); margin: 12px 0 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg2);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 10px; }
.ajuda { font-size: .8rem; color: var(--muted); margin-top: 4px; }

/* opções em cartão (anamnese) */
.opcoes { display: grid; gap: 8px; }
.opcoes.duas { grid-template-columns: 1fr 1fr; }
.opcao { display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); cursor: pointer; margin: 0; color: var(--text); font-size: .95rem; }
.opcao input { width: auto; margin: 3px 0 0; accent-color: var(--primary); }
.opcao:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.opcao small { display: block; }

.passos { display: flex; gap: 5px; margin: 4px 0 16px; }
.passos i { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.passos i.on { background: var(--brasa); }

/* dia */
.daynav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.daynav h1 { margin: 0; text-align: center; font-size: 1.15rem; }
.daynav h1 small { display: block; font-weight: 400; font-size: .8rem; }

.resumo { display: flex; align-items: center; gap: 16px; }
.anel { position: relative; width: 112px; height: 112px; flex: none; }
.anel svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.anel .num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.anel .num strong { font-size: 1.35rem; }
.anel .num small { font-size: .72rem; }
.macros { flex: 1; min-width: 0; }
.macro { margin: 4px 0 8px; font-size: .85rem; }
.macro .lbl { display: flex; justify-content: space-between; }
.bar { height: 7px; background: var(--line); border-radius: 9px; overflow: hidden; margin-top: 3px; }
.bar i { display: block; height: 100%; border-radius: 9px; background: var(--brasa); }
.bar.prot i { background: var(--prot); } .bar.carb i { background: var(--carb); } .bar.gord i { background: var(--gord); }
.bar.over i { background: var(--bad); }

.refeicao h3 { font-size: 1rem; margin: 0; }
.refeicao .head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); cursor: pointer; }
.refeicao .head + .item, .card > .item:first-child { border-top: 0; }
.item .nm { flex: 1; min-width: 0; }
.item .nm div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .nm small { font-size: .8rem; }
.item .kc { font-weight: 700; white-space: nowrap; }
.empty { color: var(--muted); font-size: .9rem; padding: 6px 0 2px; }

/* revisão do cardápio */
.rev { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.rev .nm { flex: 1; min-width: 0; }
.rev .nm small { display: block; font-size: .78rem; }
.rev .acoes { display: flex; gap: 6px; flex: none; }
.rev .acoes button { width: 38px; height: 38px; padding: 0; border-radius: 10px; font-size: 1.05rem; }
.rev.aprovado .nm div::before { content: "✓ "; color: var(--ok); font-weight: 800; }
.rev.reprovado .nm div { text-decoration: line-through; color: var(--muted); }
.rev.aprovado button[data-st="aprovado"] { background: var(--ok-soft); border-color: var(--ok); }
.rev.reprovado button[data-st="reprovado"] { background: var(--bad-soft); border-color: var(--bad); }
.refeicao.toda-aprovada { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.chips button { flex: none; border-radius: 999px; padding: 7px 13px; font-size: .88rem; }
.chips button.on { background: var(--brasa); color: #1a0c03; border-color: transparent; font-weight: 700; }

.tag { display: inline-block; font-size: .7rem; padding: 2px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-weight: 700; vertical-align: middle; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.cinza { background: var(--line); color: var(--muted); }
.aviso { border-left: 3px solid var(--warn); background: var(--warn-soft); padding: 10px 12px; border-radius: 10px; font-size: .9rem; margin-bottom: 10px; }
.aviso.info { border-color: var(--primary); background: var(--primary-soft); }

/* números */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stats strong { display: block; font-size: 1.25rem; }
.stats small { font-size: .74rem; }
.grafico svg { width: 100%; height: auto; display: block; }
.grafico text { fill: var(--muted); font-size: 10px; }
table.tab { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.tab td { padding: 8px 4px; border-top: 1px solid var(--line); vertical-align: top; }
table.tab tr.escolhido td { color: var(--primary); font-weight: 700; }
table.tab td:last-child { text-align: right; white-space: nowrap; }

/* fotos */
.fotos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.foto { aspect-ratio: 3/4; border: 1.5px dashed var(--line); border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); font-size: .8rem; cursor: pointer; overflow: hidden; position: relative; background: var(--bg2); margin: 0; }
.foto img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.foto span.pos { position: absolute; bottom: 6px; left: 6px; background: rgba(0,0,0,.6); color: #fff; border-radius: 6px; padding: 1px 6px; font-size: .72rem; }
.foto input { display: none; }
.foto .mais { font-size: 1.6rem; line-height: 1; color: var(--primary); }

/* treinos */
.sessao { display: flex; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); cursor: pointer; align-items: flex-start; }
.sessao:first-of-type { border-top: 0; }
.sessao .dia { width: 44px; flex: none; text-align: center; line-height: 1.1; }
.sessao .dia strong { display: block; font-size: 1.15rem; }
.sessao .dia small { font-size: .7rem; text-transform: uppercase; }
.sessao.feito .dia strong { color: var(--ok); }
.sessao.hoje { background: var(--primary-soft); margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.sessao .nm { flex: 1; min-width: 0; }
.sessao .nm small { display: block; font-size: .8rem; }
.check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: flex; align-items: center; justify-content: center; font-size: .85rem; }
.sessao.feito .check { background: var(--ok); border-color: var(--ok); color: #052e16; }
.zonas { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: .9rem; }
.zonas b { text-align: right; }

/* modal */
dialog {
  border: 0; border-radius: 20px 20px 0 0; padding: 0; width: 100%; max-width: 640px;
  margin: auto auto 0; max-height: 92vh; background: var(--card); color: var(--text);
}
@media (min-width: 700px) { dialog { border-radius: 20px; margin: auto; } }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; position: sticky; top: 0; background: var(--card); z-index: 1; }
.modal-head h3 { margin: 0; font-size: 1.1rem; }
.modal-head .x { border: 0; background: transparent; font-size: 1.7rem; line-height: 1; padding: 0 4px; color: var(--muted); }
.modal-body { padding: 0 16px calc(16px + env(safe-area-inset-bottom)); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

.busca { position: sticky; top: 50px; background: var(--card); padding-bottom: 8px; z-index: 1; }
.lista-alim { margin: 0; padding: 0; list-style: none; }
.lista-alim li { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-top: 1px solid var(--line); cursor: pointer; }
.lista-alim li:hover { background: var(--bg2); }
.lista-alim .grupo { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); cursor: default; padding-top: 14px; border-top: 0; }
.prev { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; gap: 6px; background: var(--bg2); border-radius: 12px; padding: 10px 6px; margin-top: 12px; }
.prev strong { display: block; font-size: 1.05rem; }
.prev small { font-size: .72rem; }

.toast {
  position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: #2a211b; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: .92rem; border: 1px solid #3d3027;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 20; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.carregando { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 2.5rem 0; color: var(--muted); text-align: center; }
.carregando .chama { width: 46px; height: 46px; border-radius: 50%; background: var(--brasa); animation: pulsa 1.1s ease-in-out infinite; }
@keyframes pulsa { 50% { transform: scale(.82); opacity: .6; } }

/* login */
.login { max-width: 380px; margin: 7vh auto 0; }
.login .logo { width: 92px; height: 92px; display: block; margin: 0 auto 14px; border-radius: 22px; box-shadow: 0 10px 40px rgba(255, 106, 26, .25); }
.login h1 { text-align: center; font-size: 2rem; letter-spacing: .22em; font-weight: 900; margin-bottom: 2px; }
.login .lema { text-align: center; color: var(--muted); margin-bottom: 4px; }
.tabs2 { display: flex; background: var(--bg2); border-radius: 12px; padding: 4px; margin: 18px 0 8px; }
.tabs2 button { flex: 1; border: 0; background: transparent; }
.tabs2 button.on { background: var(--card2); font-weight: 700; color: var(--primary); }
