:root {
  --cacau: #250101;
  --laranja: #d96704;
  --laranja-escuro: #b35400;
  --bege: #be9c87;
  --papel: #f6f1eb;
  --cartao: #fffdfa;
  --linha: #e6dcd2;
  --suave: #7a6a62;
  --tinta: #250101;
  --ok: #2f6b3f;
  --ok-fundo: #e3efe5;
  --pend: #9a5b00;
  --pend-fundo: #fbebd3;
  --cheio: #250101;
  --bloq: #8c8580;
  --erro: #a3261b;
  --erro-fundo: #f9e1de;
  --raio: 14px;
  --sombra: 0 1px 2px rgb(37 1 1 / .06), 0 4px 16px rgb(37 1 1 / .05);
  --abas: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--papel);
  color: var(--tinta);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--abas) + env(safe-area-inset-bottom));
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--laranja); outline-offset: 2px; }

/* ---------- topo e abas ---------- */
.topo {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--cacau); color: #fff;
}
.marca { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.marca img { border-radius: 7px; }
.marca span { display: flex; flex-direction: column; line-height: 1.1; }
.marca b { font-size: 15px; letter-spacing: .01em; }
.marca small { font-size: 12px; color: var(--bege); text-transform: uppercase; letter-spacing: .12em; }
.quem { font-size: 13px; color: var(--bege); }

.abas {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--abas) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--cartao); border-top: 1px solid var(--linha);
}
.abas a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; font-size: 12px; color: var(--suave);
}
.abas svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.abas a[aria-current="page"] { color: var(--laranja-escuro); font-weight: 600; }
.abas .aba-nova svg { background: var(--laranja); color: #fff; border-radius: 50%; padding: 3px; width: 30px; height: 30px; stroke-width: 2.4; }

main { max-width: 1180px; margin: 0 auto; padding: 16px; outline: none; }
.carregando { color: var(--suave); }

@media (min-width: 900px) {
  body { padding-bottom: 0; padding-left: 92px; }
  .abas {
    inset: 0 auto 0 0; width: 92px; height: auto; padding: 72px 0 0;
    grid-template-columns: 1fr; grid-auto-rows: 76px; align-content: start;
    border-top: 0; border-right: 1px solid var(--linha);
  }
  .topo { margin-left: -92px; padding-left: 116px; }
  main { padding: 24px 28px; }
}

/* ---------- blocos ---------- */
h1 { font-size: 24px; line-height: 1.2; margin: 4px 0 16px; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0 0 6px; }
.cartao { background: var(--cartao); border: 1px solid var(--linha); border-radius: var(--raio); padding: 16px; box-shadow: var(--sombra); }
.pilha > * + * { margin-top: 16px; }
.suave { color: var(--suave); }
.peq { font-size: 13px; }
.linha-titulo { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.linha-titulo h1, .linha-titulo h2 { margin: 0; }

.botao {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 999px;
  border: 1px solid var(--linha); background: var(--cartao); cursor: pointer;
  font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: transform .08s ease, background .15s ease;
}
.botao:active { transform: scale(.97); }
.botao.primario { background: var(--laranja); border-color: var(--laranja); color: #fff; }
.botao.primario:hover { background: var(--laranja-escuro); }
.botao.escuro { background: var(--cacau); border-color: var(--cacau); color: #fff; }
.botao.perigo { color: var(--erro); border-color: #e9c3be; }
.botao.mini { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.botao[disabled] { opacity: .5; cursor: not-allowed; }
.botoes { display: flex; flex-wrap: wrap; gap: 8px; }

.selo { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.selo.pendente { background: var(--pend-fundo); color: var(--pend); }
.selo.confirmada { background: var(--ok-fundo); color: var(--ok); }
.selo.cancelada { background: #eee; color: #666; text-decoration: line-through; }
.selo.especial { background: #fde7d3; color: var(--laranja-escuro); }

.alerta { border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.alerta.erro { background: var(--erro-fundo); color: var(--erro); }
.alerta.aviso { background: var(--pend-fundo); color: #6e4100; }
.alerta + .alerta { margin-top: 6px; }

/* ---------- resumo do dia ---------- */
.resumo { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
@media (min-width: 700px) { .resumo { grid-template-columns: repeat(4, 1fr); } }
.resumo a { text-decoration: none; padding: 12px 14px; }
.resumo b { display: block; font-size: 28px; line-height: 1; margin-bottom: 4px; }
.resumo span { font-size: 13px; color: var(--suave); }
.resumo .destaque b { color: var(--laranja-escuro); }

/* ---------- mapa de ocupação ---------- */
.mapa-nav { display: flex; align-items: center; gap: 8px; }
.mapa-nav h2 { margin: 0; min-width: 150px; text-align: center; text-transform: capitalize; }
.grade-rolagem { overflow-x: auto; border-radius: var(--raio); border: 1px solid var(--linha); background: var(--cartao); box-shadow: var(--sombra); overscroll-behavior-x: contain; }
.grade { border-collapse: separate; border-spacing: 0; font-size: 13px; }
.grade th, .grade td { padding: 0; text-align: center; border-bottom: 1px solid var(--linha); }
.grade thead th { position: sticky; top: 0; background: var(--cartao); font-weight: 500; color: var(--suave); height: 46px; min-width: 44px; line-height: 1.1; }
.grade thead th b { display: block; font-size: 15px; color: var(--tinta); }
.grade thead th.fds { background: #f3ece4; }
.grade thead th.hoje b { background: var(--laranja); color: #fff; border-radius: 6px; padding: 1px 5px; display: inline-block; }
.grade thead th.esp { box-shadow: inset 0 3px 0 var(--laranja); }
.grade .rotulo {
  position: sticky; left: 0; z-index: 2; background: var(--cartao);
  text-align: left; padding: 0 10px; min-width: 112px; max-width: 132px; font-weight: 600; font-size: 13px;
  border-right: 1px solid var(--linha); line-height: 1.2;
}
.grade .rotulo small { display: block; font-weight: 400; color: var(--suave); }
.grade thead .rotulo { z-index: 3; }
.cel {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 44px; height: 52px; border: 0; background: none; cursor: pointer; position: relative;
  font-weight: 700; font-size: 15px; border-right: 1px solid #f1e9e1;
}
.cel small { font-weight: 400; font-size: 10px; color: var(--suave); }
.cel.livre { background: #fff; }
.cel.parcial { background: #fbf3ea; }
.cel.cheio { background: var(--cheio); color: #fff; }
.cel.cheio small { color: var(--bege); }
.cel.zero { background: repeating-linear-gradient(-45deg, #f2eeea 0 4px, #fff 4px 8px); color: #b9b0aa; cursor: default; }
.cel .ponto { position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--laranja); }
.cel .ponto.bloq { right: auto; left: 5px; background: var(--bloq); }
.cel:hover:not(.zero) { outline: 2px solid var(--laranja); outline-offset: -2px; }
.legenda { display: flex; flex-wrap: wrap; gap: 14px; margin: 10px 2px 0; font-size: 12px; color: var(--suave); }
.legenda i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 5px; border: 1px solid var(--linha); }

/* ---------- listas ---------- */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--linha); background: var(--cartao); cursor: pointer; font-size: 14px; min-height: 40px; }
.chip[aria-pressed="true"] { background: var(--cacau); color: #fff; border-color: var(--cacau); }
.busca { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--linha); background: var(--cartao); margin-bottom: 12px; }
.lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.lista a { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 14px; text-decoration: none; }
.lista .nome { font-weight: 700; }
.lista .direita { text-align: right; }
.lista .linha2 { grid-column: 1 / -1; font-size: 13px; color: var(--suave); }
.vazio { padding: 24px; text-align: center; color: var(--suave); }

/* ---------- formulários ---------- */
.campos { display: grid; gap: 12px; }
@media (min-width: 600px) { .campos.duas { grid-template-columns: 1fr 1fr; } .campos.tres { grid-template-columns: repeat(3, 1fr); } }
label.campo { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--suave); }
.campo input, .campo select, .campo textarea {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid #d9cdc2; background: #fff; font-weight: 400; font-size: 16px; color: var(--tinta); min-height: 44px;
}
.campo textarea { min-height: 72px; resize: vertical; }
.campo input:focus, .campo select:focus, .campo textarea:focus { border-color: var(--laranja); outline: none; box-shadow: 0 0 0 3px rgb(217 103 4 / .18); }

.itens { display: grid; gap: 8px; }
.item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px 12px; padding: 12px; border: 1px solid var(--linha); border-radius: 12px; background: #fff; }
.item.ativo { border-color: var(--laranja); box-shadow: 0 0 0 1px var(--laranja); }
.item.esgotado { opacity: .55; }
.item .nome { font-weight: 700; }
.item .info { font-size: 13px; color: var(--suave); }
.item .pessoas { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; border-top: 1px dashed var(--linha); padding-top: 8px; }
.passo { display: inline-flex; align-items: center; border: 1px solid #d9cdc2; border-radius: 999px; overflow: hidden; background: #fff; }
.passo button { width: 40px; height: 40px; border: 0; background: none; font-size: 20px; cursor: pointer; }
.passo button:disabled { color: #ccc; cursor: default; }
.passo output { min-width: 28px; text-align: center; font-weight: 700; }

@media (min-width: 900px) { .orcamento { position: sticky; top: 76px; } }
.orcamento table { width: 100%; border-collapse: collapse; font-size: 14px; }
.orcamento td { padding: 5px 0; vertical-align: top; }
.orcamento td:last-child { text-align: right; white-space: nowrap; }
.orcamento .total td { border-top: 1px solid var(--linha); padding-top: 10px; font-weight: 800; font-size: 18px; }
.orcamento .sinal td { color: var(--laranja-escuro); font-weight: 700; }
.layout-nova { display: grid; gap: 16px; }
@media (min-width: 900px) { .layout-nova { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; } }

/* ---------- detalhe ---------- */
.dados { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: 15px; }
.dados dt { color: var(--suave); }
.dados dd { margin: 0; font-weight: 600; }
.valores { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 600px) { .valores { grid-template-columns: repeat(4, 1fr); } }
.valores div { background: var(--papel); border-radius: 10px; padding: 10px 12px; }
.valores span { display: block; font-size: 12px; color: var(--suave); }
.valores b { font-size: 18px; }
.historico { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.historico li { padding: 8px 0; border-bottom: 1px solid var(--linha); }
.historico li:last-child { border-bottom: 0; }
.mensagem { white-space: pre-wrap; font-family: inherit; line-height: 1.5; background: #e7f4e4; border-radius: 12px; padding: 12px; font-size: 14px; margin: 0; }

/* ---------- ajustes ---------- */
.tabela-precos { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabela-precos th, .tabela-precos td { padding: 8px 6px; border-bottom: 1px solid var(--linha); text-align: left; vertical-align: middle; }
.tabela-precos td.num, .tabela-precos th.num { text-align: right; }
.rolagem-x { overflow-x: auto; }
.pendencias li { margin-bottom: 6px; }

/* ---------- folha (diálogo) e toast ---------- */
.folha { border: 0; border-radius: 18px; padding: 0; width: min(520px, calc(100vw - 24px)); max-height: 88vh; box-shadow: 0 20px 60px rgb(0 0 0 / .3); color: var(--tinta); background: var(--cartao); }
.folha::backdrop { background: rgb(37 1 1 / .45); }
.folha > div { padding: 20px; }
@media (max-width: 599px) {
  .folha { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
.aviso-toast {
  position: fixed; left: 50%; bottom: calc(var(--abas) + 16px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--cacau); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px);
}
.aviso-toast.mostra { opacity: 1; transform: translate(-50%, 0); }
.aviso-toast.erro { background: var(--erro); }
@media (min-width: 900px) { .aviso-toast { bottom: 24px; } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
