:root {
  --verde: #24574a;
  --verde-escuro: #1b4338;
  --verde-claro: #e9f0ed;
  --dourado: #b08d57;
  --texto: #1f2422;
  --cinza: #6b7270;
  --borda: #d5dcd9;
  --fundo: #f6f5f2;
  --branco: #ffffff;
  --vermelho: #b3261e;
  --alerta: #8a5a00;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--texto);
  background: var(--fundo);
  font-size: 16px;
}

body.com-barra { padding-bottom: 72px; }

/* ---------- login ---------- */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--verde), var(--verde-escuro));
}

.login-card {
  background: var(--branco);
  padding: 2rem;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  width: 340px;
  max-width: calc(100vw - 2rem);
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.login-card .marca { margin: 0; color: var(--dourado); font-weight: 700; letter-spacing: .15em; font-size: .75rem; }
.login-card h1 { margin: 0 0 .5rem; color: var(--verde); font-size: 1.5rem; }

/* ---------- topo ---------- */

.topo {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: .5rem;
  padding: .7rem 1rem;
  padding-top: max(.7rem, env(safe-area-inset-top));
  background: var(--verde);
  color: var(--branco);
}

.topo-titulo { font-weight: 700; text-align: center; white-space: nowrap; }
.topo-dir { margin: 0; text-align: right; }

.btn-link-claro {
  background: none;
  border: none;
  color: var(--branco);
  font: inherit;
  font-size: .95rem;
  padding: .3rem 0;
  cursor: pointer;
  text-decoration: none;
}

/* ---------- layout ---------- */

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.carregando, .vazio { color: var(--cinza); text-align: center; padding: 2rem 0; }

.secao {
  background: var(--branco);
  border: 1px solid var(--borda);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.secao h2 {
  margin: .25rem 0 0;
  font-size: .8rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--verde);
}

.form { display: flex; flex-direction: column; gap: .75rem; }

.linha2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
/* 3 datas lado a lado não cabem num celular estreito: quebra em 2 + 1 */
.linha3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; }

.ajuda { margin: 0; color: var(--cinza); font-size: .85rem; line-height: 1.35; }
.centro { text-align: center; }

/* ---------- formulário ---------- */

label {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .8rem;
  font-weight: 600;
  color: #3b4240;
  min-width: 0;
}

input, select, textarea, button { font: inherit; }

/* 16px evita o zoom automático do iPhone ao focar o campo */
input, select, textarea {
  width: 100%;
  min-width: 0;
  padding: .65rem .7rem;
  border: 1px solid var(--borda);
  border-radius: 8px;
  font-size: 16px;
  background: var(--branco);
  color: var(--texto);
}

input[type="date"] { padding: .55rem .4rem; min-height: 2.75rem; }

textarea { resize: vertical; line-height: 1.35; }

input:focus, select:focus, textarea:focus { outline: 2px solid var(--verde); outline-offset: -1px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  cursor: pointer;
  border: 1px solid var(--borda);
  border-radius: 10px;
  padding: .7rem 1rem;
  background: var(--branco);
  color: var(--texto);
  font-weight: 600;
  font-size: .95rem;
  text-decoration: none;
  min-height: 2.75rem;
}

