/* ============================================================
   PR330 — QuickBooks AP/AR Two-Way Sync Engine
   TradeRail Field Management Portal
   Class prefix: .pr330-
   QB green brand: #2CA01C
   TradeRail brand: #FF6B00, #1A1A2E
   ============================================================ */

/* ── Reset & base ─────────────────────────────────────────── */
.pr330-panel {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: #1A1A2E;
  background: #F9FAFB;
  min-height: 100%;
  padding: 0;
}

/* ── Page header ──────────────────────────────────────────── */
.pr330-page-header {
  background: #FFFFFF;
  border-bottom: 1px solid #E5E7EB;
  padding: 20px 24px 16px;
}

.pr330-page-title {
  font-size: 22px;
  font-weight: 700;
  color: #1A1A2E;
  margin-bottom: 4px;
}

.pr330-page-subtitle {
  font-size: 13px;
  color: #6B7280;
  margin-bottom: 12px;
}

/* ── Lily insight bar ─────────────────────────────────────── */
.pr330-lily-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(90deg, #1A1A2E 0%, #2C2C4E 100%);
  color: #FFFFFF;
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 10px;
  font-size: 13px;
}

.pr330-lily-icon {
  background: #FF6B00;
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.pr330-lily-text {
  flex: 1;
  line-height: 1.4;
}

/* ── Section tabs (Connection / Sync Status / Mapping / Recon) */
.pr330-section-tabs {
  display: flex;
  gap: 0;
  background: #FFFFFF;
  border-bottom: 2px solid #E5E7EB;
  padding: 0 24px;
  overflow-x: auto;
}

.pr330-section-tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 500;
  color: #6B7280;
  cursor: pointer;
  white-space: nowrap;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.pr330-section-tab:hover {
  color: #1A1A2E;
}

.pr330-section-tab--active {
  color: #2CA01C;
  border-bottom-color: #2CA01C;
  font-weight: 600;
}

/* ── Sections ─────────────────────────────────────────────── */
.pr330-section {
  padding: 20px 24px;
}

.pr330-section--hidden {
  display: none;
}

.pr330-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.pr330-section-title {
  font-size: 16px;
  font-weight: 600;
  color: #1A1A2E;
}

/* ── Connection card ──────────────────────────────────────── */
.pr330-conn-card {
  background: #FFFFFF;
  border-radius: 10px;
  border: 2px solid #E5E7EB;
  padding: 20px;
  max-width: 640px;
}

.pr330-conn-card--connected {
  border-color: #2CA01C;
}

.pr330-conn-card--disconnected {
  border-color: #CC0000;
}

.pr330-conn-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.pr330-conn-status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pr330-dot-green {
  background: #2CA01C;
}

.pr330-dot-red {
  background: #CC0000;
}

.pr330-conn-status-text {
  font-size: 15px;
  font-weight: 600;
  color: #1A1A2E;
}

.pr330-token-warning {
  background: #FEF3C7;
  border: 1px solid #F59E0B;
  color: #92400E;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

.pr330-conn-detail {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #F3F4F6;
  font-size: 13px;
}

.pr330-conn-detail:last-of-type {
  border-bottom: none;
}

.pr330-conn-label {
  color: #6B7280;
  min-width: 120px;
}

.pr330-conn-value {
  color: #1A1A2E;
  font-weight: 500;
}

.pr330-conn-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Frequency selector ───────────────────────────────────── */
.pr330-freq-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 0;
}

.pr330-field-label {
  font-size: 13px;
  color: #6B7280;
  min-width: 120px;
}

/* ── KPI tiles ────────────────────────────────────────────── */
.pr330-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.pr330-kpi-tile {
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  padding: 16px 14px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.pr330-kpi-value {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
  color: #1A1A2E;
}

.pr330-kpi-synced { color: #16A34A; }
.pr330-kpi-pending { color: #D97706; }
.pr330-kpi-error { color: #CC0000; }
.pr330-kpi-time { font-size: 13px; font-weight: 600; color: #374151; }

.pr330-kpi-label {
  font-size: 12px;
  color: #6B7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Filter tabs ──────────────────────────────────────────── */
.pr330-filter-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.pr330-tab-btn {
  background: #F3F4F6;
  border: 1px solid #E5E7EB;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.pr330-tab-btn:hover {
  background: #E5E7EB;
}

.pr330-tab-active {
  background: #1A1A2E;
  color: #FFFFFF;
  border-color: #1A1A2E;
}

/* ── Table ────────────────────────────────────────────────── */
.pr330-table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid #E5E7EB;
  background: #FFFFFF;
}

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

.pr330-table thead tr {
  background: #F9FAFB;
  border-bottom: 1px solid #E5E7EB;
}

.pr330-table th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  color: #374151;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.pr330-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #F3F4F6;
  vertical-align: top;
  color: #1A1A2E;
}

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

.pr330-table tbody tr:hover {
  background: #F9FAFB;
}

.pr330-row-error {
  background: #FEF2F2;
}

.pr330-row-error:hover {
  background: #FEE2E2;
}

.pr330-error-msg {
  color: #CC0000;
  font-size: 12px;
  margin-top: 3px;
}

.pr330-entity-label {
  max-width: 280px;
}

.pr330-entity-link {
  color: #1A1A2E;
  text-decoration: none;
  font-weight: 500;
}

.pr330-entity-link:hover {
  color: #FF6B00;
  text-decoration: underline;
}

.pr330-qbid {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 12px;
  color: #6B7280;
}

.pr330-actions-cell {
  white-space: nowrap;
}

/* ── Badges ───────────────────────────────────────────────── */
.pr330-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pr330-badge-synced {
  background: #DCFCE7;
  color: #16A34A;
}

.pr330-badge-pending {
  background: #FEF3C7;
  color: #D97706;
}

.pr330-badge-error {
  background: #FEE2E2;
  color: #CC0000;
}

.pr330-badge-push {
  background: #DBEAFE;
  color: #2563EB;
}

.pr330-badge-pull {
  background: #EDE9FE;
  color: #7C3AED;
}

.pr330-badge-sandbox {
  background: #FEF3C7;
  color: #92400E;
}

.pr330-badge-production {
  background: #DCFCE7;
  color: #166534;
}

/* ── Buttons ──────────────────────────────────────────────── */
.pr330-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, opacity 0.15s;
}

.pr330-btn-primary {
  background: #FF6B00;
  color: #FFFFFF;
}

.pr330-btn-primary:hover {
  background: #E05E00;
}

.pr330-btn-secondary {
  background: #F3F4F6;
  color: #374151;
  border: 1px solid #D1D5DB;
}

.pr330-btn-secondary:hover {
  background: #E5E7EB;
}

.pr330-btn-danger {
  background: #CC0000;
  color: #FFFFFF;
}

.pr330-btn-danger:hover {
  background: #AA0000;
}

.pr330-btn-danger-sm {
  background: #CC0000;
  color: #FFFFFF;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

.pr330-btn-ghost-sm {
  background: transparent;
  color: #374151;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #D1D5DB;
}

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

.pr330-btn-retry {
  background: #DBEAFE;
  color: #1D4ED8;
  border: 1px solid #BFDBFE;
}

.pr330-btn-retry:hover {
  background: #BFDBFE;
}

.pr330-btn-map {
  background: #EDE9FE;
  color: #5B21B6;
  border: 1px solid #DDD6FE;
}

.pr330-btn-map:hover {
  background: #DDD6FE;
}

/* ── Disconnect confirm (two-tap) ─────────────────────────── */
.pr330-confirm-pending {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #374151;
}

.pr330-confirm-disconnect {
  display: none;
}

/* ── Mapping panel ────────────────────────────────────────── */
.pr330-mapping-panel {
  background: #FFFFFF;
  border-radius: 8px;
  border: 1px solid #E5E7EB;
  padding: 16px;
}

.pr330-mapping-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.pr330-mapping-toolbar {
  margin-bottom: 14px;
}

.pr330-mapping-table {
  width: 100%;
}

.pr330-unmapped-text {
  color: #9CA3AF;
  font-style: italic;
}

/* ── Selects ──────────────────────────────────────────────── */
.pr330-select {
  padding: 6px 10px;
  border: 1px solid #D1D5DB;
  border-radius: 6px;
  font-size: 13px;
  color: #374151;
  background: #FFFFFF;
  cursor: pointer;
  min-width: 180px;
}

.pr330-select-sm {
  padding: 4px 8px;
  font-size: 12px;
  min-width: 140px;
}

.pr330-select:focus {
  outline: 2px solid #2CA01C;
  outline-offset: 1px;
}

/* ── Reconciliation panel ─────────────────────────────────── */
.pr330-recon-panel {
  background: #FFFFFF;
  border-radius: 8px;
  border: 1px solid #E5E7EB;
  padding: 20px;
}

.pr330-recon-summary {
  margin-bottom: 20px;
}

.pr330-recon-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.pr330-recon-col {
  background: #F9FAFB;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  padding: 14px;
}

.pr330-recon-heading {
  font-size: 14px;
  font-weight: 600;
  color: #1A1A2E;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #E5E7EB;
}

.pr330-recon-detail {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 13px;
  color: #374151;
}

.pr330-recon-match {
  color: #16A34A;
  font-weight: 600;
}

.pr330-recon-diff {
  color: #CC0000;
  font-weight: 600;
}

.pr330-recon-unmatched {
  margin-bottom: 16px;
}

.pr330-unmatched-item {
  padding: 7px 10px;
  font-size: 13px;
  color: #374151;
  background: #FEF9F0;
  border-left: 3px solid #FF6B00;
  margin-bottom: 5px;
  border-radius: 0 4px 4px 0;
}

.pr330-recon-actions {
  padding-top: 16px;
  border-top: 1px solid #E5E7EB;
}

/* ── Empty state ──────────────────────────────────────────── */
.pr330-empty-state {
  text-align: center;
  padding: 32px 16px;
  color: #9CA3AF;
  font-size: 14px;
  background: #FFFFFF;
  border-radius: 8px;
  border: 1px solid #E5E7EB;
}

/* ── Access denied ────────────────────────────────────────── */
.pr330-access-denied {
  text-align: center;
  padding: 48px 24px;
  color: #9CA3AF;
  font-size: 15px;
  background: #FFFFFF;
  border-radius: 10px;
  border: 1px solid #E5E7EB;
  margin: 24px;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 767px) {
  .pr330-kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .pr330-recon-row {
    grid-template-columns: 1fr;
  }

  .pr330-page-header {
    padding: 14px 16px 12px;
  }

  .pr330-section {
    padding: 14px 16px;
  }

  .pr330-page-title {
    font-size: 18px;
  }

  .pr330-conn-card {
    max-width: 100%;
  }

  .pr330-section-tabs {
    padding: 0 12px;
  }

  .pr330-section-tab {
    padding: 10px 10px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .pr330-kpi-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .pr330-table th,
  .pr330-table td {
    padding: 8px 10px;
  }

  .pr330-btn {
    padding: 7px 12px;
    font-size: 12px;
  }
}
