/*
 * Pesobal — estilo único do laboratório.
 * Pior caso manda no desenho: tablet no chão de fábrica, com luva, tela molhada e pouca
 * luz (CONTRATO servidor §9.4). Alvos de toque ≥ 48px, contraste alto, pouca digitação.
 */
:root {
    --fundo: #f4f5f7;
    --superficie: #ffffff;
    --texto: #1f2933;
    --texto-fraco: #52606d;
    --borda: #cbd2d9;
    --marca: #0f766e;
    --marca-escura: #0b5a54;
    --ok-fundo: #e3f9e5;
    --ok-texto: #0e5a1f;
    --aviso-fundo: #fff4d6;
    --aviso-texto: #7a4d00;
    --erro-fundo: #fde8e8;
    --erro-texto: #8a1c1c;
    --raio: 10px;
    --toque: 48px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --fundo: #111418;
        --superficie: #1b2027;
        --texto: #eef1f4;
        --texto-fraco: #a3adb8;
        --borda: #3a434e;
        --marca: #2dd4bf;
        --marca-escura: #5eead4;
        --ok-fundo: #103a1c;
        --ok-texto: #b6f2c2;
        --aviso-fundo: #3d2e05;
        --aviso-texto: #ffe08a;
        --erro-fundo: #3f1414;
        --erro-texto: #ffc2c2;
    }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--fundo);
    color: var(--texto);
    font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

a { color: var(--marca); }

h1 { font-size: 1.6rem; margin: 0 0 .25rem; }

.sub { color: var(--texto-fraco); margin: 0 0 1.25rem; }

.sr-only {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Páginas públicas (entrar, cadastro) ---------- */

body.publico {
    display: flex;
    justify-content: center;
    padding: 16px;
}

.cartao {
    width: 100%;
    max-width: 440px;
    margin-top: 6vh;
    background: var(--superficie);
    border-radius: var(--raio);
    padding: 28px 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .08);
}

.marca {
    font-weight: 800;
    font-size: 1.4rem;
    letter-spacing: -.02em;
    color: var(--marca);
    text-decoration: none;
    margin-bottom: 1rem;
    display: inline-block;
}

.rodape-links {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin: 1.25rem 0 0;
}

.rodape-links a { min-height: var(--toque); display: inline-flex; align-items: center; }

/* ---------- Formulários ---------- */

.formulario { display: flex; flex-direction: column; }

.formulario label { font-weight: 600; margin: 14px 0 6px; }

.formulario small { color: var(--texto-fraco); margin-top: 4px; }

input, select {
    min-height: var(--toque);
    padding: 10px 12px;
    font: inherit;
    color: inherit;
    background: var(--superficie);
    border: 2px solid var(--borda);
    border-radius: 8px;
    width: 100%;
}

input:focus, select:focus { outline: none; border-color: var(--marca); }

.aceite {
    display: flex !important;
    gap: 10px;
    align-items: flex-start;
    font-weight: 400 !important;
    margin-top: 18px !important;
}

.aceite input { width: 24px; min-height: 24px; height: 24px; flex: none; margin-top: 2px; }

.grupo {
    border: 2px solid var(--borda);
    border-radius: 8px;
    padding: 4px 14px 14px;
    margin: 18px 0 0;
    display: flex;
    flex-direction: column;
}

.grupo legend { font-weight: 600; padding: 0 6px; }

.acoes { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }

/* ---------- Botões ---------- */

