*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:           #f4efe6;
  --superficie:   #fffdf8;
  --superficie2:  #fff8ee;
  --borda:        #ddd5c4;
  --borda-suave:  #ece6d8;

  --destaque:       #c8522a;
  --destaque-escuro:#a33e1c;
  --destaque-claro: #fbeee8;

  --verde:        #3a7d44;
  --verde-escuro: #2c6035;

  --ouro:         #d4a017;
  --ouro-claro:   #fdf4db;

  --texto:        #2a1f10;
  --texto-suave:  #8a7a65;
  --texto-claro:  #b5a898;

  --sombra:       0 4px 28px rgba(42,31,16,.11);
  --sombra-sm:    0 2px 10px rgba(42,31,16,.07);
  --sombra-lg:    0 10px 40px rgba(42,31,16,.16);

  --raio:         18px;
  --raio-sm:      10px;
  --raio-xs:      7px;

  --transicao:    0.18s ease;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--texto);
  min-height: 100vh;
  padding: 0;
  overflow-x: hidden;
}

.bg-blobs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.45;
}

.blob-1 {
  width: 520px; height: 520px;
  background: radial-gradient(circle, #e9d5bc 0%, transparent 70%);
  top: -160px; left: -160px;
}

.blob-2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #d4e9c8 0%, transparent 70%);
  bottom: 40px; right: -120px;
}

.blob-3 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, #f5d8c8 0%, transparent 70%);
  top: 50%; left: 60%;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 44px 20px 90px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 8px;
}

.header-icon {
  font-size: 3.2rem;
  animation: flutuar 3.5s ease-in-out infinite;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 8px rgba(200,82,42,.25));
}

@keyframes flutuar {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%       { transform: translateY(-8px) rotate(2deg); }
}

.header-texto h1 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.9rem, 5vw, 3rem);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.header-texto h1 span { color: var(--destaque); }

.header-texto p {
  color: var(--texto-suave);
  font-size: 0.92rem;
  font-weight: 300;
  margin-top: 5px;
}

.card {
  background: var(--superficie);
  border: 1.5px solid var(--borda);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  overflow: hidden;
}

.card-titulo {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--texto);
}

.card-titulo-icone {
  width: 28px; height: 28px;
  background: var(--destaque-claro);
  color: var(--destaque);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-style: normal;
}

.form-card { padding: 24px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  margin-top: 18px;
  align-items: end;
}

.campo {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--texto-suave);
}

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--borda);
  border-radius: var(--raio-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.94rem;
  color: var(--texto);
  background: var(--bg);
  transition: all var(--transicao);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

input:focus {
  border-color: var(--destaque);
  background: white;
  box-shadow: 0 0 0 3px rgba(200,82,42,.13);
}

input::placeholder { color: var(--texto-claro); }

.campo-qtd { min-width: 120px; }
.campo-preco { min-width: 130px; }

.qtd-controle {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--borda);
  border-radius: var(--raio-sm);
  overflow: hidden;
  background: var(--bg);
  transition: all var(--transicao);
}

.qtd-controle:focus-within {
  border-color: var(--destaque);
  background: white;
  box-shadow: 0 0 0 3px rgba(200,82,42,.13);
}

.qtd-btn {
  width: 34px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--destaque);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transicao);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.qtd-btn:hover { background: var(--destaque-claro); }
