/* ==========================================================
   Orçamentos e fichas de impressão 3D
   Visual: creme/menta com marinho como cor de ação (paleta do cliente),
   botões em pílula, cartões arredondados. Tema claro e escuro.
   O documento (orçamento/ficha) é sempre "papel" claro.
   ========================================================== */

/* ---------- Tokens ---------- */

:root,
[data-theme="light"] {
    /* Paleta: #05386B marinho · #379683 verde-petróleo · #5CDB95 menta · #8EE4AF menta clara · #EDF5E1 creme */
    --fundo: #edf5e1;
    --superficie: #ffffff;
    --superficie-2: #f7fbf2;
    --superficie-3: #e6efdb;
    --borda: #dce6d2;
    --borda-forte: #c3d2b9;
    --texto: #0b2540;
    --texto-2: #3d5166;
    --texto-3: #5a6c7d;

    --acento: #05386b;
    --acento-hover: #0a4a88;
    --acento-texto: #ffffff;
    --acento-suave: #e3edf6;
    --acento-escuro: #05386b;
    --acento-sombra: rgba(5, 56, 107, .35);

    --menta: #5cdb95;
    --menta-clara: #8ee4af;
    --petroleo: #379683;
    --destaque-valor: #8ee4af;

    --ok: #1f6b5a;
    --ok-suave: #d4f3e1;
    --alerta: #8a5a00;
    --alerta-suave: #fbefc9;
    --perigo: #c62828;
    --perigo-suave: #fde3e1;
    --whatsapp: #1e8e5a;

    --topo-fundo: rgba(255, 255, 255, .78);
    --anel: 0 0 0 4px rgba(92, 219, 149, .45);
    --sombra-1: 0 1px 2px rgba(5, 56, 107, .05), 0 4px 16px -6px rgba(5, 56, 107, .10);
    --sombra-2: 0 12px 40px -12px rgba(5, 56, 107, .28);

    color-scheme: light;
}

[data-theme="dark"] {
    --fundo: #03192f;
    --superficie: #072440;
    --superficie-2: #0a2b4c;
    --superficie-3: #0f3559;
    --borda: #163f66;
    --borda-forte: #22517f;
    --texto: #edf5e1;
    --texto-2: #b3c6bf;
    --texto-3: #93a9ad;
    --acento: #5cdb95;
    --acento-hover: #8ee4af;
    --acento-texto: #05386b;
    --acento-suave: #0e3b44;
    --acento-escuro: #8ee4af;
    --acento-sombra: rgba(92, 219, 149, .3);
    --destaque-valor: #05386b;
    --ok: #5cdb95;
    --ok-suave: #0f3b33;
    --alerta: #f5c451;
    --alerta-suave: #3a2f0e;
    --perigo: #ff8a80;
    --perigo-suave: #3e1c1f;
    --whatsapp: #25b862;
    --topo-fundo: rgba(3, 25, 47, .8);
    --anel: 0 0 0 4px rgba(92, 219, 149, .35);
    --sombra-1: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px -6px rgba(0, 0, 0, .5);
    --sombra-2: 0 16px 48px -12px rgba(0, 0, 0, .7);
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --fundo: #03192f;
        --superficie: #072440;
        --superficie-2: #0a2b4c;
        --superficie-3: #0f3559;
        --borda: #163f66;
        --borda-forte: #22517f;
        --texto: #edf5e1;
        --texto-2: #b3c6bf;
        --texto-3: #93a9ad;
        --acento: #5cdb95;
        --acento-hover: #8ee4af;
        --acento-texto: #05386b;
        --acento-suave: #0e3b44;
        --acento-escuro: #8ee4af;
        --acento-sombra: rgba(92, 219, 149, .3);
        --destaque-valor: #05386b;
        --ok: #5cdb95;
        --ok-suave: #0f3b33;
        --alerta: #f5c451;
        --alerta-suave: #3a2f0e;
        --perigo: #ff8a80;
        --perigo-suave: #3e1c1f;
        --whatsapp: #25b862;
        --topo-fundo: rgba(3, 25, 47, .8);
        --anel: 0 0 0 4px rgba(92, 219, 149, .35);
        --sombra-1: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px -6px rgba(0, 0, 0, .5);
        --sombra-2: 0 16px 48px -12px rgba(0, 0, 0, .7);
        color-scheme: dark;
    }
}

:root {
    --fonte: "Plus Jakarta Sans", "Segoe UI", Roboto, Arial, sans-serif;
    --fonte-tecnica: var(--fonte);
    --raio-campo: 12px;
    --raio-cartao: 20px;
    --alt-ctrl: 2.75rem;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--fundo);
    color: var(--texto);
    font: 400 .97rem/1.55 var(--fonte);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.015em; }
code { font-size: .88em; padding: .1em .4em; border-radius: 6px; background: var(--superficie-3); }

