/* ================================================================
   Conciliação de Retenções — Portal de Suprimentos
   ================================================================ */
#page-retencoes.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.ret-page-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header */
.ret-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.ret-header h1 {
  font-size: 21px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.ret-header p {
  font-size: 13px;
  color: var(--muted);
  margin: 4px 0 0;
  max-width: 520px;
}

.ret-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* Competência bar */
.ret-competencia-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 18px;
  flex-wrap: wrap;
}

.ret-competencia-bar label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
}

.ret-competencia-bar select,
.ret-competencia-bar input[type="month"] {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
}

/* KPI Cards */
.ret-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}

.ret-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ret-kpi-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
}

.ret-kpi-value {
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.ret-kpi.danger .ret-kpi-value  { color: #c0392b; }
.ret-kpi.warning .ret-kpi-value { color: #a36a00; }
.ret-kpi.success .ret-kpi-value { color: var(--accent); }

/* Tabs */
.ret-tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
}

.ret-tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.ret-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.ret-tab:hover:not(.active) { color: var(--text); }

/* Upload Area */
.ret-upload-area {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}

.ret-upload-area:hover,
.ret-upload-area.dragover {
  border-color: var(--accent);
  background: #f0faf7;
}

.ret-upload-area h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 12px 0 4px;
}

.ret-upload-area p {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.ret-upload-icon {
  font-size: 36px;
  display: block;
  margin-bottom: 4px;
}

/* Queue */
.ret-queue-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 20px 16px;
}

.ret-queue-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
}

.ret-queue-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ret-queue-item-size {
  font-size: 11px;
  color: var(--muted);
}

.ret-progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 5px;
  grid-column: 1 / -1;
}

.ret-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width .3s;
}

/* Status Badges */
.ret-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.ret-badge.extraido    { background: #e8f5e9; color: #2e7d32; }
.ret-badge.revisao     { background: #fff3e0; color: #e65100; }
.ret-badge.validado    { background: #e3f2fd; color: #1565c0; }
.ret-badge.erro        { background: #ffebee; color: #c62828; }
.ret-badge.duplicado   { background: #f3e5f5; color: #6a1b9a; }
.ret-badge.pendente    { background: #f5f5f5; color: #757575; }

.ret-badge.pago        { background: #e8f5e9; color: #2e7d32; }
.ret-badge.prevista    { background: #e3f2fd; color: #1565c0; }
.ret-badge.vencida     { background: #ffebee; color: #c62828; }
.ret-badge.parcial     { background: #fff8e1; color: #f57f17; }
.ret-badge.cancelada   { background: #f5f5f5; color: #757575; }

.ret-badge.conciliado  { background: #e8f5e9; color: #1b5e20; }
.ret-badge.ressalva    { background: #fff8e1; color: #e65100; }
.ret-badge.ag-pgto     { background: #e3f2fd; color: #1565c0; }
.ret-badge.ag-guia     { background: #fff3e0; color: #e65100; }
.ret-badge.divergencia { background: #ffebee; color: #c62828; }
.ret-badge.em-revisao  { background: #f3e5f5; color: #6a1b9a; }

/* Table Container */
.ret-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.ret-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.ret-table-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.ret-table-scroll { overflow-x: auto; }

.ret-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ret-table th {
  padding: 9px 13px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--bg);
}

.ret-table td {
  padding: 10px 13px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.ret-table tr:last-child td { border-bottom: none; }
.ret-table tr:hover td      { background: var(--bg); }

.ret-table .mono {
  font-family: 'Courier New', monospace;
  font-size: 12px;
}

.ret-table .right  { text-align: right; }
.ret-table .center { text-align: center; }

.ret-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.ret-btn {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  color: var(--text);
  transition: background .15s;
  white-space: nowrap;
}
.ret-btn:hover          { background: var(--surface); }
.ret-btn.primary        { background: var(--accent); color: #fff; border-color: var(--accent); }
.ret-btn.primary:hover  { opacity: .9; }
.ret-btn.danger         { color: #c0392b; border-color: #f5c2c7; }
.ret-btn.danger:hover   { background: #ffebee; }

/* Filters inline */
.ret-inline-filter {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
}

/* Modal */
.ret-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(23,32,44,.65);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.ret-modal-overlay.open { display: flex; }

.ret-modal {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 740px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  display: flex;
  flex-direction: column;
}

.ret-modal.wide { max-width: 1050px; }

.ret-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}

.ret-modal-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.ret-modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
}
.ret-modal-close:hover { background: var(--bg); }

.ret-modal-body {
  padding: 22px 24px;
  flex: 1;
}

.ret-modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
}

/* Form */
.ret-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

.ret-form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ret-form-group label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.ret-form-group input,
.ret-form-group select,
.ret-form-group textarea {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  width: 100%;
  box-sizing: border-box;
}

.ret-form-group textarea { resize: vertical; }

.ret-form-group input.low-confidence {
  border-color: #f57f17;
  background: #fffde7;
}

.ret-form-section {
  margin-bottom: 18px;
}

.ret-form-section h4 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* Notice */
.ret-notice {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 12px;
  color: #5d4037;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  line-height: 1.5;
}

/* Divergence list */
.ret-div-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.ret-div-item:last-child { border-bottom: none; }

.ret-div-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.ret-div-dot.critico { background: #c62828; }
.ret-div-dot.alto    { background: #e65100; }
.ret-div-dot.medio   { background: #f57f17; }
.ret-div-dot.baixo   { background: #0f7b5f; }

/* Empty */
.ret-empty {
  text-align: center;
  padding: 56px 32px;
  color: var(--muted);
}

.ret-empty .ret-empty-icon { font-size: 40px; display: block; margin-bottom: 8px; }
.ret-empty h3 { font-size: 15px; font-weight: 600; color: var(--text); margin: 0 0 4px; }
.ret-empty p  { margin: 0; font-size: 13px; }

/* Responsive */
@media (max-width: 768px) {
  .ret-page-body   { padding: 14px; }
  .ret-kpi-grid    { grid-template-columns: repeat(2, 1fr); }
  .ret-header      { flex-direction: column; }
  .ret-table th, .ret-table td { padding: 7px 9px; }
}
