:root {
  --verde: #15803d;
  --verde-claro: #dcfce7;
  --fundo: #f4f7f5;
  --cartao: #ffffff;
  --texto: #1d2b24;
  --texto-suave: #5b6b63;
  --borda: #d6e0da;
  --erro: #b3261e;
  --ok: #1a9c4a;
}

* { box-sizing: border-box; }

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fundo);
  color: var(--texto);
  -webkit-text-size-adjust: 100%;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#app { max-width: 480px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 0 0 8px; }
p { margin: 0 0 12px; }

.tela { flex: 1; padding: 20px 16px 96px; }
.centro { text-align: center; }
.logo { width: 88px; height: 88px; display: block; margin: 8px auto 8px; }
.suave { color: var(--texto-suave); font-size: 0.9rem; }

/* campos */
.campo { margin-bottom: 14px; }
.campo label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 4px; }
.campo input[type="text"], .campo input[type="email"], .campo input[type="tel"], .campo input[type="password"] {
  width: 100%; font: inherit; font-size: 16px; /* 16px: o iPhone nao da zoom ao tocar */
  padding: 12px; border: 1px solid var(--borda); border-radius: 10px; background: #fff; color: var(--texto);
}
.campo input:focus { outline: 2px solid var(--verde); outline-offset: 0; border-color: var(--verde); }
.campo input:disabled { background: #eef2ef; color: var(--texto-suave); }
.campo .dica { display: block; margin-top: 4px; font-size: 0.82rem; color: var(--texto-suave); }
.prefixo { display: flex; align-items: center; border: 1px solid var(--borda); border-radius: 10px; background: #fff; }
.prefixo:focus-within { outline: 2px solid var(--verde); border-color: var(--verde); }
.prefixo span { padding-left: 12px; font-weight: 700; color: var(--texto-suave); }
.prefixo input { border: 0 !important; outline: none !important; border-radius: 0 10px 10px 0 !important; }

/* botoes */
.botao {
  display: block; width: 100%; font: inherit; font-weight: 700; font-size: 1rem; min-height: 48px;
  padding: 12px 16px; border: 0; border-radius: 12px; background: var(--verde); color: #fff; cursor: pointer;
}
.botao:disabled { opacity: 0.6; cursor: default; }
.botao.claro { background: var(--verde-claro); color: var(--verde); }
.botao.perigo { background: #fff; color: var(--erro); border: 1px solid var(--erro); }
.link { background: none; border: 0; padding: 12px 0; font: inherit; color: var(--verde); font-weight: 700; cursor: pointer; width: 100%; }

.erro { background: #fdecea; color: var(--erro); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 0.92rem; }
.aviso-ok { background: var(--verde-claro); color: var(--verde); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 0.92rem; }

/* foto */
.avatar { flex: none; width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--verde-claro); border: 2px solid var(--borda); }
.avatar.grande { width: 96px; height: 96px; }
.foto-escolha { display: flex; align-items: center; gap: 14px; }
.foto-escolha input[type="file"] { font-size: 0.9rem; max-width: 100%; }

/* cartoes */
.cartao { background: var(--cartao); border: 1px solid var(--borda); border-radius: 16px; padding: 16px; margin-bottom: 14px; }
.codigo { font-size: 2.4rem; font-weight: 800; letter-spacing: 0.12em; color: var(--verde); text-align: center; margin: 6px 0; font-variant-numeric: tabular-nums; }

.topo { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--cartao); border-bottom: 1px solid var(--borda); }
.topo .quem { font-weight: 700; }
.topo .quem small { display: block; font-weight: 400; color: var(--texto-suave); }

/* barra de baixo */
.abas { position: fixed; left: 0; right: 0; bottom: 0; background: var(--cartao); border-top: 1px solid var(--borda); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); }
.abas .grupo { display: flex; width: 100%; max-width: 480px; }
.abas button { flex: 1; font: inherit; background: none; border: 0; padding: 12px 8px; min-height: 56px; color: var(--texto-suave); font-weight: 600; cursor: pointer; }
.abas button.ativa { color: var(--verde); box-shadow: inset 0 3px 0 var(--verde); }

/* servidor online */
.servidor { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--texto-suave); margin: 14px 0; }
.bolinha { width: 10px; height: 10px; border-radius: 50%; background: #aab5af; }
.bolinha.on { background: var(--ok); }
.bolinha.off { background: var(--erro); }

.bloqueado { opacity: 0.6; pointer-events: none; }

/* ---- etapa 2: conectados e pedidos ---- */
.painel { background: var(--cartao); border: 3px solid var(--borda); border-radius: 16px; padding: 14px; margin-bottom: 14px; }
.painel.verde { border-color: var(--ok); }
.painel.vermelho { border-color: var(--erro); }
.painel h2 { margin-bottom: 4px; }

.pessoa { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; padding: 12px 0; border-top: 1px solid var(--borda); }
.painel h2 + .pessoa { border-top: 0; }
.pessoa .nome { flex: 1; min-width: 0; font-weight: 700; word-break: break-all; }
.pessoa .nome small { display: block; font-weight: 400; color: var(--texto-suave); word-break: normal; }
.pessoa .acoes { display: flex; flex-wrap: wrap; gap: 8px; flex-basis: 100%; }
.pessoa .conferencia { flex-basis: 100%; }
.conferencia small { display: block; color: var(--texto-suave); font-size: 0.82rem; margin-top: 4px; }

.avatar-box { position: relative; width: 44px; height: 44px; flex: none; }
.avatar-box .avatar { display: block; }
.ponto { position: absolute; right: -1px; bottom: -1px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; background: #aab5af; }
.ponto.on { background: var(--ok); }

.botao.mini { display: inline-block; width: auto; min-height: 40px; padding: 8px 14px; font-size: 0.9rem; }
.botao.verde { background: var(--verde); color: #fff; }
.botao.espaco { margin-bottom: 10px; }
.botao.perigo.mini { background: #fff; }

.marca { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 14px; font-size: 0.92rem; font-weight: 600; cursor: pointer; }
.marca input { width: 22px; height: 22px; flex: none; margin: 1px 0 0; accent-color: var(--verde); }
.marca small { display: block; font-weight: 400; color: var(--texto-suave); font-size: 0.82rem; margin-top: 2px; }

.campo-conferencia { width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid var(--borda); border-radius: 10px; letter-spacing: 0.2em; }
.conf-numero { font-size: 1.8rem; font-weight: 800; letter-spacing: 0.25em; color: var(--verde); margin-top: 6px; font-variant-numeric: tabular-nums; }

/* ---- etapa 3: envio e recebimento ---- */
.anel { position: absolute; left: -6px; top: -6px; width: calc(100% + 12px); height: calc(100% + 12px); pointer-events: none; }
.anel-fundo { fill: none; stroke: rgba(37, 99, 235, 0.18); stroke-width: 3; }
.anel-valor { fill: none; stroke: #2563eb; stroke-width: 3; stroke-linecap: round; transition: stroke-dashoffset 0.15s linear; }
.anel-check { fill: none; stroke: #fff; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.anel.pronto .anel-fundo { fill: rgba(37, 99, 235, 0.7); stroke: #2563eb; }
.anel.pronto .anel-check { opacity: 1; }

.estado { display: block; margin-top: 4px; font-weight: 600; color: #2563eb; word-break: normal; }
.estado.ok { color: var(--ok); }
.estado.erro { color: var(--erro); }
.controle { margin-top: 6px; }
.controle:empty { display: none; }

.selo { display: inline-block; min-width: 20px; margin-left: 6px; padding: 1px 6px; border-radius: 10px; background: var(--erro); color: #fff; font-size: 0.78rem; line-height: 18px; text-align: center; }
.selo[hidden] { display: none; }

.estado[hidden] { display: none; }

/* ---- ajuste da foto (recorte com zoom) ---- */
.avatar.clicavel { cursor: pointer; }
.recorte-fundo { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.6); display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.recorte-caixa { background: var(--cartao); border-radius: 16px; padding: 18px 16px; width: 100%; max-width: 360px; text-align: center; }
.recorte-caixa h2 { margin-bottom: 4px; }
.recorte-janela { position: relative; width: min(300px, 100%); aspect-ratio: 1 / 1; margin: 12px auto; overflow: hidden; background: #222; border-radius: 12px; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.recorte-janela:active { cursor: grabbing; }
.recorte-img { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; pointer-events: none; -webkit-user-drag: none; }
.recorte-mascara { position: absolute; left: 20px; top: 20px; width: 260px; height: 260px; border-radius: 50%; /* tamanho real ajustado pelo app */ border: 2px solid #fff; box-shadow: 0 0 0 400px rgba(0, 0, 0, 0.55); pointer-events: none; }
.recorte-zoom-linha { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-weight: 800; font-size: 1.3rem; color: var(--texto-suave); }
.recorte-zoom { flex: 1; accent-color: var(--verde); height: 32px; }
.recorte-botoes { display: flex; gap: 10px; }
.recorte-botoes .botao { flex: 1; }