:focus-visible { outline: 2px solid var(--petroleo); outline-offset: 2px; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.pular {
    position: absolute; left: 1rem; top: -4rem; z-index: 50;
    padding: .6rem 1.1rem; border-radius: 999px;
    background: var(--acento); color: var(--acento-texto); font-weight: 600; text-decoration: none;
}
.pular:focus { top: 1rem; }

.icone { flex: none; }

.so-escuro { display: none; }
[data-theme="dark"] .so-claro { display: none; }
[data-theme="dark"] .so-escuro { display: inline-flex; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .so-claro { display: none; }
    :root:not([data-theme="light"]) .so-escuro { display: inline-flex; }
}

/* ---------- Topo ---------- */

.topo {
    position: sticky; top: 0; z-index: 20;
    background: var(--topo-fundo);
    backdrop-filter: saturate(1.6) blur(14px);
    -webkit-backdrop-filter: saturate(1.6) blur(14px);
    border-bottom: 1px solid var(--borda);
}
.topo-interno {
    display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
    max-width: 1240px; margin: 0 auto;
    padding: .7rem clamp(1rem, 3vw, 2rem);
}

.marca { display: flex; align-items: center; gap: .7rem; text-decoration: none; min-width: 0; }
.marca-icone {
    width: 38px; height: 38px; padding: 7px; flex: none;
    border-radius: 12px; background: #05386b; color: var(--menta);
    box-shadow: 0 6px 16px -6px var(--acento-sombra);
}
.marca strong { display: block; font-weight: 800; font-size: 1.02rem; line-height: 1.15; letter-spacing: -.02em; }
.marca small { display: block; color: var(--texto-3); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topo-nav {
    display: flex; gap: .2rem; margin-right: auto; padding: .25rem;
    border-radius: 999px; background: var(--superficie-3);
}
.topo-nav a {
    padding: .45rem 1rem; border-radius: 999px;
    color: var(--texto-2); text-decoration: none; font-weight: 600; font-size: .92rem;
    transition: background-color .15s, color .15s;
}
.topo-nav a:hover { color: var(--texto); }
.topo-nav a.ativo { color: var(--texto); background: var(--superficie); box-shadow: var(--sombra-1), inset 0 -2px 0 var(--menta); }

.topo-acoes { display: flex; align-items: center; gap: .5rem; }

.botao-icone {
    display: inline-grid; place-items: center;
    width: var(--alt-ctrl); height: var(--alt-ctrl);
    border: 1px solid var(--borda); border-radius: 999px;
    background: var(--superficie); color: var(--texto-2); cursor: pointer; list-style: none;
    transition: background-color .15s, color .15s, border-color .15s;
}
.botao-icone::-webkit-details-marker { display: none; }
.botao-icone:hover { color: var(--texto); border-color: var(--borda-forte); background: var(--superficie-2); }

.menu-usuario { position: relative; }
.menu-usuario-painel {
    position: absolute; right: 0; top: calc(100% + .5rem); z-index: 30;
    min-width: 15.5rem; padding: .4rem;
    background: var(--superficie); color: var(--texto);
    border: 1px solid var(--borda); border-radius: 18px; box-shadow: var(--sombra-2);
}
.menu-usuario-nome { margin: 0 0 .3rem; padding: .6rem .75rem .75rem; border-bottom: 1px solid var(--borda); font-weight: 700; }
.menu-usuario-nome span { display: block; font-weight: 400; font-size: .84rem; color: var(--texto-3); }
.menu-usuario-painel a,
.menu-usuario-painel button {
    display: flex; align-items: center; gap: .6rem; width: 100%;
    padding: .6rem .75rem; border: 0; border-radius: 12px; background: none;
    color: inherit; font: inherit; font-weight: 500; text-align: left; text-decoration: none; cursor: pointer;
}
.menu-usuario-painel a:hover,
.menu-usuario-painel button:hover { background: var(--superficie-3); }
.menu-usuario-painel form { margin: 0; }

.conteudo {
    max-width: 1240px; margin: 0 auto;
    padding: clamp(1.5rem, 3vw, 2.5rem) clamp(1rem, 3vw, 2rem) 4rem;
}

.cabecalho-pagina {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 1rem; margin-bottom: 1.5rem;
}
.cabecalho-pagina h1 { font-weight: 800; font-size: clamp(1.6rem, 3.5vw, 2.1rem); letter-spacing: -.03em; }

/* ---------- Botões (pílula) ---------- */

.botao {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    min-height: var(--alt-ctrl); padding: .5rem 1.25rem;
    border: 1px solid var(--borda-forte); border-radius: 999px;
    background: var(--superficie); color: var(--texto);
    font: 600 .92rem/1 var(--fonte); text-decoration: none; white-space: nowrap; cursor: pointer;
    transition: background-color .15s, border-color .15s, box-shadow .15s, transform .08s;
}
.botao:hover { background: var(--superficie-2); border-color: var(--texto-3); }
.botao:active { transform: scale(.98); }

.botao-primario {
    background: var(--acento); border-color: var(--acento); color: var(--acento-texto);
    box-shadow: 0 8px 20px -8px var(--acento-sombra);
}
.botao-primario:hover { background: var(--acento-hover); border-color: var(--acento-hover); box-shadow: 0 10px 24px -8px var(--acento-sombra); }

.botao-whatsapp { background: var(--whatsapp); border-color: var(--whatsapp); color: #fff; }
.botao-whatsapp:hover { background: var(--whatsapp); border-color: var(--whatsapp); filter: brightness(1.07); }

.botao-largo { width: 100%; }
.botao-grande { min-height: 3.15rem; font-size: 1rem; }
.botao.desativado { opacity: .45; pointer-events: none; }
.botao[aria-busy="true"] { opacity: .7; cursor: progress; }

.botao-texto {
    display: inline-flex; align-items: center; gap: .35rem;
    background: none; border: 0; padding: .45rem .75rem; cursor: pointer;
    font: 600 .9rem var(--fonte); color: var(--texto-2); text-decoration: none; border-radius: 999px;
    transition: background-color .15s, color .15s;
}
.botao-texto:hover { color: var(--texto); background: var(--superficie-3); }
.botao-perigo { color: var(--perigo); }
.botao-perigo:hover { color: var(--perigo); background: var(--perigo-suave); }

.linha-botoes { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.25rem; }

/* ---------- Avisos ---------- */

.aviso {
    display: flex; align-items: flex-start; gap: .7rem;
    padding: .9rem 1.1rem; margin-bottom: 1.25rem;
    border: 1px solid transparent; border-radius: 16px;
    transition: opacity .25s, transform .25s;
}
.aviso .icone { margin-top: .12rem; }
.aviso > span, .aviso > div { flex: 1; }
.aviso p { margin: 0 0 .3rem; font-weight: 700; }
.aviso ul { margin: 0; padding-left: 1.1rem; }
.aviso-ok { background: var(--ok-suave); color: var(--texto); }
.aviso-ok .icone { color: var(--ok); }
.aviso-erro { background: var(--perigo-suave); color: var(--texto); }
.aviso-erro .icone { color: var(--perigo); }
.aviso.saindo { opacity: 0; transform: translateY(-4px); }
.aviso-fechar { background: none; border: 0; padding: .2rem; color: var(--texto-2); cursor: pointer; border-radius: 999px; }
.aviso-fechar:hover { color: var(--texto); background: rgba(0, 0, 0, .06); }

/* ---------- Campos ---------- */

.campos { display: grid; gap: 1rem; margin-bottom: 1rem; }
.campos-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.campos-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.campos-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.campos-3 .campo-largo { grid-column: span 2; }

.campo { display: flex; flex-direction: column; gap: .4rem; min-width: 0; }
.campo label, .rotulo { font-size: .84rem; font-weight: 600; color: var(--texto-2); }
.bloco > .campo, .login-cartao > .campo { margin-bottom: 1rem; }

input, select, textarea {
    width: 100%; min-height: var(--alt-ctrl); padding: .6rem .9rem;
    border: 1px solid var(--borda-forte); border-radius: var(--raio-campo);
    background: var(--superficie); color: var(--texto); font: inherit;
    transition: border-color .15s, box-shadow .15s, background-color .15s;
}
input::placeholder, textarea::placeholder { color: var(--texto-3); opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: var(--texto-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--petroleo); box-shadow: var(--anel); }
textarea { resize: vertical; min-height: 6rem; }
select {
    appearance: none; -webkit-appearance: none; padding-right: 2.4rem; cursor: pointer;
    background-image: linear-gradient(45deg, transparent 50%, var(--texto-3) 50%), linear-gradient(135deg, var(--texto-3) 50%, transparent 50%);
    background-position: calc(100% - 1.2rem) 52%, calc(100% - .85rem) 52%;
    background-size: .35rem .35rem; background-repeat: no-repeat;
}
[aria-invalid="true"] { border-color: var(--perigo); }
[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--perigo) 22%, transparent); border-color: var(--perigo); }
.erro-campo { display: flex; align-items: center; gap: .35rem; margin: .1rem 0 0; color: var(--perigo); font-size: .85rem; font-weight: 600; }

.ajuda { margin: -.2rem 0 1rem; color: var(--texto-3); font-size: .88rem; max-width: 75ch; }
.campo .ajuda { margin: 0; }
.sub { font-weight: 700; font-size: 1rem; margin: .25rem 0 .75rem; }

.com-unidade { display: flex; align-items: stretch; }
.com-unidade input { border-top-right-radius: 0; border-bottom-right-radius: 0; min-width: 0; }
.com-unidade span {
    display: grid; place-items: center; padding: 0 .7rem;
    border: 1px solid var(--borda-forte); border-left: 0; border-radius: 0 var(--raio-campo) var(--raio-campo) 0;
    background: var(--superficie-3); color: var(--texto-2); font-size: .84rem; white-space: nowrap;
}

.check { display: flex; gap: .65rem; align-items: flex-start; cursor: pointer; }
.check input {
    width: 1.2rem; height: 1.2rem; min-height: 0; padding: 0; margin: .15rem 0 0; flex: none;
    accent-color: var(--petroleo);
}
.campo-check { justify-content: flex-end; padding-bottom: .6rem; }

/* Opções em pílula (esforço, material) */
.chips { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: 1rem; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.chip span {
    display: inline-flex; align-items: center; min-height: 2.4rem; padding: 0 1.05rem;
    border: 1px solid var(--borda-forte); border-radius: 999px;
    font-weight: 600; font-size: .9rem; background: var(--superficie); color: var(--texto-2);
    transition: background-color .15s, border-color .15s, color .15s;
}
.chip:hover span { border-color: var(--texto-3); color: var(--texto); }
.chip input:checked + span { background: var(--ok-suave); border-color: var(--petroleo); color: var(--texto); }
.chip input:focus-visible + span { outline: 2px solid var(--acento); outline-offset: 2px; }

/* Busca com ícone */
.busca { position: relative; display: block; }
.busca .icone { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--texto-3); pointer-events: none; }
.busca input { padding-left: 2.6rem; border-radius: 999px; }

/* ---------- Lista ---------- */

.filtros { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filtros .busca input { min-width: 18rem; }
.filtros select { width: auto; border-radius: 999px; padding-left: 1.1rem; }

.tabela-rolagem { overflow-x: auto; }

.lista {
    width: 100%; border-collapse: separate; border-spacing: 0;
    background: var(--superficie);
    border: 1px solid var(--borda); border-radius: var(--raio-cartao); overflow: hidden;
    box-shadow: var(--sombra-1);
}
.lista th, .lista td { padding: .95rem 1.15rem; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--borda); }
.lista tbody tr:last-child td { border-bottom: 0; }
.lista th { font-size: .78rem; font-weight: 600; color: var(--texto-3); background: var(--superficie-2); }
.lista tbody tr { transition: background-color .12s; }
.lista tbody tr:hover { background: var(--superficie-2); }
.lista .numero { font-weight: 800; text-decoration: none; letter-spacing: -.01em; }
.lista .numero:hover { color: var(--petroleo); }
.secundario { display: block; color: var(--texto-3); font-size: .84rem; }
.vencido { color: var(--perigo); }
.num { text-align: right !important; white-space: nowrap; font-variant-numeric: tabular-nums; }

.selo {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .25rem .7rem; border-radius: 999px;
    font-size: .78rem; font-weight: 700; white-space: nowrap;
    background: var(--superficie-3); color: var(--texto-2);
}
.selo::before { content: ""; width: .42rem; height: .42rem; border-radius: 50%; background: currentColor; }
.selo-enviado { background: var(--acento-suave); color: var(--acento-escuro); }
.selo-ficha-em_andamento { background: var(--alerta-suave); color: var(--alerta); }
.selo-aceito, .selo-ficha-aprovado { background: var(--ok-suave); color: var(--ok); }
.selo-entregue, .selo-ficha-concluido { background: var(--texto); color: var(--superficie); }
.selo-cancelado, .selo-ficha-reajuste { background: var(--perigo-suave); color: var(--perigo); }

.vazio {
    padding: 3.5rem 1.5rem; text-align: center;
    background: var(--superficie); border: 1.5px dashed var(--borda-forte); border-radius: var(--raio-cartao);
}
.vazio p { max-width: 46ch; margin: 0 auto 1.25rem; color: var(--texto-2); }

.paginacao { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.25rem; color: var(--texto-2); }

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

.form-grade { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 1.5rem; align-items: start; }

.bloco {
    margin: 0 0 1.25rem; padding: 1.5rem;
    min-width: 0;
    background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio-cartao);
    box-shadow: var(--sombra-1);
}
.bloco legend {
    float: left; width: 100%; padding: 0; margin: 0 0 1.15rem;
    font-weight: 800; font-size: 1.08rem; letter-spacing: -.02em;
}
.bloco legend + * { clear: both; }
.bloco-estreito { max-width: 32rem; }

