:root {
  --rosa: #ec4899;
  --roxo: #8b5cf6;
  --gradiente: linear-gradient(135deg, #ec4899 0%, #a855f7 55%, #7c3aed 100%);
  --verde: #22c55e;
  --verde-escuro: #16a34a;
  --texto: #1f2937;
  --texto-suave: #6b7280;
  --borda: #e5e7eb;
  --fundo-campo: #f9fafb;
  --vermelho: #ef4444;
  --sombra: 0 10px 30px rgba(76, 29, 149, 0.18);
  --raio: 20px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--gradiente);
  background-attachment: fixed;
  color: var(--texto);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

/* ------------------------------------------------------------------ header */
.topo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 4px 16px;
  color: #fff;
}

.topo h1 {
  font-size: 1.25rem;
  margin: 0;
  flex: 1;
  line-height: 1.25;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.topo .bolo { font-size: 1.8rem; }

.icone-botao {
  position: relative;
  background: rgba(255, 255, 255, 0.22);
  border: none;
  color: #fff;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 1.15rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s;
}
.icone-botao:hover { background: rgba(255, 255, 255, 0.35); }

.indicador {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d1d5db;
  border: 2px solid rgba(255, 255, 255, 0.8);
}
.indicador.ativo { background: var(--verde); }

/* ------------------------------------------------------------------- cards */
.card {
  background: #fff;
  border-radius: var(--raio);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--sombra);
}

