*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #f0f4f8;
  color: #1a2a3a;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: #1a4f8a;
  color: #fff;
  padding: 20px 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  display: flex;
  align-items: center;
  gap: 20px;
}
.header-left { flex: 1; min-width: 0; }
header h1 { font-size: 1.2rem; font-weight: 600; letter-spacing: .02em; }
header p  { font-size: .8rem; opacity: .7; margin-top: 2px; }

.header-nav {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
}
.header-nav a {
  color: rgba(255,255,255,.6);
  font-size: 1.2rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: color .15s;
  white-space: nowrap;
}
.header-nav a:hover  { color: rgba(255,255,255,.9); }
.header-nav a.active { color: #fff; }

.container { max-width: 720px; margin: 0 auto; padding: 24px 16px; flex: 1; width: 100%; }

/* Search */
.search-wrap { position: relative; margin-bottom: 20px; }
.search-wrap input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  border: 1px solid #c8d8e8;
  border-radius: 10px;
  font-size: .95rem;
  background: #fff;
  outline: none;
  transition: border-color .2s;
}
.search-wrap input:focus { border-color: #1a4f8a; }
.search-wrap::before {
  content: '';
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='10' cy='10' r='7'/%3E%3Cline x1='15.5' y1='15.5' x2='21' y2='21'/%3E%3C/svg%3E") no-repeat center;
  background-size: contain;
  pointer-events: none;
}

/* Cards */
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  overflow: hidden;
  margin-bottom: 10px;
  cursor: pointer;
  transition: box-shadow .15s, transform .1s;
}
.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.12); transform: translateY(-1px); }

