:root {
  --fundo: #07070d;
  --painel: #11111b;
  --painel2: #181826;
  --linha: #26263a;
  --texto: #ececf4;
  --suave: #9a9ab2;
  --marca: #7c5cff;
  --ok: #34d399;
  --aviso: #f59e0b;
  --erro: #ef4444;
  --raio: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--fundo); color: var(--texto); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--marca); }
.oculto { display: none !important; }

/* ---------- telas de entrada ---------- */
.entrada { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.cartao { width: 100%; max-width: 380px; background: var(--painel); border: 1px solid var(--linha); border-radius: 20px; padding: 28px 22px; }
.cartao h1 { margin: 0 0 4px; font-size: 1.5rem; }
.cartao p { margin: 0 0 18px; color: var(--suave); }
label { display: block; font-size: .85rem; color: var(--suave); margin: 12px 0 4px; }
input, select, textarea { width: 100%; background: var(--painel2); border: 1px solid var(--linha); border-radius: 10px; padding: 11px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--marca); }
textarea { min-height: 90px; resize: vertical; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 10px; padding: 11px 16px; background: var(--marca); color: #fff; font-weight: 600; cursor: pointer; }
.btn.largo { width: 100%; margin-top: 18px; }
.btn.sec { background: var(--painel2); border: 1px solid var(--linha); color: var(--texto); }
.btn.perigo { background: var(--erro); }
.btn.peq { padding: 7px 11px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }
/* ---------- ÍCONES (SVG em traço) e TILES com degradê — padrão do ECO CHAT ----------
 * Cada função tem a SUA cor (--c) e a segunda ponta do degradê (--c2); o ícone
 * fica branco sobre o degradê. */
.ic { display: inline-block; vertical-align: middle; flex: 0 0 auto; }
.tile { --c: #8b5cf6; --c2: #6366f1; display: inline-grid; place-items: center; width: 38px; height: 38px; flex: 0 0 38px; border-radius: 11px;
  background: linear-gradient(135deg, var(--c), var(--c2)); color: #fff;
  box-shadow: 0 2px 8px -2px color-mix(in srgb, var(--c) 65%, transparent), inset 0 1px 0 rgba(255,255,255,.18); }
.tile .ic { stroke: #fff; }
.tile.marca-tile .ic { fill: #fff; }
.tile.peq { width: 28px; height: 28px; flex-basis: 28px; border-radius: 8px; }
.tile.grande { width: 84px; height: 84px; flex-basis: 84px; border-radius: 24px; }
.c-violeta  { --c: #8b5cf6; --c2: #14b8a6; }
.c-indigo   { --c: #6366f1; --c2: #8b5cf6; }
.c-azul     { --c: #3b82f6; --c2: #6366f1; }
.c-verde    { --c: #22c55e; --c2: #0d9488; }
.c-turquesa { --c: #14b8a6; --c2: #0891b2; }
.c-ambar    { --c: #f59e0b; --c2: #ef6c1a; }
.c-vermelho { --c: #ef4444; --c2: #db2777; }
.c-rosa     { --c: #ec4899; --c2: #8b5cf6; }
.c-cinza    { --c: #64748b; --c2: #475569; }
.btn .ic { margin: -2px 0; }
.ok-ic { color: var(--ok); }
.erro-ic { color: var(--erro); }
.acoes .ic { margin-right: 2px; }
.codigo-zap { font-size: 2rem; font-weight: 800; letter-spacing: .12em; text-align: center; padding: 14px 8px; margin: 12px 0 6px; border-radius: 14px;
  background: var(--painel2); border: 1px dashed color-mix(in srgb, #22c55e 55%, var(--linha)); font-variant-numeric: tabular-nums; user-select: all; }
.passos { margin: 10px 0 0; padding-left: 20px; color: var(--suave); font-size: .9rem; display: flex; flex-direction: column; gap: 4px; }
.passos b { color: var(--texto); }
.abas-zap { display: flex; gap: 6px; margin: 12px 0 4px; }
.abas-zap button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; border-radius: 10px; border: 1px solid var(--linha); background: var(--painel2); cursor: pointer; font-weight: 600; font-size: .9rem; }
.abas-zap button.sel { border-color: #22c55e; background: color-mix(in srgb, #22c55e 14%, var(--painel2)); }
.aviso-linha { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; color: var(--suave); font-size: .85rem; }
.aviso-linha .ic { color: var(--aviso); margin-top: 2px; }

/* Olhinho de mostrar/esconder senha */
.campo-senha { position: relative; }
.campo-senha input { padding-right: 48px; }
.campo-senha .olho { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border: 0; background: none; color: var(--suave); display: grid; place-items: center; cursor: pointer; border-radius: 8px; }
.campo-senha .olho:hover, .campo-senha .olho:focus-visible { color: var(--texto); }
.campo-senha .olho svg { width: 22px; height: 22px; }
.erro-msg { color: var(--erro); font-size: .9rem; min-height: 1.2em; margin-top: 10px; }

/* ---------- tela principal ---------- */
.principal { height: 100%; display: flex; flex-direction: column; }
.topo { display: flex; align-items: center; gap: 10px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); }
.topo .nome { font-weight: 700; font-size: 1.1rem; }
.topo .estado { color: var(--suave); font-size: .85rem; }
.topo .esp { flex: 1; }
.icone { position: relative; width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--linha); background: var(--painel); display: grid; place-items: center; cursor: pointer; }
.icone svg { width: 22px; height: 22px; }
.selo { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--erro); color: #fff; font-size: .7rem; display: grid; place-items: center; }
.palco { flex: 1; position: relative; min-height: 0; }
#esfera { width: 100%; height: 100%; display: block; cursor: pointer; touch-action: manipulation; }
.dica { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; color: var(--suave); font-size: .85rem; pointer-events: none; }
.legenda { padding: 0 16px; min-height: 92px; max-height: 28vh; overflow-y: auto; text-align: center; }
.legenda .eu { color: var(--suave); font-size: .9rem; }
.legenda .ia { font-size: 1.05rem; margin-top: 6px; }
.legenda .acoes { margin-top: 6px; font-size: .75rem; color: var(--suave); }
.barra { display: flex; gap: 8px; padding: 10px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.barra input { flex: 1; border-radius: 24px; padding: 12px 16px; }
.mic { width: 48px; height: 48px; flex: 0 0 48px; border-radius: 50%; border: 0; background: var(--marca); color: #fff; display: grid; place-items: center; cursor: pointer; }
.mic.ativo { background: #0e7490; box-shadow: 0 0 0 6px rgba(34,211,238,.2); }
.mic svg { width: 22px; height: 22px; }

.legenda .btn.largo { margin-top: 10px; }
.mapa { margin: 10px auto 0; max-width: 520px; border: 1px solid var(--linha); border-radius: var(--raio); overflow: hidden; background: var(--painel); text-align: left; }
.mapa iframe { display: block; width: 100%; height: 190px; border: 0; }
.mapa-rodape { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.mapa-rodape > div { flex: 1; min-width: 0; }
.mapa-rodape .sub { color: var(--suave); font-size: .8rem; }
.legenda:has(.mapa) { max-height: 46vh; }

/* ---------- gaveta / folhas ---------- */
.veu { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20; }
.gaveta { position: fixed; top: 0; bottom: 0; right: 0; width: min(320px, 86vw); background: var(--painel); border-left: 1px solid var(--linha); z-index: 21; padding: 18px 12px; padding-top: max(18px, env(safe-area-inset-top)); overflow-y: auto; }
.gaveta h3 { margin: 4px 8px 12px; }
.gaveta button { display: flex; width: 100%; align-items: center; gap: 12px; padding: 9px 10px; font-weight: 550; border: 0; background: none; border-radius: 10px; text-align: left; cursor: pointer; }
.gaveta button:hover { background: var(--painel2); }
.gaveta .quem { padding: 8px 12px 16px; color: var(--suave); font-size: .85rem; border-bottom: 1px solid var(--linha); margin-bottom: 8px; }
.folha { position: fixed; inset: 0; z-index: 30; background: var(--fundo); display: flex; flex-direction: column; }
.folha header { display: flex; align-items: center; gap: 12px; padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top)); border-bottom: 1px solid var(--linha); }
.folha header h2 { margin: 0; font-size: 1.15rem; flex: 1; }
.folha .corpo { flex: 1; overflow-y: auto; padding: 16px; padding-bottom: 40px; max-width: 720px; width: 100%; margin: 0 auto; }
.bloco { background: var(--painel); border: 1px solid var(--linha); border-radius: var(--raio); padding: 14px; margin-bottom: 12px; }
.bloco h4 { margin: 0 0 6px; }
.bloco .sub { color: var(--suave); font-size: .85rem; }
.linha { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.linha > * { flex: 1 1 auto; }
.item { display: flex; gap: 10px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--linha); }
.item:last-child { border-bottom: 0; }
.item .txt { flex: 1; min-width: 0; }
.item .tit { font-weight: 600; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .72rem; background: var(--painel2); border: 1px solid var(--linha); color: var(--suave); }
.chip.ok { color: var(--ok); border-color: rgba(52,211,153,.35); }
.chip.aviso { color: var(--aviso); border-color: rgba(245,158,11,.35); }
.chip.erro { color: var(--erro); border-color: rgba(239,68,68,.35); }
.vazio { color: var(--suave); text-align: center; padding: 18px 0; }
.chave { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--linha); }
.chave:last-child { border-bottom: 0; }
.interruptor { position: relative; width: 46px; height: 26px; flex: 0 0 46px; }
.interruptor input { opacity: 0; width: 0; height: 0; }
.interruptor span { position: absolute; inset: 0; border-radius: 13px; background: var(--linha); transition: .2s; cursor: pointer; }
.interruptor span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; }
.interruptor input:checked + span { background: var(--ok); }
.interruptor input:checked + span::after { transform: translateX(20px); }
.codigo { font-size: 2.2rem; letter-spacing: .35em; font-weight: 800; text-align: center; padding: 12px 0; font-variant-numeric: tabular-nums; }
.qr { display: block; margin: 12px auto; background: #fff; padding: 8px; border-radius: 12px; width: 260px; max-width: 100%; }
.cores { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.cores button { width: 34px; height: 34px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.cores button.sel { border-color: #fff; }

/* ---------- toast + alarme ---------- */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); top: max(12px, env(safe-area-inset-top)); z-index: 50; width: min(420px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--painel2); border: 1px solid var(--linha); border-radius: 12px; padding: 12px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: entra .25s ease; }
.toast b { display: block; }
@keyframes entra { from { opacity: 0; transform: translateY(-8px); } }
.alarme { position: fixed; inset: 0; z-index: 60; background: radial-gradient(circle at 50% 35%, rgba(239,68,68,.35), rgba(7,7,13,.97) 60%); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px 16px; gap: 12px; }
.alarme .sino { animation: balanca .5s ease-in-out infinite alternate; }
@keyframes balanca { from { transform: rotate(-14deg); } to { transform: rotate(14deg); } }
.alarme h2 { margin: 0; font-size: 1.6rem; }
.alarme p { margin: 0; color: var(--suave); max-width: 420px; }
.alarme .linha { width: 100%; max-width: 420px; margin-top: 16px; }
.alarme .btn { padding: 14px; }

/* ---------- tabela (admin) ---------- */
.tabela { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabela th, .tabela td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--linha); vertical-align: top; }
.tabela th { color: var(--suave); font-weight: 500; font-size: .8rem; }
.rolar { overflow-x: auto; }
@media (min-width: 900px) {
  .legenda { max-width: 720px; margin: 0 auto; width: 100%; }
  .barra { max-width: 720px; margin: 0 auto; width: 100%; }
}