.botao {
    min-height: var(--toque);
    padding: 10px 22px;
    margin-top: 22px;
    font: inherit;
    font-weight: 700;
    color: #fff;
    background: var(--marca);
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.acoes .botao, .cabecalho .botao, .lista .botao { margin-top: 0; }

.botao:hover { background: var(--marca-escura); }

.botao-secundario {
    background: transparent;
    color: var(--marca);
    border: 2px solid var(--marca);
}

.botao-secundario:hover { background: transparent; color: var(--marca-escura); }

.link {
    background: none;
    border: 0;
    padding: 0 4px;
    min-height: var(--toque);
    font: inherit;
    color: var(--marca);
    text-decoration: underline;
    cursor: pointer;
}

/* ---------- Mensagens ---------- */

.msg { padding: 12px 14px; border-radius: 8px; margin: 0 0 16px; }
.msg-ok { background: var(--ok-fundo); color: var(--ok-texto); }
.msg-aviso { background: var(--aviso-fundo); color: var(--aviso-texto); }
.msg-erro { background: var(--erro-fundo); color: var(--erro-texto); }

/* ---------- Área logada ---------- */

.topo {
    display: flex;
    align-items: center;
    gap: 12px 16px;
    flex-wrap: wrap;
    padding: 8px 16px;
    background: var(--superficie);
    border-bottom: 1px solid var(--borda);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topo .marca { margin: 0; }

.seletor { flex: 1 1 220px; display: flex; gap: 8px; min-width: 0; }

.seletor select { font-weight: 600; }

.menu { display: flex; align-items: center; gap: 4px 16px; flex-wrap: wrap; }

.menu a, .menu .link {
    min-height: var(--toque);
    display: inline-flex;
    align-items: center;
    font-weight: 600;
    text-decoration: none;
}

.menu form { margin: 0; }

.faixa-aviso {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px 12px;
    flex-wrap: wrap;
    padding: 4px 16px;
    background: var(--aviso-fundo);
    color: var(--aviso-texto);
    text-align: center;
}

.faixa-aviso form { margin: 0; }
.faixa-aviso .link { color: inherit; }

.conteudo { max-width: 960px; margin: 0 auto; padding: 20px 16px 40px; }

.cabecalho {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.lista { list-style: none; margin: 0; padding: 0; }

.lista li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--superficie);
    border-radius: var(--raio);
    margin-bottom: 10px;
}

.lista .detalhe { display: block; color: var(--texto-fraco); font-size: .92rem; }

.vazio {
    background: var(--superficie);
    border: 2px dashed var(--borda);
    border-radius: var(--raio);
    padding: 20px;
}

.conteudo .formulario { max-width: 520px; }

/* ---------- Balanças: pesar e detectar (CONTRATO servidor §9) ---------- */

.balancas {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    gap: 16px;
}

.balanca {
    background: var(--superficie);
    border-radius: var(--raio);
    padding: 16px;
    margin-bottom: 16px;
}

.balanca-topo { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.balanca-topo h2 { margin: 0; font-size: 1.25rem; }
.balanca .detalhe { color: var(--texto-fraco); margin: 4px 0 12px; }

/* O peso tem que ser legível a um braço de distância, com pouca luz. */
.visor {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 140px;
    border-radius: 8px;
    background: var(--fundo);
    border: 3px solid var(--borda);
    text-align: center;
    padding: 12px;
}

.visor-peso {
    font-size: clamp(2.8rem, 12vw, 4.5rem);
    font-weight: 800;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.02em;
}

.visor-info { color: var(--texto-fraco); font-weight: 600; margin-top: 4px; }
.visor-ok .visor { border-color: var(--marca); }
.visor-erro .visor { border-color: var(--erro-texto); }

/* Botão principal do chão de fábrica: grande, para toque com luva. */
.botao-pesar { width: 100%; min-height: 72px; font-size: 1.5rem; margin-top: 12px; }
.botao:disabled { opacity: .6; cursor: progress; }

.resultado { margin-top: 12px; }
.resultado h3 { margin: 0 0 8px; }
.resultado ol { padding-left: 1.4em; margin: 4px 0 8px; }
.resultado li { margin-bottom: 4px; }
.progresso { font-weight: 600; }

.comparacao { border-collapse: collapse; width: 100%; margin: 8px 0; }
.comparacao th { text-align: left; padding: 6px 12px 6px 0; color: var(--texto-fraco); width: 1%; white-space: nowrap; }
.comparacao td { padding: 6px 0; font-weight: 600; }

.pendente {
    background: var(--aviso-fundo);
    color: var(--aviso-texto);
    border-radius: var(--raio);
    padding: 16px;
    margin-bottom: 16px;
}
.pendente h2 { margin: 0 0 8px; font-size: 1.2rem; }
.pendente .comparacao th, .pendente .detalhe { color: inherit; }
.pendente form { margin: 0; }

.selo-aviso { color: var(--aviso-texto); font-weight: 700; }

.despejo {
    background: var(--fundo);
    border: 1px solid var(--borda);
    border-radius: 8px;
    padding: 10px;
    font-size: .85rem;
    overflow-x: auto;
    white-space: pre;
    max-height: 280px;
}

.valor-fixo { margin: 0; font-weight: 600; }
.conteudo h2 { font-size: 1.2rem; }

/* Balança online/desconectada, vista pelo Poiter */
.ponto { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.ponto-on { background: #16a34a; }
.ponto-off { background: #9ca3af; }

.instalacao { max-width: 520px; margin-top: 28px; }
.instalacao h2 { margin: 8px 0; }
.chave { font-family: ui-monospace, Consolas, monospace; font-size: .9rem; }
.chave-copiar { display: flex; gap: 8px; align-items: stretch; }
.chave-copiar .chave { flex: 1; min-width: 0; }
.instalacao .chave-copiar .botao { flex: none; margin-top: 0; }

/* Excluir balança: discreto, só aparece quando ela está desconectada */
.excluir { margin: 12px 0 0; text-align: right; }
.link-perigo { color: var(--erro-texto); }

/* ---------- Tela de pesar: visor no centro, seletor de balança ---------- */
.pesagem {
    max-width: 560px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}
.pesagem .rotulo { font-weight: 700; margin-bottom: 6px; }
.escolha { width: 100%; }
select.escolha { font-size: 1.2rem; font-weight: 700; min-height: 56px; }
.pesagem .detalhe { margin: 6px 0 14px; min-height: 1.5em; }
.visor-grande { min-height: 220px; }
.visor-grande .visor-peso { font-size: clamp(3.5rem, 16vw, 6.5rem); }
.pesagem .botao-pesar { min-height: 88px; font-size: 1.8rem; }
.pesagem [data-nao-configurada] .botao { margin-top: 12px; }
.pesagem .rodape-links { justify-content: center; gap: 24px; }
[hidden] { display: none !important; }

.passos { padding-left: 1.4em; margin: 12px 0; }
.passos li { margin-bottom: 4px; }
.instalacao .botao { margin-top: 8px; }

/* ---------- Documentação pública (/integracao) ---------- */

body.documentacao { margin: 0; background: var(--fundo); color: var(--texto); }
.doc-topo {
    position: sticky; top: 0; z-index: 1;
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
    padding: 12px 16px; background: var(--superficie); border-bottom: 1px solid var(--borda);
}
.doc-topo .marca { font-weight: 700; font-size: 1.2rem; color: var(--marca); text-decoration: none; margin-right: auto; }
.doc-topo nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.doc-topo nav a { color: var(--texto-fraco); text-decoration: none; padding: 6px 0; }
.doc-topo nav a[aria-current="page"] { color: var(--marca); font-weight: 600; border-bottom: 2px solid var(--marca); }

.doc { max-width: 900px; margin: 0 auto; padding: 24px 16px 64px; line-height: 1.6; }
.doc h1 { font-size: 1.9rem; line-height: 1.25; margin: 8px 0 16px; }
.doc h2 { font-size: 1.4rem; margin: 40px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--borda); }
.doc h3 { font-size: 1.15rem; margin: 28px 0 8px; }
.doc h4 { margin: 20px 0 6px; }
.doc a { color: var(--marca); }
.doc hr { border: 0; border-top: 1px solid var(--borda); margin: 32px 0; }
.doc code { font-family: ui-monospace, Consolas, monospace; font-size: .88em; background: var(--superficie); border: 1px solid var(--borda); border-radius: 4px; padding: 1px 5px; }
.doc pre { background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio); padding: 14px 16px; overflow-x: auto; line-height: 1.45; }
.doc pre code { border: 0; padding: 0; background: none; font-size: .85rem; }
/* Tabelas largas rolam dentro delas mesmas, sem empurrar a página no celular. */
.doc table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 12px 0; font-size: .95rem; }
.doc th, .doc td { border: 1px solid var(--borda); padding: 8px 10px; text-align: left; vertical-align: top; }
.doc th { background: var(--superficie); }
.doc blockquote { margin: 16px 0; padding: 10px 16px; background: var(--aviso-fundo); color: var(--aviso-texto); border-radius: var(--raio); }
.doc blockquote p { margin: 4px 0; }
.doc li { margin: 4px 0; }
.doc input[type="checkbox"] { min-height: 0; margin-right: 6px; }
.doc-rodape { margin-top: 48px; color: var(--texto-fraco); font-size: .9rem; }
