/* ERP Construtech — folha de estilo única, sem dependências externas (CSP 'self'). */
:root {
  --fundo: #f4f2ee;
  --superficie: #ffffff;
  --superficie-2: #faf8f5;
  --borda: #e3ded6;
  --texto: #23201c;
  --texto-2: #6b645a;
  --marca: #c2561a;
  --marca-escura: #9a4212;
  --marca-clara: #fbeee6;
  --lateral: #1f1d1a;
  --lateral-texto: #cfc8bd;
  --ok: #2f7d4f;
  --ok-fundo: #e6f3ea;
  --ruim: #b3261e;
  --ruim-fundo: #fbe9e7;
  --meio: #8a6100;
  --meio-fundo: #fdf3d8;
  --raio: 8px;
  --sombra: 0 1px 2px rgba(35, 32, 28, .06), 0 2px 8px rgba(35, 32, 28, .04);
  --fonte: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #161513;
    --superficie: #201e1b;
    --superficie-2: #1b1a17;
    --borda: #34312c;
    --texto: #ece7df;
    --texto-2: #a39b8f;
    --marca: #e0763a;
    --marca-escura: #f08f55;
    --marca-clara: #3a2618;
    --lateral: #100f0e;
    --ok-fundo: #18301f;
    --ok: #6cc28c;
    --ruim-fundo: #3a1b18;
    --ruim: #f08a80;
    --meio-fundo: #352a10;
    --meio: #e6bd5c;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--fonte); color: var(--texto); background: var(--fundo); }
a { color: var(--marca); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--texto-2); text-transform: uppercase; letter-spacing: .04em; }
.mono { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.mudo { color: var(--texto-2); }
.direita { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Estrutura */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.lateral { background: var(--lateral); color: var(--lateral-texto); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; font-size: 15px; }
.logo-marca { width: 28px; height: 28px; border-radius: 6px; background: var(--marca); display: grid; place-items: center; font-size: 13px; color: #fff; }
.lateral a { color: var(--lateral-texto); padding: 8px 10px; border-radius: 6px; display: block; }
.lateral a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.lateral a.ativo { background: rgba(224,118,58,.16); color: #fff; box-shadow: inset 3px 0 0 var(--marca); }
.lateral .rodape { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding-top: 12px; font-size: 13px; }
.lateral form button { background: none; border: 0; color: var(--lateral-texto); padding: 8px 10px; cursor: pointer; font: inherit; width: 100%; text-align: left; border-radius: 6px; }
.lateral form button:hover { background: rgba(255,255,255,.06); color: #fff; }
.principal { padding: 24px 32px 48px; min-width: 0; }
.topo { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.acoes { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Cartões e grades */
.cartao { background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio); box-shadow: var(--sombra); padding: 18px; }
.cartao + .cartao { margin-top: 16px; }
.grade { display: grid; gap: 16px; }
.grade-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grade-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grade-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.indicador .rotulo { color: var(--texto-2); font-size: 12.5px; }
.indicador .valor { font-size: 22px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.indicador .sub { color: var(--texto-2); font-size: 12px; }
.indicador.alerta .valor { color: var(--ruim); }
dl.dados { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.dados dt { color: var(--texto-2); }
dl.dados dd { margin: 0; }

/* Tabelas */
.tabela-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--borda); text-align: left; vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--texto-2); font-weight: 600; background: var(--superficie-2); }
tbody tr:hover { background: var(--superficie-2); }
tfoot td { font-weight: 650; border-bottom: 0; }
td.vazio { text-align: center; color: var(--texto-2); padding: 28px; }

/* Etiquetas de status */
.etiqueta { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--superficie-2); color: var(--texto-2); border: 1px solid var(--borda); }
.etiqueta.ok { background: var(--ok-fundo); color: var(--ok); border-color: transparent; }
.etiqueta.ruim { background: var(--ruim-fundo); color: var(--ruim); border-color: transparent; }
.etiqueta.meio { background: var(--meio-fundo); color: var(--meio); border-color: transparent; }

/* Botões */
.botao, button.botao, input[type=submit] { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--borda); background: var(--superficie); color: var(--texto); font: inherit; font-weight: 600; cursor: pointer; line-height: 1.2; }
.botao:hover { text-decoration: none; border-color: var(--texto-2); }
.botao.primario { background: var(--marca); border-color: var(--marca); color: #fff; }
.botao.primario:hover { background: var(--marca-escura); border-color: var(--marca-escura); }
.botao.perigo { color: var(--ruim); }
.botao.perigo:hover { border-color: var(--ruim); }
.botao.pequeno { padding: 4px 10px; font-size: 12.5px; }
form.inline { display: inline; }

/* Formulários */
.form-grade { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.campo { display: flex; flex-direction: column; gap: 4px; }
.campo.largo { grid-column: 1 / -1; }
.campo label { font-weight: 600; font-size: 13px; }
.campo .ajuda { color: var(--texto-2); font-size: 12px; }
.campo .erro, .erros { color: var(--ruim); font-size: 12.5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=url], input[type=tel], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--borda); border-radius: 6px; background: var(--superficie); color: var(--texto); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--marca); outline-offset: -1px; border-color: var(--marca); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--marca); }
.campo.checkbox { flex-direction: row; align-items: center; gap: 8px; padding-top: 22px; }
table.formset td { padding: 6px; }
table.formset input, table.formset select { min-width: 80px; }
.filtros { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filtros input[type=search] { width: 280px; }
.filtros select, .filtros input[type=date] { width: auto; }

/* Mensagens */
.mensagens { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.mensagens li { padding: 10px 14px; border-radius: 6px; background: var(--superficie); border: 1px solid var(--borda); border-left-width: 4px; }
.mensagens .success { border-left-color: var(--ok); }
.mensagens .error { border-left-color: var(--ruim); }
.mensagens .warning { border-left-color: var(--meio); }
.aviso { padding: 12px 14px; border-radius: 6px; background: var(--meio-fundo); color: var(--texto); border: 1px solid transparent; margin-bottom: 16px; }

/* Paginação */
.paginacao { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 12px; color: var(--texto-2); }

/* Fluxo (gráfico de barras simples) */
.fluxo { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; align-items: end; height: 190px; padding-top: 8px; }
.fluxo .mes { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.fluxo .barras { display: flex; gap: 4px; align-items: flex-end; height: 150px; }
.fluxo .barra { width: 18px; border-radius: 4px 4px 0 0; min-height: 2px; }
.fluxo .barra.receber { background: var(--marca); }
.fluxo .barra.pagar { background: var(--texto-2); opacity: .55; }
.legenda { display: flex; gap: 16px; font-size: 12.5px; color: var(--texto-2); }
.legenda span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legenda .l-receber::before { background: var(--marca); }
.legenda .l-pagar::before { background: var(--texto-2); opacity: .55; }
.h-10 { height: 10%; } .h-20 { height: 20%; } .h-30 { height: 30%; } .h-40 { height: 40%; } .h-50 { height: 50%; }
.h-60 { height: 60%; } .h-70 { height: 70%; } .h-80 { height: 80%; } .h-90 { height: 90%; } .h-100 { height: 100%; } .h-0 { height: 2px; }

/* Tela de entrada */
.entrada { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 20% 10%, var(--marca-clara), transparent 50%), var(--fundo); }
.entrada .cartao { width: 100%; max-width: 380px; padding: 28px; }
.entrada .logo { color: var(--texto); padding: 0 0 18px; }
.entrada form { display: grid; gap: 14px; }
.qr svg { max-width: 220px; height: auto; background: #fff; padding: 8px; border-radius: 6px; }

/* Impressão */
@media print {
  .lateral, .acoes, .nao-imprimir { display: none !important; }
  .app { display: block; }
  .principal { padding: 0; }
  .cartao { box-shadow: none; border: 0; padding: 0; }
  body { background: #fff; color: #000; }
}

/* Celular */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .lateral { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .lateral .logo { width: 100%; padding-bottom: 6px; }
  .lateral .rodape { margin: 0; border: 0; padding: 0; display: flex; }
  .principal { padding: 16px; }
  .grade-2, .grade-3, .grade-4, .form-grade { grid-template-columns: 1fr; }
  .filtros input[type=search] { width: 100%; }
}
.grade > .cartao + .cartao { margin-top: 0; }
.grade + .grade, .grade + .cartao, .cartao + .grade { margin-top: 16px; }
.grade { align-items: start; }
.lateral { min-height: 100vh; }
@media (max-width: 900px) {
  .lateral { min-height: 0; height: auto; align-items: center; align-content: flex-start; gap: 2px; }
  .lateral a { padding: 6px 10px; }
  .lateral a.ativo { box-shadow: inset 0 -2px 0 var(--marca); }
}

.secao-menu { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8a8378; padding: 14px 10px 4px; }
.lateral a { padding: 6px 10px; }
.contador { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 999px; background: var(--marca); color: #fff; font-size: 11px; text-align: center; }
@media (max-width: 900px) { .secao-menu { width: 100%; padding: 6px 10px 0; } }
/* Calendário */
.cal-grade { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--borda); border-left: 1px solid var(--borda); }
.cal-cab { padding: 6px 8px; font-size: 12px; text-transform: uppercase; color: var(--texto-2); background: var(--superficie-2); border-right: 1px solid var(--borda); border-bottom: 1px solid var(--borda); }
.cal-dia { min-height: 104px; padding: 4px 6px; border-right: 1px solid var(--borda); border-bottom: 1px solid var(--borda); display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cal-dia.fora { background: var(--superficie-2); color: var(--texto-2); }
.cal-dia.hoje .cal-num { background: var(--marca); color: #fff; border-radius: 999px; padding: 0 7px; }
.cal-num { font-size: 12px; font-weight: 600; align-self: flex-start; }
.cal-ev { display: block; font-size: 12px; padding: 1px 6px; border-radius: 4px; background: var(--marca-clara); color: var(--texto); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid var(--marca); }
.cal-ev:hover { text-decoration: none; filter: brightness(.97); }
.cal-ev.tipo-tarefa { border-left-color: var(--meio); background: var(--meio-fundo); }
.cal-ev.tipo-obra { border-left-color: var(--ok); background: var(--ok-fundo); }
.cal-ev.tipo-licitacao { border-left-color: var(--texto-2); background: var(--superficie-2); }
.texto-ruim { color: var(--ruim); font-weight: 600; }
tr.nao-lida td { font-weight: 600; }
button.link { background: none; border: 0; padding: 0; color: var(--marca); font: inherit; cursor: pointer; text-align: left; }
button.link:hover { text-decoration: underline; }
@media (max-width: 900px) { .cal-dia { min-height: 64px; } .cal-ev { font-size: 10px; } }
.texto-ok { color: var(--ok); }
.fluxo-12 { grid-template-columns: repeat(12, 1fr); }
