:root {
  --azul: #2c4a73;
  --azul-claro: #5b7ca8;
  --azul-escuro: #0f1b2e;
  --azul-meio: #1c3252;
  --verde: #16a34a;
  --laranja: #f59e0b;
  --vermelho: #dc2626;
  --roxo: #7c3aed;
  --cinza: #64748b;
  --fundo: #eef2f7;
  --cartao: #ffffff;
  --texto: #0f172a;
  --raio: 14px;
  --gradiente-marca: linear-gradient(135deg, #1c3252 0%, #2c4a73 50%, #5b7ca8 100%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--fundo);
  color: var(--texto);
  font-size: 19px;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  height: 100dvh;
  background: var(--fundo);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#conteudo {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

/* Tela de login */
.tela-login {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradiente-marca);
  padding: 24px;
}
.tela-login.escondida { display: none; }
.login-cartao {
  background: var(--cartao);
  border-radius: var(--raio);
  padding: 28px 24px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.login-cartao .login-logo {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  margin-bottom: 12px;
}
.login-cartao h1 { font-size: 22px; margin: 0 0 4px; }
.login-cartao p { color: var(--cinza); margin: 0 0 16px; font-size: 16px; }
.login-cartao input {
  width: 100%;
  font-size: 20px;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  text-align: center;
  letter-spacing: .12em;
  margin-bottom: 12px;
}
.login-cartao button {
  width: 100%;
  font-size: 18px;
  font-weight: 700;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: var(--azul);
  color: white;
  cursor: pointer;
}
.login-erro {
  color: var(--vermelho) !important;
  font-size: 15px !important;
  min-height: 20px;
  margin: 10px 0 0 !important;
}

/* Botão do usuário logado (sair) */
.usuario-logado {
  margin-left: auto;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  color: white;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
}

/* Cabeçalho */
.topo {
  background: var(--gradiente-marca);
  color: white;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 10px rgba(15,27,46,.35);
}
.topo .logo-topo {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.4), inset 0 0 0 1px rgba(255,255,255,.15);
  flex: none;
}
.topo h1 {
  font-size: 23px;
  margin: 0;
  font-weight: 700;
  letter-spacing: .01em;
}
.topo .voltar {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  color: white;
  font-size: 22px;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
}
.topo small { display:block; opacity:.75; font-size: 15px; }

/* Filtros */
.filtros {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  background: var(--cartao);
  border-bottom: 1px solid #e2e8f0;
}
.filtro-chip {
  flex: none;
  padding: 12px 18px;
  border-radius: 999px;
  border: 2px solid #e2e8f0;
  background: white;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.filtro-chip.ativo { border-color: var(--azul); background: var(--gradiente-marca); color: white; box-shadow: 0 2px 8px rgba(44,74,115,.35); }
.raio-cor { display:inline-flex; }
.raio-cor.livre { color: #16a34a; }
.raio-cor.microgeracao { color: #5b7ca8; }
.raio-cor.cativo { color: #000000; }
.filtro-chip.ativo .raio-cor { color: white; }

/* Mapa */
#conteudo:has(#mapa) { overflow: hidden; }
#mapa { flex: 1; min-height: 0; touch-action: none; overscroll-behavior: contain; }
.marcador-raio { background: none; border: none; }
.marcador-raio span {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35);
}

/* Lista */
.lista {
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.cartao {
  width: 75%;
  background: var(--cartao);
  border-radius: var(--raio);
  padding: 16px;
  box-shadow: 0 2px 8px rgba(15,27,46,.08);
  cursor: pointer;
  border-left: 6px solid var(--cinza);
  border: 1px solid #e2e8f0;
  border-left-width: 6px;
  transition: box-shadow .15s ease;
}
.cartao:active { box-shadow: 0 1px 3px rgba(15,27,46,.12); }
.cartao.livre { border-left-color: var(--verde); }
.cartao.microgeracao { border-left-color: var(--laranja); }
.cartao.cativo { border-left-color: var(--azul); }
.cartao .uc { font-size: 21px; font-weight: 800; }
.cartao .cliente { color: var(--cinza); font-size: 17px; margin-top: 3px; }
.cartao .linha2 { display:flex; justify-content: space-between; align-items:center; margin-top: 10px; }
.tag {
  font-size: 15px;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 8px;
  display: inline-block;
}
.tag.livre { background: #dcfce7; color: #166534; }
.tag.microgeracao { background: #fef3c7; color: #92400e; }
.tag.cativo { background: #dbeafe; color: #1e40af; }
.tag.executada { background: #dcfce7; color: #166534; }
.tag.pendente { background: #f1f5f9; color: var(--cinza); }
.tag.sharepoint_ok { background: #dcfce7; color: #166534; }
.tag.impedimento { background: #fee2e2; color: #991b1b; }
.tag.cancelada { background: #f1f5f9; color: var(--cinza); }

/* Navegação inferior */
.tabs {
  display: flex;
  background: var(--gradiente-marca);
  border-top: 1px solid rgba(255,255,255,.15);
  position: sticky;
  bottom: 0;
}
.tab {
  flex: 1;
  border: none;
  background: none;
  padding: 14px 0 12px;
  font-size: 16px;
  font-weight: 600;
  color: rgba(255,255,255,.65);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.tab.ativo { color: white; position: relative; }
.tab.ativo::before {
  content: '';
  position: absolute;
  top: -1px; left: 22%; right: 22%;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: white;
}
.tab .ic { font-size: 26px; }

/* Tela de detalhe */
.detalhe { padding: 16px; display:flex; flex-direction:column; gap:14px; }
.bloco {
  background: var(--cartao);
  border-radius: var(--raio);
  padding: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.bloco h3 { margin: 0 0 12px; font-size: 18px; color: var(--cinza); text-transform: uppercase; letter-spacing: .03em;}
.campo { display:flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #f1f5f9; font-size: 18px; }
.campo:last-child { border-bottom: none; }
.campo .rotulo { color: var(--cinza); }
.campo .valor { font-weight: 700; text-align: right; }

.botao {
  display:block;
  width: 100%;
  padding: 18px;
  border-radius: var(--raio);
  border: none;
  font-size: 20px;
  font-weight: 800;
  cursor: pointer;
  text-align: center;
}
.botao.principal { background: var(--gradiente-marca); color: white; box-shadow: 0 3px 10px rgba(44,74,115,.35); }
.botao.navegar { background: var(--verde); color: white; }
.botao.secundario { background: white; color: var(--azul); border: 2px solid var(--azul-claro); }
.botao.perigo { background: var(--vermelho); color: white; }
.botao:disabled { opacity: .5; }

/* Formulário de apontamento */
.pergunta { font-size: 19px; font-weight: 800; margin-bottom: 14px; }
.opcoes-sim-nao { display:flex; gap: 10px; }
.opcoes-sim-nao button {
  flex:1; padding: 18px; border-radius: var(--raio); border: 2px solid #e2e8f0;
  background: white; font-size: 19px; font-weight: 800; cursor:pointer; color: var(--texto);
}
.opcoes-sim-nao button.sim.selecionado { border-color: var(--verde); background:#dcfce7; color:#166534; }
.opcoes-sim-nao button.nao.selecionado { border-color: var(--vermelho); background:#fee2e2; color:#991b1b; }

.lista-itens { display:flex; flex-direction:column; gap:8px; margin-top: 10px;}
.item-linha { display:flex; gap:8px; align-items:center; }
.item-linha input {
  flex:1; padding: 14px; border-radius: 10px; border: 2px solid #e2e8f0; font-size: 18px;
}
.flag-preenchido {
  width: 0; opacity: 0; overflow: hidden;
  color: var(--verde); font-size: 22px; font-weight: 800;
  transition: width .15s ease, opacity .15s ease;
}
.flag-preenchido.mostrar { width: 26px; opacity: 1; }
.item-linha button.remover {
  width:44px; height:44px; border-radius: 10px; border: 2px solid #e2e8f0; background:#f8fafc; color: var(--cinza); font-size:18px; cursor:pointer;
}
.add-item {
  margin-top: 8px; padding: 14px; border-radius: 10px; border: 2px dashed #cbd5e1;
  background: none; color: var(--azul); font-weight:800; width:100%; font-size:17px; cursor:pointer;
}

select, textarea {
  width: 100%; padding: 16px; border-radius: 10px; border: 2px solid #e2e8f0; font-size: 18px;
  font-family: inherit; margin-top: 6px;
}
textarea { min-height: 90px; resize: vertical; }

.fotos-grade { display:flex; gap:10px; flex-wrap: wrap; margin-top: 10px; }
.foto-slot {
  width: 100px; height: 100px; border-radius: 12px; border: 2px dashed #cbd5e1;
  display:flex; align-items:center; justify-content:center; font-size: 28px; color: var(--cinza);
  cursor:pointer; background: #f8fafc; overflow:hidden; position:relative;
}
.foto-slot img { width:100%; height:100%; object-fit: cover; }
.foto-slot .remover-foto {
  position:absolute; top:4px; right:4px; background:rgba(220,38,38,.9); color:white; border:none;
  width:26px; height:26px; border-radius:50%; font-size:14px; cursor:pointer;
}

.banner-offline {
  background: var(--laranja); color: white; text-align:center; font-size: 16px; font-weight:800;
  padding: 8px; display: none;
}
.banner-offline.mostrar { display:block; }

.aviso-sucesso {
  background: #dcfce7; color: #166534; padding: 18px; border-radius: var(--raio);
  font-weight: 800; text-align:center; font-size: 18px;
}

.contador-pendentes {
  background: var(--vermelho); color:white; border-radius:999px; font-size:12px; font-weight:800;
  padding: 1px 7px; margin-left: 4px;
}

.vazio { text-align:center; color: var(--cinza); padding: 40px 20px; font-size:16px; }
