/* ================================================================
   PRECIFIKA — MÓDULO DE RECIBOS FINANCEIROS
   Versão 1.0 — Maio 2026
   Arquivos relacionados: js/receipts.js, js/receipt-pdf.js
   ================================================================ */

/* ── Variáveis do módulo ── */
:root {
  --rec-primary:    #2563eb;
  --rec-success:    #16a34a;
  --rec-warning:    #d97706;
  --rec-danger:     #dc2626;
  --rec-purple:     #7c3aed;
  --rec-gray-50:    #f8fafc;
  --rec-gray-100:   #f1f5f9;
  --rec-gray-200:   #e2e8f0;
  --rec-gray-400:   #94a3b8;
  --rec-gray-600:   #475569;
  --rec-gray-800:   #1e293b;
  --rec-radius:     14px;
  --rec-shadow:     0 4px 20px rgba(0,0,0,.08);
}

/* ================================================================
   1. BOTÃO EMITIR RECIBO — na tabela/card de orçamentos aprovados
   ================================================================ */

/* Badge na listagem indicando recibos emitidos */
.est-receipt-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--rec-success);
  background: #dcfce7;
  border: 1px solid #bbf7d0;
  padding: 2px 7px;
  border-radius: 20px;
  margin-left: 4px;
  white-space: nowrap;
  vertical-align: middle;
}

/* Botão emitir recibo na coluna de ações */
.btn-emit-receipt {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--rec-success);
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
  white-space: nowrap;
}
.btn-emit-receipt:hover {
  background: #dcfce7;
  border-color: #86efac;
  transform: translateY(-1px);
}
.btn-emit-receipt i { font-size: 11px; }

/* ================================================================
   2. MODAL — EMITIR RECIBO (overlay + box)
   ================================================================ */

.receipt-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(3px);
  z-index: 1100;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.receipt-modal-overlay.active {
  display: flex;
}

.receipt-modal-box {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 100%;
  max-width: 700px;
  max-height: 92vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  animation: recModalIn .22s ease;
}

@keyframes recModalIn {
  from { opacity: 0; transform: translateY(24px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.receipt-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 26px 18px;
  border-bottom: 1px solid var(--rec-gray-200);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
  border-radius: 20px 20px 0 0;
}

.receipt-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.receipt-modal-title-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #dcfce7, #bbf7d0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--rec-success);
  flex-shrink: 0;
}

.receipt-modal-title h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--rec-gray-800);
  margin: 0;
  line-height: 1.2;
}

.receipt-modal-title p {
  font-size: 12px;
  color: var(--rec-gray-400);
  margin: 2px 0 0;
}

.receipt-modal-close {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: var(--rec-gray-100);
  color: var(--rec-gray-600);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background .15s;
  flex-shrink: 0;
}
.receipt-modal-close:hover { background: var(--rec-gray-200); }

.receipt-modal-body {
  padding: 24px 26px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.receipt-modal-footer {
  padding: 16px 26px 20px;
  border-top: 1px solid var(--rec-gray-200);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  position: sticky;
  bottom: 0;
  background: #fff;
  border-radius: 0 0 20px 20px;
}

/* ================================================================
   3. SEÇÕES INTERNAS DO MODAL DE EMISSÃO
   ================================================================ */

/* Cabeçalho de seção */
.rec-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--rec-gray-600);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.rec-section-title i {
  width: 18px;
  text-align: center;
  color: var(--rec-primary);
}

/* Card resumo do orçamento */
.rec-estimate-summary {
  background: var(--rec-gray-50);
  border: 1px solid var(--rec-gray-200);
  border-radius: var(--rec-radius);
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.rec-sum-item {}
.rec-sum-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--rec-gray-400);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 3px;
}
.rec-sum-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--rec-gray-800);
}
.rec-sum-value--big {
  font-size: 18px;
  color: var(--rec-primary);
}
.rec-sum-value--green {
  font-size: 14px;
  color: var(--rec-success);
}

/* Grid de campos do formulário */
.rec-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.rec-form-grid--3 {
  grid-template-columns: 1fr 1fr 1fr;
}
.rec-form-full { grid-column: 1 / -1; }

