/* obras.css — aba 🏗️ Obras (módulo Controle de Obras, 2026-11-18).
   Usa as variáveis de cor do style.css principal (--border, --muted, --surface…),
   então segue o tema claro/escuro sem regra própria. */
#obras-raiz .card { padding: .75rem 1rem; margin-bottom: .75rem; }
.obras-escolha, .obras-filtros, .obras-form-linha {
  display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: end;
}
.obras-escolha label, .obras-filtros label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--muted); }
.obras-escolha select { min-width: 16rem; max-width: 100%; }
.obras-busca input { min-width: 14rem; }
.obras-check { flex-direction: row !important; align-items: center; gap: .35rem !important; }
.obras-filtros { margin-bottom: .5rem; }
.obras-resumo { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .85rem; color: var(--muted); margin: .25rem 0 .5rem; }
.obras-cortado { color: #b45309; }
/* 24/11 (pedido dele): cabeçalho fixo ao rolar — a caixa rola por dentro (altura da tela), senão o sticky do th não pega */
.obras-tabela-caixa { overflow: auto; max-height: calc(100vh - 5.5rem); max-height: calc(100dvh - 5.5rem); border: 1px solid var(--border); border-radius: 8px; }
.obras-tabela { width: 100%; border-collapse: collapse; font-size: .85rem; }
.obras-tabela th, .obras-tabela td { padding: .35rem .5rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.obras-tabela thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); box-shadow: inset 0 -1px 0 var(--border); }
.obras-tabela .num { text-align: right; white-space: nowrap; }
.obras-tabela tr.obras-ok td { color: #15803d; }
.obras-tabela tr.obras-excesso td { color: #b91c1c; }
.obras-aviso { padding: .5rem .75rem; border-radius: 6px; margin-bottom: .5rem; border: 1px solid var(--border); }
.obras-aviso.erro { border-color: #b91c1c; color: #b91c1c; }
.obras-aviso.ok { border-color: #15803d; color: #15803d; }
.obras-admin summary { cursor: pointer; font-weight: 600; }
.obras-adm-bloco { margin-top: 1rem; }
.obras-adm-bloco h3 { font-size: 1rem; margin: 0 0 .4rem; }
.obras-lista { margin: .25rem 0 .5rem 1rem; padding: 0; }
.obras-acesso { margin: .5rem 0 .75rem; }
.obras-form-linha input, .obras-form-linha select { max-width: 100%; }
#obras-raiz [hidden] { display: none !important; }

/* Fase 2 (2026-11-18): vistas, notas, conferência, equivalentes */
.obras-vistas { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .75rem; }
.obras-envio .obras-form-linha { margin-top: .4rem; }
.obras-envio input[type=text] { min-width: 22rem; max-width: 100%; }
.obras-clicavel { cursor: pointer; }
.obras-clicavel:hover td { background: var(--border); }
.obras-conf td { vertical-align: top; }
.obras-conf select.obras-l-alvo { max-width: 34rem; width: 100%; }
.obras-l-fator { width: 5rem; }
.obras-l-busca { width: 12rem; }
tr.obras-l-casada td { background: color-mix(in srgb, #15803d 8%, transparent); }
tr.obras-l-fora_escopo td, tr.obras-l-ignorada td { opacity: .7; }
tr.obras-l-confirmada td { background: color-mix(in srgb, #15803d 14%, transparent); }   /* 23/11: confirmação parcial */
tr.obras-l-miuda td { background: color-mix(in srgb, #b45309 12%, transparent); opacity: 1; }   /* 23/11: 🔩 miúdo — destaque como a casada, em âmbar */
.obras-grupo label { display: flex; gap: .4rem; margin: .2rem 0; }
.obras-grupo { margin-bottom: .5rem; }

/* 19/11: descrição curta × detalhada */
.obras-desc-longa { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.obras-detalhada { display: block; font-size: .78rem; }
.obras-curta-texto { min-width: 18rem; max-width: 100%; }
.obras-tabela td.obras-pacote-ok { color: #15803d; }
.obras-tabela td.obras-pacote-excesso { color: #b91c1c; font-weight: 600; }
.obras-selo { font-size: .7rem; padding: 0 .3rem; border: 1px solid var(--border); border-radius: 4px; color: var(--muted); white-space: nowrap; }

/* 19/11: nota × orçamento do faturamento direto */
.obras-orc { font-size: .8rem; color: var(--muted); margin-top: .2rem; }
.obras-orc select { max-width: 30rem; font-size: .8rem; }
.obras-orc-alerta, .obras-orc.obras-orc-alerta { color: #b45309; }
.obras-o-qtd, .obras-o-preco { width: 7rem; }
.obras-o-un { width: 4rem; }
.obras-o-contrato { min-width: 18rem; }
.obras-o-contrato select.obras-c-alvo { max-width: 26rem; width: 100%; }
.obras-c-busca { width: 9rem; }
.obras-c-fator { width: 4.5rem; }
/* 19/11: busca "conforme digita" (lista abaixo do campo) */
.obras-sugere-pai { position: relative; }
.obras-sugere { position: absolute; z-index: 20; left: 0; top: 100%; min-width: 26rem; max-width: min(40rem, 92vw);
  max-height: 22rem; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,.18); padding: .2rem; }
.obras-sugere button { display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 4px;
  padding: .3rem .45rem; font-size: .82rem; color: inherit; cursor: pointer; }
.obras-sugere button:hover, .obras-sugere button.ativo { background: var(--border); }
.obras-sugere-qtd { white-space: nowrap; }
.obras-sugere-det { display: block; font-size: .74rem; }
.obras-sugere > .hint { padding: .3rem .45rem; }
/* 19/11: take-in / take-out */
.obras-tabela tr.obras-tio-in td:nth-child(5) { color: #b91c1c; }
.obras-tabela tr.obras-tio-out td:nth-child(5) { color: #15803d; }
.obras-tio-docs { margin: .4rem 0 .6rem; }
.obras-tio-docs summary { cursor: pointer; }
.obras-sme-qtd { width: 8rem; }

/* 23/11: 📋 Listas de materiais (importador web, Fase 3) */
.obras-soltar { border: 2px dashed var(--border); border-radius: 8px; padding: 1rem; margin-top: .5rem; display: flex;
  flex-wrap: wrap; gap: .75rem; align-items: center; color: var(--muted); }
.obras-soltar.obras-soltar-ativo { border-color: #15803d; color: #15803d; }
.obras-grade { max-height: 26rem; }
.obras-grade td, .obras-grade th { white-space: nowrap; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; font-size: .78rem; }
.obras-grade th.obras-ls-col, .obras-grade th.obras-ls-lin { cursor: pointer; text-align: center; }
.obras-grade th.obras-ls-col:hover, .obras-grade th.obras-ls-lin:hover { background: var(--border); }
.obras-grade th.obras-ls-col-marcada { background: color-mix(in srgb, #15803d 18%, var(--surface)); }
.obras-grade tr.obras-ls-cab td { background: color-mix(in srgb, #b45309 14%, transparent); font-weight: 600; }
.obras-ls-motivo { width: 16rem; max-width: 100%; }
#obras-v-listas h4 { margin: .9rem 0 .35rem; font-size: .95rem; }
.obras-ls-linhas summary { cursor: pointer; margin: .75rem 0 .35rem; font-weight: 600; }
/* 23/11: coluna Engenharia (🧱/📊) e saldo da conta corrente do take-in/out (📐) */
.obras-tabela td.obras-eng-dif { font-weight: 600; background: color-mix(in srgb, #2563eb 10%, transparent); }
.obras-saldo-cc { font-weight: 600; }
.obras-saldo-cc.obras-saldo-neg { color: #15803d; }
.obras-saldo-cc.obras-saldo-pos { color: #b91c1c; }
/* 23/11: escolha da linha da PPU (💰) — busca na 1ª linha e lista que quebra o texto (no <select> ficava cortado) */
.obras-ppu-escolha { display: flex; flex-direction: column; gap: .35rem; min-width: 16rem; max-width: 40rem; }
.obras-ppu-escolha .obras-ppu-busca { width: 100%; }
.obras-ppu-sel { display: flex; flex-direction: column; gap: .2rem; max-height: 16rem; overflow-y: auto; }
.obras-ppu-op { display: flex; gap: .4rem; align-items: flex-start; white-space: normal; overflow-wrap: anywhere; cursor: pointer;
  padding: .2rem .3rem; border: 1px solid var(--border); border-radius: 4px; font-size: .85rem; line-height: 1.3; }
.obras-ppu-op:has(input:checked) { border-color: #2563eb; background: color-mix(in srgb, #2563eb 8%, transparent); }
.obras-ppu-op input { margin-top: .15rem; flex: 0 0 auto; }
.obras-tabela td.obras-ppu-texto { white-space: normal; overflow-wrap: anywhere; min-width: 14rem; }
/* 24/11: material aplicado por material na 📐 (take-in/out pelo material aplicado) */
.obras-tabela.obras-tio th, .obras-tabela.obras-tio td { padding: .3rem .35rem; font-size: .8rem; }
.obras-tio-uso { display: inline-flex; gap: .2rem; align-items: center; }
.obras-tio-usado { width: 5.2rem; text-align: right; }
.obras-tio-devolve { font-size: .68rem; line-height: 1.15; white-space: normal; text-align: left; }
.obras-tio-devolve input { margin: 0; transform: scale(.9); }
.obras-tio-pendente { opacity: .75; font-style: italic; }
/* 24/11: acompanhamento por material na 🧱 — 💰 PPU (NF + PPU) | 🔩 Miúdo (só NF) */
.obras-acomp { display: inline-flex; gap: .2rem; flex-wrap: wrap; }
/* 24/11: 💰 por linha da PPU — materiais vinculados (1 linha → N materiais) e sugeridos */
.obras-ppu-mats { min-width: 16rem; }
.obras-ppu-mat, .obras-ppu-sug { display: flex; flex-wrap: wrap; gap: .25rem; align-items: baseline; padding: .1rem 0; }
.obras-ppu-mat + .obras-ppu-mat { border-top: 1px dashed color-mix(in srgb, currentColor 20%, transparent); }
.obras-ppu-sug { opacity: .9; }
.obras-ppu-modo { gap: .3rem; align-items: center; }
/* 24/11: linha da PPU vinculada na 🧱 Por material */
.obras-ppu-mcel { min-width: 14rem; max-width: 28rem; }
.obras-ppu-mtexto { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