.bloco legend .n {
    display: inline-grid; place-items: center; width: 1.75rem; height: 1.75rem; margin-right: .5rem;
    border-radius: 999px; background: var(--acento-suave); color: var(--acento-escuro); font-size: .85rem; vertical-align: 1px;
}

.itens, .cotas { display: flex; flex-direction: column; gap: .75rem; margin-bottom: 1rem; }
.item { padding: 1.1rem; border: 1px solid var(--borda); border-radius: 16px; background: var(--superficie-2); }
.item-campos { grid-template-columns: minmax(0, 3fr) minmax(0, 1.3fr) 5.5rem 8.5rem; margin-bottom: .65rem; }
.item-detalhe { grid-column: 1 / -1; }
.item-rodape { display: flex; justify-content: space-between; align-items: center; color: var(--texto-3); font-size: .88rem; }
.item-rodape strong { color: var(--texto); font-variant-numeric: tabular-nums; }

.opcoes-material { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.opcao-material { position: relative; cursor: pointer; }
.opcao-material input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.opcao-material span {
    display: block; height: 100%; padding: 1rem 1.15rem;
    border: 1px solid var(--borda-forte); border-radius: 16px;
    color: var(--texto-2); font-size: .9rem; background: var(--superficie);
    transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.opcao-material:hover span { border-color: var(--texto-3); }
.opcao-material strong { display: block; color: var(--texto); font-weight: 700; font-size: 1rem; margin-bottom: .15rem; }
.opcao-material input:checked + span { border-color: var(--petroleo); background: var(--ok-suave); box-shadow: var(--anel); }
.opcao-material input:focus-visible + span { outline: 2px solid var(--acento); outline-offset: 2px; }

/* Resumo lateral */
.resumo {
    position: sticky; top: 5.75rem;
    display: flex; flex-direction: column; gap: .6rem;
    padding: 1.15rem; border-radius: var(--raio-cartao);
    background: var(--superficie); border: 1px solid var(--borda); box-shadow: var(--sombra-1);
}
.resumo-numero { margin: 0 .2rem; font-weight: 700; font-size: .88rem; color: var(--texto-3); }
.resumo dl { margin: 0 0 .4rem; }
.resumo dl div { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem .2rem; border-bottom: 1px solid var(--borda); font-size: .92rem; }
.resumo dl div:last-child { border-bottom: 0; }
.resumo dt { color: var(--texto-2); }
.resumo dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; }
.resumo dl div:first-child {
    flex-direction: column; gap: .15rem; margin-bottom: .35rem; padding: 1rem 1.1rem;
    border: 0; border-radius: 16px; background: #05386b; color: #fff;
    box-shadow: 0 12px 28px -12px var(--acento-sombra);
}
.resumo dl div:first-child dt { color: rgba(255, 255, 255, .82); font-size: .85rem; }
.resumo dl div:first-child dd { color: var(--menta-clara); text-align: left; font-size: 2rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.resumo dd.negativo { color: var(--perigo); }

/* ---------- Página de detalhe ---------- */

.acoes { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.acoes-grupo { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.acoes-grupo form { margin: 0; }
.form-status select { width: auto; min-width: 12.5rem; font-weight: 600; border-radius: 999px; padding-left: 1.1rem; }

/* ----------------------------------------------------------
   Documento (orçamento / ficha): sempre claro, como no PDF
   ---------------------------------------------------------- */

.folha {
    --texto: #0b2540; --texto-2: #3d5166; --texto-3: #5a6c7d;
    --borda: #dce6d2; --borda-forte: #c3d2b9; --superficie: #fff; --superficie-2: #f7fbf2; --superficie-3: #e6efdb;
    --acento: #05386b; --acento-suave: #edf5e1; --acento-escuro: #05386b; --acento-texto: #fff;
    --ok: #1f6b5a; --ok-suave: #d4f3e1; --perigo: #c62828; --perigo-suave: #fde3e1;
    --alerta: #a16207; --alerta-suave: #fef3c7;
    --grafite: #0b2540;
    --menta: #5cdb95; --menta-clara: #8ee4af; --petroleo: #379683;
    color-scheme: light;

    position: relative;
    max-width: 940px; margin: 0 auto;
    padding: clamp(1.25rem, 4vw, 2.75rem);
    background: #fff; color: var(--texto);
    border-radius: 24px;
    border-top: 6px solid var(--menta);
    box-shadow: var(--sombra-2);
}

.folha-cabecalho { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.75rem; }
.folha-empresa { font-weight: 800; font-size: clamp(1.4rem, 3.5vw, 1.8rem); letter-spacing: -.03em; }
.folha-slogan { margin: .3rem 0 0; color: var(--texto-3); font-size: .92rem; }
.folha-numero { text-align: right; }
.folha-numero span { display: block; color: var(--texto-3); font-size: .85rem; }
.folha-numero strong { font-weight: 800; font-size: clamp(1.7rem, 4.5vw, 2.4rem); color: var(--acento); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.folha-ficha .folha-numero strong { color: var(--texto); }
.folha-ficha .folha-numero .selo { margin-bottom: .35rem; }

.partes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.parte { padding: 1rem 1.15rem; border: 1px solid var(--borda); border-radius: 16px; }
.parte h2 { font-size: .8rem; font-weight: 700; color: var(--ok); margin-bottom: .5rem; letter-spacing: 0; }
.parte dl { display: grid; grid-template-columns: 7.5rem 1fr; gap: .3rem .75rem; margin: 0; }
.parte dt { color: var(--texto-3); font-size: .88rem; }
.parte dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

.folha section { margin-bottom: 2rem; }

.secao-titulo { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.1rem; margin-bottom: .9rem; letter-spacing: -.02em; }
.secao-titulo span {
    display: inline-grid; place-items: center; width: 1.75rem; height: 1.75rem; flex: none;
    border-radius: 999px; background: var(--acento-suave); color: var(--acento-escuro); font-size: .85rem;
}

.itens-tabela { width: 100%; border-collapse: separate; border-spacing: 0; }
.itens-tabela th { padding: .6rem .75rem; text-align: left; font-size: .76rem; font-weight: 700; color: var(--texto-2); background: var(--superficie-2); }
.itens-tabela th:first-child { border-radius: 10px 0 0 10px; }
.itens-tabela th:last-child { border-radius: 0 10px 10px 0; }
.itens-tabela td { padding: .85rem .75rem; border-bottom: 1px solid var(--borda); vertical-align: top; }
.itens-tabela .detalhe { display: block; margin-top: .15rem; color: var(--texto-3); font-size: .86rem; max-width: 56ch; }
.itens-tabela tfoot td { padding: .6rem .75rem; font-weight: 700; }

.fechamento { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: stretch; gap: 1rem; margin-top: 1rem; }
.fechamento dl { margin: 0; display: flex; flex-wrap: wrap; gap: .5rem 2rem; align-self: center; }
.fechamento dt { font-size: .82rem; color: var(--texto-3); }
.fechamento dd { margin: 0; font-weight: 700; }
.total {
    display: flex; flex-direction: column; justify-content: center; align-items: flex-end;
    padding: 1rem 1.4rem; background: #05386b; color: #fff; border-radius: 18px;
}
.total span { font-size: .85rem; font-weight: 600; opacity: .85; }
.total strong { color: var(--menta-clara); font-weight: 800; font-size: 2rem; line-height: 1.1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }

.specs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.spec { padding: 1rem 1.1rem; border: 1px solid var(--borda); border-radius: 16px; }
.spec h3 { font-weight: 700; font-size: .98rem; margin-bottom: .4rem; }
.spec h3 em { display: inline-block; margin-left: .3rem; padding: .05rem .55rem; border-radius: 999px; font-style: normal; font-weight: 700; font-size: .72rem; background: var(--menta-clara); color: #05386b; vertical-align: middle; }
.spec p { margin: 0; font-size: .88rem; color: var(--texto-2); }
.spec-escolhida { border: 1.5px solid var(--petroleo); background: #f6fbf0; }

.condicoes { margin: 0; padding-left: 1.3rem; }
.condicoes li { margin-bottom: .55rem; padding-left: .25rem; max-width: 78ch; color: var(--texto-2); }
.condicoes li strong { color: var(--texto); }
.condicoes li::marker { font-weight: 700; color: var(--ok); }

.observacoes { margin-top: 1rem; padding: .9rem 1.1rem; background: var(--acento-suave); border-radius: 14px; color: var(--acento-escuro); }
.observacoes h3 { font-weight: 700; font-size: .95rem; margin-bottom: .25rem; }
.observacoes p { margin: 0; }

.assinaturas { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2.5rem; margin-top: 3rem; text-align: center; }
.assinaturas div { display: flex; flex-direction: column; gap: .15rem; }
.linha-assinatura { display: block; height: 2.5rem; border-bottom: 1px solid var(--texto-3); margin-bottom: .4rem; }
.assinaturas span:last-child { color: var(--texto-3); font-size: .86rem; }

.legenda {
    display: grid; grid-template-columns: 2fr repeat(5, minmax(0, 1fr));
    margin-top: 1.25rem; border-radius: 16px; overflow: hidden; background: var(--superficie-2);
}
.legenda > div { padding: .6rem .8rem; min-width: 0; }
.legenda > div:first-child { background: #05386b; color: #fff; }
.legenda span { display: block; font-size: .72rem; color: var(--texto-3); }
.legenda > div:first-child span { color: rgba(255, 255, 255, .8); }
.legenda strong { display: block; font-weight: 700; font-size: .92rem; line-height: 1.25; overflow-wrap: anywhere; }

.carimbo {
    display: inline-block; margin-bottom: 1rem;
    padding: .3rem .9rem; border-radius: 999px;
    font-weight: 700; font-size: .82rem; pointer-events: none;
}
.carimbo-aceito { background: var(--ok-suave); color: var(--ok); }
.carimbo-entregue { background: var(--texto); color: #fff; }
.carimbo-cancelado { background: var(--perigo-suave); color: var(--perigo); }

.excluir { max-width: 940px; margin: 1.5rem auto 0; text-align: right; }

/* ---------- Fichas técnicas ---------- */

.contagem-cotas { display: flex; flex-wrap: wrap; gap: .3rem; }
.cc { font-size: .76rem; font-weight: 700; padding: .15rem .6rem; border-radius: 999px; white-space: nowrap; }
.cc-aprovado { background: var(--ok-suave); color: var(--ok); }
.cc-reprovado { background: var(--perigo); color: #fff; }
.cc-pendente { background: var(--superficie-3); color: var(--texto-2); }

.indice-ficha {
    position: sticky; top: 4.75rem; z-index: 5;
    display: flex; gap: .35rem; overflow-x: auto;
    margin: 0 0 1.25rem; padding: .35rem; border-radius: 999px;
    background: var(--topo-fundo); border: 1px solid var(--borda);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.indice-ficha a {
    flex: none; padding: .45rem .95rem; border-radius: 999px;
    text-decoration: none; font-weight: 600; font-size: .88rem; color: var(--texto-2); white-space: nowrap;
}
.indice-ficha a:hover { background: var(--superficie-3); color: var(--texto); }
.bloco { scroll-margin-top: 8.5rem; }

.cota {
    display: grid; align-items: end; gap: .6rem;
    grid-template-columns: 2.8rem minmax(0, 2.4fr) repeat(5, minmax(0, 1fr));
    padding: 1rem; border: 1px solid var(--borda); border-radius: 16px; background: var(--superficie-2);
}
.cota[data-status="aprovado"] { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.cota[data-status="reprovado"] { border-color: color-mix(in srgb, var(--perigo) 55%, transparent); background: var(--perigo-suave); }
.cota-codigo {
    align-self: center; justify-self: start; margin-top: 1.4rem;
    padding: .2rem .5rem; border-radius: 999px; background: var(--superficie-3);
    font-weight: 800; font-size: .8rem;
}
.cota .campo label { font-size: .76rem; }
.cota input { font-variant-numeric: tabular-nums; }
.cota-resultado { grid-column: 2 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1.25rem; font-size: .86rem; color: var(--texto-3); }
.cota-resultado strong { color: var(--texto); font-variant-numeric: tabular-nums; }
.cota-resultado .botao-texto { margin-left: auto; font-size: .86rem; }

.selo-cota { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 700; white-space: nowrap; }
.selo-cota-aprovado { background: var(--ok-suave); color: var(--ok); }
.selo-cota-reprovado { background: var(--perigo); color: #fff; }
.selo-cota-pendente { background: var(--superficie-3); color: var(--texto-2); }

.slicer { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.75rem; }
.slicer-grupo { grid-column: 1 / -1; font-weight: 700; font-size: .95rem; margin: 1.1rem 0 .2rem; padding-bottom: .35rem; border-bottom: 1px solid var(--borda); }
.slicer-grupo:first-child { margin-top: 0; }
.slicer-linha { display: grid; grid-template-columns: minmax(0, 1fr) 9rem; gap: .75rem; align-items: center; padding: .4rem 0; }
.slicer-linha label { font-size: .9rem; font-weight: 600; }
.slicer-linha small { display: block; color: var(--texto-3); font-size: .78rem; font-weight: 400; }
.slicer-linha input { min-height: 2.4rem; padding: .35rem .7rem; }

.orientacao { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.eixos { margin: 0; --linha: var(--borda-forte); --grafite: var(--texto); --aco: var(--texto-2); }
.eixos svg { width: 100%; height: auto; display: block; }
.eixos figcaption { display: flex; flex-direction: column; gap: .3rem; margin-top: .5rem; font-size: .8rem; color: var(--texto-3); }
.leg { padding-left: 1rem; position: relative; }
.leg::before { content: ""; position: absolute; left: 0; top: .55em; width: .6rem; height: 2px; }
.leg-z::before { background: var(--perigo); }
.leg-xy::before { background: var(--ok); }

.custos-form { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.custos-form th { text-align: left; font-size: .78rem; font-weight: 600; color: var(--texto-3); padding: .5rem; border-bottom: 1px solid var(--borda-forte); }
.custos-form td { padding: .5rem; border-bottom: 1px solid var(--borda); vertical-align: middle; }
.custos-form td:first-child { font-size: .9rem; }
.custos-form input { min-height: 2.4rem; padding: .35rem .7rem; max-width: 9rem; }
.custos-form .com-unidade { max-width: 9rem; }
.custos-form .calculado { color: var(--texto-3); font-size: .88rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.custos-form td.num { font-weight: 700; }
.margem-linha { margin-bottom: 0; }

.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.checklist .check { padding: .8rem 1rem; border: 1px solid var(--borda); border-radius: 14px; background: var(--superficie-2); transition: background-color .15s, border-color .15s; }
.checklist .check:has(input:checked) { border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: var(--ok-suave); }
.checklist .check span { font-size: .92rem; color: var(--texto-2); }
.checklist strong { display: block; color: var(--texto); }

.ficha-dados { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem 1.5rem; margin: 0; }
.ficha-dados-1 { grid-template-columns: 1fr; }
.ficha-dados .largo { grid-column: 1 / -1; }
.ficha-dados dt { font-size: .8rem; color: var(--texto-3); }
.ficha-dados dd { margin: 0; font-weight: 600; }
.marcadores { display: flex; flex-wrap: wrap; gap: .35rem; }
.marcadores span { padding: .15rem .7rem; border: 1px solid var(--borda); border-radius: 999px; color: var(--texto-3); font-size: .84rem; font-weight: 500; }
.marcadores span.marcado { background: var(--ok-suave); border-color: var(--petroleo); color: var(--texto); font-weight: 700; }

.cotas-tabela td, .cotas-tabela th { white-space: nowrap; }
.cotas-tabela td:nth-child(2) { white-space: normal; min-width: 12rem; }
.cotas-tabela tr.linha-reprovado td { background: var(--perigo-suave); }
.nota { margin: .5rem 0 0; font-size: .8rem; color: var(--texto-3); }

.slicer-ver { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem 1.5rem; }
.slicer-bloco h3 { font-weight: 700; font-size: .92rem; padding-bottom: .3rem; border-bottom: 1px solid var(--borda-forte); margin-bottom: .35rem; }
.slicer-bloco dl { margin: 0; }
.slicer-bloco div { display: flex; justify-content: space-between; gap: .75rem; padding: .25rem 0; border-bottom: 1px dashed var(--borda); font-size: .86rem; }
.slicer-bloco dt { color: var(--texto-3); }
.slicer-bloco dd { margin: 0; font-weight: 700; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

.checklist-ver li { display: flex; gap: .65rem; align-items: flex-start; font-size: .92rem; padding: 0; border: 0; background: none; }
.checklist-ver .caixa { display: grid; place-items: center; flex: none; width: 1.3rem; height: 1.3rem; margin-top: .05rem; border: 1.5px solid var(--borda-forte); border-radius: 999px; font-weight: 800; font-size: .75rem; }
.checklist-ver li.feito .caixa { background: var(--menta); border-color: var(--menta); color: #05386b; }
.checklist-ver li:not(.feito) { color: var(--texto-3); }

.diario { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.diario div { padding: 1rem 1.15rem; background: var(--superficie-2); border-radius: 16px; }
.diario h3 { font-weight: 700; font-size: .92rem; margin-bottom: .3rem; }
.diario p { margin: 0; font-size: .92rem; color: var(--texto-2); }

/* ---------- Login ---------- */

.pagina-login {
    min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem;
    background:
        radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--texto) 9%, transparent) 1px, transparent 0) 0 0 / 22px 22px,
        var(--fundo);
}
.login { width: 100%; max-width: 25.5rem; }
.login-marca { display: flex; align-items: center; gap: .8rem; margin-bottom: 1.4rem; justify-content: center; }
.login-marca .marca-icone { width: 44px; height: 44px; padding: 8px; border-radius: 14px; background: #05386b; color: var(--menta); box-shadow: 0 8px 20px -8px var(--acento-sombra); }
.login-marca strong { display: block; font-weight: 800; font-size: 1.2rem; line-height: 1.15; letter-spacing: -.02em; }
.login-marca span { display: block; color: var(--texto-3); font-size: .82rem; }
.login-cartao {
    padding: 2rem; background: var(--superficie);
    border: 1px solid var(--borda); border-radius: 26px; box-shadow: var(--sombra-2);
}
.login-cartao h1 { font-weight: 800; font-size: 1.6rem; letter-spacing: -.03em; }
.login-sub { margin: .35rem 0 1.5rem; color: var(--texto-3); }
.login-cartao .check { margin: .25rem 0 1.4rem; font-size: .9rem; color: var(--texto-2); }
.login-rodape { margin: 1rem 0 0; text-align: center; font-size: .84rem; color: var(--texto-3); }

/* ---------- Responsivo ---------- */

@media (max-width: 1000px) {
    .form-grade { grid-template-columns: 1fr; }
    .resumo { position: static; }
    .specs { grid-template-columns: 1fr; }
    .legenda { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .legenda > div:first-child { grid-column: 1 / -1; }
    .cota { grid-template-columns: 2.8rem repeat(3, minmax(0, 1fr)); }
    .cota-descricao { grid-column: 2 / -1; }
    .slicer, .slicer-ver { grid-template-columns: 1fr; }
    .campos-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .topo-interno { gap: .75rem; }
    .marca small { display: none; }
    .topo-nav { order: 3; width: 100%; margin: 0; }
    .topo-nav a { flex: 1; text-align: center; }
    .topo-acoes { margin-left: auto; }
    .indice-ficha { top: 7.6rem; }
}

@media (max-width: 640px) {
    .campos-2, .campos-3, .partes, .assinaturas, .opcoes-material { grid-template-columns: 1fr; }
    .campos-3 .campo-largo { grid-column: auto; }
    .item-campos { grid-template-columns: 1fr 1fr; }
    .item-descricao, .item-categoria { grid-column: 1 / -1; }
    .filtros, .filtros .busca, .filtros .busca input, .filtros select { width: 100%; min-width: 0; }
    .folha-cabecalho { flex-direction: column; }
    .folha-numero { text-align: left; }
    .total { width: 100%; align-items: flex-start; }
    .cota { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .cota-codigo { grid-column: 1 / -1; margin-top: 0; }
    .cota-descricao, .cota-resultado { grid-column: 1 / -1; }
    .orientacao, .ficha-dados, .diario { grid-template-columns: 1fr; }
    .eixos { max-width: 260px; }
    .slicer-linha { grid-template-columns: minmax(0, 1fr) 7.5rem; }
    .topo-acoes .botao-primario { font-size: 0; gap: 0; width: var(--alt-ctrl); padding: 0; }
    .topo-acoes .botao-primario .icone { width: 20px; height: 20px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Impressão ---------- */

@page { size: A4; margin: 10mm; }

@media print {
    :root, [data-theme="dark"] { color-scheme: light; --fundo: #fff; --texto: #0b2540; }
    body { background: #fff; color: #0b2540; font-size: 10pt; }
    .nao-imprimir, .excluir, .pular { display: none !important; }
    .conteudo { padding: 0; max-width: none; }
    .folha { box-shadow: none; max-width: none; padding: 6mm; border-radius: 0; }
    .folha section { margin-bottom: 6mm; break-inside: avoid; }
    .folha, .itens-tabela th, .legenda, .legenda > div:first-child, .total, .spec h3 em, .selo, .selo-cota, .secao-titulo span,
    .marcadores span.marcado, .checklist-ver li.feito .caixa, .cotas-tabela tr.linha-reprovado td, .observacoes, .carimbo {
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
    .specs, .slicer-ver { grid-template-columns: repeat(3, 1fr); }
    .partes, .assinaturas, .ficha-dados, .diario { grid-template-columns: 1fr 1fr; }
    .orientacao { grid-template-columns: 200px 1fr; }
    .legenda { grid-template-columns: 2fr repeat(5, 1fr); }
    .legenda > div:first-child { grid-column: auto; }
    .cotas-tabela { font-size: 9pt; }
    a { text-decoration: none; }
}