.rec-form-group {}
.rec-form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--rec-gray-600);
  margin-bottom: 5px;
}
.rec-form-label span { color: var(--rec-danger); }

.rec-form-input,
.rec-form-select,
.rec-form-textarea {
  width: 100%;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--rec-gray-800);
  background: #fff;
  border: 1.5px solid var(--rec-gray-200);
  border-radius: 9px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  box-sizing: border-box;
}
.rec-form-input:focus,
.rec-form-select:focus,
.rec-form-textarea:focus {
  border-color: var(--rec-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.rec-form-textarea {
  resize: vertical;
  min-height: 70px;
}

/* Campo calculado (somente leitura com destaque) */
.rec-calculated-field {
  display: flex;
  align-items: center;
  gap: 0;
  background: #f0fdf4;
  border: 1.5px solid #bbf7d0;
  border-radius: 9px;
  overflow: hidden;
}
.rec-calculated-prefix {
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--rec-success);
  background: #dcfce7;
  border-right: 1px solid #bbf7d0;
  white-space: nowrap;
}
.rec-calculated-value {
  flex: 1;
  padding: 9px 12px;
  font-size: 16px;
  font-weight: 800;
  color: var(--rec-success);
  background: transparent;
  border: none;
  outline: none;
  cursor: default;
  font-family: inherit;
}

/* Card de progresso do faturamento */
.rec-billing-progress {
  background: var(--rec-gray-50);
  border: 1px solid var(--rec-gray-200);
  border-radius: var(--rec-radius);
  padding: 14px 16px;
}
.rec-billing-progress-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--rec-gray-600);
  margin-bottom: 8px;
}
.rec-billing-progress-bar-wrap {
  height: 8px;
  background: var(--rec-gray-200);
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 6px;
}
.rec-billing-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  border-radius: 20px;
  transition: width .4s ease;
}
.rec-billing-progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--rec-gray-400);
}
.rec-billing-progress-meta strong { color: var(--rec-gray-800); }

/* ================================================================
   4. SEÇÃO DE DADOS BANCÁRIOS NO MODAL
   ================================================================ */

.rec-bank-selector {
  display: flex;
  align-items: center;
  gap: 10px;
}
.rec-bank-selector select {
  flex: 1;
}

.btn-rec-add-bank {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--rec-primary);
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  border-radius: 9px;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
  font-family: inherit;
}
.btn-rec-add-bank:hover { background: #dbeafe; }

/* Preview card de dados bancários selecionados */
.rec-bank-preview {
  background: var(--rec-gray-50);
  border: 1px solid var(--rec-gray-200);
  border-radius: var(--rec-radius);
  padding: 14px 16px;
  display: none;
}
.rec-bank-preview.visible { display: block; }

.rec-bank-preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.rec-bank-preview-item {}
.rec-bank-preview-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--rec-gray-400);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.rec-bank-preview-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--rec-gray-800);
  margin-top: 1px;
}

/* ================================================================
   5. MODAL DE DADOS BANCÁRIOS (cadastro/edição)
   ================================================================ */

.bank-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.6);
  backdrop-filter: blur(3px);
  z-index: 1200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.bank-modal-overlay.active { display: flex; }

.bank-modal-box {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.22);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: recModalIn .2s ease;
}

.bank-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--rec-gray-200);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
  border-radius: 18px 18px 0 0;
}

.bank-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--rec-gray-800);
}

.bank-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--rec-gray-100);
  color: var(--rec-gray-600);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background .15s;
  font-family: inherit;
}
.bank-modal-close:hover { background: var(--rec-gray-200); }

