:root {
  --fundo: #f7f5f1;
  --superficie: #ffffff;
  --superficie-2: #f2efea;
  --borda: #ebe6de;
  --texto: #2d2b35;
  --texto-2: #85818f;
  --acento: #7467d4;
  --acento-forte: #5d51bd;
  --acento-suave: #eeebfb;
  --ok: #3e9a6c;
  --ok-suave: #e5f3eb;
  --perigo: #d4605f;
  --perigo-suave: #fbeaea;
  --chip: #f4f1ec;
  --chip-texto: #45424f;
  --topo-fundo: rgba(247, 245, 241, .82);
  --sombra: 0 1px 2px rgba(45, 43, 53, .04), 0 8px 24px rgba(45, 43, 53, .05);
  --sombra-forte: 0 12px 40px rgba(45, 43, 53, .14);
  --raio: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fundo: #18171c;
    --superficie: #212026;
    --superficie-2: #2a2930;
    --borda: #312f38;
    --texto: #ecebf1;
    --texto-2: #9a97a6;
    --acento: #a99ff0;
    --acento-forte: #bdb5f5;
    --acento-suave: #2e2b45;
    --ok: #79c99d;
    --ok-suave: #1f3329;
    --perigo: #ec8b8a;
    --perigo-suave: #3a2324;
    --chip: #2a2930;
    --chip-texto: #dcdae4;
    --topo-fundo: rgba(24, 23, 28, .82);
    --sombra: 0 1px 2px rgba(0, 0, 0, .2), 0 8px 24px rgba(0, 0, 0, .18);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fundo: #18171c; --superficie: #212026; --superficie-2: #2a2930; --borda: #312f38; --texto: #ecebf1; --texto-2: #9a97a6;
  --acento: #a99ff0; --acento-forte: #bdb5f5; --acento-suave: #2e2b45; --ok: #79c99d; --ok-suave: #1f3329; --perigo: #ec8b8a; --perigo-suave: #3a2324;
  --chip: #2a2930; --chip-texto: #dcdae4; --topo-fundo: rgba(24, 23, 28, .82); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fundo);
  color: var(--texto);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }

