/* =============================================================
   Dashboard de gestão — RBCIP
   (complementa styles.css)
   ============================================================= */

.admin-wrap { max-width: 1180px; margin: 0 auto; padding: 24px 20px 64px; }

/* Barra superior do dashboard */
.admin-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.admin-top h1 { margin: 0; font-size: 1.4rem; }

/* Navegação entre dashboards */
.dash-nav { display: flex; flex-wrap: wrap; gap: 6px; }
.dash-nav a {
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px;
}
.dash-nav a:hover { background: var(--brand-light); color: var(--brand); }
.dash-nav a.ativo { background: var(--brand); color: #fff; }
.admin-user { display: flex; align-items: center; gap: 12px; font-size: 0.9rem; color: var(--muted); }

/* Abas por formulário — controle segmentado (pílulas) */
.tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 22px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 5px;
  box-shadow: var(--shadow-sm);
}
.tab {
  appearance: none;
  border: none;
  background: none;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
  padding: 9px 16px;
  cursor: pointer;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background .15s ease, color .15s ease;
}
.tab:hover { background: var(--brand-light); color: var(--brand); }
.tab.ativa {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .18);
}
.tab .cont {
  background: var(--brand-light);
  color: var(--brand);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 8px;
  min-width: 20px;
  text-align: center;
}
.tab.ativa .cont { background: rgba(255, 255, 255, .22); color: #fff; }

/* Cartões de resumo */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat .rotulo { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat .valor { font-size: 1.5rem; font-weight: 700; margin-top: 4px; }
.stat.tot-valor .valor { color: var(--brand); }

/* Barra de filtros */
.filtros {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
}
.filtros .campo { display: flex; flex-direction: column; gap: 4px; }
.filtros label { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.filtros input, .filtros select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font: inherit;
  font-size: 0.9rem;
  background: #fff;
}
.filtros .cresce { flex: 1; min-width: 160px; }
.filtros input:focus, .filtros select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31,95,139,.15);
}

/* Gráficos */
.graficos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.grafico {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
}
.grafico h3 { margin: 0 0 14px; font-size: 1rem; color: var(--brand-dark); }
.barra-row {
  display: grid;
  grid-template-columns: 118px 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
  font-size: 0.85rem;
}
.barra-lbl { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra-track { background: var(--bg); border-radius: 6px; height: 16px; overflow: hidden; }
.barra-fill { display: block; height: 100%; background: var(--brand); border-radius: 6px; min-width: 2px; }
.barra-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.vazio-min { color: var(--muted); font-size: 0.85rem; margin: 0; }

/* Tabela */
.tabela-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}
table.subs { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.subs th, table.subs td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.subs th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  background: #fafbfc;
  position: sticky; top: 0;
}
table.subs tbody tr:hover { background: #f7fafc; }
table.subs tr.clicavel { cursor: pointer; }
table.subs tr.clicavel:hover { background: var(--brand-light); }
.col-valor { text-align: right; font-variant-numeric: tabular-nums; }
.col-recibo { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--brand); }
.col-status { white-space: nowrap; }
.vazio { padding: 40px; text-align: center; color: var(--muted); }

