/* ==========================================================================
   A/R (Accounts Receivable) & QuickBooks Reconciliation Module CSS
   Cellador Operations Hub
   ========================================================================== */

.hub-view#view-ar {
  flex: 1;
  height: 100%;
  width: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

#arApp {
  width: 100%;
  min-height: 100%;
}

.ar-container {
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 28px 80px 28px;
  box-sizing: border-box;
  color: #1e293b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Header & Controls Bar */
.ar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.ar-header-left h2 {
  margin: 0 0 6px 0;
  font-size: 24px;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ar-header-left p {
  margin: 0;
  font-size: 13.5px;
  color: #64748b;
}

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

.ar-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  text-decoration: none;
}

.ar-btn-primary {
  background: #2563eb;
  color: #ffffff;
  border-color: #1d4ed8;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}

.ar-btn-primary:hover {
  background: #1d4ed8;
}

.ar-btn-secondary {
  background: #ffffff;
  color: #334155;
  border-color: #cbd5e1;
}

.ar-btn-secondary:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.ar-btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
}

/* Beergang Draft Orders Styling */
.ar-drafts-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 16px;
}

.ar-draft-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
  padding: 20px 24px;
  transition: all 0.2s ease;
}

.ar-draft-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.07);
  border-color: #cbd5e1;
}

.ar-draft-card.has-custom {
  border-left: 5px solid #f59e0b;
}

.ar-draft-card.status-pushed {
  border-left: 5px solid #10b981;
  background: #f8fafc;
}

.ar-draft-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.ar-draft-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ar-draft-title {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.ar-draft-meta {
  font-size: 13px;
  color: #64748b;
}

.ar-draft-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.ar-draft-badge.badge-ready {
  background: #dcfce7;
  color: #15803d;
}

.ar-draft-badge.badge-custom {
  background: #fef3c7;
  color: #b45309;
}

.ar-draft-badge.badge-pushed {
  background: #e0f2fe;
  color: #0369a1;
}

.ar-draft-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
  background: #f8fafc;
  padding: 14px 18px;
  border-radius: 8px;
  border: 1px solid #f1f5f9;
}

.ar-detail-block label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}

.ar-detail-block div {
  font-size: 13.5px;
  color: #1e293b;
  line-height: 1.4;
}

.ar-draft-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 18px;
}

.ar-draft-items-table th {
  background: #f1f5f9;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid #e2e8f0;
}

.ar-draft-items-table td {
  padding: 10px 12px;
  font-size: 13.5px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.ar-draft-items-table tr.custom-item-row {
  background: #fffbeb;
}

.ar-item-custom-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 12px;
  color: #b45309;
}

.ar-draft-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #f1f5f9;
  padding-top: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.ar-draft-total-box {
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
}

.ar-draft-total-val {
  font-size: 20px;
  font-weight: 800;
  color: #10b981;
  margin-left: 6px;
}

.ar-sync-btn.syncing svg {
  animation: ar-spin 1s linear infinite;
}

@keyframes ar-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* KPI Summary Cards Grid */
.ar-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.ar-kpi-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.ar-kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: #cbd5e1;
}