.bank-modal-body {
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bank-modal-footer {
  padding: 14px 24px 18px;
  border-top: 1px solid var(--rec-gray-200);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  position: sticky;
  bottom: 0;
  background: #fff;
  border-radius: 0 0 18px 18px;
}

/* ================================================================
   6. MODAL — HISTÓRICO DE RECIBOS
   ================================================================ */

.history-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(3px);
  z-index: 1100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.history-modal-overlay.active { display: flex; }

.history-modal-box {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 100%;
  max-width: min(1100px, 94vw);   /* ← era 720px — largo o suficiente para 5 botões */
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;             /* evita scroll lateral no modal */
  animation: recModalIn .22s ease;
  display: flex;
  flex-direction: column;
}

.history-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;                /* ← cabeçalho quebra em telas menores */
  padding: 22px 26px 18px;
  border-bottom: 1px solid var(--rec-gray-200);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
  border-radius: 20px 20px 0 0;
}
.history-modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--rec-gray-800);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;                   /* ← impede crescimento ilimitado do título */
}
.history-modal-title i { color: var(--rec-primary); }
.history-modal-subtitle {
  font-size: 12px;
  color: var(--rec-gray-400);
  margin-top: 2px;
}
.history-modal-close {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: var(--rec-gray-100);
  color: var(--rec-gray-600);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background .15s;
  font-family: inherit;
}
.history-modal-close:hover { background: var(--rec-gray-200); }

.history-modal-body {
  padding: 22px 26px;
  flex: 1;
  overflow-y: auto;               /* scroll vertical apenas no corpo */
  overflow-x: hidden;
  min-width: 0;                   /* ← impede que filho alargue o modal */
}

/* Barra de progresso de faturamento no histórico */
.hist-billing-summary {
  background: linear-gradient(135deg, #eff6ff, #f0fdf4);
  border: 1px solid var(--rec-gray-200);
  border-radius: var(--rec-radius);
  padding: 16px 18px;
  margin-bottom: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}
.hist-sum-item {}
.hist-sum-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--rec-gray-400);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 3px;
}
.hist-sum-value {
  font-size: 16px;
  font-weight: 800;
  color: var(--rec-gray-800);
}
.hist-sum-value--blue  { color: var(--rec-primary); }
.hist-sum-value--green { color: var(--rec-success); }
.hist-sum-value--amber { color: var(--rec-warning); }

/* Barra de progresso total */
.hist-progress-wrap {
  margin-top: 10px;
  grid-column: 1 / -1;
}
.hist-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--rec-gray-400);
  margin-bottom: 5px;
}
.hist-progress-label strong { color: var(--rec-gray-800); }
.hist-progress-bar-bg {
  height: 10px;
  background: var(--rec-gray-200);
  border-radius: 20px;
  overflow: hidden;
}
.hist-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  border-radius: 20px;
  transition: width .4s ease;
}

/* Lista de recibos no histórico */
.hist-receipts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;                   /* ← impede alargamento horizontal */
  width: 100%;
}

/* Regra legacy removida — layout do card definido abaixo na seção "Cards redesenhados" */
/* (mantida apenas estrutura .hist-receipt-icon/.hist-receipt-body/.hist-receipt-right
    para compatibilidade com qualquer JS que ainda use o HTML antigo) */

.hist-receipt-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, #dcfce7, #bbf7d0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--rec-success);
  flex-shrink: 0;
}
.hist-receipt-icon--cancelled {
  background: #fef2f2;
  color: var(--rec-danger);
}

.hist-receipt-body { flex: 1; min-width: 0; }
.hist-receipt-code {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--rec-gray-800);
  margin-bottom: 2px;
}
.hist-receipt-meta {
  font-size: 11.5px;
  color: var(--rec-gray-400);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.hist-receipt-meta span { display: flex; align-items: center; gap: 4px; }

.hist-receipt-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}
.hist-receipt-value {
  font-size: 16px;
  font-weight: 800;
  color: var(--rec-success);
}
.hist-receipt-pct {
  font-size: 11px;
  font-weight: 700;
  color: var(--rec-primary);
  background: #eff6ff;
  padding: 2px 7px;
  border-radius: 20px;
}
.hist-receipt-status {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
}
.hist-receipt-status--emitido {
  background: #dcfce7;
  color: var(--rec-success);
}
.hist-receipt-status--cancelado {
  background: #fef2f2;
  color: var(--rec-danger);
}

