/* Contas a Receber (FP-206B) — skin claro ReserveX, escopado em .ar-shell / .ar-modal. */

.ar-shell {
  display: flex;
  flex-direction: column;
  gap: 18px;
  color: #0f172a;
}

.ar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.ar-head h2 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.ar-head p {
  margin: 0;
  color: #64748b;
  font-size: 13px;
}

/* KPIs ------------------------------------------------------------------ */
.ar-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}
.ar-kpi {
  background: #fff;
  border: 1px solid #e6eaf0;
  border-radius: 16px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  border-top: 3px solid #cbd5e1;
}
.ar-kpi.is-accent { border-top-color: #2563eb; }
.ar-kpi.is-danger { border-top-color: #dc2626; }
.ar-kpi.is-warn { border-top-color: #d97706; }
.ar-kpi.is-partial { border-top-color: #d97706; background: linear-gradient(180deg, #fffbeb 0%, #fff 48%); }
.ar-kpi[data-ar-filter-status] { cursor: pointer; transition: box-shadow 0.15s ease, transform 0.12s ease, border-color 0.15s ease; }
.ar-kpi[data-ar-filter-status]:hover { box-shadow: 0 4px 14px rgba(15, 23, 42, 0.1); transform: translateY(-1px); }
.ar-kpi.is-active {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.22), 0 4px 14px rgba(37, 99, 235, 0.12);
}
.ar-kpi.is-danger.is-active { border-color: #dc2626; box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2); }
.ar-kpi.is-warn.is-active,
.ar-kpi.is-partial.is-active { border-color: #d97706; box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.22); }
.ar-kpi small {
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.ar-kpi strong {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.ar-kpi-meta {
  font-size: 12px;
  color: #94a3b8;
}

/* Toolbar --------------------------------------------------------------- */
.ar-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  background: #fff;
  border: 1px solid #e6eaf0;
  border-radius: 14px;
  padding: 14px 16px;
}
.ar-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}
.ar-field--search { flex: 1 1 220px; }
.ar-field input,
.ar-field select,
.ar-field textarea {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  color: #0f172a;
  background: #fff;
  font-weight: 500;
}
.ar-field input:focus,
.ar-field select:focus,
.ar-field textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.ar-refresh { align-self: flex-end; }

/* Table ----------------------------------------------------------------- */
.ar-table-wrap {
  background: #fff;
  border: 1px solid #e6eaf0;
  border-radius: 16px;
  overflow: hidden;
}
.ar-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.ar-table thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
  background: #f8fafc;
  border-bottom: 1px solid #eef2f7;
  font-weight: 700;
}
.ar-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.ar-table tbody tr {
  cursor: pointer;
  transition: background 0.12s ease;
}
.ar-table tbody tr:hover { background: #f8fafc; }
.ar-table tbody tr:last-child td { border-bottom: none; }
.ar-table td strong { font-weight: 700; display: block; }
.ar-sub { color: #94a3b8; font-size: 12px; }
.ar-num { text-align: right; white-space: nowrap; }
.ar-strong { font-weight: 800; color: #0f172a; }
.ar-td-actions { text-align: right; }
.ar-td-status { white-space: nowrap; text-align: center; }
.ar-table thead th:first-child { text-align: center; }

/* Badges ---------------------------------------------------------------- */
.ar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
  min-width: 4.75rem;
  box-sizing: border-box;
  background: #eef2f7;
  color: #475569;
}
.ar-badge.is-open { background: #dbeafe; color: #1d4ed8; }
.ar-badge.is-partial { background: #fef3c7; color: #b45309; }
.ar-badge.is-overdue { background: #fee2e2; color: #b91c1c; }
.ar-badge.is-paid { background: #dcfce7; color: #15803d; }
.ar-badge.is-cancelled { background: #f1f5f9; color: #64748b; }
.ar-badge.is-writtenoff { background: #ede9fe; color: #6d28d9; }

/* Buttons (escopados para o skin claro) --------------------------------- */
.ar-shell .btn-primary,
.ar-modal .btn-primary {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 9px 16px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.ar-shell .btn-primary:hover,
.ar-modal .btn-primary:hover { background: #1d4ed8; }
.ar-shell .btn-primary:disabled,
.ar-modal .btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.ar-shell .btn-ghost,
.ar-modal .btn-ghost {
  background: #fff;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 9px 16px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.ar-shell .btn-ghost:hover,
.ar-modal .btn-ghost:hover { background: #f1f5f9; }
.ar-btn-sm { padding: 6px 12px !important; font-size: 13px !important; }
.ar-modal .ar-danger,
.ar-shell .ar-danger { color: #b91c1c; border-color: #fecaca; }
.ar-modal .ar-danger:hover,
.ar-shell .ar-danger:hover { background: #fef2f2; }
.ar-danger-btn { background: #dc2626 !important; }
.ar-danger-btn:hover { background: #b91c1c !important; }

/* Empty / loading ------------------------------------------------------- */
.ar-empty {
  background: #fff;
  border: 1px dashed #cbd5e1;
  border-radius: 16px;
  padding: 36px 24px;
  text-align: center;
  color: #64748b;
}
.ar-empty strong { display: block; font-size: 16px; color: #334155; margin-bottom: 6px; }
.ar-empty p { margin: 0; font-size: 13px; }
.ar-empty--denied { border-style: solid; border-color: #fed7aa; background: #fffbeb; }

.ar-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #64748b;
  padding: 24px;
  font-size: 14px;
}
.ar-spinner {
  width: 16px; height: 16px;
  border: 2px solid #cbd5e1;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: ar-spin 0.7s linear infinite;
}
@keyframes ar-spin { to { transform: rotate(360deg); } }

.ar-feedback {
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
}
.ar-feedback[data-tone="success"] { background: #dcfce7; color: #166534; }
.ar-feedback[data-tone="error"] { background: #fee2e2; color: #991b1b; }

/* Modal ----------------------------------------------------------------- */
.ar-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 3000;
}
.ar-modal-backdrop[hidden] { display: none; }
body.ar-modal-open { overflow: hidden; }
.ar-modal {
  background: #fff;
  border-radius: 18px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
  overflow: hidden;
  color: #0f172a;
}
.ar-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #eef2f7;
}
.ar-modal-head h3 { margin: 0; font-size: 17px; font-weight: 800; }
.ar-modal-close {
  background: #f1f5f9;
  border: none;
  border-radius: 8px;
  width: 30px; height: 30px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: #64748b;
}
.ar-modal-close:hover { background: #e2e8f0; }
.ar-modal-body { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.ar-modal-note { margin: 0; font-size: 13px; color: #64748b; }
.ar-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.ar-form { display: flex; flex-direction: column; gap: 12px; }
.ar-form-msg {
  background: #fee2e2;
  color: #991b1b;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
}

/* Detalhe --------------------------------------------------------------- */
.ar-detail { display: flex; flex-direction: column; gap: 2px; }
.ar-detail-top { margin-bottom: 10px; }
.ar-detail-top h3 { margin: 8px 0 2px; font-size: 16px; }
.ar-detail-cust { margin: 0; color: #64748b; font-size: 13px; }
.ar-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 14px;
}
.ar-detail-row span { color: #64748b; }
.ar-detail-row strong { font-weight: 700; text-align: right; }

/* Receber — resultado --------------------------------------------------- */
.ar-receive-ok {
  background: #dcfce7;
  color: #166534;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  font-weight: 800;
  font-size: 16px;
}
.ar-alloc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ar-alloc-list li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  background: #f8fafc;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
}
.ar-alloc-list li strong { font-weight: 800; }
.ar-alloc-list li em { font-style: normal; color: #64748b; font-size: 12px; }
.ar-hub-ok { color: #15803d; font-weight: 800; }

/* Timeline -------------------------------------------------------------- */
.ar-timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.ar-timeline li { display: flex; gap: 12px; align-items: flex-start; }
.ar-timeline-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #2563eb;
  margin-top: 4px;
  flex-shrink: 0;
}
.ar-timeline strong { display: block; font-size: 14px; }
.ar-timeline small { color: #94a3b8; font-size: 12px; }

/* KPI 'A receber' nos dashboards existentes ----------------------------- */
.fl-pay-kpi.is-receivable { border-color: rgba(37, 99, 235, 0.35); }

@media (max-width: 1100px) {
  .ar-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .ar-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .ar-kpis { grid-template-columns: 1fr; }
  .ar-table thead { display: none; }
  .ar-table, .ar-table tbody, .ar-table tr, .ar-table td { display: block; width: 100%; }
  .ar-table tbody tr { padding: 8px 4px; border-bottom: 1px solid #eef2f7; }
  .ar-table tbody td { border: none; padding: 4px 12px; text-align: left; }
  .ar-num { text-align: left; }
}
