* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --verde: #2e7d32;
  --verde-claro: #4caf50;
  --fundo: #f5f5f5;
  --branco: #ffffff;
  --cinza-claro: #eeeeee;
  --cinza: #9e9e9e;
  --texto: #212121;
  --perigo: #c62828;
  --nav-altura: 65px;
  --cabecalho-altura: 56px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--fundo);
  color: var(--texto);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- UTILITÁRIOS ---- */
.oculto { display: none !important; }
.erro { color: var(--perigo); font-size: 0.875rem; margin-top: 8px; min-height: 20px; }
.opcional { font-size: 0.75rem; color: var(--cinza); font-weight: normal; }
.status-msg { font-size: 0.8rem; color: var(--cinza); margin-top: 4px; min-height: 18px; }

/* ---- TELA LOGIN ---- */
#tela-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--verde);
}

.login-box {
  background: var(--branco);
  border-radius: 16px;
  padding: 40px 32px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.login-logo {
  font-size: 3rem;
  margin-bottom: 12px;
}

.login-box h1 {
  font-size: 1.5rem;
  color: var(--verde);
  margin-bottom: 28px;
}

.login-box input {
  display: block;
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 12px;
  border: 1.5px solid var(--cinza-claro);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s;
}

.login-box input:focus {
  outline: none;
  border-color: var(--verde-claro);
}

/* ---- APP ---- */
#tela-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- BARRA SUPERIOR ---- */
#barra-usuario {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 32px;
  background: var(--verde);
  color: rgba(255,255,255,0.92);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 16px;
  font-size: 0.75rem;
  font-weight: 500;
  z-index: 90;
  letter-spacing: 0.01em;
}

/* ---- NAVEGAÇÃO INFERIOR ---- */
#nav-app {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-altura);
  background: var(--branco);
  border-top: 1px solid var(--cinza-claro);
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--cinza);
  font-size: 0.7rem;
  padding: 8px 4px;
  transition: color 0.2s;
}

.nav-btn.ativo {
  color: var(--verde);
}

.nav-icon {
  font-size: 1.4rem;
}

/* ---- SEÇÕES ---- */
.secao {
  flex: 1;
  padding: 16px;
  padding-top: calc(32px + 16px);
  padding-bottom: calc(var(--nav-altura) + 16px);
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

.cabecalho {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-top: 8px;
}

.cabecalho h2 {
  font-size: 1.5rem;
  color: var(--verde);
}

.cabecalho-acoes {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ---- LISTA DE RECEITAS ---- */
.lista {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-receita {
  background: var(--branco);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  transition: box-shadow 0.2s, transform 0.1s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-receita:active {
  transform: scale(0.98);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.card-receita h3 {
  font-size: 1rem;
  font-weight: 600;
}

.card-receita .subtexto {
  font-size: 0.8rem;
  color: var(--cinza);
}

.vazio {
  text-align: center;
  color: var(--cinza);
  padding: 48px 16px;
  font-size: 0.95rem;
}

/* ---- DETALHE RECEITA ---- */
#conteudo-detalhe h2 {
  font-size: 1.4rem;
  margin-bottom: 16px;
  color: var(--verde);
}

#conteudo-detalhe .secao-titulo {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cinza);
  margin: 20px 0 8px;
}

.ingrediente-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--cinza-claro);
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
}

.ingrediente-item .qtd {
  color: var(--cinza);
  font-size: 0.85rem;
}

.instrucoes-texto {
  font-size: 0.95rem;
  line-height: 1.7;
  white-space: pre-wrap;
  background: var(--branco);
  border-radius: 8px;
  padding: 16px;
}

/* ---- FORMULÁRIO ---- */
.form-grupo {
  margin-bottom: 20px;
}

.form-grupo label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--texto);
}

.form-grupo input,
.form-grupo textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--cinza-claro);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--branco);
  transition: border-color 0.2s;
}

.form-grupo input:focus,
.form-grupo textarea:focus {
  outline: none;
  border-color: var(--verde-claro);
}

.input-com-botao {
  display: flex;
  gap: 8px;
}

.input-com-botao input {
  flex: 1;
}

/* ---- LINHA DE INGREDIENTE NO FORM ---- */
.linha-ingrediente {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  align-items: center;
}

.linha-ingrediente .input-nome {
  flex: 3;
}

.linha-ingrediente .input-qtd {
  flex: 1.5;
}

.linha-ingrediente .input-unidade {
  flex: 1.5;
}

.linha-ingrediente .btn-remover {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--cinza-claro);
  color: var(--cinza);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* ---- CARDÁPIO ---- */