.ar-kpi-card.kpi-total::before { background: #3b82f6; }
.ar-kpi-card.kpi-collectible::before { background: #10b981; }
.ar-kpi-card.kpi-pastdue::before { background: #f59e0b; }
.ar-kpi-card.kpi-credits::before { background: #6366f1; }

.ar-kpi-label {
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ar-kpi-value {
  font-size: 26px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.ar-kpi-sub {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 6px;
}

/* Aging Breakdown Banner */
.ar-aging-section {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.ar-aging-header {
  font-size: 13px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ar-aging-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.ar-aging-pill {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
}

.ar-aging-pill:hover, .ar-aging-pill.active {
  background: #f1f5f9;
  border-color: #3b82f6;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.1);
}

.ar-aging-pill .pill-title {
  font-size: 11.5px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 4px;
}

.ar-aging-pill .pill-amount {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
}

/* Filter Controls Toolbar */
.ar-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 16px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 18px;
}

.ar-search-box {
  position: relative;
  min-width: 280px;
  flex: 1;
}

.ar-search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease;
  box-sizing: border-box;
}

.ar-search-box input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.ar-search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
}

.ar-filter-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.ar-pill {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ar-pill:hover {
  background: #e2e8f0;
}

.ar-pill.active {
  background: #2563eb;
  color: #ffffff;
}

/* Main Ledger Table */
.ar-table-wrapper {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  width: 100%;
  box-sizing: border-box;
}

.ar-table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  text-align: left;
  font-size: 13.5px;
}

.ar-table th {
  background: #f8fafc;
  padding: 12px 16px;
  font-weight: 600;
  color: #475569;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

.ar-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.ar-table tr:last-child td {
  border-bottom: none;
}

.ar-table tr:hover {
  background: #fafafa;
}

.ar-table tr.is-ignored {
  opacity: 0.65;
  background: #f8fafc;
}

.ar-table tr.is-credit {
  background: #f0fdf4;
}

/* Cell Specific Styles */
.ar-customer-cell {
  font-weight: 600;
  color: #0f172a;
}

.ar-customer-email {
  font-size: 12px;
  font-weight: normal;
  color: #64748b;
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ar-customer-email a {
  color: #2563eb;
  text-decoration: none;
}

.ar-customer-email a:hover {
  text-decoration: underline;
}

.ar-credit-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  background: #e0e7ff;
  color: #4338ca;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  margin-top: 4px;
}

.ar-inv-badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 700;
  color: #334155;
  background: #f1f5f9;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.ar-days-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

.ar-days-current { background: #dcfce7; color: #15803d; }
.ar-days-warning { background: #fef3c7; color: #b45309; }
.ar-days-danger { background: #fee2e2; color: #b91c1c; }
.ar-days-severe { background: #7f1d1d; color: #fef2f2; }
.ar-days-credit { background: #e0f2fe; color: #0369a1; }

.ar-balance-val {
  font-weight: 700;
  font-size: 14.5px;
  color: #0f172a;
}

.ar-balance-val.credit-val {
  color: #059669;
}

/* Status Select Dropdown */
.ar-status-select {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
}

.ar-status-select.status-past-due { background: #fffbeb; border-color: #fde68a; color: #b45309; }
.ar-status-select.status-current { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.ar-status-select.status-processing { background: #f5f3ff; border-color: #ddd6fe; color: #6d28d9; }
.ar-status-select.status-ignored { background: #f1f5f9; border-color: #cbd5e1; color: #475569; }
.ar-status-select.status-uncollectible { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.ar-status-select.status-paid { background: #f0fdf4; border-color: #86efac; color: #166534; }
.ar-status-select.status-credit { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }

/* Notes Column & Modal */
.ar-notes-preview {
  max-width: 260px;
  font-size: 12px;
  color: #475569;
  line-height: 1.4;
}

.ar-note-item {
  display: flex;
  gap: 6px;
  margin-bottom: 3px;
}

.ar-note-date {
  font-weight: 700;
  color: #64748b;
  white-space: nowrap;
}

/* Outreach Action Modal */
.ar-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.ar-modal {
  background: #ffffff;
  border-radius: 14px;
  width: 90%;
  max-width: 520px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
  border: 1px solid #e2e8f0;
  overflow: hidden;
  animation: ar-modal-pop 0.2s ease;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.ar-modal.ar-modal-lg {
  max-width: 680px;
}

@keyframes ar-modal-pop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.ar-modal-header {
  padding: 16px 20px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.ar-modal-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ar-modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: #64748b;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.ar-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.ar-modal-footer {
  padding: 14px 20px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.ar-modal-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ar-outreach-summary-banner {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.ar-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 600px) {
  .ar-form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

.ar-btn-send {
  background: #f59e0b;
  color: #1e293b;
  font-weight: 700;
  border-color: #d97706;
}

.ar-btn-send:hover {
  background: #d97706;
  color: #ffffff;
}

.ar-btn-gmail {
  background: #ffffff;
  color: #ea4335;
  border-color: #fca5a5;
}

.ar-btn-gmail:hover {
  background: #fef2f2;
  border-color: #ef4444;
}

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

.ar-form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.ar-form-group input,
.ar-form-group select,
.ar-form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13.5px;
  box-sizing: border-box;
  outline: none;
}

.ar-form-group input:focus,
.ar-form-group select:focus,
.ar-form-group textarea:focus {
  border-color: #2563eb;
}

.ar-quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.ar-chip {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 16px;
  padding: 4px 10px;
  font-size: 12px;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ar-chip:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
  color: #1e293b;
}

/* Row Actions Button Group */
.ar-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.ar-btn-qbo-inv {
  background: #0284c7;
  color: #ffffff;
  border-color: #0369a1;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(2, 132, 199, 0.2);
}

.ar-btn-qbo-inv:hover {
  background: #0369a1;
  border-color: #075985;
}

.ar-btn-qbo-rem {
  background: #d97706;
  color: #ffffff;
  border-color: #b45309;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(217, 119, 6, 0.2);
}

.ar-btn-qbo-rem:hover {
  background: #b45309;
  border-color: #92400e;
}

/* QBO Dispatch Modal Styles */
.ar-modal.ar-modal-invoice {
  border-top: 4px solid #0284c7;
}

.ar-modal.ar-modal-reminder {
  border-top: 4px solid #d97706;
}

.ar-modal-header.header-invoice {
  background: #f0f9ff;
  border-bottom: 1px solid #bae6fd;
}

.ar-modal-header.header-invoice h3 {
  color: #0369a1;
}

.ar-modal-header.header-reminder {
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
}

.ar-modal-header.header-reminder h3 {
  color: #92400e;
}

.ar-qbo-summary-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ar-qbo-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
}

.ar-qbo-summary-row .label {
  color: #64748b;
  font-weight: 600;
}

.ar-qbo-summary-row .value {
  color: #0f172a;
}

.ar-qbo-summary-row .font-bold {
  font-weight: 700;
}

.ar-qbo-info-banner {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
}

.ar-qbo-info-banner.info-invoice {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  color: #0369a1;
}

.ar-qbo-info-banner.info-reminder {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

/* Toast Notification */
.ar-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: ar-toast-slide 0.25s ease;
}

@keyframes ar-toast-slide {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