.hist-receipt-actions {
  display: flex;
  gap: 6px;
}
.hist-action-btn {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: background .15s;
  font-family: inherit;
}
.hist-action-btn--pdf {
  background: #eff6ff;
  color: var(--rec-primary);
}
.hist-action-btn--pdf:hover { background: #dbeafe; }
.hist-action-btn--cancel {
  background: #fef2f2;
  color: var(--rec-danger);
}
.hist-action-btn--cancel:hover { background: #fee2e2; }

/* Botão editar no histórico */
.hist-action-btn--edit {
  background: #eff6ff;
  color: var(--rec-primary);
  border: 1px solid #bfdbfe;
}
.hist-action-btn--edit:hover { background: #dbeafe; }

/* Badge "editado Nx" no código do recibo */
.hist-receipt-edited-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  color: #7c3aed;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  padding: 1px 6px;
  border-radius: 20px;
  margin-left: 5px;
  vertical-align: middle;
}

/* ================================================================
   MODAL DE EDIÇÃO — reutiliza .receipt-modal-* mas com acento azul
   ================================================================ */

/* Banner de % disponível */
.edit-rec-pct-banner {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 7px 12px;
  margin-bottom: 12px;
  font-size: 12px;
  flex-wrap: wrap;
}
.edit-rec-pct-banner-label { color: var(--rec-gray-600); font-weight: 500; }
.edit-rec-pct-banner-val   { color: var(--rec-primary);  font-weight: 800; font-size: 13px; }
.edit-rec-pct-banner-sep   { color: var(--rec-gray-400); }

/* Indicador inline do campo de percentual */
.edit-rec-pct-indicator {
  font-size: 11px;
  color: #64748b;
  margin-top: 4px;
  min-height: 15px;
  transition: color .2s;
}
.edit-rec-pct-indicator.over { color: var(--rec-danger); font-weight: 700; }
.edit-rec-pct-indicator.ok   { color: var(--rec-success); font-weight: 600; }

/* Contador no cabeçalho do histórico */
.history-modal-header-info { display: flex; flex-direction: column; gap: 2px; }
.history-modal-count {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--rec-primary);
  margin-top: 3px;
  letter-spacing: .2px;
}

/* Título da seção de lista */
.hist-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.hist-list-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--rec-gray-600);
  display: flex;
  align-items: center;
  gap: 6px;
}
.hist-list-title i { color: var(--rec-primary); font-size: 11px; }

/* ─── Cards de recibo redesenhados ─── */
/* RESET completo do layout legacy (display:flex row) → card vertical */
.hist-receipt-item {
  display: flex;              /* ← sobrescreve flex herdado */
  flex-direction: column;     /* ← filhos empilham verticalmente */
  align-items: stretch;       /* ← filhos ocupam largura total */
  gap: 0;                     /* ← espaçamento gerido por border-bottom de cada seção */
  background: #fff;
  border: 1.5px solid var(--rec-gray-200);
  border-radius: var(--rec-radius);
  padding: 0;
  overflow: visible;          /* ← NUNCA hidden: impediria ver botões */
  transition: box-shadow .2s, border-color .2s;
  min-width: 0;               /* ← impede alargamento em contexto flex */
  width: 100%;                /* ← card sempre ocupa 100% da lista */
  box-sizing: border-box;
}
.hist-receipt-item:hover {
  box-shadow: 0 4px 18px rgba(37,99,235,.1);
  border-color: #bfdbfe;
}
.hist-receipt-item--cancelled {
  opacity: .75;
  border-color: #fecaca;
  background: #fffbfb;
}
.hist-receipt-item--cancelled:hover { border-color: #fca5a5; }

/* Cabeçalho do card — cantos superiores arredondados (substitui overflow:hidden no pai) */
.hist-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;                /* ← valor monetário desce se não couber */
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--rec-gray-100);
  background: var(--rec-gray-50);
  min-width: 0;
  border-radius: var(--rec-radius) var(--rec-radius) 0 0; /* ← arredondamento sem overflow:hidden */
}
.hist-item-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;                   /* ← permite que texto interno trunce/quebre */
  flex: 1;
}
.hist-item-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: var(--rec-primary);
  flex-shrink: 0;
}
.hist-item-icon--cancelled {
  background: linear-gradient(135deg, #fecaca, #fca5a5);
  color: var(--rec-danger);
}
.hist-item-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;                   /* ← texto do código não empurra botões */
}
.hist-item-code {
  font-size: 14px;
  font-weight: 800;
  color: var(--rec-gray-800);
  letter-spacing: .3px;
  overflow-wrap: anywhere;        /* ← código longo quebra se necessário */
}
.hist-item-badges { display: flex; gap: 5px; flex-wrap: wrap; }
.hist-item-value-wrap { text-align: right; }
.hist-item-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--rec-success);
  line-height: 1.1;
}
.hist-item-value--cancelled {
  color: var(--rec-gray-400);
  text-decoration: line-through;
}
.hist-item-pct {
  font-size: 11px;
  font-weight: 600;
  color: var(--rec-primary);
  background: #eff6ff;
  padding: 2px 8px;
  border-radius: 20px;
  display: inline-block;
  margin-top: 3px;
}

