:root {
  --lateral: #111827; --lateral-ativo: #1f2937; --roxo: #5b4fe9; --roxo-claro: #eeecfd; --fundo: #f3f4f8; --cartao: #fff;
  --texto: #111827; --suave: #6b7280; --linha: #e7e9f0; --ok: #16a34a; --exec: #3b5bdb; --exced: #b45309; --prev: #c7eadf;
  --alerta-fundo: #fff4d6; --alerta: #a16207; --erro: #b91c1c; --raio: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--fundo); color: var(--texto); font-size: 15px; line-height: 1.45; display: flex; min-height: 100vh; }
a { color: var(--roxo); }
small { font-size: 12px; }

/* ---------- menu lateral ---------- */
.lateral { width: 230px; background: var(--lateral); color: #e5e7eb; display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.lateral[hidden] { display: none; }
.marca { display: flex; gap: 10px; align-items: center; padding: 0 6px 18px; }
.marca small { display: block; color: #9ca3af; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #6d5efc, #38bdf8); display: grid; place-items: center; font-weight: 800; color: #fff; }
.lateral nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.lateral nav small { color: #6b7280; font-weight: 700; letter-spacing: .06em; padding: 14px 8px 6px; font-size: 11px; }
.lateral nav a { color: #d1d5db; text-decoration: none; padding: 9px 10px; border-radius: 9px; font-weight: 500; }
.lateral nav a:hover { background: var(--lateral-ativo); }
.lateral nav a.ativo { background: var(--lateral-ativo); color: #fff; box-shadow: inset 3px 0 0 var(--roxo); }
.usuario { display: flex; gap: 10px; align-items: center; border-top: 1px solid #1f2937; padding: 14px 6px 8px; }
.usuario small { display: block; color: #9ca3af; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--roxo); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; }
.sair { background: none; border: 0; color: #9ca3af; text-align: left; padding: 4px 8px; cursor: pointer; font: inherit; text-decoration: underline; }

/* ---------- conteúdo ---------- */
main { flex: 1; padding: 22px 26px 40px; min-width: 0; max-width: 1280px; }
.cabeca { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
h1 { font-size: 26px; margin: 0; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 0 0 10px; font-weight: 700; }
.sub { color: var(--suave); font-size: 14px; margin-top: 2px; }
.trilha { font-size: 13px; color: var(--suave); margin-bottom: 4px; }
.trilha a { color: var(--suave); text-decoration: none; }
.aviso { color: var(--suave); }
.erro { color: var(--erro); }
.botao { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--linha); background: #fff; color: var(--texto); font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; }
.botao.principal { background: var(--roxo); border-color: var(--roxo); color: #fff; }
.cartao { background: var(--cartao); border-radius: var(--raio); padding: 16px 18px; border: 1px solid var(--linha); margin-bottom: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--linha); border-radius: var(--raio); padding: 14px 16px; }
.kpi:first-child { box-shadow: inset 0 3px 0 var(--roxo); }
.kpi small { color: var(--suave); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-size: 11px; }
.kpi b { display: block; font-size: 26px; font-weight: 800; margin: 2px 0; }
.kpi span { color: var(--suave); font-size: 13px; }
.filtros { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.pilula { padding: 7px 14px; border-radius: 20px; border: 1px solid var(--linha); background: #fff; font-weight: 600; font-size: 13px; cursor: pointer; color: var(--texto); text-decoration: none; }
.pilula.ativa { background: var(--texto); color: #fff; border-color: var(--texto); }
.filtros input, .filtros select { padding: 8px 10px; border: 1px solid var(--linha); border-radius: 10px; font: inherit; font-size: 14px; background: #fff; }

/* ---------- cartões de obra ---------- */
.obras { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.obra { background: #fff; border: 1px solid var(--linha); border-radius: var(--raio); padding: 14px 16px; text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 6px; transition: box-shadow .15s; }
.obra:hover { box-shadow: 0 6px 18px rgba(17,24,39,.08); }
.obra .topo { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.obra .corpo { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.obra h3 { margin: 0; font-size: 17px; font-weight: 800; }
.obra .rodape { border-top: 1px solid var(--linha); padding-top: 8px; margin-top: 4px; display: flex; gap: 12px; font-size: 13px; color: var(--suave); }
.obra .rodape b { color: var(--texto); }
.obra .rodape .ult { margin-left: auto; }
.etiqueta { display: inline-block; font-size: 12px; padding: 3px 9px; border-radius: 20px; background: #f1f2f6; color: #4b5563; font-weight: 600; white-space: nowrap; }
.etiqueta.amarela { background: var(--alerta-fundo); color: var(--alerta); }
.etiqueta.verde { background: #dcfce7; color: var(--ok); }
.etiqueta.roxa { background: var(--roxo-claro); color: var(--roxo); }
.etiqueta.vermelha { background: #fee2e2; color: var(--erro); }
.anel { flex-shrink: 0; }

/* ---------- abas ---------- */
.abas { display: flex; gap: 4px; border-bottom: 1px solid var(--linha); margin: 6px 0 16px; overflow-x: auto; }
.abas a { padding: 10px 12px; text-decoration: none; color: var(--suave); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.abas a.ativa { color: var(--texto); border-color: var(--roxo); }

/* ---------- tabelas ---------- */
.tabela { width: 100%; border-collapse: collapse; background: #fff; font-size: 14px; }
.caixa-tabela { background: #fff; border: 1px solid var(--linha); border-radius: var(--raio); overflow: auto; margin-bottom: 14px; }
.tabela th { text-align: left; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--suave); background: #f8f9fc; padding: 10px 12px; border-bottom: 1px solid var(--linha); white-space: nowrap; }
.tabela td { padding: 11px 12px; border-bottom: 1px solid var(--linha); vertical-align: top; }
.tabela tr.clica { cursor: pointer; }
.tabela tr.clica:hover td { background: #fafbff; }
.tabela td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tabela .dia { font-weight: 700; white-space: nowrap; }
.tabela .dia small { display: block; color: var(--suave); font-weight: 400; }

/* ---------- Gantt ---------- */
.gantt { display: grid; grid-template-columns: 230px 1fr; font-size: 13px; overflow-x: auto; }
.gantt .cab, .gantt .lin { display: contents; }
.gantt .nome { padding: 9px 10px 9px 6px; border-bottom: 1px solid var(--linha); }
.gantt .nome small { display: block; color: var(--suave); }
.gantt .nome i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.gantt .trilho { position: relative; border-bottom: 1px solid var(--linha); min-width: 560px; background-image: linear-gradient(90deg, var(--linha) 1px, transparent 1px); background-size: var(--semana) 100%; }
.gantt .semanas { position: relative; height: 30px; border-bottom: 1px solid var(--linha); min-width: 560px; }
.gantt .semanas span { position: absolute; top: 8px; font-size: 11px; color: var(--suave); padding-left: 4px; }
.gantt .barra { position: absolute; top: 50%; height: 11px; transform: translateY(-50%); border-radius: 6px; }
.gantt .barra.prev { background: var(--prev); height: 17px; opacity: .9; }
.gantt .hoje { position: absolute; top: 0; bottom: 0; border-left: 2px dashed #dc2626; z-index: 2; }
.cor-concluido { background: var(--ok); } .cor-execucao { background: var(--exec); } .cor-excedente { background: var(--exced); } .cor-previsto { background: var(--prev); }
.legenda { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--suave); align-items: center; }
.legenda i { display: inline-block; width: 12px; height: 8px; border-radius: 3px; margin-right: 4px; }

/* ---------- atividade recente ---------- */
.recentes { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.recente { min-width: 220px; max-width: 220px; border: 1px solid var(--linha); border-radius: 12px; padding: 10px; display: flex; gap: 10px; text-decoration: none; color: inherit; background: #fff; }
.recente .data { background: var(--roxo-claro); color: var(--roxo); border-radius: 10px; min-width: 44px; text-align: center; padding: 6px 4px; font-weight: 800; line-height: 1.1; }
.recente .data small { display: block; font-weight: 600; text-transform: uppercase; }
.recente.interf .data { background: var(--alerta-fundo); color: var(--alerta); }
.recente p { margin: 0; font-size: 13px; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- diário de obra ---------- */
.diario { max-width: 900px; background: #fff; border: 1px solid var(--linha); border-radius: var(--raio); }
.diario section { padding: 14px 18px; border-bottom: 1px solid var(--linha); }
.diario section:last-child { border-bottom: 0; }
.diario h4 { margin: 0 0 8px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--suave); }
.grade { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 18px; }
.grade small { display: block; color: var(--suave); font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: .04em; }
.relato { white-space: pre-wrap; background: #f6f7fa; border-radius: 10px; padding: 10px 12px; font-size: 14px; color: #374151; }
.fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.fotos figure { margin: 0; }
.fotos img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; cursor: zoom-in; background: #e5e7eb; display: block; }
.fotos figcaption { font-size: 12px; color: var(--suave); margin-top: 4px; }

/* ---------- etapas CAIXA ---------- */
.caixa-topo { display: grid; grid-template-columns: 180px 1fr; gap: 18px; align-items: center; }
.linha-info { display: flex; align-items: center; gap: 10px; background: #f6f7fa; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.linha-info b { margin-left: auto; font-size: 18px; }
.linha-info i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- login ---------- */
form.entrar { max-width: 400px; margin: 60px auto; }
form.entrar input { width: 100%; padding: 12px; font-size: 16px; border: 1px solid var(--linha); border-radius: 10px; margin: 10px 0; font-family: inherit; }
form.entrar .botao { width: 100%; justify-content: center; padding: 12px; font-size: 16px; }

/* ---------- foto grande ---------- */
#foto-grande { position: fixed; inset: 0; background: rgba(0,0,0,.88); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 50; padding: 14px; cursor: zoom-out; }
#foto-grande[hidden] { display: none; }
#foto-grande img { max-width: 100%; max-height: 86vh; border-radius: 8px; }
#foto-grande p { color: #fff; text-align: center; max-width: 760px; }

/* ---------- celular ---------- */
@media (max-width: 820px) {
  body { flex-direction: column; }
  .lateral { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; gap: 6px; }
  .lateral nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; order: 3; }
  .lateral nav small, .usuario { display: none; }
  .marca { padding: 0; flex: 1; }
  main { padding: 14px; }
  .gantt { grid-template-columns: 150px 1fr; }
  .caixa-topo { grid-template-columns: 1fr; }
  .esconde-celular { display: none; }
}

/* ---------- impressão / PDF ---------- */
@media print {
  body { background: #fff; display: block; }
  .lateral, .nao-imprime, .abas { display: none !important; }
  main { padding: 0; max-width: none; }
  .diario { border: 0; max-width: none; }
  .fotos { grid-template-columns: repeat(3, 1fr); }
  .fotos img { break-inside: avoid; }
}