.qtd-btn:active { background: #f5d5c8; }

.qtd-controle input[type="number"] {
  flex: 1;
  border: none;
  background: transparent;
  text-align: center;
  padding: 11px 4px;
  font-weight: 600;
  box-shadow: none;
  min-width: 0;
}

.qtd-controle input[type="number"]:focus {
  box-shadow: none;
  background: transparent;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
input[type="number"] { -moz-appearance: textfield; }

.form-rodape {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--raio-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transicao);
  white-space: nowrap;
  user-select: none;
}

.btn-adicionar {
  background: var(--destaque);
  color: white;
  padding: 12px 26px;
  box-shadow: 0 4px 14px rgba(200,82,42,.35);
  font-size: 0.93rem;
}

.btn-adicionar:hover {
  background: var(--destaque-escuro);
  transform: translateY(-2px);
  box-shadow: 0 7px 18px rgba(200,82,42,.42);
}

.btn-adicionar:active { transform: translateY(0); }

.btn-sm {
  padding: 6px 11px;
  font-size: 0.8rem;
  border-radius: var(--raio-xs);
}

.btn-editar {
  background: var(--superficie2);
  color: var(--texto-suave);
  border: 1.5px solid var(--borda);
}
.btn-editar:hover { background: var(--ouro-claro); color: var(--ouro); border-color: var(--ouro); }

.btn-salvar {
  background: var(--verde);
  color: white;
  box-shadow: 0 2px 8px rgba(58,125,68,.3);
}
.btn-salvar:hover { background: var(--verde-escuro); }

.btn-cancelar {
  background: var(--superficie2);
  color: var(--texto-suave);
  border: 1.5px solid var(--borda);
}
.btn-cancelar:hover { background: #fde8e8; color: #c0392b; border-color: #c0392b; }

.btn-remover {
  background: #fde8e8;
  color: #c0392b;
  border: 1.5px solid #f5c6c6;
}
.btn-remover:hover { background: #c0392b; color: white; border-color: #c0392b; }

.btn-limpar {
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.75);
  border: 1px solid rgba(255,255,255,.2);
  padding: 9px 16px;
  font-size: 0.82rem;
}
.btn-limpar:hover { background: rgba(192,57,43,.75); color: white; border-color: transparent; }

.lista-cabecalho {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1.5px solid var(--borda-suave);
  background: var(--superficie2);
}

.badge {
  background: var(--destaque-claro);
  color: var(--destaque);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 0.03em;
}

.estado-vazio {
  text-align: center;
  padding: 60px 24px;
  color: var(--texto-suave);
}

.icone-vazio {
  font-size: 3.8rem;
  margin-bottom: 14px;
  opacity: 0.4;
  display: block;
  animation: balanco 4s ease-in-out infinite;
}

@keyframes balanco {
  0%,100% { transform: rotate(-5deg); }
  50%      { transform: rotate(5deg); }
}

.estado-vazio p {
  font-size: 0.93rem;
  font-weight: 300;
  line-height: 1.6;
}

.col-cabecalhos {
  display: flex;
  align-items: center;
  padding: 9px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--borda-suave);
  gap: 8px;
}

.col-cabecalhos span {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--texto-claro);
}

.ch-num      { width: 28px; flex-shrink: 0; }
.ch-nome     { flex: 1; }
.ch-qtd      { width: 90px; text-align: center; }
.ch-subtotal { width: 90px; text-align: right; }
.ch-acoes    { width: 88px; }

.lista-itens { list-style: none; }

.item {
  animation: entrar 0.26s cubic-bezier(.23,1,.32,1);
  border-bottom: 1px solid var(--borda-suave);
  transition: background var(--transicao);
}

.item:last-child { border-bottom: none; }
.item:hover:not(.editando) { background: var(--superficie2); }

@keyframes entrar {
  from { opacity: 0; transform: translateX(-14px); }
  to   { opacity: 1; transform: translateX(0); }
}

.item-visualizacao {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 24px;
}