/* Detalhes do card */
.hist-item-details {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--rec-gray-100);
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
.hist-item-notes {
  font-size: 12px;
  color: var(--rec-gray-600);
  background: #fffbeb;
  border-left: 3px solid #fbbf24;
  padding: 7px 12px;
  margin: 0 16px;
  border-radius: 0 6px 6px 0;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.hist-item-notes i { color: #d97706; margin-top: 1px; flex-shrink: 0; }

/* Badges reutilizáveis */
.hist-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.hist-badge--green  { background: #dcfce7; color: var(--rec-success); border: 1px solid #bbf7d0; }
.hist-badge--red    { background: #fef2f2; color: var(--rec-danger);  border: 1px solid #fecaca; }
.hist-badge--purple { background: #f5f3ff; color: #7c3aed;            border: 1px solid #ddd6fe; }
.hist-badge--blue   { background: #eff6ff; color: var(--rec-primary); border: 1px solid #bfdbfe; }

/* Chips de informação */
.hist-info-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--rec-gray-600);
  background: var(--rec-gray-100);
  padding: 3px 9px;
  border-radius: 20px;
  font-weight: 500;
}
.hist-info-chip i { color: var(--rec-primary); font-size: 10px; }
.hist-info-chip--green { background: #dcfce7; color: #15803d; }
.hist-info-chip--green i { color: #15803d; }

/* Log de edições */
.hist-edit-log {
  margin: 0 16px 0;
  padding: 10px 12px;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  border-radius: 8px;
}
.hist-edit-log-title {
  font-size: 11px;
  font-weight: 700;
  color: #7c3aed;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.hist-edit-log-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 11px;
  color: var(--rec-gray-600);
  padding: 3px 0;
  border-top: 1px solid #ede9fe;
}
.hist-edit-log-row:first-of-type { border-top: none; }
.hist-edit-log-date { color: #6d28d9; font-weight: 600; flex-shrink: 0; }
.hist-edit-log-detail em { font-style: normal; font-weight: 600; color: var(--rec-gray-800); }

/* Ações do card — NUNCA cortam, sempre visíveis */
.hist-item-actions {
  display: flex;
  flex-wrap: wrap;                /* ← botões quebram linha automaticamente */
  gap: 6px 8px;
  padding: 10px 16px 12px;
  background: var(--rec-gray-50);
  border-top: 1px solid var(--rec-gray-100);
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  border-radius: 0 0 var(--rec-radius) var(--rec-radius); /* ← arredondamento inferior sem overflow:hidden */
}
.hist-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1.5px solid transparent;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
  white-space: nowrap;            /* texto do botão nunca quebra */
  flex-shrink: 0;                 /* botão não encolhe abaixo do mínimo */
}
.hist-btn:active { transform: scale(.97); }
.hist-btn--pdf {
  background: #eff6ff;
  color: var(--rec-primary);
  border-color: #bfdbfe;
}
.hist-btn--pdf:hover { background: #dbeafe; }
.hist-btn--edit {
  background: #f0fdf4;
  color: #15803d;
  border-color: #bbf7d0;
}
.hist-btn--edit:hover { background: #dcfce7; }
.hist-btn--cancel {
  background: #fef2f2;
  color: var(--rec-danger);
  border-color: #fecaca;
}
.hist-btn--cancel:hover { background: #fee2e2; }

/* ── Botão Visualizar ── */
.hist-btn--preview {
  background: #f0f9ff;
  color: #0369a1;
  border-color: #bae6fd;
}
.hist-btn--preview:hover { background: #e0f2fe; }

/* ── Botão Reimprimir ── */
.hist-btn--reprint {
  background: #faf5ff;
  color: #7c3aed;
  border-color: #ddd6fe;
}
.hist-btn--reprint:hover { background: #ede9fe; }

/* ── Resumo financeiro no card de recibo ── */
.hist-financial-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--rec-gray-100);
  background: #f8faff;
}
.hist-fin-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}
.hist-fin-chip--gross {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}
.hist-fin-chip--disc {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}
.hist-fin-chip--net {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

/* ── Badge cinza (cancelado nas badges) ── */
.hist-badge--grey {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

/* ── Indicador de desconto na modal de emissão ── */
.rec-financial-summary-box {
  background: #f8faff;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
}
.rec-fin-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  gap: 8px;
}
.rec-fin-row--gross  { color: #64748b; }
.rec-fin-row--disc   { color: #dc2626; font-weight: 600; }
.rec-fin-row--net    {
  color: #1e40af;
  font-weight: 700;
  font-size: 13px;
  grid-column: 1 / -1;
  border-top: 1px solid #bfdbfe;
  padding-top: 6px;
  margin-top: 2px;
}
.rec-fin-label { font-weight: 500; }
.rec-fin-value { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Estado vazio do histórico */
.hist-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--rec-gray-400);
}
.hist-empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--rec-gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 26px;
  color: var(--rec-gray-400);
}
.hist-empty-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--rec-gray-800);
  margin: 0 0 6px;
}
.hist-empty-sub {
  font-size: 13px;
  color: var(--rec-gray-400);
  margin: 0 0 20px;
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
}

/* ================================================================
   7. BOTÃO HISTÓRICO DE RECIBOS na tabela de orçamentos
   ================================================================ */
.btn-receipt-history {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--rec-primary);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 7px;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
  font-family: inherit;
}
.btn-receipt-history:hover { background: #dbeafe; }

/* ================================================================
   8. MODAIS — BOTÕES PADRÃO (reutilizando estilo do app)
   ================================================================ */
.btn-rec {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  white-space: nowrap;
}
.btn-rec:active { transform: scale(.97); }

.btn-rec--primary {
  background: var(--rec-success);
  color: #fff;
  box-shadow: 0 2px 8px rgba(22,163,74,.3);
}
.btn-rec--primary:hover {
  background: #15803d;
  box-shadow: 0 4px 14px rgba(22,163,74,.4);
}
.btn-rec--primary:disabled {
  opacity: .6;
  cursor: not-allowed;
  transform: none;
}

.btn-rec--ghost {
  background: var(--rec-gray-100);
  color: var(--rec-gray-600);
}
.btn-rec--ghost:hover { background: var(--rec-gray-200); }

.btn-rec--danger {
  background: #fef2f2;
  color: var(--rec-danger);
  border: 1px solid #fecaca;
}
.btn-rec--danger:hover { background: #fee2e2; }

/* Spinner de carregamento */
.btn-rec .rec-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: recSpin .7s linear infinite;
  display: none;
}
.btn-rec--loading .rec-spinner { display: inline-block; }
.btn-rec--loading .rec-btn-text { opacity: .6; }
@keyframes recSpin { to { transform: rotate(360deg); } }

/* ================================================================
   9. TOAST / NOTIFICAÇÕES — reutiliza showToast do app.js
   ================================================================ */

/* ================================================================
   10. RESPONSIVO
   ================================================================ */
/* ── 768px: tablet ── */
@media (max-width: 768px) {
  /* Modal do histórico ocupa quase toda a tela */
  .history-modal-overlay { padding: 0; align-items: flex-end; }
  .history-modal-box {
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 96vh;
    margin: 0;
  }
  .history-modal-header { border-radius: 20px 20px 0 0; padding: 16px 18px 14px; }
  .history-modal-body   { padding: 14px 16px; }

  /* Cabeçalho do histórico */
  .history-modal-header-info { flex: 1; min-width: 0; }
  .history-modal-title    { font-size: 15px; }
  .history-modal-subtitle { white-space: normal; font-size: 11px; }

  /* Cards de recibo: layout vertical */
  .hist-item-header       { flex-direction: column; align-items: flex-start; gap: 6px; }
  .hist-item-header-left  { width: 100%; }
  .hist-item-value-wrap   { width: 100%; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .hist-item-value        { font-size: 20px; }

  /* Ações: duas colunas em tablet */
  .hist-item-actions { gap: 6px; }
  .hist-btn          { flex: 1 1 calc(50% - 6px); justify-content: center; min-height: 40px; font-size: 12px; }

  /* Resumo de faturamento */
  .hist-billing-summary { grid-template-columns: 1fr 1fr; gap: 8px; }
}

/* ── 700px: mobile modal ── */
@media (max-width: 700px) {
  .receipt-modal-overlay,
  .bank-modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .receipt-modal-box,
  .bank-modal-box {
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 96vh;
    margin: 0;
  }
  .receipt-modal-header { border-radius: 20px 20px 0 0; }
  .bank-modal-header    { border-radius: 20px 20px 0 0; }

  /* Padding dos corpos */
  .receipt-modal-body  { padding: 16px; }
  .bank-modal-body     { padding: 16px; }

  /* Footer: botões em coluna */
  .receipt-modal-footer {
    padding: 12px 16px 24px;
    flex-direction: column;
    gap: 8px;
  }
  .receipt-modal-footer .btn-rec {
    width: 100%;
    justify-content: center;
    min-height: 48px;
    font-size: 15px;
  }
  .bank-modal-footer {
    padding: 12px 16px 24px;
    flex-direction: column;
    gap: 8px;
  }
  .bank-modal-footer .btn-rec {
    width: 100%;
    justify-content: center;
    min-height: 48px;
  }

  /* Grids do formulário */
  .rec-form-grid        { grid-template-columns: 1fr; }
  .rec-form-grid--3     { grid-template-columns: 1fr 1fr; }
  .rec-estimate-summary { grid-template-columns: 1fr 1fr; }

  /* Banco */
  .rec-bank-selector { flex-direction: column; align-items: stretch; }
  .btn-rec-add-bank  { justify-content: center; min-height: 44px; }
  .btn-rec { min-height: 44px; }
}

/* ── 480px: celular pequeno ── */
@media (max-width: 480px) {
  .rec-form-grid--3     { grid-template-columns: 1fr; }
  .hist-billing-summary { grid-template-columns: 1fr; }
  .rec-estimate-summary { grid-template-columns: 1fr; }
  .rec-bank-card        { padding: 12px; }
  .rec-bank-name        { font-size: 13px; }

  /* Card de recibo: padding menor */
  .hist-item-header  { padding: 12px 14px 10px; }
  .hist-item-details { padding: 8px 14px; }
  .hist-item-actions { padding: 8px 14px 12px; gap: 5px; }

  /* Botões: uma coluna em telas < 480px */
  .hist-btn {
    flex: 1 1 100%;
    justify-content: center;
    min-height: 42px;
    font-size: 13px;
  }

  /* Valor monetário menor */
  .hist-item-value { font-size: 18px; }

  /* Resumo de faturamento: coluna única */
  .hist-sum-item  { padding: 12px; border-radius: 10px; }
  .hist-sum-value { font-size: 15px; }
}

/* ================================================================
   11. ANIMAÇÕES UTILITÁRIAS
   ================================================================ */
.rec-fade-in {
  animation: recFadeIn .25s ease;
}
@keyframes recFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Highlight do campo percentual ao alterar */
.rec-pct-highlight {
  animation: recPctPulse .5s ease;
}
@keyframes recPctPulse {
  0%   { box-shadow: 0 0 0 0   rgba(22,163,74,.4); }
  50%  { box-shadow: 0 0 0 8px rgba(22,163,74,.1); }
  100% { box-shadow: 0 0 0 0   rgba(22,163,74,0);  }
}