.card-dia {
  background: var(--branco);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.card-dia .dia-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--verde);
  margin-bottom: 6px;
}

.card-dia .receita-nome {
  font-size: 1rem;
  font-weight: 600;
}

.card-dia .sem-receita {
  color: var(--cinza);
  font-size: 0.9rem;
  font-style: italic;
}

#btn-confirmar-cardapio {
  margin-top: 20px;
}

/* ---- LISTA DE COMPRAS ---- */
.item-compra {
  background: var(--branco);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: opacity 0.2s;
}

.item-compra.riscado {
  opacity: 0.45;
  text-decoration: line-through;
}

.item-compra input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--verde);
  cursor: pointer;
  flex-shrink: 0;
}

.item-compra .nome-ingrediente {
  flex: 1;
  font-size: 0.95rem;
}

.item-compra .qtd-ingrediente {
  font-size: 0.85rem;
  color: var(--cinza);
}

.categoria-compra {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cinza);
  padding: 12px 4px 4px;
}

/* ---- BOTÕES ---- */
.btn-primary {
  background: var(--verde);
  color: var(--branco);
  border: none;
  border-radius: 8px;
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:active { background: var(--verde-claro); }

.btn-secundario {
  background: var(--cinza-claro);
  color: var(--texto);
  border: none;
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-secundario:active { background: #e0e0e0; }

.btn-perigo {
  background: none;
  color: var(--perigo);
  border: 1.5px solid var(--perigo);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-voltar {
  background: none;
  border: none;
  color: var(--verde);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 0;
  font-weight: 600;
}

.btn-fab {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--verde);
  color: var(--branco);
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(46,125,50,0.3);
}

.btn-full { width: 100%; }

/* ---- SPINNER ---- */
.spinner {
  text-align: center;
  padding: 32px;
  color: var(--cinza);
  font-size: 0.9rem;
}

/* ---- HISTÓRICO ---- */
.historico {
  margin-top: 24px;
}

.historico-titulo {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cinza);
  margin-bottom: 8px;
}

.historico-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--cinza);
  padding: 7px 0;
  border-bottom: 1px solid var(--cinza-claro);
}

.historico-item:last-child { border-bottom: none; }

.historico-nome {
  font-weight: 600;
  color: var(--texto);
}

.historico-detalhe {
  color: var(--cinza);
}

.historico-tempo {
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--cinza);
}

/* ---- BUSCA RÁPIDA ---- */
.busca-rapida {
  display: block;
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 14px;
  border: 1.5px solid var(--cinza-claro);
  border-radius: 24px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--branco);
  transition: border-color 0.2s;
}

.busca-rapida:focus {
  outline: none;
  border-color: var(--verde-claro);
}

/* ---- CARD DIA: layout com botão trocar ---- */
.dia-receita {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.btn-trocar-dia {
  background: none;
  border: 1px solid var(--cinza-claro);
  color: var(--cinza);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.75rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}

.btn-trocar-dia:active {
  border-color: var(--verde);
  color: var(--verde);
}

/* ---- ÁREA DE COLAR (OCR) ---- */
.area-colar {
  border: 2px dashed var(--cinza-claro);
  border-radius: 8px;
  padding: 20px 16px;
  text-align: center;
  color: var(--cinza);
  font-size: 0.88rem;
  line-height: 1.5;
  cursor: pointer;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s;
}

.area-colar:focus {
  outline: none;
  border-color: var(--verde-claro);
}

.area-colar.processando {
  border-color: var(--verde-claro);
}

.ocr-log-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--cinza-claro);
  border-radius: 8px;
  font-size: 0.78rem;
  font-family: monospace;
  background: var(--fundo);
  color: var(--texto);
  resize: vertical;
  margin-top: 8px;
  line-height: 1.5;
}

#ocr-preview {
  max-width: 100%;
  max-height: 180px;
  border-radius: 6px;
  object-fit: contain;
}

/* ---- MODAL BOTTOM SHEET ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: flex;
  align-items: flex-end;
}

.modal-sheet {
  background: var(--branco);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--cinza-claro);
  flex-shrink: 0;
}

.modal-titulo {
  font-weight: 700;
  font-size: 1rem;
}

.btn-fechar-modal {
  background: none;
  border: none;
  color: var(--cinza);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.modal-lista {
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
}

.modal-item {
  padding: 14px 20px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.15s;
  border-bottom: 1px solid var(--cinza-claro);
}

.modal-item:last-child { border-bottom: none; }

.modal-item:active { background: var(--cinza-claro); }

.modal-item.ativo {
  color: var(--verde);
  font-weight: 600;
}

.modal-item-vazio {
  color: var(--cinza);
  font-style: italic;
}