.btn:disabled { opacity: .45; cursor: default; }
.btn-primario { background: var(--verde); border-color: var(--verde); color: var(--branco); }
.btn-secundario { background: var(--verde-claro); border-color: #cbdcd5; color: var(--verde-escuro); }
.btn-perigo { background: var(--branco); border-color: #e3b9b5; color: var(--vermelho); }
.btn-icone { padding: .4rem; min-width: 2.5rem; min-height: 2.5rem; font-size: 1.05rem; }
.largo { width: 100%; }
.grande { padding: .9rem 1rem; font-size: 1.05rem; }

/* ---------- lista ---------- */

.busca { font-size: 16px; }

.abas { display: flex; gap: .5rem; }
.aba {
  flex: 1;
  padding: .55rem;
  border: 1px solid var(--borda);
  background: var(--branco);
  border-radius: 999px;
  font-weight: 600;
  color: var(--cinza);
  cursor: pointer;
}
.aba.ativa { background: var(--verde); border-color: var(--verde); color: var(--branco); }

.lista { display: flex; flex-direction: column; gap: .6rem; }

.card {
  display: flex;
  gap: .8rem;
  align-items: center;
  background: var(--branco);
  border: 1px solid var(--borda);
  border-radius: 12px;
  padding: .6rem;
  color: inherit;
  text-decoration: none;
}
.card.urgente { border-left: 4px solid var(--dourado); }

.card-capa {
  width: 64px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: var(--verde-claro);
}
.card-capa.vazia {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  color: var(--cinza);
}

.card-info { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.card-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-sub { color: #4a514f; font-size: .88rem; }
.card-meta { color: var(--cinza); font-size: .8rem; }

/* ---------- ficha ---------- */

.resumo { display: flex; flex-direction: column; gap: .5rem; }
.resumo h1 { margin: 0; font-size: 1.35rem; color: var(--verde-escuro); }
.resumo p { margin: 0; }

.selo {
  align-self: flex-start;
  background: var(--verde-claro);
  color: var(--verde);
  font-size: .75rem;
  font-weight: 700;
  padding: .2rem .6rem;
  border-radius: 999px;
}

/* fotos */
.fotos { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }

.foto { display: flex; flex-direction: column; gap: .4rem; min-width: 0; }
.foto-acoes { display: flex; gap: .4rem; align-items: center; }
.foto-acoes select { padding: .45rem; font-size: 14px; }

.foto-wrap {
  position: relative;
  line-height: 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--verde-claro);
  user-select: none;
  -webkit-user-select: none;
}
.foto-wrap img { width: 100%; height: auto; display: block; pointer-events: none; }

.pin {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--verde);
  color: var(--branco);
  border: 2px solid var(--branco);
  font-size: 13px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .4);
  pointer-events: none;
}
.pin.apagado { opacity: .45; }
.pin.destaque { background: var(--dourado); width: 32px; height: 32px; line-height: 28px; font-size: 15px; z-index: 2; }

/* ajustes */
.ajustes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }

.ajuste {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .25rem .7rem;
  padding: .7rem 0;
  border-bottom: 1px solid #eceeed;
}
.ajuste:last-child { border-bottom: none; }

.num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--verde);
  color: var(--branco);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: .1rem;
}
.num.sem-pin { background: var(--branco); color: var(--verde); border: 2px solid var(--verde); }

.ajuste-texto { cursor: pointer; min-width: 0; }
.ajuste-desc { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.35; }
.ajuste-obs { font-size: .82rem; font-style: italic; color: var(--cinza); white-space: pre-wrap; }
.ajuste-acoes { grid-column: 2; display: flex; gap: .35rem; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  border: 1px solid var(--borda);
  background: var(--branco);
  border-radius: 999px;
  padding: .45rem .8rem;
  font-size: .88rem;
  cursor: pointer;
  color: var(--texto);
}
.chip.ativo { background: var(--verde); border-color: var(--verde); color: var(--branco); }
.chip-mais { border-style: dashed; color: var(--verde); }

/* medidas */
.medidas { display: flex; flex-direction: column; gap: .5rem; }
.medida { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: .4rem; align-items: center; }

/* barra de salvar */
.barra-salvar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem 1rem;
  padding-bottom: max(.7rem, env(safe-area-inset-bottom));
  background: #fff8e8;
  border-top: 2px solid var(--dourado);
  color: var(--alerta);
  font-weight: 600;
}
.barra-salvar[hidden] { display: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  z-index: 50;
  background: var(--verde-escuro);
  color: var(--branco);
  padding: .7rem 1rem;
  border-radius: 10px;
  max-width: calc(100vw - 2rem);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
  font-size: .92rem;
}
.toast.erro { background: var(--vermelho); }
.toast[hidden] { display: none; }

/* ---------- diálogos ---------- */

.dlg {
  border: none;
  border-radius: 14px;
  padding: 0;
  width: min(560px, calc(100vw - 1.5rem));
  max-height: calc(100dvh - 1.5rem);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
}
.dlg::backdrop { background: rgba(20, 30, 27, .55); }

.dlg-corpo { padding: 1rem; display: flex; flex-direction: column; gap: .75rem; }
.dlg h2 { margin: 0; font-size: 1.1rem; color: var(--verde-escuro); }
.dlg-acoes { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }

.dlg-cheio { width: calc(100vw - 1rem); max-width: 760px; height: calc(100dvh - 1rem); max-height: none; }
.pin-topo { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.pin-fotos { display: flex; flex-direction: column; gap: 1rem; }
.pin-foto .foto-wrap.alvo { cursor: crosshair; outline: 2px dashed var(--dourado); outline-offset: 2px; }

@media (min-width: 640px) {
  .fotos { grid-template-columns: repeat(3, 1fr); }
  .pin-fotos { display: grid; grid-template-columns: repeat(2, 1fr); }
}
