:root {
  --fundo: #f4f5f7; --cartao: #ffffff; --borda: #e2e5ea; --texto: #1d2129; --suave: #5b6472; --fraco: #8c94a1;
  --acento: #4f46e5; --acento-bg: #eef0ff; --ok: #15803d; --ok-bg: #e7f6ec; --erro: #c62828; --erro-bg: #fdecec;
  --aviso: #92400e; --aviso-bg: #fdf3e1; --porta: #e9ebef; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --fundo: #121417; --cartao: #1b1e23; --borda: #2c3038; --texto: #e7e9ee; --suave: #a3abb8; --fraco: #737b88;
    --acento: #8b84ff; --acento-bg: #24224a; --ok: #5bd28a; --ok-bg: #16301f; --erro: #ff7b7b; --erro-bg: #3a1c1c;
    --aviso: #f3c37a; --aviso-bg: #3a2c14; --porta: #23262c; color-scheme: dark; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fundo); color: var(--texto); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, select, input { font: inherit; color: inherit; }
button { background: var(--cartao); border: 1px solid var(--borda); border-radius: 8px; padding: .45rem .8rem; cursor: pointer; }
button:hover { border-color: var(--acento); }
button.perigo { color: var(--erro); }
select { background: var(--cartao); border: 1px solid var(--borda); border-radius: 8px; padding: .4rem .5rem; min-width: 0; }

.topo { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .8rem 1.25rem;
  background: var(--cartao); border-bottom: 1px solid var(--borda); }
.marca-topo { font-weight: 600; display: flex; align-items: center; gap: .6rem; }
.logo { letter-spacing: .15em; color: var(--acento); }
.selo { font-size: .75rem; font-weight: 500; background: var(--acento-bg); color: var(--acento); padding: .1rem .55rem; border-radius: 999px; }
.topo-dir { font-size: .85rem; color: var(--suave); display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }
.topo-dir code { font-family: var(--mono); background: var(--fundo); border: 1px solid var(--borda); border-radius: 6px; padding: .05rem .4rem; }

.grade { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 1.25rem; padding: 1.25rem; align-items: start; }
@media (max-width: 900px) { .grade { grid-template-columns: minmax(0, 1fr); padding: 1rem; } }

/* ---------------- a fechadura */
.col-fech { position: sticky; top: 1rem; }
@media (max-width: 900px) { .col-fech { position: static; } }
.porta-cena { background: var(--porta); border-radius: 14px; padding: 22px 0 22px 120px; position: relative; display: flex; justify-content: center; }
.corpo { width: 150px; height: 500px; background: #0b0b0d; border: 3px solid #2b2b30; border-radius: 20px; position: relative; }
.vidro { position: absolute; inset: 6px 6px 120px 6px; border-radius: 14px; background: #050506; border: 1px solid #1a1a1d; }
.sensor { position: absolute; top: 8px; left: 50%; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: #1d1d22; }
.visor { position: absolute; top: 20px; left: 0; right: 0; text-align: center; font: 12px var(--mono); letter-spacing: 4px; color: #8be28b; height: 16px; }
.visor.msg { letter-spacing: 0; font-size: 11px; color: #d8d8d8; }
.teclado { position: absolute; top: 58px; left: 12px; right: 12px; display: grid; grid-template-columns: repeat(3, 1fr); row-gap: 20px; }
.k { background: none; border: none; color: #2a2a2e; font-size: 21px; font-weight: 300; height: 32px; padding: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; transition: color .25s; border-radius: 6px; }
.k:hover { border: none; }
.k:focus-visible { outline: 1px solid #555; }
.acesa .k { color: #f1f1f1; }
.k:active { transform: scale(.92); }
.k small { font-size: 8px; letter-spacing: .5px; border: 1px solid currentColor; border-radius: 3px; padding: 0 3px; margin-top: 3px; font-weight: 400; }
.k svg { width: 15px; height: 15px; margin-top: 2px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.roseta { position: absolute; bottom: 52px; left: 50%; width: 62px; height: 62px; margin-left: -31px; border-radius: 50%; background: #141417; border: 2px solid #2b2b30; }
.alavanca { position: absolute; bottom: 62px; right: 58px; width: 200px; height: 40px; background: #141417; border: 2px solid #2b2b30;
  border-radius: 20px 8px 8px 20px; transform-origin: calc(100% - 8px) 50%; transition: transform .5s; display: flex; align-items: center; padding: 0 0 0 10px; }
.alavanca:hover { border-color: #3a3a42; }
.aberta .alavanca { transform: rotate(-28deg); }
.anel { width: 26px; height: 26px; border-radius: 50%; border: 3px solid #1f6fe5; background: #0a0a0c; transition: border-color .2s; display: block; }
.anel.ok { border-color: #2ec95c; } .anel.erro { border-color: #e5484d; } .anel.espera { border-color: #f5a524; }
.dorme .anel { border-color: #10284d; }
.marca { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; font-size: 11px; letter-spacing: 3px; color: #3a3a40; }
.lingueta { position: absolute; right: 18px; top: 50%; width: 10px; height: 34px; margin-top: -17px; border-radius: 3px; background: #9aa0a8; transition: width .3s; }
.destrancada .lingueta { width: 3px; }

.estado { margin: .8rem 0; font-size: .9rem; color: var(--suave); min-height: 2.6em; }
.estado b { color: var(--texto); font-weight: 600; }
.acoes { background: var(--cartao); border: 1px solid var(--borda); border-radius: 12px; padding: .8rem; display: flex; flex-direction: column; gap: .35rem; }
.acoes > label { font-size: .78rem; color: var(--fraco); margin-top: .2rem; }
.linha { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.linha select { flex: 1; }
.larga { flex: 1; }
.chk { display: inline-flex; gap: .4rem; align-items: center; font-size: .88rem; }
.mais summary { cursor: pointer; font-size: .88rem; color: var(--suave); margin-top: .3rem; }
.mais .linha { margin-top: .4rem; }
.mais input[type=range] { flex: 1; }
.nota { font-size: .8rem; color: var(--fraco); margin: .5rem 0; }

/* ---------------- lado direito */
.col-dir { min-width: 0; background: var(--cartao); border: 1px solid var(--borda); border-radius: 12px; overflow: hidden; }
.abas { display: flex; gap: 0; border-bottom: 1px solid var(--borda); overflow-x: auto; }
.abas button { border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: .7rem 1rem; white-space: nowrap; background: none; color: var(--suave); }
.abas button.ativa { color: var(--texto); border-bottom-color: var(--acento); font-weight: 600; }
.cont { font-size: .72rem; background: var(--acento-bg); color: var(--acento); border-radius: 999px; padding: 0 .45rem; margin-left: .2rem; }
.cont:empty { display: none; }
.aba { padding: 1rem; }
.oculta { display: none; }
#aba-painel { padding: 0; }
#painel { width: 100%; height: calc(100vh - 140px); min-height: 640px; border: none; display: block; background: #f4f5f7; }

.barra { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .6rem; }
.trafego { list-style: none; margin: 0; padding: 0; font: 12.5px/1.45 var(--mono); max-height: calc(100vh - 200px); overflow: auto; }
.trafego li { border-bottom: 1px solid var(--borda); padding: .35rem .2rem; display: grid; grid-template-columns: 70px 92px minmax(0, 1fr); gap: .5rem; }
.trafego .hora { color: var(--fraco); }
.trafego .cat { font-weight: 600; }
.cat.webhook { color: #0e7490; } .cat.pendencias { color: #7c3aed; } .cat.mqtt { color: #b45309; } .cat.api { color: var(--acento); } .cat.fechadura { color: var(--suave); }
.trafego .ok { color: var(--ok); } .trafego .erro { color: var(--erro); }
.trafego details summary { cursor: pointer; overflow-wrap: anywhere; }
.trafego pre { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--fundo); border-radius: 6px; padding: .4rem .5rem; margin: .3rem 0 0; }

.checklist { margin: 0 0 1rem; padding: 0; list-style: none; }
.checklist li { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: .5rem; padding: .55rem .2rem; border-bottom: 1px solid var(--borda); }
.checklist .marca-ck { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--borda); margin-top: 2px; }
.checklist li.feito .marca-ck { background: var(--ok); border-color: var(--ok); }
.checklist li.feito .marca-ck::after { content: ""; display: block; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: translate(6px, 2px) rotate(45deg); }
.checklist .t { font-weight: 600; }
.checklist .d { font-size: .84rem; color: var(--suave); }
.checklist .q { font-size: .78rem; color: var(--ok); }
.tag { font-size: .7rem; border-radius: 999px; padding: 0 .45rem; background: var(--aviso-bg); color: var(--aviso); margin-left: .3rem; font-weight: 500; }

.ajuda { max-width: 760px; font-size: .92rem; }
.ajuda h3 { margin: 1.2rem 0 .4rem; font-size: 1rem; }
.ajuda code { font-family: var(--mono); background: var(--fundo); border: 1px solid var(--borda); border-radius: 5px; padding: 0 .3rem; overflow-wrap: anywhere; }
.ajuda table { border-collapse: collapse; width: 100%; font-size: .85rem; }
.ajuda td, .ajuda th { border-bottom: 1px solid var(--borda); padding: .35rem .4rem; text-align: left; vertical-align: top; }

.aviso-fim { margin: 2rem auto; max-width: 520px; background: var(--cartao); border: 1px solid var(--borda); border-radius: 12px; padding: 1.5rem; text-align: center; }