.card-row {
  display: flex;
  align-items: center;
  padding: 16px 18px;
  gap: 12px;
}
.card-nome  { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.card-razao { font-weight: 600; font-size: .95rem; }
.card-cnpj  { font-weight: 400; font-size: .8rem; color: #64748b; }
.card-badge {
  font-size: .75rem;
  background: #e8f0fb;
  color: #1a4f8a;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.card-arrow { color: #94a3b8; font-size: 1.1rem; }

.btn-pdf {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #e8f0fb;
  color: #1a4f8a;
  border: 1.5px solid #b8cff0;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: .82rem;
  font-weight: 700;
  font-family: inherit;
  line-height: normal;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
  flex-shrink: 0;
}
.btn-pdf:hover { background: #d0e4f8; border-color: #1a4f8a; }
.btn-pdf.loading { opacity: .6; cursor: wait; }
/* Alguns navegadores aplicam estilo nativo de botão desabilitado (padding e
   caixa maiores), ignorando o box model do flex acima — reafirma as mesmas
   propriedades no estado :disabled para o tamanho nunca mudar ao clicar. */
.btn-pdf:disabled {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border: 1.5px solid #b8cff0;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 700;
  line-height: normal;
  background: #e8f0fb;
  color: #1a4f8a;
}

/* Dias view */
#view-dias { display: none; }

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: #1a4f8a;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  margin-bottom: 16px;
}
.back-btn:hover { text-decoration: underline; }

.camp-header-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.camp-title { font-size: 1.3rem; font-weight: 700; flex: 1; }

/* Dia card */
.dia-card { background: #fff; border-radius: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.08); overflow: hidden; margin-bottom: 8px; }

.dia-header {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  cursor: pointer;
  gap: 12px;
  transition: background .15s;
}
.dia-header:hover { background: #f7fafd; }

.dia-data   { flex: 1; font-weight: 600; font-size: .95rem; }
.dia-count  { font-size: .8rem; color: #64748b; }
.dia-arrow  { color: #94a3b8; font-size: 1rem; transition: transform .2s; }
.dia-arrow.open { transform: rotate(90deg); }

.dia-arquivos { display: none; padding: 0 18px 14px; border-top: 1px solid #f0f4f8; }

.arquivo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #f5f7fa;
}
.arquivo-row:last-child { border-bottom: none; }

.arquivo-nome { flex: 1; font-size: .85rem; color: #475569; word-break: break-all; }

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #1a4f8a;
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 7px 14px;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s;
}
.btn-download:hover { background: #15407a; }

/* Group header for campaigns by client */
.camp-group-header {
  font-size: .82rem;
  font-weight: 700;
  color: #1a4f8a;
  padding: 16px 18px 6px;
  letter-spacing: .04em;
}
.camp-group-header:first-of-type {
  padding-top: 0;
}

/* States */
.empty { text-align: center; color: #94a3b8; padding: 48px 0; font-size: .95rem; }
.loading { text-align: center; color: #64748b; padding: 48px 0; }

.section-label {
  font-size: .75rem;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* ── Modal ─────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 40, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-box {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,.22);
  padding: 28px 28px 24px;
}

.modal-cols {
  display: flex;
  gap: 24px;
  align-items: stretch;
}

.modal-col-left {
  flex: 1;
  min-width: 0;
}

/* Sem a margem do último campo, a coluna direita (esticada pelo flex)
   termina alinhada com o último input da coluna esquerda */
.modal-col-left .form-group:last-child {
  margin-bottom: 0;
}

.modal-col-right {
  flex: 0 0 260px;
  position: relative;
}

/* Absoluto: a coluna direita não contribui para a altura da linha, que passa
   a ser ditada só pela coluna esquerda — a lista rola dentro desse espaço */
.modal-col-right .form-group {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

.modal-col-right .dias-list {
  flex: 1;
  min-height: 100px;
  overflow-y: auto;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a2a3a;
  margin-bottom: 22px;
  text-align: center;
  padding-bottom: 14px;
  border-bottom: 1px solid #e8f0f8;
}

.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}
.form-group label .req { color: #e53e3e; margin-left: 2px; }

.form-group input,
.form-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #c8d8e8;
  border-radius: 8px;
  font-size: .92rem;
  color: #1a2a3a;
  background: #fff;
  outline: none;
  transition: border-color .2s;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus { border-color: #1a4f8a; }
.form-group input.error,
.form-group select.error { border-color: #e53e3e; }

/* Seta customizada dos selects — alinhada com o ícone dos campos de data
   (a seta nativa fica colada na borda direita e não pode ser reposicionada).
   Quem usa esta seta reserva o espaço dela no próprio padding-right. */
.form-group select,
#cnd-emissora,
.cnd-row select.cnd-situacao {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

/* Ícone de calendário nos campos de data (flatpickr) */
.form-group input.date-field {
  padding-right: 38px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

/* Dias checkboxes */
.dias-list {
  border: 1.5px solid #c8d8e8;
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 4px 0;
}

.dia-check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .12s;
}
.dia-check-row:hover { background: #f5f9ff; }
.dia-check-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: #1a4f8a; cursor: pointer; flex-shrink: 0; }
.dia-check-label { font-size: .88rem; color: #1a2a3a; user-select: none; white-space: nowrap; }

/* Toggle-all row: visually distinct from the scrollable day list */
.dias-toggle-all-wrap {
  border: 1.5px solid #c8d8e8;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
}
.dias-toggle-all-wrap .dia-check-row {
  padding: 8px 14px;
  cursor: pointer;
}
.dias-toggle-all-wrap .dia-check-label {
  font-weight: 600;
  color: #1a4f8a;
}
.dias-toggle-all-wrap:hover,
.dias-toggle-all-wrap .dia-check-row:hover { background: #f5f9ff; border-radius: 8px 8px 0 0; }

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid #e8f0f8;
  overflow: visible;
}

.modal-actions .btn-cancelar {
  grid-column: 1 / -1;
}

.btn-cancelar {
  flex: 1;
  background: none;
  border: 1.5px solid #c8d8e8;
  border-radius: 8px;
  padding: 11px 0;
  font-size: .88rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  font-family: inherit;
}
.btn-cancelar:hover { border-color: #94a3b8; color: #1a2a3a; }

.btn-gerar {
  flex: 1;
  background: #1a4f8a;
  border: none;
  border-radius: 8px;
  padding: 11px 0;
  font-size: .88rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: background .15s;
  font-family: inherit;
}
.btn-gerar:hover { background: #15407a; }
.btn-gerar:disabled { opacity: .6; cursor: wait; }

.error-msg { font-size: .78rem; color: #e53e3e; margin-top: 4px; display: none; }
.error-msg.visible { display: block; }
.cnpj-status { font-size: .78rem; margin-top: 4px; min-height: 1em; color: #475569; }
.cnpj-status.erro { color: #e53e3e; }
.form-group input:disabled { background: #f1f5f9; color: #94a3b8; cursor: not-allowed; }

/* Campo com botão + inline (ex: seletor de cliente) */
.input-with-btn {
  display: flex;
  gap: 8px;
  align-items: center;
}
.input-with-btn input {
  flex: 1;
  width: auto;   /* sobrescreve width:100% do .form-group input */
}


.btn-add-inline {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  background: #1a4f8a;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.btn-add-inline:hover { background: #15407a; }

/* Split button */
.btn-split {
  position: relative;
  display: flex;
  border-radius: 8px;
  overflow: visible;
}

.btn-split-main {
  flex: 1;
  background: #1a4f8a;
  border: none;
  border-radius: 8px 0 0 8px;
  padding: 11px 12px;
  font-size: .84rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: background .15s;
  font-family: inherit;
  text-align: center;
  line-height: 1.2;
  min-width: 0;
}
.btn-split-main:hover:not(:disabled) { background: #15407a; }
.btn-split-main:disabled { opacity: .6; cursor: wait; }

.btn-split-arrow {
  background: #15407a;
  border: none;
  border-left: 1px solid rgba(255,255,255,0.25);
  border-radius: 0 8px 8px 0;
  padding: 11px 11px;
  color: #fff;
  cursor: pointer;
  font-size: .72rem;
  transition: background .15s;
  font-family: inherit;
  flex-shrink: 0;
}
.btn-split-arrow:hover:not(:disabled) { background: #0f3060; }
.btn-split-arrow:disabled { opacity: .6; cursor: wait; }

.btn-split-menu {
  background: #fff;
  border: 1px solid #c8d8e8;
  border-radius: 8px;
  overflow: hidden;
  z-index: 9999;
  min-width: 90px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}
.btn-split-menu button {
  display: block;
  width: 100%;
  padding: 9px 18px;
  border: none;
  background: none;
  text-align: left;
  font-size: .88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  color: #1a2a3a;
}
.btn-split-menu button:hover { background: #f0f6ff; color: #1a4f8a; }

/* Workflow status */
#workflow-status { font-size: .78rem; margin-top: 5px; opacity: .9; }
#workflow-status a { color: inherit; text-underline-offset: 2px; }
.status-ok   { color: #a8f0c0; }
.status-fail { color: #fca5a5; }
.status-mock { color: #fcd34d; }

/* DB connectivity status */
#db-status { font-size: .78rem; margin-top: 3px; opacity: .9; }
#user-status { font-size: .78rem; margin-top: 3px; opacity: .9; }

/* Botão "GERAR CAPTURA" — a mensagem de status fica numa linha própria
   abaixo do cabeçalho, com espaço pra quebrar sem afetar botão/LOGS. */
.trigger-capture-status { font-size: .78rem; font-weight: 600; margin: -4px 0 10px; }
.trigger-capture-status:empty { display: none; margin: 0; }
.trigger-capture-status.status-ok   { color: #15803d; }
.trigger-capture-status.status-fail { color: #e53e3e; }

/* Log de Capturas view */
#view-historico { display: none; }

/* Clientes view */
#view-clientes { display: none; }

/* Card com botão de ação lateral (ex: Campanhas) */
.card-with-action {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
}
.card-with-action .card-row {
  flex: 1;
  cursor: pointer;
  padding: 14px 12px;
}
.card-with-action .btn-cliente-camp { flex-shrink: 0; margin-right: 12px; }

.btn-cliente-camp {
  background: #f0fdf4;
  color: #15803d;
  border: 1.5px solid #86efac;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.btn-cliente-camp:hover { background: #dcfce7; }


.btn-cliente-del {
  background: none;
  color: #dc2626;
  border: 1.5px solid #fca5a5;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, border-color .15s;
}
.btn-cliente-del:hover { background: #fef2f2; border-color: #dc2626; }

/* Modal de cliente (mais estreito) */
.modal-box-sm {
  max-width: 480px;
}

.modal-actions-sm {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid #e8f0f8;
}

/* Todos os botões do modal de cliente: mesmo tamanho */
.modal-actions-sm .btn-gerar,
.modal-actions-sm .btn-cancelar,
.modal-actions-sm .btn-cliente-del {
  width: 100%;
  padding: 11px 0;
  font-size: .88rem;
  font-weight: 700;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
  text-align: center;
}

/* Cancelar — sem preenchimento */
.modal-actions-sm .btn-cancelar {
  background: none;
  border: 1.5px solid #c8d8e8;
  color: #64748b;
}
.modal-actions-sm .btn-cancelar:hover { border-color: #94a3b8; color: #1a2a3a; }

/* Excluir — preenchido com vermelho */
.modal-actions-sm .btn-cliente-del {
  background: #dc2626;
  color: #fff;
}
.modal-actions-sm .btn-cliente-del:hover { background: #b91c1c; }
.historico-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
  margin-top: 12px;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
}
.historico-table th {
  text-align: center;
  padding: 8px 14px;
  background: #e8f0fb;
  color: #1a4f8a;
  font-size: .75rem;
  letter-spacing: .04em;
}
.historico-table td { padding: 8px 14px; border-bottom: 1px solid #f0f4f8; text-align: center; }
.historico-table tr:last-child td { border-bottom: none; }
.historico-table a { color: #1a4f8a; text-decoration: none; }
.historico-table a:hover { text-decoration: underline; }
.mes-stats { display: flex; gap: 12px; font-size: .8rem; }
.badge-ok   { color: #16a34a; font-weight: 600; }
.badge-fail { color: #dc2626; font-weight: 600; }

/* ── Comprovante Genérico ──────────────────────────────────────────────────── */

.modal-box-wide {
  max-width: 800px;
}

.form-row {
  display: flex;
  gap: 16px;
}
.form-row .form-group {
  flex: 1;
}

.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #c8d8e8;
  border-radius: 8px;
  font-size: .92rem;
  color: #1a2a3a;
  background: #fff;
  outline: none;
  transition: border-color .2s;
  font-family: inherit;
  resize: vertical;
}
.form-group textarea:focus { border-color: #1a4f8a; }

.gen-categoria {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}

.gen-cat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.gen-cat-nome {
  flex: 1;
  padding: 8px 12px;
  border: 1.5px solid #c8d8e8;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  color: #1a2a3a;
  background: #fff;
  outline: none;
  font-family: inherit;
  transition: border-color .2s;
}
.gen-cat-nome:focus { border-color: #1a4f8a; }

.btn-remover-cat {
  background: none;
  border: 1.5px solid #fca5a5;
  color: #dc2626;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.btn-remover-cat:hover { background: #fef2f2; }

.gen-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #e8f0f8;
}
.gen-item-row:last-child { border-bottom: none; }

.gen-item-img-wrap {
  flex-shrink: 0;
  width: 80px;
  height: 60px;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 1.5px dashed #c8d8e8;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gen-item-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gen-item-placeholder {
  font-size: .7rem;
  color: #94a3b8;
  text-align: center;
  padding: 4px;
}

.gen-item-fields {
  flex: 1;
}

.gen-item-link {
  width: 100%;
  padding: 7px 10px;
  border: 1.5px solid #c8d8e8;
  border-radius: 6px;
  font-size: .82rem;
  color: #1a2a3a;
  background: #fff;
  outline: none;
  font-family: inherit;
  transition: border-color .2s;
}
.gen-item-link:focus { border-color: #1a4f8a; }

.btn-remover-item {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
  transition: color .15s;
}
.btn-remover-item:hover { color: #dc2626; }

.btn-add-item {
  width: 100%;
  padding: 7px;
  margin-top: 6px;
  background: #f1f5f9;
  border: 1.5px dashed #c8d8e8;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, border-color .15s;
}
.btn-add-item:hover { background: #e2e8f0; border-color: #94a3b8; }

.btn-add-cat {
  width: 100%;
  padding: 10px;
  margin: 4px 0 8px;
  background: #e8f0fb;
  border: 2px dashed #b8cff0;
  border-radius: 10px;
  font-size: .88rem;
  font-weight: 700;
  color: #1a4f8a;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, border-color .15s;
}
.btn-add-cat:hover { background: #d0e4f8; border-color: #1a4f8a; }

.btn-generico {
  background: #f0fdf4;
  border: 1.5px solid #86efac;
  border-radius: 8px;
  padding: 11px 0;
  font-size: .88rem;
  font-weight: 700;
  color: #15803d;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
  text-align: center;
}
.btn-generico:hover { background: #dcfce7; }

/* ── Modal de campanha com anexos ────────────────────────────────────────── */

.modal-box-camp {
  max-width: 1139px;
}

.modal-box-camp .modal-cols {
  display: grid;
  grid-template-columns: 1fr 300px 280px;
}


.modal-col-right-anexos {
  flex: 0 0 300px;
  display: flex;
  flex-direction: column;
}

.modal-col-right-anexos .form-group {
  display: flex;
  flex-direction: column;
  flex: 1;
  margin-bottom: 0;
}

/* Anexos area */
.anexos-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
}

.anexos-lista:empty,
.anexos-status:empty {
  display: none;
}

.anexos-dropzone {
  flex: 1;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed #c8d8e8;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}

.anexos-dropzone:hover,
.anexos-dropzone--active {
  border-color: #1a4f8a;
  background: #f0f6ff;
}

.anexos-dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.anexos-dropzone-icon {
  font-size: 1.5rem;
}

.anexos-dropzone-text {
  font-size: .82rem;
  font-weight: 600;
  color: #1a2a3a;
}

.anexos-dropzone-hint {
  font-size: .72rem;
  color: #94a3b8;
}

.anexos-lista {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  max-height: 325px;
}

.anexos-lista-empty {
  font-size: .82rem;
  color: #94a3b8;
  text-align: center;
  padding: 16px 0;
}

.anexo-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid #e8f0f8;
  border-radius: 8px;
}

/* Segunda linha: tamanho + data à esquerda, botões à direita */
.anexo-item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.anexo-item--pendente {
  background: #fffbeb;
  border-color: #fde68a;
  opacity: .85;
}

.anexo-item-nome {
  min-width: 0;
  font-size: .8rem;
  font-weight: 600;
  color: #1a2a3a;
  word-break: break-all;
  line-height: 1.2;
}

.anexo-item-meta {
  font-size: .7rem;
  color: #94a3b8;
}

.anexo-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.anexo-btn-download,
.anexo-btn-excluir {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: .68rem;
  transition: background .15s;
}

.anexo-btn-download {
  background: #e8f0fb;
  color: #1a4f8a;
}

.anexo-btn-download:hover {
  background: #d0e4f8;
}

.anexo-btn-excluir {
  background: #fef2f2;
  color: #dc2626;
}

.anexo-btn-excluir:hover {
  background: #fee2e2;
}

.anexos-status {
  font-size: .75rem;
  color: #64748b;
  min-height: 1.2em;
}

/* Telas estreitas: empilha as colunas (form, anexos, documentos) */
@media (max-width: 960px) {
  .modal-box-camp .modal-cols {
    grid-template-columns: 1fr;
  }
  .modal-col-right-anexos,
  .modal-col-docs {
    width: 100%;
    border-top: 1px solid #e8f0f8;
    padding-top: 16px;
    margin-top: 8px;
  }
}

footer {
  text-align: center;
  padding: 16px 24px;
  font-size: .82rem;
  color: #94a3b8;
  border-top: 1px solid #e2e8f0;
  margin-top: 40px;
}
footer a {
  color: #1a4f8a;
  text-decoration: none;
  font-weight: 600;
}
footer a:hover {
  text-decoration: underline;
}

/* ── Banner atrelado na campanha ───────────────────────────────────────────── */

.camp-divider {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 16px 0;
}

.helper-msg {
  font-size: .75rem;
  color: #94a3b8;
  margin-top: 4px;
}

/* ── Atrelar banner ────────────────────────────────────────────────────────── */

.btn-atrelar-banner {
  display: block;
  width: 100%;
  height: 41px;               /* mesma altura do botão Salvar */
  box-sizing: border-box;
  line-height: 38px;          /* centra verticalmente (altura - borda) */
  padding: 0 12px;
  background: #eff6ff;
  border: 1.5px solid #93c5fd;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 700;
  color: #1d4ed8;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-atrelar-banner:hover { background: #dbeafe; }

/* Banner já atrelado: a própria célula vira o "chip" verde clicável */
.btn-atrelar-banner.tem-banner {
  background: #f0fdf4;
  border-color: #86efac;
  color: #15803d;
}
.btn-atrelar-banner.tem-banner:hover { background: #dcfce7; }

.modal-box-atrelar { max-width: 460px; }
.modal-box-atrelar .dias-banner-section { margin-top: 0; border-top: none; padding-top: 0; }
.modal-box-atrelar .dias-list { max-height: 220px; }

/* ── Dias do banner na campanha ────────────────────────────────────────────── */

.dias-banner-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e8f0f8;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.dias-banner-section label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}

.dias-banner-section .dias-list {
  flex: 1;
  min-height: 60px;
  overflow-y: auto;
}

/* ── Documentos na campanha ────────────────────────────────────────────────── */

.camp-doc-actions {
  display: grid;
  grid-template-rows: auto repeat(6, minmax(0, 1fr));
  gap: 10px;
  height: 100%;
}
/* Os 6 botões dividem igualmente a altura disponível da coluna */
.camp-doc-actions .btn-split,
.camp-doc-actions .btn-gerar,
.camp-doc-actions .btn-generico {
  min-height: 0;
  box-sizing: border-box;
}
/* Centra o conteúdo verticalmente quando os botões crescem */
.camp-doc-actions .btn-split-main,
.camp-doc-actions .btn-split-arrow,
.camp-doc-actions .btn-gerar,
.camp-doc-actions .btn-generico {
  display: flex;
  align-items: center;
  justify-content: center;
}

.camp-doc-actions .section-label {
  margin-top: 0;
  margin-bottom: 8px;
  text-align: center;
  color: #64748b;            /* mesma cor do header "ANEXOS" */
}

/* Botão de gerar todas as CNDs: nasce desabilitado e assim fica enquanto não
   houver certidão, então não usa o `cursor: wait` de .btn-gerar:disabled, que
   sinaliza ocupado. */
#camp-cnds:disabled { opacity: .5; cursor: default; }

/* Centraliza o header "ANEXOS" como o box de documentos */
.modal-col-right-anexos label {
  text-align: center;
}

.camp-doc-actions .camp-divider {
  margin: 4px 0;
}

.anexos-and-dias {
  display: flex;
  flex-direction: column;
  flex: 1;
  margin-bottom: 0;
}

/* ---------------------------------------------------------------------------
   Overlay de login (Supabase Auth)
   --------------------------------------------------------------------------- */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 40, .65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}

.auth-box {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 40px rgba(0,0,0,.28);
  padding: 32px 28px 28px;
}

.auth-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1a4f8a;
  text-align: center;
}

.auth-subtitle {
  font-size: .85rem;
  color: #667;
  text-align: center;
  margin-bottom: 22px;
}

.auth-box .form-group { margin-bottom: 16px; }
.auth-box .btn-gerar { width: 100%; margin-top: 4px; }

.auth-error {
  color: #c0392b;
  font-size: .85rem;
  min-height: 1.1em;
  margin-bottom: 10px;
}

/* ── CNDs (certidões negativas de débito) ─────────────────────────────────── */

/* Sem max-width: acompanha a largura dos cards de certidão logo abaixo */
.cnd-emissora-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 18px;
}

#cnd-emissora {
  /* min-width: 0 para o select encolher junto com a linha em telas estreitas,
     em vez de empurrar o botão de copiar para fora do card */
  flex: 1 1 auto;
  min-width: 0;
  /* padding-left igual ao da direita (a seta): o texto centraliza na content
     box, então sem simetria ele ficaria deslocado para a esquerda */
  padding: 9px 38px;
  text-align: center;
  border: 1.5px solid #c8d8e8;
  border-radius: 8px;
  font-size: .92rem;
  font-family: inherit;
  color: #1a2a3a;
  /* background-color, e não o atalho: o atalho apagaria a seta customizada */
  background-color: #fff;
  outline: none;
  transition: border-color .2s;
}
/* A lista aberta herda o padding do select, que é o que joga as opções para a
   direita; zerado aqui, elas centralizam na largura da lista. */
#cnd-emissora option {
  padding-left: 0;
  padding-right: 0;
  text-align: center;
}
#cnd-emissora:focus { border-color: #1a4f8a; }

/* Mesma altura do select ao lado, sem depender do tamanho do ícone */
#btn-copiar-cnpj { flex: 0 0 auto; padding: 0 12px; }

.cnd-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  padding: 12px 16px;
  margin-bottom: 10px;
}

.cnd-status { font-size: 1.1rem; line-height: 1; flex: 0 0 auto; }

.cnd-info-btn {
  position: relative;
  font-size: .85rem;
  line-height: 1;
  flex: 0 0 auto;
  cursor: help;
  opacity: .55;
  transition: opacity .15s;
  text-decoration: none;
}
/* Só os tipos com portal oficial viram link: aí o ícone é clicável. */
a.cnd-info-btn { cursor: pointer; }
.cnd-info-btn:hover,
.cnd-info-btn:focus { opacity: 1; }

.cnd-info-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  width: 260px;
  padding: 10px 12px;
  background: #1a2a3a;
  color: #fff;
  font-size: .78rem;
  line-height: 1.45;
  font-weight: 400;
  border-radius: 8px;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity .15s, visibility .15s;
  z-index: 10;
}
.cnd-info-btn::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1a2a3a;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity .15s, visibility .15s;
  z-index: 10;
}
.cnd-info-btn:hover::after,
.cnd-info-btn:focus::after,
.cnd-info-btn:hover::before,
.cnd-info-btn:focus::before {
  opacity: 1;
  visibility: visible;
}

.cnd-tipo { flex: 1 1 auto; min-width: 0; }
.cnd-tipo-nome { font-weight: 600; color: #1a2a3a; font-size: .95rem; }
.cnd-arquivo {
  font-size: .78rem;
  color: #94a3b8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cnd-row select.cnd-situacao,
.cnd-row input.cnd-validade {
  padding: 7px 10px;
  border: 1.5px solid #c8d8e8;
  border-radius: 8px;
  font-size: .85rem;
  font-family: inherit;
  color: #1a2a3a;
  background-color: #fff;
  outline: none;
}
/* padding-left igual ao da direita: o texto centraliza na content box, então
   sem simetria ele ficaria deslocado para a esquerda dentro da borda */
.cnd-row select.cnd-situacao {
  flex: 0 0 auto;
  padding-right: 38px;
  padding-left: 38px;
  text-align: center;
}
/* A lista aberta herda o padding do select, que é o que joga as opções para a
   direita; zerado aqui, elas centralizam na largura da lista. */
.cnd-row select.cnd-situacao option {
  padding-left: 0;
  padding-right: 0;
  text-align: center;
}
/* min-width: 0 para o flex-basis valer: sem isso o `min-width: auto` do item
   flex resolve para a largura intrínseca do input (size=20, ~196px) e o campo
   fica muito maior que a data que ele guarda, espremendo o nome do arquivo */
.cnd-row input.cnd-validade  { flex: 0 0 120px; min-width: 0; cursor: pointer; text-align: center; }
.cnd-row select.cnd-situacao:focus,
.cnd-row input.cnd-validade:focus { border-color: #1a4f8a; }
.cnd-row select.cnd-situacao:disabled,
.cnd-row input.cnd-validade:disabled { background-color: #f4f7fa; color: #94a3b8; cursor: default; }

/* Acompanha a largura dos cards, como o seletor de emissora no topo */
#btn-cnds-consolidadas { width: 100%; margin-top: 8px; }
#btn-cnds-consolidadas:disabled { opacity: .5; cursor: default; }

.cnd-acoes { display: flex; gap: 6px; flex: 0 0 auto; }

.cnd-btn {
  background: none;
  border: 1.5px solid #c8d8e8;
  border-radius: 8px;
  padding: 5px 9px;
  font-size: .95rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.cnd-btn:hover:not(:disabled) { border-color: #1a4f8a; background: #f0f6fc; }
.cnd-btn:disabled { opacity: .35; cursor: default; }

@media (max-width: 640px) {
  .cnd-row { flex-wrap: wrap; }
  .cnd-tipo { flex: 1 1 100%; order: -1; }
  .cnd-row input.cnd-validade { flex: 1 1 100px; }
}