/* Badges de status */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.badge.pendente    { background:#fff4e5; color:#8a5a00; border-color:#f2d9a8; }
.badge.em_analise  { background:#e8f1f8; color:#1f5f8b; border-color:#cfe1ef; }
.badge.aprovado    { background:#e7f6ec; color:#1d7a3f; border-color:#bfe6cc; }
.badge.rejeitado   { background:#fdecea; color:#c0392b; border-color:#f5c6c2; }
.badge.pago        { background:#ece9fb; color:#5b3fc0; border-color:#d6cdf3; }

/* Modal de detalhe */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(20,30,45,.5);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}
.modal-bg.aberto { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 920px;
  width: 100%;
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-head {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-fechar { background:none; border:none; font-size:1.4rem; cursor:pointer; color:var(--muted); line-height:1; }
.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1 1 auto; }
.det-linha { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.det-linha .k { flex: 0 0 200px; color: var(--muted); font-size: 0.85rem; }
.det-linha .v { flex: 1; font-size: 0.92rem; word-break: break-word; }
.modal-foot {
  flex-shrink: 0;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
  box-shadow: 0 -3px 10px rgba(20, 30, 45, .05);
}
.modal-foot .rotulo { font-size: 0.8rem; color: var(--muted); display:block; margin-bottom: 8px; }
.acoes-status { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-status {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 7px;
  padding: 7px 12px;
  font: inherit; font-size: 0.85rem; font-weight: 600;
  cursor: pointer;
  transition: all .12s ease;
}
.btn-status:hover { border-color: var(--brand); color: var(--brand); }
.btn-status.ativo { background: var(--brand); color:#fff; border-color: var(--brand); }

/* Histórico de alterações (auditoria) */
.hist-titulo {
  margin: 20px 0 10px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brand);
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.hist { list-style: none; margin: 0; padding: 0; }
.hist-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}
.hist-item:last-child { border-bottom: none; }
.hist-mov { display: inline-flex; align-items: center; gap: 7px; }
.hist-seta { color: var(--muted); font-weight: 700; }
.hist-meta { color: var(--muted); font-size: 0.82rem; }
.hist-meta b { color: var(--text); font-weight: 600; }

/* Login / negado */
.centro {
  max-width: 420px; margin: 60px auto; text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px 28px;
}

/* =============================================================
   Responsivo — telas pequenas (celular)
   ============================================================= */
@media (max-width: 720px) {
  .admin-wrap { padding: 16px 14px 48px; }

  /* Barra superior: navegação e usuário empilhados */
  .admin-top { gap: 10px; margin-bottom: 16px; }
  .dash-nav { width: 100%; }
  .dash-nav a { flex: 1; text-align: center; padding: 9px 10px; }
  .admin-user { width: 100%; justify-content: space-between; flex-wrap: wrap; }
  .link-formularios { padding: 6px 10px; font-size: 0.85rem; }

  /* Abas: grade 2x2 — as 4 cabem na tela, sem corte e sem rolagem lateral */
  .tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    width: 100%;
    border-radius: 10px;
  }
  .tab {
    justify-content: center;
    text-align: center;
    font-size: 0.8rem;
    padding: 10px 8px;
    gap: 6px;
    min-width: 0;
    line-height: 1.25;
  }
  .tab .cont { flex: none; font-size: 0.68rem; padding: 1px 6px; }

  /* Cartões de resumo: 2 colunas, valor sempre em uma linha */
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .stat { padding: 12px 14px; }
  .stat .rotulo { font-size: 0.68rem; letter-spacing: 0.3px; }
  .stat .valor { font-size: 1.15rem; white-space: nowrap; margin-top: 2px; }
  /* Cartão sozinho na última linha ocupa a largura toda */
  .stats .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }

  /* Filtros: cada campo em uma linha; botões lado a lado */
  .filtros { padding: 12px 13px; gap: 10px; margin-bottom: 14px; }
  .filtros .campo { flex: 1 1 100%; min-width: 0; }
  .filtros .campo.acao { flex: 1 1 calc(50% - 5px); }
  .filtros .campo.acao label { display: none; }
  .filtros .campo.acao .btn { width: 100%; padding: 10px 12px; }
  .filtros input, .filtros select { width: 100%; min-width: 0; max-width: 100%; }
  /* iOS: input[type=date] tem largura intrínseca própria e ignora width:100%,
     estourando o cartão. appearance:none devolve o controle do tamanho. */
  .filtros input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    box-sizing: border-box;
    height: 38px;
  }

  /* Tabela: Status fixo à esquerda enquanto o resto rola */
  table.subs { font-size: 0.84rem; }
  table.subs th, table.subs td { padding: 10px 11px; }
  table.subs th:first-child, table.subs td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--surface);
    box-shadow: 1px 0 0 var(--border);
  }
  table.subs thead th:first-child { background: #f7f9fb; }
  table.subs tr.clicavel:hover td:first-child { background: var(--brand-light); }

  /* Modal: rótulo acima do valor (não espreme o texto) */
  .modal-bg { padding: 12px 10px; }
  .modal { max-height: calc(100vh - 24px); }
  .modal-head { padding: 14px 16px; }
  .modal-head h2 { font-size: 1rem; }
  .modal-body { padding: 14px 16px; }
  .modal-foot { padding: 12px 16px; }
  .det-linha { flex-direction: column; gap: 2px; padding: 9px 0; }
  .det-linha .k { flex: none; font-size: 0.78rem; }
  .btn-status { flex: 1 1 calc(50% - 4px); padding: 9px 10px; }

  /* Gráficos (Acompanhamento): uma coluna, rótulo mais estreito */
  .graficos { grid-template-columns: 1fr; gap: 12px; }
  .grafico { padding: 14px 15px; }
  .barra-row { grid-template-columns: 84px 1fr auto; gap: 8px; font-size: 0.78rem; }
}

/* Atalho para a página de formulários, na barra do usuário */
.link-formularios {
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--brand);
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 12px;
  white-space: nowrap;
  transition: border-color .15s ease, background .15s ease;
}
.link-formularios:hover { border-color: var(--brand); background: var(--brand-light); }

/* Anexo clicável no detalhe da solicitação */
.link-anexo {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--brand);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 7px;
  padding: 5px 11px;
  cursor: pointer;
  text-align: left;
  word-break: break-word;
  transition: border-color .15s ease, background .15s ease;
}
.link-anexo:hover { border-color: var(--brand); background: var(--brand-light); }
.link-anexo:disabled { opacity: .6; cursor: default; }
.anexo-ausente { color: #b3261e; font-size: 0.88rem; }

/* Situação do envio do recibo por e-mail */
.email-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.email-tag.ok       { background:#e7f6ec; color:#1d7a3f; border-color:#bfe6cc; }
.email-tag.erro     { background:#fdecea; color:#b3261e; border-color:#f5c6c2; }
.email-tag.pendente { background:#f2f4f7; color:#5c6b78; border-color:#dde3e9; }
.col-email { white-space: nowrap; }

.email-painel {
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: var(--radius-sm);
  background: #fbfcfd;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.email-painel.ok   { border-left-color: #1d7a3f; }
.email-painel.erro { border-left-color: #b3261e; }
.email-linha { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.email-quando { color: var(--muted); font-size: 0.85rem; }
.btn-reenviar { margin-left: auto; padding: 6px 13px; font-size: 0.85rem; }
.email-motivo {
  margin: 10px 0 0;
  font-size: 0.83rem;
  color: #b3261e;
  word-break: break-word;
}
.email-aviso { margin: 10px 0 0; font-size: 0.85rem; }
.email-aviso.ok   { color: #1d7a3f; }
.email-aviso.erro { color: #b3261e; }
@media (max-width: 720px) {
  .btn-reenviar { margin-left: 0; width: 100%; }
}
