:root {
  --fundo: #f6f4ef;
  --cartao: #ffffff;
  --texto: #1c1f26;
  --suave: #5d6270;
  --linha: #e4e0d6;
  --marca: #14213d;
  --acento: #e2683c;
  --acento-escuro: #c4532b;
  --ok: #2f7d4f;
  --raio: 14px;
  --sombra: 0 1px 2px rgba(20, 33, 61, .06), 0 4px 14px rgba(20, 33, 61, .06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--texto);
  background: var(--fundo);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }

.tela { min-height: 100dvh; }
.marca { margin: 0; font-weight: 700; letter-spacing: .02em; color: var(--marca); font-size: .9rem; text-transform: uppercase; }

/* Botões */
.botao {
  border: 1px solid var(--linha); background: var(--cartao); color: var(--texto);
  border-radius: 999px; padding: .8rem 1.2rem; min-height: 44px; font-weight: 600;
}
.botao.primario { background: var(--acento); border-color: var(--acento); color: #fff; width: 100%; }
.botao.primario:active { background: var(--acento-escuro); }
.botao.pequeno { padding: .45rem .85rem; min-height: 36px; font-size: .88rem; }
.botao.texto { background: none; border: none; color: var(--marca); text-decoration: underline; width: 100%; }
.botao:disabled { opacity: .5; cursor: default; }
.botao:focus-visible, input:focus-visible { outline: 3px solid #f4b393; outline-offset: 2px; }

/* Login */
#tela-login, #tela-sem-acesso { display: grid; place-items: center; padding: 1.5rem; }
.login-caixa {
  width: 100%; max-width: 400px; background: var(--cartao); border-radius: 20px; padding: 2rem 1.5rem;
  box-shadow: var(--sombra);
}
.login-caixa h1 { font-size: 1.5rem; margin: .4rem 0 1.4rem; color: var(--marca); }
.login-caixa form { display: grid; gap: .7rem; }
label { font-weight: 600; font-size: .92rem; }
input[type="email"], input[type="text"], input[type="search"] {
  width: 100%; font-size: 16px; padding: .85rem 1rem; border: 1px solid var(--linha); border-radius: 12px;
  background: #fff; color: var(--texto);
}
#campo-codigo { font-size: 1.5rem; letter-spacing: .4em; text-align: center; }
.ajuda { color: var(--suave); font-size: .88rem; margin: 0; }
.mensagem { margin: 1rem 0 0; padding: .75rem 1rem; border-radius: 10px; background: #fdecea; color: #8a1f11; font-size: .92rem; }
.mensagem.ok { background: #e8f4ec; color: var(--ok); }

/* Topo do app */
.topo {
  position: sticky; top: 0; z-index: 5; background: rgba(246, 244, 239, .96); backdrop-filter: blur(6px);
  padding: .8rem 1rem .6rem; border-bottom: 1px solid var(--linha); display: grid; gap: .6rem;
  padding-top: max(.8rem, env(safe-area-inset-top));
}
.topo-linha { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.topo-acoes { display: flex; gap: .3rem; }
.topo-acoes .botao.texto { width: auto; }
.plano { margin: .1rem 0 0; font-size: .82rem; color: var(--suave); }
#selo-plano { font-weight: 700; color: var(--acento-escuro); }

.chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .2rem; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--linha); background: #fff; border-radius: 999px; padding: .45rem .8rem;
  font-size: .86rem; color: var(--texto); min-height: 36px;
}
.chip[aria-pressed="true"] { background: var(--marca); border-color: var(--marca); color: #fff; }
.chip small { opacity: .7; margin-left: .2rem; }

.opcoes { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.alternar { display: inline-flex; border: 1px solid var(--linha); border-radius: 999px; overflow: hidden; background: #fff; }
.alternar button { border: 0; background: none; padding: .4rem .8rem; min-height: 36px; font-weight: 600; font-size: .86rem; }
.alternar button[aria-pressed="true"] { background: var(--marca); color: #fff; }
#filtro-fav[aria-pressed="true"] { background: #fff4d6; border-color: #e9c46a; }
.checa { font-weight: 500; font-size: .86rem; display: inline-flex; gap: .35rem; align-items: center; color: var(--suave); }
.checa input { width: 18px; height: 18px; }

/* Lista */
.lista { padding: .8rem 1rem 6rem; display: grid; gap: .7rem; max-width: 760px; margin: 0 auto; }
.secao { margin: 1rem 0 .1rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--suave); font-weight: 700; }
.secao:first-child { margin-top: .2rem; }
.cartao { background: var(--cartao); border-radius: var(--raio); padding: .9rem 1rem; box-shadow: var(--sombra); display: grid; gap: .5rem; }
.cartao-topo { display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start; }
.cartao h3 { margin: 0; font-size: 1rem; line-height: 1.3; }
.cartao h3 .id { color: var(--suave); font-weight: 600; font-variant-numeric: tabular-nums; margin-right: .25rem; }
.selos { display: flex; flex-wrap: wrap; gap: .3rem; }
.selo { font-size: .74rem; border-radius: 6px; padding: .15rem .45rem; background: #eef0f4; color: #3b4252; }
.selo.grupo { background: #fff1e8; color: #9a4421; }
.selo.usado { background: #e8f4ec; color: var(--ok); }
.texto-prompt {
  margin: 0; font-size: .9rem; color: #393d47; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.cartao.aberto .texto-prompt { -webkit-line-clamp: unset; display: block; }
.cartao-acoes { display: flex; gap: .5rem; align-items: center; }
.cartao-acoes .copiar { flex: 1; width: auto; }
.icone { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--linha); background: #fff; font-size: 1.15rem; line-height: 1; }
.icone[aria-pressed="true"] { background: #fff4d6; border-color: #e9c46a; }
.ver-tudo { background: none; border: 0; color: var(--marca); text-decoration: underline; padding: 0; font-size: .85rem; justify-self: start; }

.vazio { text-align: center; color: var(--suave); padding: 2rem 1rem; }
.aviso-upgrade { max-width: 760px; margin: 0 auto 6rem; padding: 0 1rem; }
.aviso-upgrade .caixa { background: var(--marca); color: #fff; border-radius: var(--raio); padding: 1.1rem; display: grid; gap: .6rem; }
.aviso-upgrade a { color: #fff; font-weight: 700; }

dialog { border: 0; border-radius: 18px; padding: 1.4rem; max-width: 480px; width: calc(100% - 2rem); box-shadow: var(--sombra); }
dialog::backdrop { background: rgba(20, 33, 61, .45); }
dialog h2 { margin-top: 0; color: var(--marca); }
dialog li { margin-bottom: .6rem; line-height: 1.45; }

.toast {
  position: fixed; left: 50%; bottom: max(1.2rem, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--marca); color: #fff; padding: .8rem 1.1rem; border-radius: 12px; font-size: .92rem;
  width: max-content; max-width: calc(100% - 2rem); box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 20; text-align: center;
}

@media (min-width: 720px) {
  .topo { padding-left: max(1rem, calc((100% - 760px) / 2)); padding-right: max(1rem, calc((100% - 760px) / 2)); }
}
