:root {
  --fundo: #f4efe6;
  --cartao: #fbf8f2;
  --borda: #e2d9c8;
  --texto: #2f2b26;
  --suave: #6f675c;
  --oliva: #5f6b3a;
  --oliva-escuro: #4a5430;
  --salvia: #8a9a6b;
  --ocre: #b9832f;
  --terracota: #a9583a;
  --erro-fundo: #f6e3dc;
  --info-fundo: #eef0e4;
  --raio: 10px;
  --serif: 'Lora', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--fundo);
  color: var(--texto);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}

[hidden] { display: none !important; }

h1, h2 { font-family: var(--serif); font-weight: 600; margin: 0 0 12px; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; color: var(--oliva-escuro); }

.topo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: var(--cartao);
  border-bottom: 1px solid var(--borda);
}
.marca { display: flex; align-items: center; gap: 10px; }
.logo { height: 36px; width: auto; }
.marca-nome { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; color: var(--oliva-escuro); }
.marca-sub { color: var(--suave); font-size: .9rem; border-left: 1px solid var(--borda); padding-left: 10px; }
.operador { display: flex; align-items: center; gap: 10px; font-size: .9rem; color: var(--suave); }

.conteudo { max-width: 760px; margin: 0 auto; padding: 20px 16px 48px; }
.tela { display: block; }
form.tela > .cartao, .tela > .cartao { margin-bottom: 16px; }

.cartao {
  background: var(--cartao);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  padding: 20px;
}

.suave { color: var(--suave); }
.pequeno { font-size: .85rem; }
.carregando { color: var(--suave); text-align: center; margin: 24px 0; }

.faixa-testes { background: #C99A34; color: #221F19; text-align: center; font-weight: 600; font-size: .9rem; padding: 8px 16px; }

.campo { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; position: relative; }
.campo-curto { max-width: 220px; }
label { font-size: .85rem; font-weight: 500; color: var(--suave); }

input[type=text], input[type=date], select, textarea {
  font: inherit;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--borda);
  border-radius: 8px;
  background: #fff;
  color: var(--texto);
  min-height: 44px;
}
textarea { resize: vertical; min-height: 72px; }
.contador { font-size: .75rem; color: var(--suave); align-self: flex-end; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--salvia);
  outline-offset: 1px;
}
.invalido { border-color: var(--terracota) !important; }

.lista-pacientes {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--borda);
  border-radius: 8px;
  background: #fff;
}
.lista-pacientes:empty { display: none; }
.lista-pacientes li { padding: 10px 12px; cursor: pointer; border-bottom: 1px solid #f0ebe1; }
.lista-pacientes li:last-child { border-bottom: 0; }
.lista-pacientes li:hover, .lista-pacientes li.foco { background: var(--info-fundo); }
.lista-pacientes li.bloqueado { color: var(--suave); cursor: not-allowed; background: #faf7f1; }
.lista-pacientes .num { color: var(--suave); font-size: .85rem; margin-left: 6px; }
.lista-pacientes .tag { font-size: .75rem; color: var(--terracota); margin-left: 6px; }

.selecionado {
  margin: 0;
  padding: 10px 12px;
  background: var(--info-fundo);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.item {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) 36px;
  grid-template-areas:
    "produto produto produto lote remover"
    "qtd preco total total .";
  gap: 10px;
  align-items: end;
  padding: 12px 0;
  border-bottom: 1px dashed var(--borda);
}
.item-produto { grid-area: produto; }
.item-lote { grid-area: lote; }
.item-qtd { grid-area: qtd; }
.item-preco { grid-area: preco; }
.item-total { grid-area: total; }
.remover { grid-area: remover; }
.item .campo { margin-bottom: 0; }
.item-total { display: flex; flex-direction: column; gap: 6px; padding-bottom: 10px; }
.item-total .rotulo { font-size: .85rem; color: var(--suave); }
.i-total { font-weight: 600; }
.remover {
  border: 1px solid var(--borda);
  background: #fff;
  border-radius: 8px;
  height: 44px;
  font-size: 1.3rem;
  color: var(--terracota);
  cursor: pointer;
}

.grade { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.desconto { display: flex; gap: 8px; }
.alternador { display: flex; border: 1px solid var(--borda); border-radius: 8px; overflow: hidden; flex-shrink: 0; }
.alternador button { border: 0; background: #fff; padding: 0 14px; font: inherit; cursor: pointer; color: var(--suave); min-height: 44px; }
.alternador button.ativo { background: var(--oliva); color: #fff; }

.totais { margin: 12px 0 0; border-top: 1px solid var(--borda); padding-top: 12px; }
.totais div { display: flex; justify-content: space-between; padding: 3px 0; }
.totais dt { color: var(--suave); }
.totais dd { margin: 0; }
.totais .total dt, .totais .total dd { font-weight: 600; color: var(--texto); font-size: 1.15rem; }

.acoes { display: flex; justify-content: flex-end; gap: 12px; flex-wrap: wrap; margin-top: 8px; }

.botao {
  font: inherit;
  font-weight: 600;
  border-radius: 8px;
  padding: 12px 20px;
  min-height: 46px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.principal { background: var(--oliva); color: #fff; border: 1px solid var(--oliva); }
.principal:hover { background: var(--oliva-escuro); }
.principal:disabled { background: #b8bda6; border-color: #b8bda6; cursor: not-allowed; }
.secundario { background: #fff; color: var(--oliva-escuro); border: 1px solid var(--salvia); }
.link { background: none; border: 0; color: var(--oliva); font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }

.aviso { padding: 12px 14px; border-radius: 8px; margin: 0 0 16px; }
.aviso-erro { background: var(--erro-fundo); color: #6e2c17; border: 1px solid #e8c4b5; }
.aviso-info { background: var(--info-fundo); color: var(--oliva-escuro); }

.botao-google { margin: 16px 0 8px; min-height: 44px; }

.recibo-titulo { font-family: var(--serif); font-size: 1.2rem; margin: 0 0 12px; color: var(--oliva-escuro); }
.recibo-dados { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin: 0 0 16px; }
.recibo-dados dt { font-size: .8rem; color: var(--suave); }
.recibo-dados dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.recibo-itens { width: 100%; border-collapse: collapse; font-size: .95rem; }
.recibo-itens th { text-align: left; font-size: .8rem; color: var(--suave); font-weight: 500; border-bottom: 1px solid var(--borda); padding: 6px 4px; }
.recibo-itens td { padding: 8px 4px; border-bottom: 1px solid #f0ebe1; vertical-align: top; }
.recibo-itens th:not(:first-child), .recibo-itens td:not(:first-child) { text-align: right; white-space: nowrap; }

.confirmacao { display: flex; align-items: center; gap: 10px; margin: 16px 0; font-size: 1rem; color: var(--texto); cursor: pointer; }
.confirmacao input { width: 22px; height: 22px; accent-color: var(--oliva); }

.selo { display: inline-block; background: var(--oliva); color: #fff; font-size: .8rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; margin: 0 0 12px; }

@media (max-width: 640px) {
  .topo { padding: 12px 16px; }
  .marca-sub { display: none; }
  .cartao { padding: 16px; }
  .grade { grid-template-columns: 1fr; }
  .recibo-dados { grid-template-columns: 1fr; }
  .item {
    grid-template-columns: 1fr 1fr 36px;
    grid-template-areas:
      "produto produto remover"
      "lote lote lote"
      "qtd preco preco"
      "total total total";
  }
  .item-total { flex-direction: row; justify-content: space-between; padding-bottom: 0; }
  .acoes { flex-direction: column-reverse; }
  .acoes .botao { width: 100%; }
}