.item-numero {
  width: 28px; height: 28px;
  background: var(--destaque-claro);
  color: var(--destaque);
  border-radius: 50%;
  font-size: 0.74rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.item-info {
  flex: 1;
  min-width: 0;
}

.item-nome {
  font-weight: 500;
  font-size: 0.96rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-qtd-wrap {
  width: 90px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.item-qtd-ctrl {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--borda);
  border-radius: 7px;
  overflow: hidden;
  background: var(--bg);
}

.item-qtd-ctrl button {
  width: 26px; height: 28px;
  border: none;
  background: transparent;
  color: var(--destaque);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transicao);
  display: flex;
  align-items: center;
  justify-content: center;
}

.item-qtd-ctrl button:hover { background: var(--destaque-claro); }

.item-qtd-ctrl .qtd-exibicao {
  min-width: 28px;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0 2px;
  color: var(--texto);
}

.item-subtotal {
  width: 90px;
  flex-shrink: 0;
  text-align: right;
  font-weight: 700;
  font-size: 0.97rem;
  color: var(--verde);
}

.item-preco-unit {
  font-size: 0.72rem;
  color: var(--texto-claro);
  font-weight: 400;
  display: block;
  margin-top: 1px;
}

.item-acoes {
  width: 88px;
  flex-shrink: 0;
  display: flex;
  gap: 5px;
  justify-content: flex-end;
}

.item.editando { background: #fffbf0; }

.item-edicao {
  display: none;
  padding: 12px 24px;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.item-edicao .campos-edicao {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
  align-items: end;
}

.item-edicao .campo-edicao {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.item-edicao .campo-edicao.ef-nome  { flex: 1; min-width: 130px; }
.item-edicao .campo-edicao.ef-qtd   { width: 80px; }
.item-edicao .campo-edicao.ef-preco { width: 110px; }

.item-edicao label { font-size: 0.68rem; }

.item-edicao input {
  padding: 8px 10px;
  font-size: 0.88rem;
  border-radius: 7px;
}

.item-edicao .acoes-edicao {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.barra-total {
  background: var(--texto);
  border-radius: var(--raio);
  padding: 20px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--sombra-lg);
  gap: 12px;
}

.total-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.total-rotulo {
  color: rgba(255,255,255,.55);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.total-resumo {
  color: rgba(255,255,255,.4);
  font-size: 0.78rem;
  font-weight: 300;
  font-style: italic;
}

.total-direita {
  display: flex;
  align-items: center;
  gap: 14px;
}

.total-valor {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 900;
  color: white;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(90px);
  background: var(--texto);
  color: white;
  padding: 12px 24px;
  border-radius: 50px;
  font-size: 0.86rem;
  font-weight: 500;
  box-shadow: 0 8px 28px rgba(0,0,0,.28);
  transition: transform 0.32s cubic-bezier(.34,1.56,.64,1);
  z-index: 999;
  white-space: nowrap;
  pointer-events: none;
}

.toast.visivel {
  transform: translateX(-50%) translateY(0);
}

@keyframes sacudir {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-7px); }
  40%      { transform: translateX(7px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

.sacudir { animation: sacudir 0.38s ease; }


 /* --- CORREÇÃO DO LAYOUT MOBILE --- */

  @media (max-width: 600px) {
  /* Mantém as configurações do formulário de inserção */
  .form-grid { grid-template-columns: 1fr 1fr; }
  .campo-nome  { grid-column: 1 / -1; }
  .campo-preco { grid-column: 1 / -1; }
  .col-cabecalhos { display: none !important; }

  /* 1. Ajuste do Item: Agora focado apenas em Nome e Preço */
  .item-visualizacao { 
    display: flex !important; 
    align-items: center; 
    justify-content: space-between;
    padding: 14px 12px;
    gap: 12px;
  }

  /* REMOVE O NÚMERO (ÍNDICE) DA LISTA */
  .item-numero { display: none !important; }

  /* REMOVE O SELETOR DE QUANTIDADE (- 1 +) */
  .item-qtd-wrap { display: none !important; }

  /* 2. O NOME AGORA TEM MUITO ESPAÇO */
  .item-info {
    flex: 1 !important;
    min-width: 0;
  }

  .item-nome {
    display: block !important;
    font-size: 1.05rem;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* 3. Estilo do Subtotal e Preço Unitário */
  .item-subtotal {
    text-align: right;
    min-width: 85px; /* Espaço para o valor em Reais */
    flex-shrink: 0;
    font-weight: 700;
    color: #2d6a4f;
    font-size: 1rem;
    line-height: 1.2;
  }

  /* Mostra a quantidade e o preço unitário logo abaixo do subtotal */
  .item-preco-unit {
  display: block;
  font-size: 0.7rem; /* Diminuído para caber tudo */
  color: #888;
  font-weight: normal;
  margin-top: 2px;
}


  /* 4. Botões de Ação (Editar e Excluir) */
  .item-acoes {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
  }

  .btn-sm {
    padding: 6px;
    font-size: 0.9rem;
  }

  .barra-total { padding: 16px 18px; }
}



@media (max-width: 420px) {
  .header { flex-direction: column; text-align: center; }
  .barra-total { flex-direction: column; align-items: flex-start; gap: 10px; }
  .total-direita { width: 100%; justify-content: space-between; display: flex; }
}