.card h2 {
  margin: 0 0 14px;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-destaque {
  background: linear-gradient(135deg, #f472b6 0%, #a855f7 100%);
  color: #fff;
}
.card-destaque h2 { color: #fff; }

/* ------------------------------------------------------------------- busca */
.linha-busca {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.linha-busca input {
  flex: 1;
  border: none;
  border-radius: 999px;
  padding: 13px 18px;
  font-size: 0.95rem;
  box-shadow: var(--sombra);
  outline: none;
}

.botao-mais {
  background: #fff;
  color: var(--roxo);
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 1.6rem;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--sombra);
  flex-shrink: 0;
}

/* -------------------------------------------------------------- pessoa item */
.pessoa {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--borda);
}
.pessoa:last-child { border-bottom: none; }

.card-destaque .pessoa { border-bottom-color: rgba(255, 255, 255, 0.3); }

.pessoa-dados { flex: 1; min-width: 0; }

.pessoa-nome {
  font-weight: 600;
  font-size: 0.98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pessoa-info {
  font-size: 0.82rem;
  color: var(--texto-suave);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.card-destaque .pessoa-info { color: rgba(255, 255, 255, 0.9); }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #fff;
  background: var(--roxo);
}
.card-destaque .badge { background: rgba(255, 255, 255, 0.28); }

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

.botao-acao {
  background: var(--fundo-campo);
  border: 1px solid var(--borda);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  font-size: 0.95rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.botao-acao:hover { background: #f3f4f6; }
.botao-acao.perigo:hover { background: #fee2e2; border-color: #fca5a5; }

/* ------------------------------------------------------------------ botões */
.botao {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  padding: 13px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.15s;
}
.botao:hover { filter: brightness(0.95); }
.botao:disabled { opacity: 0.6; cursor: not-allowed; }

.botao-verde { background: var(--verde); color: #fff; }
.botao-roxo { background: var(--roxo); color: #fff; }
.botao-branco { background: #fff; color: var(--roxo); }
.botao-neutro { background: var(--fundo-campo); color: var(--texto); border: 1px solid var(--borda); }
.botao-perigo { background: var(--vermelho); color: #fff; }
.botao-bloco { width: 100%; margin-top: 14px; }
.botao-pequeno { padding: 8px 14px; font-size: 0.85rem; border-radius: 10px; }

.botao-direto {
  background: var(--verde);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ campos */
label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--texto);
}

input[type="text"], input[type="password"], input[type="number"],
input[type="time"], input[type="search"], select, textarea {
  width: 100%;
  border: 1px solid var(--borda);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--fundo-campo);
  color: var(--texto);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--roxo);
  background: #fff;
}

textarea { resize: vertical; min-height: 90px; line-height: 1.5; }

.campo { margin-bottom: 14px; }
.campos-lado { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.ajuda { font-size: 0.78rem; color: var(--texto-suave); margin-top: 5px; line-height: 1.4; }

.aviso {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.82rem;
  margin-top: 8px;
  line-height: 1.45;
}
.aviso button {
  margin-top: 8px;
  background: #f59e0b;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.vazio {
  text-align: center;
  color: var(--texto-suave);
  font-size: 0.9rem;
  padding: 18px 8px;
}
.card-destaque .vazio { color: rgba(255, 255, 255, 0.9); }

/* ------------------------------------------------------------------ modais */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding: 0;
}
.modal.aberto { display: flex; }

.modal-caixa {
  background: #fff;
  border-radius: 22px 22px 0 0;
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 22px 20px calc(24px + env(safe-area-inset-bottom));
  animation: sobe 0.2s ease-out;
}

@keyframes sobe {
  from { transform: translateY(24px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

@media (min-width: 641px) {
  .modal { align-items: center; padding: 20px; }
  .modal-caixa { border-radius: var(--raio); }
}

.modal-topo {
  display: flex;
  align-items: center;
  margin-bottom: 18px;
}
.modal-topo h2 { margin: 0; font-size: 1.1rem; flex: 1; }

.fechar {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--texto-suave);
  cursor: pointer;
  padding: 0 4px;
}

.modal-acoes { display: flex; gap: 10px; margin-top: 20px; }
.modal-acoes .botao { flex: 1; }

/* ---------------------------------------------------------------- switches */
.linha-config {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--borda);
}
.linha-config:last-of-type { border-bottom: none; }

.switch { position: relative; width: 50px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute;
  inset: 0;
  background: #d1d5db;
  border-radius: 999px;
  transition: background 0.2s;
  cursor: pointer;
}
.switch span::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.switch input:checked + span { background: var(--verde); }
.switch input:checked + span::before { transform: translateX(22px); }

/* ------------------------------------------------------------------- login */
.tela-login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.caixa-login {
  background: #fff;
  border-radius: 24px;
  padding: 34px 26px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--sombra);
  text-align: center;
}
.caixa-login .bolo { font-size: 3.4rem; }
.caixa-login h1 { font-size: 1.3rem; margin: 12px 0 6px; }
.caixa-login p { color: var(--texto-suave); font-size: 0.88rem; margin: 0 0 22px; }
.caixa-login input { text-align: center; margin-bottom: 14px; }

.erro {
  color: var(--vermelho);
  font-size: 0.85rem;
  min-height: 20px;
  margin-top: 10px;
}

/* -------------------------------------------------------------- preview/etc */
.preview {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  padding: 14px;
  font-size: 0.86rem;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  max-height: 260px;
  overflow-y: auto;
}

.aba-linha { display: flex; gap: 8px; margin-bottom: 16px; }
.aba {
  flex: 1;
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 11px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.aba.ativa { background: #fff; color: var(--roxo); }

.categoria-linha {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--borda);
}
.categoria-linha:last-child { border-bottom: none; }
.categoria-linha .dados { flex: 1; min-width: 0; }
.categoria-linha .tratamento { font-size: 0.8rem; color: var(--texto-suave); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(90px);
  background: #111827;
  color: #fff;
  padding: 13px 20px;
  border-radius: 12px;
  font-size: 0.88rem;
  z-index: 100;
  transition: transform 0.25s;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.toast.visivel { transform: translateX(-50%) translateY(0); }

.carregando { text-align: center; color: #fff; padding: 30px; font-size: 0.9rem; }

.oculto { display: none !important; }
