:root {
  --papel: #f3ede2; --papel-2: #ebe3d4; --branco: #fffdf8; --tinta: #1d1a16; --tinta-2: #4d473f; --tinta-3: #7a7266; --fio: #d6ccba;
  --terra: #b8492a; --mata: #24493a; --mostarda: #e2a63b; --wa: #1f9d55;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter Tight", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --raio: 10px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--papel); color: var(--tinta); font: 16px/1.45 var(--sans); -webkit-font-smoothing: antialiased; min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--mostarda); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; letter-spacing: -.015em; line-height: 1.1; }
h1 { font-size: 26px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; font-family: var(--sans); font-weight: 700; letter-spacing: 0; }
p { margin: 0; }
.mudo { color: var(--tinta-3); font-size: 14px; }
.marca { font-family: var(--serif); font-weight: 800; letter-spacing: -.02em; }
.marca i { color: var(--terra); font-style: normal; }

/* Estrutura */
.topo { position: sticky; top: 0; z-index: 10; background: var(--papel); border-bottom: 1.5px solid var(--tinta);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; display: flex; align-items: center; gap: 12px; }
.topo .marca { font-size: 20px; }
.topo .empresa { font-weight: 600; font-size: 15px; color: var(--tinta-2); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
main { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(110px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.abas { position: fixed; inset: auto 0 0 0; z-index: 10; background: var(--branco); border-top: 1.5px solid var(--tinta);
  display: grid; grid-template-columns: repeat(3, 1fr); padding-bottom: env(safe-area-inset-bottom); }
.abas a { display: grid; justify-items: center; gap: 2px; padding: 9px 4px 10px; text-decoration: none; font-size: 13px; font-weight: 600; color: var(--tinta-3); position: relative; }
.abas a svg { width: 24px; height: 24px; }
.abas a[aria-current="page"] { color: var(--tinta); }
.abas a[aria-current="page"]::before { content: ""; position: absolute; top: -1.5px; left: 25%; right: 25%; height: 3px; background: var(--terra); }
.contador { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
  background: var(--terra); color: var(--branco); font-size: 11px; line-height: 19px; text-align: center; }

/* Botões */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 18px; border-radius: 6px;
  border: 1.5px solid var(--tinta); background: var(--tinta); color: var(--papel); font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.claro { background: var(--branco); color: var(--tinta); }
.btn.verde { background: var(--mata); border-color: var(--mata); color: var(--branco); }
.btn.wa { background: var(--wa); border-color: var(--wa); color: var(--branco); }
.btn.perigo { background: var(--branco); color: var(--terra); border-color: var(--terra); }
.btn.pequeno { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.largo { width: 100%; }
.btn svg { width: 18px; height: 18px; }
.icone { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 6px; border: 1.5px solid var(--tinta); background: var(--branco); cursor: pointer; padding: 0; }
.icone svg { width: 20px; height: 20px; }
.mais { position: fixed; right: 16px; bottom: calc(82px + env(safe-area-inset-bottom)); z-index: 11; width: 58px; height: 58px; border-radius: 50%;
  border: 1.5px solid var(--tinta); background: var(--terra); color: var(--branco); display: grid; place-items: center; box-shadow: 3px 3px 0 var(--tinta); cursor: pointer; }
.mais svg { width: 28px; height: 28px; }
.linha-btn { display: flex; gap: 8px; flex-wrap: wrap; }
.linha-btn .btn { flex: 1 1 auto; }

/* Cartões e listas */
.cartao { background: var(--branco); border: 1.5px solid var(--tinta); border-radius: var(--raio); padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
details.servico { border-top: 1px solid var(--fio); }
details.servico summary { display: flex; justify-content: space-between; gap: 10px; padding: 12px 0; cursor: pointer; list-style: none; font-weight: 600; }
details.servico summary::-webkit-details-marker { display: none; }
details.servico summary::after { content: "Editar"; font-size: 13px; color: var(--terra); font-weight: 700; }
details.servico[open] summary::after { content: "Fechar"; }
details.servico summary span { min-width: 0; }
details.servico .item-config { border-top: 0; padding-top: 0; }
details.servico.inativo summary b { color: var(--tinta-3); text-decoration: line-through; }
.cartao > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.vazio { text-align: center; padding: 28px 16px; color: var(--tinta-2); border: 1.5px dashed var(--fio); border-radius: var(--raio); }
.vazio strong { display: block; color: var(--tinta); margin-bottom: 4px; }

/* Faixa de dias */
.semana { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; }
.dias { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.dia-btn { border: 1.5px solid transparent; background: none; border-radius: 8px; padding: 6px 0; cursor: pointer; display: grid; justify-items: center; gap: 1px; position: relative; }
.dia-btn small { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--tinta-3); }
.dia-btn b { font-size: 18px; font-weight: 700; }
.dia-btn.hoje b { color: var(--terra); }
.dia-btn[aria-pressed="true"] { background: var(--tinta); border-color: var(--tinta); }
.dia-btn[aria-pressed="true"] small, .dia-btn[aria-pressed="true"] b { color: var(--papel); }
.dia-btn .ponto { width: 5px; height: 5px; border-radius: 50%; background: var(--terra); position: absolute; bottom: 2px; }
.titulo-dia { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* Filtros em pílulas */
.pilulas { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.pilula { flex: none; border: 1.5px solid var(--tinta); background: var(--branco); border-radius: 999px; padding: 6px 14px; font-size: 14px; font-weight: 600; cursor: pointer; }
.pilula[aria-pressed="true"] { background: var(--tinta); color: var(--papel); }

/* Agendamentos */
.lista { display: grid; gap: 8px; }
.ag { display: grid; grid-template-columns: 62px 1fr auto; gap: 12px; align-items: center; text-align: left; width: 100%;
  background: var(--branco); border: 1.5px solid var(--tinta); border-left-width: 6px; border-radius: var(--raio); padding: 12px; cursor: pointer; }
.ag .hora { font-weight: 700; font-size: 17px; line-height: 1.1; }
.ag .hora small { display: block; font-weight: 500; font-size: 12px; color: var(--tinta-3); }
.ag .quem { min-width: 0; }
.ag .quem b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag .quem span { font-size: 14px; color: var(--tinta-2); }
.ag.pendente { border-left-color: var(--mostarda); }
.ag.confirmado { border-left-color: var(--mata); }
.ag.concluido { border-left-color: var(--tinta-3); }
.ag.cancelado, .ag.faltou { border-left-color: var(--fio); opacity: .62; }
.ag.cancelado .quem b { text-decoration: line-through; }
.selo { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.selo.pendente { background: #f8e3b8; color: #7a5410; }
.selo.confirmado { background: #d6e5dc; color: var(--mata); }
.selo.concluido { background: var(--papel-2); color: var(--tinta-2); }
.selo.cancelado, .selo.faltou { background: #f2d9d1; color: var(--terra); }
.selo.ia { background: var(--papel-2); color: var(--tinta-2); }
.grupo-data { font-weight: 700; font-size: 14px; color: var(--tinta-2); margin-top: 6px; }

/* Formulários */
label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
input, select, textarea { width: 100%; min-width: 0; min-height: 46px; padding: 10px 12px; border: 1.5px solid var(--tinta); border-radius: 6px; background: var(--branco); font-size: 16px; }
/* iPhone: tira a sombra e o arredondamento do sistema e deixa data e hora do tamanho do campo */
input:not([type="checkbox"]), textarea { -webkit-appearance: none; appearance: none; }
input[type="date"], input[type="time"] { display: block; line-height: 24px; }
input::-webkit-date-and-time-value { text-align: left; }
textarea { min-height: 80px; resize: vertical; }
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--mata); }
.campos { display: grid; gap: 12px; }
/* align-items: end mantém os campos alinhados quando um rótulo quebra em duas linhas */
.dois { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: end; }
label { min-width: 0; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 15px; }
.erro { color: var(--terra); font-weight: 600; font-size: 14px; }
.horarios { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.horarios button { min-height: 44px; border: 1.5px solid var(--tinta); border-radius: 6px; background: var(--branco); font-weight: 700; cursor: pointer; }
.horarios button[aria-pressed="true"] { background: var(--mata); border-color: var(--mata); color: var(--branco); }
.opcoes { display: grid; gap: 6px; }
.opcao { display: flex; justify-content: space-between; gap: 10px; align-items: center; text-align: left; width: 100%; border: 1.5px solid var(--tinta); border-radius: 8px; background: var(--branco); padding: 10px 12px; cursor: pointer; }
.opcao[aria-pressed="true"] { background: var(--tinta); color: var(--papel); }
.opcao[aria-pressed="true"] .mudo { color: var(--fio); }

/* Expediente */
.exp-dia { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 8px; align-items: start; padding: 10px 0; border-top: 1px solid var(--fio); }
.exp-dia:first-of-type { border-top: 0; }
.exp-dia > b { padding-top: 10px; }
.turnos { display: grid; gap: 6px; }
.turno { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.turno input { min-height: 40px; padding: 6px 6px; min-width: 0; }
.turno .icone { width: 36px; height: 36px; }
.item-config { display: grid; gap: 10px; padding: 12px 0; border-top: 1px solid var(--fio); }
.item-config:first-of-type { border-top: 0; padding-top: 0; }

/* Folha de baixo (detalhes e ações) */
dialog { border: 0; padding: 0; width: 100%; max-width: 560px; margin: auto auto 0; background: transparent; max-height: 92dvh; }
dialog::backdrop { background: rgb(29 26 22 / .5); }
.folha { background: var(--branco); border: 1.5px solid var(--tinta); border-bottom: 0; border-radius: 16px 16px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  display: grid; gap: 14px; max-height: 92dvh; overflow-y: auto; }
.folha header { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.detalhes { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 15px; }
.detalhes dt { color: var(--tinta-3); }
.detalhes dd { margin: 0; font-weight: 600; }
@media (min-width: 700px) { dialog { margin: auto; } .folha { border-radius: 16px; border-bottom: 1.5px solid var(--tinta); } }

/* Entrada */
.entrada { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.entrada .cartao { width: 100%; max-width: 400px; padding: 24px; gap: 18px; box-shadow: 5px 5px 0 var(--terra); }
.entrada .marca { font-size: 34px; }

#aviso { position: fixed; left: 16px; right: 16px; bottom: calc(150px + env(safe-area-inset-bottom)); z-index: 30; margin: 0 auto; max-width: 420px;
  background: var(--tinta); color: var(--papel); padding: 12px 16px; border-radius: 8px; font-weight: 600; text-align: center; }
#aviso.erro-aviso { background: var(--terra); color: var(--branco); }
.carregando { padding: 40px; text-align: center; color: var(--tinta-3); }

/* No celular, com o teclado aberto, a barra de abas e o + saem da frente dos campos */
@media (max-width: 700px) {
  body.digitando .abas, body.digitando .mais { display: none; }
}
