/* Plataforma Mansarda — estilos base (sem etapa de build) */
:root {
  --azul: #1c4474;
  --azul-escuro: #13325a;
  --azul-claro: #52a6d6;
  --azul-fundo: #eef4fa;
  --texto: #1d2733;
  --texto-suave: #5b6878;
  --borda: #d8e0ea;
  --fundo: #f5f7fa;
  --branco: #fff;
  --ok: #1f7a4d;
  --ok-fundo: #e6f4ec;
  --erro: #b3261e;
  --erro-fundo: #fbeaea;
  --aviso: #8a5a00;
  --aviso-fundo: #fff4db;
  --raio: 8px;
  --fonte: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--fonte); font-size: 15px; color: var(--texto); background: var(--fundo); line-height: 1.45; }
a { color: var(--azul); }
h1 { font-size: 1.45rem; margin: 0 0 1rem; color: var(--azul-escuro); }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .75rem; color: var(--azul-escuro); }

/* Estrutura */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.lateral { background: var(--azul); color: var(--branco); display: flex; flex-direction: column; padding: 1.25rem 0; }
.lateral .marca { padding: 0 1.25rem 1.25rem; }
.lateral .marca img { width: 170px; display: block; }
.menu { list-style: none; margin: 0; padding: 0; flex: 1; }
.menu .grupo { padding: 1rem 1.25rem .35rem; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.55); }
.menu a { display: block; padding: .5rem 1.25rem; color: var(--branco); text-decoration: none; border-left: 3px solid transparent; }
.menu a:hover { background: rgba(255,255,255,.08); }
.menu a.ativo { background: rgba(255,255,255,.12); border-left-color: var(--azul-claro); font-weight: 600; }
.lateral .rodape { padding: 1rem 1.25rem 0; font-size: .85rem; border-top: 1px solid rgba(255,255,255,.15); }
.lateral .rodape .nome { font-weight: 600; }
.lateral .rodape .perfil { color: rgba(255,255,255,.7); font-size: .8rem; }
.lateral .rodape a, .lateral .rodape button { color: var(--branco); background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; margin-right: .75rem; }
.conteudo { padding: 1.75rem 2rem 3rem; max-width: 1200px; width: 100%; }
.topo { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.topo h1 { margin: 0; }

/* Cartões e tabelas */
.cartao { background: var(--branco); border: 1px solid var(--borda); border-radius: var(--raio); padding: 1.25rem; }
.grade-cartoes { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.grade-cartoes a.cartao { text-decoration: none; color: inherit; }
.grade-cartoes a.cartao:hover { border-color: var(--azul-claro); }
.grade-cartoes .titulo { font-weight: 600; color: var(--azul); margin-bottom: .25rem; }
.grade-cartoes .desc { color: var(--texto-suave); font-size: .9rem; }
.tabela-wrap { background: var(--branco); border: 1px solid var(--borda); border-radius: var(--raio); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--borda); vertical-align: top; }
th { background: var(--azul-fundo); color: var(--azul-escuro); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.acoes { text-align: right; white-space: nowrap; }
.suave { color: var(--texto-suave); }
.pequeno { font-size: .85rem; }

/* Etiquetas */
.etiqueta { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; background: var(--azul-fundo); color: var(--azul-escuro); margin: 0 .2rem .2rem 0; }
.etiqueta.ok { background: var(--ok-fundo); color: var(--ok); }
.etiqueta.off { background: #eceff3; color: var(--texto-suave); }

/* Formulários */
.form { max-width: 720px; }
.campo { margin-bottom: 1rem; }
.campo label, .campo .rotulo { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .9rem; }
.campo .ajuda { color: var(--texto-suave); font-size: .82rem; margin-top: .25rem; }
input[type=text], input[type=search], input[type=file], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--borda); border-radius: 6px; font: inherit; background: var(--branco); color: var(--texto);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--azul-claro); outline-offset: 0; border-color: var(--azul-claro); }
.campo.com-erro input, .campo.com-erro select { border-color: var(--erro); }
.erro-campo { color: var(--erro); font-size: .85rem; margin-top: .25rem; }
.linha { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.opcoes { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.opcoes label { font-weight: normal; display: flex; align-items: center; gap: .4rem; margin: 0; }
.filtros { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: 1rem; }
.filtros .campo { margin: 0; min-width: 160px; }

/* Botões */
.botao { display: inline-block; padding: .55rem 1.1rem; border-radius: 6px; border: 1px solid var(--azul); background: var(--azul); color: var(--branco); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.botao:hover { background: var(--azul-escuro); }
.botao.secundario { background: var(--branco); color: var(--azul); }
.botao.secundario:hover { background: var(--azul-fundo); }
.botao.pequeno { padding: .3rem .7rem; font-size: .85rem; }
.acoes-form { display: flex; gap: .75rem; margin-top: 1.5rem; }

/* Mensagens */
.alerta { padding: .75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.alerta.ok { background: var(--ok-fundo); color: var(--ok); }
.alerta.erro { background: var(--erro-fundo); color: var(--erro); }
.alerta.aviso { background: var(--aviso-fundo); color: var(--aviso); }
.alerta ul { margin: .25rem 0 0; padding-left: 1.2rem; }

/* Paginação */
.paginacao { display: flex; gap: .35rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.paginacao a, .paginacao span { padding: .3rem .65rem; border: 1px solid var(--borda); border-radius: 6px; background: var(--branco); text-decoration: none; font-size: .88rem; }
.paginacao .atual { background: var(--azul); color: var(--branco); border-color: var(--azul); }
.paginacao .desab { color: var(--texto-suave); }

/* Login */
.tela-entrada { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--azul) 0%, var(--azul-escuro) 100%); padding: 1rem; }
.caixa-entrada { background: var(--branco); border-radius: 12px; padding: 2rem; width: 100%; max-width: 380px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.caixa-entrada img { width: 200px; display: block; margin: 0 auto 1.5rem; }
.caixa-entrada .botao { width: 100%; }

/* Detalhes da auditoria */
details summary { cursor: pointer; color: var(--azul); }
.diff { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; white-space: pre-wrap; margin: .4rem 0 0; }

/* Celular */
.abrir-menu { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .lateral { position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .2s; z-index: 20; }
  .app.menu-aberto .lateral { transform: none; }
  .abrir-menu { display: inline-block; margin-bottom: 1rem; }
  .conteudo { padding: 1rem; }
  .linha { grid-template-columns: 1fr; }
}
@media print { .lateral, .abrir-menu, .acoes-form, .filtros { display: none !important; } .app { display: block; } }

/* Abas e grades de edição */
.abas { display: flex; gap: .25rem; border-bottom: 1px solid var(--borda); margin-bottom: 1rem; flex-wrap: wrap; }
.aba { padding: .5rem 1rem; text-decoration: none; color: var(--texto-suave); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.aba.ativa { color: var(--azul); border-bottom-color: var(--azul); font-weight: 600; }
.grade input[type=text], .grade select { padding: .35rem .5rem; font-size: .9rem; }
.grade td { padding: .35rem .4rem; vertical-align: middle; }
.grade .num { width: 90px; text-align: right; }
.grade .num-p { width: 64px; text-align: right; }
.grade tr.pausado td { opacity: .55; }
.grade tr.novo td { background: #fafcfe; }
.dica { font-size: .75rem; color: var(--texto-suave); margin-top: .15rem; white-space: nowrap; }
.alterado { outline: 2px solid var(--aviso) !important; }
th.consig, td.consig { background: #fff8ec; }
.form-inline { display: inline-flex; gap: .35rem; align-items: center; margin: 0; }
.form-inline input { width: 70px; padding: .3rem .4rem; }

/* Orçamento */
.orc-grade { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
.orc-resumo { position: sticky; top: 1rem; }
.resumo-linha { display: flex; justify-content: space-between; gap: 1rem; padding: .2rem 0; }
.resumo-linha.total { font-size: 1.15rem; border-top: 1px solid var(--borda); margin-top: .35rem; padding-top: .5rem; color: var(--azul-escuro); }
.resumo-linha.suave { color: var(--texto-suave); font-size: .9rem; }
.resumo-linha.comissao strong { color: var(--ok); }
#resumo hr { border: 0; border-top: 1px dashed var(--borda); margin: .6rem 0; }
#resumo .alerta ul { margin: 0; padding-left: 1rem; }
.selo-campanha { background: #fff1c9; color: #7a4d00; padding: .05rem .4rem; border-radius: 4px; font-weight: 600; }
tr.em-campanha td { background: #fffaf0; }
.dica .desc { color: var(--erro); font-weight: 600; }
.campanhas-orc { margin-top: 1rem; border-color: #f0c96b; background: #fffdf5; }
.titulo-campanha { font-weight: 700; color: #7a4d00; margin-bottom: .5rem; }
.campanha-linha { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: .5rem 0; border-top: 1px solid #f3e4bd; flex-wrap: wrap; }
.campanha-linha:first-of-type { border-top: 0; }
.botao:disabled { opacity: .5; cursor: not-allowed; }
.status { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--azul-fundo); color: var(--azul-escuro); }
.status.aguardando_aprovacao { background: var(--aviso-fundo); color: var(--aviso); }
.status.aprovado, .status.separado { background: #e3f0fb; color: #1b5d93; }
.status.entregue, .status.recolhido { background: var(--ok-fundo); color: var(--ok); }
.status.recusado, .status.cancelado { background: #eceff3; color: var(--texto-suave); }

/* Alerta de campanha em tempo real */
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .75rem; z-index: 50; max-width: 360px; }
.toast { background: #fffdf5; border: 1px solid #f0c96b; border-left: 5px solid #e0a100; border-radius: 8px; padding: .9rem 1rem; box-shadow: 0 8px 24px rgba(0,0,0,.18); animation: entra .25s ease-out; }
.toast .t-titulo { font-weight: 700; color: #7a4d00; margin-bottom: .2rem; }
.toast .t-acoes { margin-top: .6rem; display: flex; gap: .5rem; }
@keyframes entra { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.menu .contador { background: #e0a100; color: #fff; border-radius: 999px; font-size: .72rem; padding: .05rem .45rem; margin-left: .35rem; font-weight: 700; }
@media (max-width: 1000px) { .orc-grade { grid-template-columns: 1fr; } .orc-resumo { position: static; } }
#tabela-itens .sel-produto, #tabela-servicos select { width: 100%; max-width: 360px; }
#tabela-itens td:first-child { max-width: 380px; }
#tabela-itens .dica { white-space: normal; }

/* Crédito do cliente */
.credito-nota { margin-top: .6rem; padding: .5rem .6rem; border-radius: 6px; background: #f3f6fa; display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem .75rem; font-size: .9rem; }
.credito-nota .dica { flex-basis: 100%; }
.credito-nota.nota-A strong, .nota.A { color: var(--ok); }
.credito-nota.nota-B strong, .nota.B { color: #2f6db3; }
.credito-nota.nota-C strong, .nota.C { color: #a86b00; }
.credito-nota.nota-D { background: #fdecec; }
.credito-nota.nota-D strong, .nota.D { color: var(--erro); }
.nota { font-weight: 700; }
.indicadores { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin: .5rem 0 1rem; }
.indicadores div { background: #f6f8fb; border-radius: 6px; padding: .5rem .65rem; }
.indicadores span { display: block; font-size: .8rem; color: var(--texto-suave); }
.indicadores strong { font-size: 1.05rem; }

/* Painel do CD */
.blocos-cd { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.blocos-cd .cartao h2 { margin-top: 0; display: flex; justify-content: space-between; align-items: center; }
.pedido-cd { border-top: 1px solid var(--borda); padding: .6rem 0; }
.pedido-cd:first-of-type { border-top: 0; }
.pedido-cd .pequeno { color: var(--texto-suave); }
.atrasado { color: var(--erro); font-weight: 600; }
.pagamento.quitado { color: var(--ok); font-weight: 600; }
.pagamento.parcial { color: #a86b00; font-weight: 600; }
.pagamento.em_aberto { color: var(--erro); font-weight: 600; }
.folha-secao { margin-top: 1.25rem; }
.folha-secao table select, .folha-secao table input[type=text] { min-width: 120px; }

/* Estoque */
.grade input.filtro-item { padding: .25rem .45rem; font-size: .8rem; width: 100%; }
.grade td { vertical-align: top; }

/* Leitor de QR */
.leitor-qr { position: fixed; inset: 0; background: rgba(10, 20, 35, .75); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.leitor-caixa { background: #fff; border-radius: 10px; padding: 1rem; width: 100%; max-width: 480px; }
.leitor-topo { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.leitor-caixa video { width: 100%; border-radius: 8px; background: #000; max-height: 60vh; object-fit: cover; }
.leitor-status { margin: .5rem 0; }
.leitor-manual { display: flex; gap: .5rem; }
.leitor-manual input { flex: 1; }
tr.lido { background: #e6f4ec !important; }
.situacao { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; font-weight: 600; background: #eef2f6; color: #334; }
.situacao.disponivel { background: #e6f4ec; color: #1f7a4d; }
.situacao.cheio { background: #e3eefb; color: #1c4474; }
.situacao.em_cliente, .situacao.em_evento { background: #fff4db; color: #8a5a00; }
.situacao.atrasado { background: #fbeaea; color: #b3261e; }
.situacao.higienizacao { background: #efe9fb; color: #5b3aa0; }
.situacao.manutencao, .situacao.baixado { background: #e9ecef; color: #333; }