/* Topo */
.topo {
  position: sticky; top: 0; z-index: 20;
  background: var(--topo-fundo);
  backdrop-filter: saturate(1.4) blur(16px);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-bottom: 1px solid var(--borda);
  padding: calc(env(safe-area-inset-top) + 14px) 16px 0;
}
.topo-faixa { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1040px; margin: 0 auto; }
.marca { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: var(--acento-suave); color: var(--acento); flex: none; }
.logo svg { width: 26px; height: 26px; }
.logo.grande { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 6px; }
.logo.grande svg { width: 38px; height: 38px; }
h1 { font-size: 1.12rem; font-weight: 700; margin: 0; letter-spacing: -.02em; }
.subtitulo { margin: 2px 0 0; font-size: .8rem; color: var(--texto-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subtitulo b { color: var(--texto); font-weight: 600; }
.topo-acoes { display: flex; gap: 6px; }
.icone-btn { width: 40px; height: 40px; border-radius: 13px; border: 1px solid var(--borda); background: var(--superficie); color: var(--texto-2); display: grid; place-items: center; transition: color .15s, transform .1s; }
.icone-btn:hover { color: var(--acento); }
.icone-btn:active { transform: scale(.94); }
.icone-btn svg { width: 19px; height: 19px; }

.busca { position: relative; max-width: 1040px; margin: 12px auto 0; }
.busca svg { position: absolute; left: 14px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); color: var(--texto-2); pointer-events: none; }
.busca input {
  width: 100%; height: 44px; border-radius: 14px; border: 1px solid transparent;
  background: var(--superficie-2); padding: 0 14px 0 40px; font-size: 16px; outline: none; transition: border-color .15s, background .15s;
}
.busca input::placeholder { color: var(--texto-2); }
.busca input:focus { border-color: var(--acento); background: var(--superficie); }

.abas { display: flex; align-items: center; gap: 8px; padding: 12px 0; max-width: 1040px; margin: 0 auto; }
.seletor {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-align: left;
  border: 1px solid var(--borda); background: var(--superficie); border-radius: 16px; padding: 8px 12px 8px 8px; box-shadow: var(--sombra);
  transition: border-color .15s;
}
.seletor:hover { border-color: var(--acento); }
.seletor:active { transform: scale(.99); }
.seletor-icone { width: 36px; height: 36px; border-radius: 11px; background: var(--acento-suave); color: var(--acento); display: grid; place-items: center; flex: none; }
.seletor-icone svg { width: 18px; height: 18px; }
.seletor-texto { flex: 1; min-width: 0; display: grid; }
.seletor-texto small { font-size: .7rem; color: var(--texto-2); font-weight: 500; }
.seletor-texto strong { font-size: .95rem; font-weight: 650; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.seletor .n { flex: none; font-size: .74rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--acento); color: #fff; font-variant-numeric: tabular-nums; }
.seletor-seta { width: 18px; height: 18px; color: var(--texto-2); flex: none; }
.seletor-seta svg, .seta-nav svg { width: 100%; height: 100%; }
.seta-nav { width: 40px; height: 52px; flex: none; border-radius: 14px; border: 1px solid var(--borda); background: var(--superficie); color: var(--texto-2); display: grid; place-items: center; padding: 11px; }
.seta-nav:disabled { opacity: .35; cursor: default; }
.seta-nav:not(:disabled):hover { color: var(--acento); }

.lista-secoes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cartao-secao {
  display: grid; gap: 4px; align-content: start; text-align: left; border: 1px solid var(--borda); background: var(--superficie);
  border-radius: 16px; padding: 12px 14px; min-height: 74px;
}
.cartao-secao:hover { border-color: var(--acento); }
.cartao-secao.ativa { background: var(--acento-suave); border-color: transparent; }
.cartao-secao-nome { font-weight: 650; font-size: .9rem; line-height: 1.25; }
.cartao-secao.ativa .cartao-secao-nome { color: var(--acento-forte); }
.cartao-secao-info { font-size: .76rem; color: var(--texto-2); }
.barrinha { height: 4px; border-radius: 99px; background: var(--superficie-2); overflow: hidden; margin-top: 4px; }
.barrinha > span { display: block; height: 100%; background: var(--ok); border-radius: inherit; }
.folha { overflow: auto; }
.folha input[type="search"].campo { position: sticky; top: 0; z-index: 1; box-shadow: 0 6px 12px var(--superficie); }

.barra-admin { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 0 12px; max-width: 1040px; margin: 0 auto; }
.seg { display: inline-flex; background: var(--superficie-2); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: transparent; color: var(--texto-2); padding: 6px 14px; border-radius: 9px; font-size: .84rem; font-weight: 600; }
.seg button.ativo { background: var(--superficie); color: var(--texto); box-shadow: 0 1px 3px rgba(45, 43, 53, .1); }
.chave { display: inline-flex; align-items: center; gap: 8px; font-size: .84rem; font-weight: 600; color: var(--texto-2); cursor: pointer; user-select: none; }
.chave input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--borda); position: relative; margin: 0; cursor: pointer; transition: background .2s; }
.chave input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .2s; }
.chave input:checked { background: var(--acento); }
.chave input:checked::after { transform: translateX(16px); }

/* Conteúdo */
.conteudo { max-width: 1040px; margin: 0 auto; padding: 18px 16px 120px; }

.resumo {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--superficie); border-radius: var(--raio); padding: 18px 18px 18px 20px; margin-bottom: 16px; box-shadow: var(--sombra);
}
.resumo-texto { min-width: 0; }
.resumo .rotulo { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--texto-2); margin: 0 0 4px; }
.resumo h2 { font-size: 1.4rem; margin: 0; letter-spacing: -.03em; font-weight: 700; line-height: 1.15; }
.resumo .detalhe { margin: 6px 0 0; color: var(--texto-2); font-size: .86rem; }
.resumo-lado { display: flex; align-items: center; gap: 10px; flex: none; }
.numero { text-align: right; }
.numero strong { display: block; font-size: 1.9rem; font-weight: 700; letter-spacing: -.04em; line-height: 1; color: var(--acento); font-variant-numeric: tabular-nums; }
.numero span { font-size: .75rem; color: var(--texto-2); font-weight: 500; }
.anel { width: 56px; height: 56px; flex: none; }
.anel circle { fill: none; stroke-width: 6; }
.anel .trilho { stroke: var(--superficie-2); }
.anel .valor { stroke: var(--ok); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset .4s ease; }
.anel text { font-size: 13px; font-weight: 700; fill: var(--texto); text-anchor: middle; dominant-baseline: central; font-family: inherit; }

