:root {
  --azul: #14213d;
  --azul-2: #22335c;
  --laranja: #fca311;
  --laranja-esc: #c77c00;
  --verde: #25d366;
  --verde-esc: #128c4a;
  --vermelho: #d62839;
  --fundo: #f3f4f7;
  --cartao: #ffffff;
  --texto: #1d2433;
  --suave: #667085;
  --borda: #e3e6ec;
  --raio: 12px;
  --sombra: 0 1px 2px rgba(16, 24, 40, .06), 0 2px 8px rgba(16, 24, 40, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fundo); color: var(--texto); font-size: 15px; line-height: 1.45;
}
[hidden] { display: none !important; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--borda); background: #fff; border-radius: 10px;
  padding: 9px 14px; cursor: pointer; font-weight: 600; white-space: nowrap;
}
.btn:hover { border-color: #c9ced8; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primario { background: var(--azul); border-color: var(--azul); color: #fff; }
.btn.primario:hover { background: var(--azul-2); }
.btn.whats { background: var(--verde); border-color: var(--verde); color: #fff; }
.btn.whats:hover { background: var(--verde-esc); border-color: var(--verde-esc); }
.btn.perigo { color: var(--vermelho); }
.btn.fantasma { background: transparent; border-color: transparent; color: inherit; }
.btn.pequeno { padding: 6px 10px; font-size: 13px; }
.btn.largo { width: 100%; }
.btn svg { width: 18px; height: 18px; flex: none; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(160deg, var(--azul) 0%, #0b1325 100%); }
.login-card { width: 100%; max-width: 360px; background: #fff; border-radius: 16px; padding: 28px;
  display: grid; gap: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.marca { display: flex; align-items: center; gap: 10px; }
.marca svg { width: 32px; height: 32px; }
.marca.grande { margin-bottom: 6px; }
.marca.grande svg { width: 48px; height: 48px; }
.marca.grande strong { display: block; font-size: 20px; }
.marca.grande span { color: var(--suave); font-size: 13px; }

label { display: grid; gap: 5px; font-weight: 600; font-size: 13px; color: #344054; }
input, select, textarea {
  width: 100%; border: 1px solid #d0d5dd; border-radius: 10px; padding: 10px 12px; background: #fff; font-weight: 400;
}
textarea { resize: vertical; min-height: 180px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(252,163,17,.5); border-color: var(--laranja); }
.erro-form { color: var(--vermelho); margin: 0; min-height: 1em; font-size: 14px; }

/* ---------- Topo ---------- */
.topo { position: sticky; top: 0; z-index: 10; background: var(--azul); color: #fff;
  display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 60px; }
.menu { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.menu a { text-decoration: none; padding: 8px 12px; border-radius: 8px; color: #c9d1e3; font-weight: 600; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; }
.menu a:hover { color: #fff; background: rgba(255,255,255,.08); }
.menu a.ativo { color: var(--azul); background: var(--laranja); }
.ponto { width: 8px; height: 8px; border-radius: 50%; background: #98a2b3; display: inline-block; }
.ponto.on { background: var(--verde); box-shadow: 0 0 0 3px rgba(37,211,102,.25); }
.ponto.off { background: var(--vermelho); }
.usuario-menu { position: relative; }
.usuario-menu .btn { color: #fff; }
.dropdown { position: absolute; right: 0; top: 44px; background: #fff; color: var(--texto); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2); overflow: hidden; min-width: 160px; }
.dropdown button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 11px 14px; cursor: pointer; }
.dropdown button:hover { background: var(--fundo); }
.faixa-demo { background: #fff4d6; color: #7a4d00; text-align: center; padding: 6px; font-size: 13px; font-weight: 600; }

/* ---------- Conteúdo ---------- */
.conteudo { max-width: 1200px; margin: 0 auto; padding: 22px 20px 60px; }
.cabecalho { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.cabecalho h1 { font-size: 22px; margin: 0; flex: 1; }
.barra { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: end; }
.barra > * { flex: 1 1 160px; }
.barra .btn { flex: 0 0 auto; }
.aviso { border-radius: var(--raio); padding: 12px 16px; margin-bottom: 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.aviso.alerta { background: #fff4d6; color: #7a4d00; border: 1px solid #ffe2a0; }
.aviso.erro { background: #fde8ea; color: #8a1c28; border: 1px solid #f7c1c7; }
.aviso .btn { margin-left: auto; }
.vazio { text-align: center; color: var(--suave); padding: 50px 16px; background: #fff; border-radius: var(--raio); border: 1px dashed var(--borda); }

/* ---------- Cartões de obra ---------- */
.grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.obra { background: var(--cartao); border-radius: var(--raio); box-shadow: var(--sombra); border: 1px solid var(--borda);
  padding: 16px; display: flex; flex-direction: column; gap: 10px; position: relative; }
.obra.inativa { opacity: .6; }
.obra.selecionada { outline: 3px solid var(--laranja); }
.obra h3 { margin: 0; font-size: 17px; padding-right: 30px; }
.obra .meta { color: var(--suave); font-size: 13px; display: grid; gap: 3px; }
.obra .meta span { display: flex; gap: 6px; align-items: flex-start; }
.id-obra { background: var(--fundo); padding: 1px 6px; border-radius: 5px; cursor: pointer; font-weight: 700; }
.id-obra:hover { background: var(--borda); }
.obra .grupo { font-size: 13px; background: #eefbf3; color: var(--verde-esc); border-radius: 8px; padding: 6px 10px; display: flex; gap: 6px; align-items: center; }
.obra .grupo.sem { background: #fde8ea; color: #8a1c28; }
.obra .rodape { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 6px; }
.obra .rodape .info { font-size: 12px; color: var(--suave); flex: 1; }
.obra .check { position: absolute; top: 14px; right: 14px; width: 22px; height: 22px; accent-color: var(--laranja); }
.btn-wa { width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--verde); color: #fff; cursor: pointer;
  display: grid; place-items: center; box-shadow: 0 4px 12px rgba(37,211,102,.4); flex: none; transition: transform .1s; }
.btn-wa:hover { background: var(--verde-esc); transform: scale(1.05); }
.btn-wa:disabled { background: #b8c0cc; box-shadow: none; cursor: not-allowed; transform: none; }
.btn-wa svg { width: 28px; height: 28px; }
.barra-selecao { position: sticky; bottom: 16px; margin-top: 16px; background: var(--azul); color: #fff; border-radius: var(--raio);
  padding: 12px 16px; display: flex; align-items: center; gap: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.barra-selecao span { flex: 1; font-weight: 600; }

/* ---------- Listas / tabelas ---------- */
.lista { background: #fff; border-radius: var(--raio); border: 1px solid var(--borda); overflow: hidden; }
.item { padding: 14px 16px; border-bottom: 1px solid var(--borda); display: flex; gap: 12px; align-items: flex-start; }
.item:last-child { border-bottom: 0; }
.item .corpo { flex: 1; min-width: 0; }
.item .titulo { font-weight: 700; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.item .sub { color: var(--suave); font-size: 13px; }
.item .texto { white-space: pre-wrap; font-size: 14px; margin-top: 6px; background: var(--fundo); border-radius: 8px; padding: 8px 10px;
  max-height: 4.6em; overflow: hidden; cursor: pointer; }
.item .texto.aberto { max-height: none; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: #eef1f6; color: #475467; text-transform: uppercase; letter-spacing: .02em; }
.tag.ok { background: #e3f8ec; color: var(--verde-esc); }
.tag.erro { background: #fde8ea; color: var(--vermelho); }
.tag.admin { background: #fff4d6; color: #7a4d00; }
.paginacao { display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 14px; }

/* ---------- WhatsApp ---------- */
.painel-wa { background: #fff; border-radius: var(--raio); border: 1px solid var(--borda); padding: 24px; display: grid; gap: 16px; max-width: 640px; }
.estado-wa { display: flex; align-items: center; gap: 12px; font-size: 18px; font-weight: 700; }
.estado-wa .ponto { width: 14px; height: 14px; }
.qr { display: grid; place-items: center; gap: 10px; padding: 16px; background: var(--fundo); border-radius: var(--raio); text-align: center; }
.qr img { width: 260px; height: 260px; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: 8px; }
.passos { margin: 0; padding-left: 20px; color: #344054; }
.passos li { margin: 4px 0; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(10,16,30,.55); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal-caixa { background: #fff; width: 100%; max-width: 640px; max-height: calc(100vh - 32px); overflow: auto; border-radius: 16px; }
.modal-caixa.largo { max-width: 920px; }
.modal-caixa > header { position: sticky; top: 0; background: #fff; display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--borda); z-index: 1; }
.modal-caixa h2 { margin: 0; font-size: 18px; flex: 1; }
.fechar { border: 0; background: none; font-size: 28px; line-height: 1; cursor: pointer; color: var(--suave); }
#modal-corpo { padding: 20px; }
.form { display: grid; gap: 14px; }
.form .linha { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.acoes { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding-top: 6px; }
.acoes .esq { margin-right: auto; }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.checkbox input { width: auto; }
.dica { font-size: 12px; color: var(--suave); font-weight: 400; }
.dica code { background: var(--fundo); padding: 1px 5px; border-radius: 4px; cursor: pointer; }

/* Envio */
.envio { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.destinos { display: flex; flex-wrap: wrap; gap: 6px; }
.destinos .tag { text-transform: none; font-size: 12px; background: #e3f8ec; color: var(--verde-esc); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--borda); background: #fff; border-radius: 99px; padding: 5px 11px; font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--laranja); }
.chip.ativo { background: var(--laranja); border-color: var(--laranja); color: var(--azul); font-weight: 700; }
.previa { background: #efeae2; border-radius: var(--raio); padding: 14px; min-height: 200px;
  background-image: radial-gradient(rgba(0,0,0,.035) 1px, transparent 1px); background-size: 14px 14px; }
.balao { background: #d9fdd3; border-radius: 10px 0 10px 10px; padding: 8px 10px 18px; margin-left: auto; max-width: 95%;
  white-space: pre-wrap; word-wrap: break-word; font-size: 14px; box-shadow: 0 1px .5px rgba(0,0,0,.13); position: relative; }
.balao .hora { position: absolute; right: 8px; bottom: 3px; font-size: 11px; color: #667781; }
.balao img { display: block; max-width: 100%; border-radius: 6px; margin-bottom: 6px; }
.balao .arq { background: rgba(0,0,0,.05); border-radius: 6px; padding: 8px; margin-bottom: 6px; font-size: 13px; }
.resultado { display: grid; gap: 8px; }
.resultado .item { border: 1px solid var(--borda); border-radius: 10px; }

/* Toast */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--azul); color: #fff; padding: 12px 18px;
  border-radius: 10px; z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,.3); max-width: calc(100% - 32px); }
.toast.erro { background: var(--vermelho); }

@media (max-width: 760px) {
  .topo { padding: 0 12px; gap: 10px; }
  .topo .marca strong { display: none; }
  .conteudo { padding: 16px 16px 60px; }
  .envio, .form .linha { grid-template-columns: 1fr; }
  #btn-usuario span { display: none; }
}
