/* Komprão · Comunicação Visual */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --texto: #1e293b;
  --muted: #64748b;
  --borda: #e2e8f0;
  --primary: #0f766e;
  --primary-hover: #115e59;
  --primary-soft: #ccfbf1;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --pend: #475569;
  --pend-soft: #e2e8f0;
  --raio: 12px;
  --sombra: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--texto);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 600; }
h3 { font-size: 0.95rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--primary-soft);
  outline-offset: 1px;
}

.muted { color: var(--muted); }
.pequeno { font-size: 0.82rem; }
.grande { font-size: 2rem; font-weight: 700; color: var(--primary); }
.sub { margin: 1.5rem 0 0.75rem; font-size: 1rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.link-forte { font-weight: 600; }
.vazio { padding: 2.5rem 1rem; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--borda); border-radius: var(--raio); }
.loading { padding: 3rem; text-align: center; color: var(--muted); }

.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

/* ---------- topo ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1.25rem;
  padding: 0.7rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--borda);
  flex-wrap: wrap;
}
.nav { display: flex; gap: 0.25rem; flex-wrap: wrap; flex: 1; }
.nav a {
  padding: 0.45rem 0.8rem; border-radius: 8px;
  color: var(--muted); font-weight: 500;
}
.nav a:hover { background: var(--bg); color: var(--texto); text-decoration: none; }
.nav a.ativo { color: var(--primary); background: var(--primary-soft); }

.usuario { display: flex; align-items: center; gap: 0.6rem; margin-left: auto; }
.usuario-nome { font-weight: 600; font-size: 0.9rem; }

.brand { display: inline-flex; align-items: center; color: var(--texto); }
.brand:hover { text-decoration: none; }
.brand img { display: block; height: 44px; width: auto; }
.brand-lg img { height: 72px; }

/* ---------- cabeçalho de página ---------- */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}
.page-head p { margin-top: 0.25rem; }
.acoes { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.breadcrumb { margin-bottom: 0.5rem; font-size: 0.88rem; color: var(--muted); }
.breadcrumb a { color: var(--muted); }

.ao-vivo {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.3rem 0.7rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--borda);
  font-size: 0.82rem; color: var(--muted);
}
.ao-vivo i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 0 0 rgba(21, 128, 61, 0.6);
  animation: pulso 2s infinite;
}
@keyframes pulso {
  0% { box-shadow: 0 0 0 0 rgba(21, 128, 61, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(21, 128, 61, 0); }
  100% { box-shadow: 0 0 0 0 rgba(21, 128, 61, 0); }
}

/* ---------- cartões e KPIs ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  padding: 1.1rem 1.2rem;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; margin-bottom: 0.6rem; }
.card-titulo { font-weight: 700; font-size: 1.02rem; color: var(--texto); }
.card-titulo:hover { color: var(--primary); }
.pct { font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }

.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.9rem; margin-bottom: 1rem;
}
.kpi {
  background: var(--surface); border: 1px solid var(--borda); border-radius: var(--raio);
  box-shadow: var(--sombra); padding: 1rem 1.1rem;
  display: flex; flex-direction: column; gap: 0.2rem;
}
.kpi-rotulo { font-size: 0.82rem; color: var(--muted); font-weight: 500; }
.kpi-valor { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.legenda { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.25rem; }

.campanhas-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem;
}
.campanha-card { display: flex; flex-direction: column; gap: 0.75rem; }
.datas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin: 0; }
.datas div { background: var(--bg); border-radius: 8px; padding: 0.45rem 0.6rem; }
.datas dt { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.datas dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.campanha-card .sub { margin: 0.25rem 0 0; font-size: 0.82rem; }

.lojas-status {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.5rem;
}
.loja-chip {
  display: flex; flex-direction: column; gap: 0.05rem;
  padding: 0.55rem 0.65rem; border-radius: 8px;
  border: 1px solid var(--borda); border-left: 4px solid var(--pend);
  background: var(--surface); font-size: 0.85rem;
}
.loja-chip strong { font-size: 0.9rem; }
.loja-chip span { font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loja-chip em { font-style: normal; font-weight: 700; font-size: 0.75rem; }
.loja-chip small { color: var(--muted); font-size: 0.75rem; }
.loja-chip.st-concluida { border-left-color: var(--ok); background: #f7fdf9; }
.loja-chip.st-concluida em { color: var(--ok); }
.loja-chip.st-em_andamento { border-left-color: var(--warn); background: #fffdf5; }
.loja-chip.st-em_andamento em { color: var(--warn); }
.loja-chip.st-pendente em { color: var(--pend); }

/* ---------- fotos de comprovação ---------- */
.loja-chip { position: relative; padding-right: 2.2rem; }
.btn-galeria {
  position: absolute; top: 0.4rem; right: 0.4rem;
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.2rem 0.4rem; border: 1px solid var(--borda); border-radius: 6px;
  background: var(--surface); color: var(--muted); font: inherit; cursor: pointer;
}
.btn-galeria:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
.btn-galeria.tem-fotos { color: var(--primary); }
.btn-galeria-n { font-size: 0.72rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.loja-acoes .btn-galeria { position: static; padding: 0.35rem 0.55rem; }

.modal-galeria { width: min(860px, 100%); }
.galeria-corpo { display: grid; gap: 0.9rem; }
.galeria-visor {
  min-height: 240px; display: grid; place-items: center;
  background: #0f172a; border-radius: var(--raio); overflow: hidden;
}
.galeria-visor .vazio { background: transparent; color: #cbd5e1; border-color: #334155; }
.galeria-figura { margin: 0; padding: 0.6rem; display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.galeria-figura img { max-width: 100%; max-height: 60vh; object-fit: contain; border-radius: 8px; }
.galeria-figura figcaption { color: #cbd5e1; font-size: 0.8rem; text-align: center; }
.galeria-nav { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; flex-wrap: wrap; width: 100%; padding: 0 0.6rem 0.6rem; }
.galeria-thumbs { display: flex; gap: 0.4rem; overflow-x: auto; padding-bottom: 0.2rem; }
.galeria-thumbs:empty { display: none; }
.galeria-thumb {
  flex: 0 0 72px; height: 56px; padding: 0; overflow: hidden;
  border: 2px solid transparent; border-radius: 8px; background: #e2e8f0; cursor: pointer;
}
.galeria-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.galeria-thumb.ativa { border-color: var(--primary); }
.galeria-envio { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.galeria-envio .btn { cursor: pointer; }

/* ---------- barra de progresso ---------- */
.barra {
  height: 10px; border-radius: 999px; background: #e2e8f0; overflow: hidden; width: 100%;
}
.barra span {
  display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, #14b8a6, var(--primary));
  transition: width 0.5s ease;
}
.col-progresso { min-width: 180px; }
.col-progresso .barra { margin-bottom: 0.2rem; }
.pct-texto { font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- status ---------- */
.status-pill {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.2rem 0.6rem; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600; white-space: nowrap;
  background: var(--pend-soft); color: var(--pend);
}
.status-pill.st-concluido, .status-pill.st-concluida { background: var(--ok-soft); color: var(--ok); }
.status-pill.st-em_andamento { background: var(--warn-soft); color: var(--warn); }
.status-pill.st-pendente { background: var(--pend-soft); color: var(--pend); }

.badge { padding: 0.15rem 0.55rem; border-radius: 6px; font-size: 0.75rem; font-weight: 600; }
.badge-admin { background: var(--primary-soft); color: var(--primary-hover); }
.badge-consulta { background: #e0e7ff; color: #3730a3; }

/* ---------- tabela ---------- */
.table-wrap {
  background: var(--surface); border: 1px solid var(--borda);
  border-radius: var(--raio); box-shadow: var(--sombra); overflow-x: auto;
}
.tabela { width: 100%; border-collapse: collapse; }
.tabela th, .tabela td { padding: 0.7rem 0.9rem; text-align: left; border-bottom: 1px solid var(--borda); vertical-align: middle; }
.tabela th {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); background: #f8fafc; font-weight: 600;
}
.tabela tbody tr:hover { background: #f8fafc; }
.tabela tbody tr:last-child td { border-bottom: 0; }
.col-acoes { text-align: right; white-space: nowrap; }

/* ---------- lojas detalhe / itens ---------- */
.resumo-campanha { margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.resumo-topo { display: flex; align-items: baseline; gap: 0.7rem; flex-wrap: wrap; }
.lojas-detalhe { display: grid; gap: 1rem; }
.loja-bloco { padding: 0; overflow: hidden; }
.loja-head {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 0.9rem 1.2rem; background: #f8fafc; border-bottom: 1px solid var(--borda);
}
.loja-titulo { font-size: 1.05rem; }
.loja-head p { font-size: 0.85rem; }
.loja-acoes { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.itens { list-style: none; margin: 0; padding: 0; }
.item {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1.2rem; border-bottom: 1px solid var(--borda);
}
.item:last-child { border-bottom: 0; }
.item-nome { font-weight: 500; }
.item-quem { justify-self: end; font-size: 0.78rem; }
.select-status { justify-self: center; min-width: 170px; }

/* ---------- busca ---------- */
.resultados { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.resultado { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.resultado p { font-size: 0.86rem; margin-top: 0.2rem; }
.resultado-progresso { min-width: 180px; display: grid; gap: 0.3rem; justify-items: end; }
.resultado-progresso .barra { width: 180px; }
.tags { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 0.4rem !important; }
.tag { background: var(--primary-soft); color: var(--primary-hover); padding: 0.1rem 0.5rem; border-radius: 6px; font-size: 0.78rem; font-weight: 600; }

/* ---------- formulários ---------- */
.toolbar { margin-bottom: 1rem; }
.input, .select, textarea.input {
  width: 100%; padding: 0.55rem 0.75rem;
  font: inherit; color: var(--texto);
  background: var(--surface); border: 1px solid #cbd5e1; border-radius: 8px;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--primary); }
.input-lg { font-size: 1.05rem; padding: 0.8rem 1rem; }
textarea.input { resize: vertical; }
.select { width: auto; }
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.9rem; border: 0; padding: 0; min-width: 0; }
.field > span, .field legend { font-size: 0.85rem; font-weight: 600; color: #334155; padding: 0; margin-bottom: 0.35rem; }
fieldset.field legend { float: left; width: 100%; }
fieldset.field { margin-top: 0.4rem; }
.check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.checks {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.4rem 0.8rem; max-height: 220px; overflow-y: auto;
  padding: 0.7rem; border: 1px solid var(--borda); border-radius: 8px; background: #fbfcfd;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }
.campo-largo { grid-column: 1 / -1; }
.form-erro { color: var(--danger); font-size: 0.88rem; min-height: 1.2em; margin: 0.3rem 0 0.6rem; }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.55rem 1rem; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-ghost { background: var(--surface); color: var(--texto); border-color: #cbd5e1; }
.btn-ghost:hover:not(:disabled) { background: #f1f5f9; }
.btn-danger-ghost { background: var(--surface); color: var(--danger); border-color: #fca5a5; }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-soft); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.82rem; }
.btn-block { width: 100%; }
.btn-icon {
  background: none; border: 0; font-size: 1.5rem; line-height: 1; color: var(--muted);
  cursor: pointer; padding: 0.2rem 0.4rem; border-radius: 6px;
}
.btn-icon:hover { background: #f1f5f9; color: var(--texto); }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  animation: fade 0.15s ease-out;
}
.modal {
  width: min(680px, 100%); max-height: calc(100vh - 2rem); overflow-y: auto;
  background: var(--surface); border-radius: 14px; box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--borda);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modal-body { padding: 1.25rem; }
.modal-foot { display: flex; justify-content: flex-end; gap: 0.6rem; padding-top: 0.5rem; }

/* ---------- login / setup ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card { width: min(400px, 100%); padding: 2rem; display: flex; flex-direction: column; gap: 0.2rem; }
.auth-card .brand { margin-bottom: 1.25rem; }
.auth-card h1 { margin-bottom: 0.4rem; }
.auth-card p.muted { margin-bottom: 0.9rem; font-size: 0.9rem; }
.auth-card .btn-block { margin-top: 0.4rem; }

/* ---------- avisos ---------- */
.erro { color: var(--danger); background: var(--danger-soft); border-color: #fecaca; }
.toast {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 60;
  padding: 0.75rem 1.1rem; border-radius: 10px; color: #fff; font-weight: 500;
  background: var(--texto); box-shadow: 0 10px 25px rgba(15, 23, 42, 0.25);
  animation: subir 0.2s ease-out;
}
.toast-erro { background: var(--danger); }
@keyframes subir { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- responsivo ---------- */
@media (max-width: 760px) {
  h1 { font-size: 1.3rem; }
  .topbar { padding: 0.6rem 0.9rem; gap: 0.6rem; }
  .nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .usuario { margin-left: auto; }
  .usuario-nome { display: none; }
  .campanhas-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .item { grid-template-columns: 1fr; gap: 0.4rem; }
  .item-quem, .select-status { justify-self: start; }
  .select-status { width: 100%; }
  .datas { grid-template-columns: 1fr; }
  .tabela th, .tabela td { padding: 0.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