.grupos { display: grid; gap: 12px; }
@media (min-width: 860px) { .grupos.colunas { grid-template-columns: 1fr 1fr; align-items: start; } }
.grupos.compactos { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; align-items: start; grid-auto-flow: row dense; }
.grupos.compactos .grupo.largo { grid-column: 1 / -1; }
.grupos.compactos .grupo:not(.largo) .seta { display: none; }
.grupos.compactos .grupo:not(.largo) .grupo-titulo { align-items: flex-start; }
.grupos.compactos .grupo:not(.largo) .grupo-titulo h3 { white-space: normal; line-height: 1.25; }
.grupos.compactos .grupo:not(.largo) .mini-btn { width: 28px; }
.grupos.compactos .grupo-topo { padding: 12px 6px 10px 14px; }
.grupos.compactos .itens { padding: 0 10px 12px; gap: 5px; }
.grupos.compactos .itens.codigos .item { min-width: 0; padding: 6px 9px; font-size: .82rem; }
.grupo { background: var(--superficie); border-radius: var(--raio); box-shadow: var(--sombra); overflow: hidden; }
.grupo-topo { display: flex; align-items: center; gap: 8px; padding: 14px 12px 12px 18px; }
.grupo-titulo { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; text-align: left; }
.grupo-titulo h3 { margin: 0; font-size: .98rem; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; overflow-wrap: anywhere; }
.contador { flex: none; font-size: .74rem; font-weight: 600; color: var(--texto-2); background: var(--superficie-2); padding: 2px 8px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.seta { width: 18px; height: 18px; color: var(--texto-2); transition: transform .2s; flex: none; margin-left: auto; }
.grupo.fechado .seta { transform: rotate(-90deg); }
.grupo.fechado .itens { display: none; }
.grupo.fechado .grupo-topo { padding-bottom: 14px; }
.mini-btn { width: 34px; height: 34px; border-radius: 11px; border: 0; background: transparent; display: grid; place-items: center; color: var(--texto-2); flex: none; }
.mini-btn:hover { background: var(--superficie-2); color: var(--texto); }
.mini-btn svg { width: 18px; height: 18px; }

.itens { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 16px; }
.item {
  border: 1px solid transparent; background: var(--chip); color: var(--chip-texto); border-radius: 10px; padding: 7px 11px; font-size: .86rem; font-weight: 500;
  line-height: 1.3; text-align: left; max-width: 100%; overflow-wrap: anywhere; display: inline-flex; align-items: center; gap: 6px;
}
.itens.codigos .item { min-width: 48px; justify-content: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.publico .item { cursor: default; }
.admin .item { transition: transform .12s, background .15s, color .15s; }
.admin .item:hover { border-color: var(--borda); }
.admin .item:active { transform: scale(.95); }
.item .check { width: 14px; height: 14px; flex: none; display: none; }
.item.tenho { background: var(--ok-suave); color: var(--ok); }
.item.tenho .check { display: block; }
.editando .item { border: 1px dashed var(--texto-2); }
mark { background: var(--acento-suave); color: var(--acento-forte); border-radius: 4px; padding: 0 2px; font-weight: 600; }

.vazio { text-align: center; padding: 40px 16px; color: var(--texto-2); background: var(--superficie); border-radius: var(--raio); box-shadow: var(--sombra); }
.vazio .emoji { font-size: 2.4rem; display: block; margin-bottom: 8px; }
.vazio h3 { color: var(--texto); margin: 0 0 6px; font-weight: 650; }
.vazio p { margin: 0 0 14px; }

.secao-busca { margin: 20px 4px 10px; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--texto-2); font-weight: 600; }
.secao-busca:first-child { margin-top: 4px; }

/* Botões */
.btn { border: 0; border-radius: 13px; padding: 12px 16px; font-weight: 600; font-size: .94rem; background: var(--superficie-2); color: var(--texto); }
.btn.primario { background: var(--acento); color: #fff; }
.btn.perigo { background: var(--perigo-suave); color: var(--perigo); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; }
.btn-linha { display: flex; align-items: center; gap: 14px; width: 100%; border: 0; background: none; padding: 13px 8px; border-radius: 12px; text-align: left; font-weight: 500; }
.btn-linha:hover { background: var(--superficie-2); }
.btn-linha svg { width: 20px; height: 20px; color: var(--texto-2); flex: none; }
.btn-linha.perigo, .btn-linha.perigo svg { color: var(--perigo); }

.fab {
  position: fixed; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 18px); z-index: 25;
  border: 0; border-radius: 18px; padding: 0 18px 0 14px; height: 52px; display: flex; align-items: center; gap: 8px;
  background: var(--acento); color: #fff; font-weight: 600; box-shadow: 0 10px 28px color-mix(in srgb, var(--acento) 35%, transparent);
}
.fab svg { width: 22px; height: 22px; }
.fab:active { transform: scale(.97); }

/* Login */
.login { min-height: 70vh; display: grid; place-items: center; padding: 24px 16px; }
.cartao-login { width: min(380px, 100%); background: var(--superficie); border-radius: 24px; padding: 30px 22px; box-shadow: var(--sombra); text-align: center; display: grid; gap: 12px; }
.cartao-login h2 { margin: 4px 0 0; font-weight: 700; letter-spacing: -.02em; }
.cartao-login p { margin: 0; color: var(--texto-2); font-size: .92rem; }
.campo, .cartao-login input {
  width: 100%; min-height: 48px; border-radius: 13px; border: 1px solid var(--borda); background: var(--superficie-2); padding: 12px 14px; font-size: 16px; outline: none;
}
.campo:focus, .cartao-login input:focus { border-color: var(--acento); background: var(--superficie); }
textarea.campo { min-height: 150px; resize: vertical; line-height: 1.45; }
.erro { color: var(--perigo) !important; min-height: 1.2em; font-weight: 600; }
.link { color: var(--acento); font-weight: 600; text-decoration: none; font-size: .9rem; }

/* Folha (bottom sheet) */
.folha {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 540px; max-height: 88vh;
  border-radius: 26px 26px 0 0; background: var(--superficie); color: var(--texto); box-shadow: var(--sombra-forte);
}
.folha::backdrop { background: rgba(30, 28, 38, .35); backdrop-filter: blur(3px); }
.folha[open] { animation: subir .22s ease-out; }
@keyframes subir { from { transform: translateY(30px); opacity: 0; } }
.folha form { padding: 10px 18px calc(env(safe-area-inset-bottom) + 18px); display: grid; gap: 12px; }
.folha-alca { width: 38px; height: 5px; border-radius: 99px; background: var(--borda); margin: 0 auto 4px; }
.folha h3 { margin: 0; font-size: 1.08rem; font-weight: 650; }
.folha label { font-size: .84rem; font-weight: 600; color: var(--texto-2); display: grid; gap: 6px; }
.folha .dica { margin: 0; font-size: .82rem; color: var(--texto-2); font-weight: 400; }
.folha-acoes { display: flex; gap: 10px; justify-content: flex-end; }
.folha-acoes .btn { flex: 1; }
@media (min-width: 640px) { .folha { margin: auto; border-radius: 26px; } .folha-alca { display: none; } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); transform: translateX(-50%); z-index: 40;
  background: #2d2b35; color: #fff; border-radius: 14px; padding: 10px 10px 10px 16px; display: flex; align-items: center; gap: 12px;
  box-shadow: var(--sombra-forte); font-size: .88rem; width: max-content; max-width: calc(100vw - 32px); animation: subir .2s ease-out;
}
.toast button { border: 0; background: rgba(255, 255, 255, .12); color: #cfc8ff; font-weight: 600; border-radius: 10px; padding: 7px 12px; }

.rodape { max-width: 1040px; margin: 0 auto; padding: 0 16px calc(env(safe-area-inset-bottom) + 28px); display: flex; justify-content: space-between; color: var(--texto-2); font-size: .78rem; }
.rodape a { color: var(--texto-2); }
.admin-ativo .rodape { padding-bottom: 96px; }

.esqueleto { height: 120px; border-radius: var(--raio); background: linear-gradient(90deg, var(--superficie) 0%, var(--superficie-2) 50%, var(--superficie) 100%); background-size: 200% 100%; animation: brilho 1.2s infinite; margin-bottom: 12px; }
@keyframes brilho { to { background-position: -200% 0; } }

@media (min-width: 720px) {
  .topo { padding-left: 24px; padding-right: 24px; }
  .conteudo { padding: 24px 24px 120px; }
  h1 { font-size: 1.25rem; }
  .resumo { padding: 22px 24px; }
  .resumo h2 { font-size: 1.7rem; }
}

/* Tela inicial: categorias com blocos (ícone + nome), como um app */
.intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 4px 4px 18px; }
.intro .rotulo { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--texto-2); margin: 0 0 4px; }
.intro h2 { margin: 0; font-size: 1.45rem; font-weight: 700; letter-spacing: -.03em; }
.categoria { margin-bottom: 22px; }
.categoria-titulo { display: flex; align-items: center; gap: 10px; margin: 0 4px 12px; font-size: 1.12rem; font-weight: 600; letter-spacing: -.02em; color: var(--texto); }
.categoria-icone { width: 24px; height: 24px; color: var(--texto-2); display: grid; }
.categoria-icone svg, .tile-icone svg, .seletor-icone svg, .escolha-icone svg { width: 100%; height: 100%; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 560px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 860px) { .tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; } }
.tile {
  --cor: var(--acento);
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  min-height: 116px; padding: 18px 8px 14px; text-align: center;
  background: var(--superficie); border: 1px solid color-mix(in srgb, var(--cor) 28%, var(--borda));
  border-bottom: 4px solid var(--cor); border-radius: 16px; box-shadow: var(--sombra);
  transition: transform .12s, box-shadow .15s;
}
.tile:hover { box-shadow: 0 10px 26px color-mix(in srgb, var(--cor) 18%, transparent); }
.tile:active { transform: scale(.96); }
.tile-icone { width: 38px; height: 38px; color: var(--cor); display: grid; }
.tile-nome { font-size: .8rem; font-weight: 500; line-height: 1.25; color: var(--texto); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.tile-n {
  position: absolute; top: 7px; right: 7px; font-size: .68rem; font-weight: 700; line-height: 1; padding: 4px 6px; border-radius: 999px;
  color: var(--cor); background: color-mix(in srgb, var(--cor) 13%, transparent); font-variant-numeric: tabular-nums;
}
.tile.completa .tile-n { color: var(--ok); background: var(--ok-suave); }
.tile-progresso { position: absolute; left: 10px; right: 10px; bottom: 6px; height: 3px; border-radius: 99px; background: var(--superficie-2); overflow: hidden; }
.tile-progresso > span { display: block; height: 100%; background: var(--cor); border-radius: inherit; }
.admin .tile { padding-bottom: 18px; }

/* Barra dentro da seção: voltar + seletor */
.voltar { flex: none; height: 52px; display: flex; align-items: center; gap: 2px; padding: 0 12px 0 8px; border-radius: 14px; border: 1px solid var(--borda); background: var(--superficie); color: var(--texto); font-weight: 600; font-size: .86rem; }
.voltar svg { width: 20px; height: 20px; }
.voltar:active { transform: scale(.97); }
.seletor { --cor: var(--acento); }
.seletor-icone { width: 36px; height: 36px; border-radius: 11px; padding: 7px; background: color-mix(in srgb, var(--cor) 13%, transparent); color: var(--cor); flex: none; display: grid; }
.seletor .n { background: var(--cor); }
.na-home .barra-admin { display: none; }

/* Folha de aparência */
.previa { display: flex; justify-content: center; }
.tile-previa { width: 130px; cursor: default; }
.escolhas { display: flex; flex-wrap: wrap; gap: 8px; }
.escolha { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--borda); background: var(--superficie); display: grid; place-items: center; padding: 9px; color: var(--texto-2); }
.escolha.ativa { border: 2px solid var(--acento); color: var(--acento); background: var(--acento-suave); }
.escolha-icone { width: 100%; height: 100%; display: grid; }
.bolinha { width: 22px; height: 22px; border-radius: 50%; display: block; }

.logo-img { width: 42px; height: 42px; border-radius: 12px; flex: none; display: block; box-shadow: 0 2px 8px rgba(106, 92, 201, .25); }
