:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #818cf8;
  --success: #10b981;
  --success-dark: #059669;
  --warning: #f59e0b;
  --warning-dark: #d97706;
  --error: #ef4444;
  --error-dark: #dc2626;
  --info: #0ea5e9;
  --info-dark: #0284c7;
  --purple: #8b5cf6;
  --purple-dark: #7c3aed;
  --pink: #ec4899;
  --pink-dark: #db2777;
  --teal: #14b8a6;
  --teal-dark: #0d9488;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  min-height: 100vh;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-200);
}

header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-900);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--gray-500);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gray-400);
}

.status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.status-dot.disconnected {
  background: var(--error);
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--gray-200);
  color: var(--gray-700);
}

.btn-secondary:hover {
  background: var(--gray-300);
}

.btn-info {
  background: var(--info);
  color: white;
}

.btn-info:hover {
  background: var(--info-dark);
}

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-warning:hover {
  background: var(--warning-dark);
}

.btn-danger {
  background: var(--error);
  color: white;
}

.btn-danger:hover {
  background: var(--error-dark);
}

.btn-purple {
  background: var(--purple);
  color: white;
}

.btn-purple:hover {
  background: var(--purple-dark);
}

.btn-teal {
  background: var(--teal);
  color: white;
}

.btn-teal:hover {
  background: var(--teal-dark);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* Tab Navigation */
.tab-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: white;
  padding: 4px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.tab-btn {
  padding: 10px 20px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

.tab-btn.active {
  background: var(--primary);
  color: white;
}

/* Tab Content */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Table Styles */
.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.table-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--gray-800);
}

.table-container {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  overflow: hidden;
}

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

.data-table thead {
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--gray-700);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-800);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background: var(--gray-50);
}

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

.data-table .uuid {
  font-family: monospace;
  font-size: 11px;
  color: var(--gray-500);
}

.data-table .stage-cell {
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  display: inline-block;
}

.data-table .stage-complete {
  background: #d1fae5;
  color: #065f46;
}

.data-table .stage-error {
  background: #fee2e2;
  color: #991b1b;
}

.data-table .stage-active {
  background: #dbeafe;
  color: #1e40af;
}

.data-table .stage-warning {
  background: #fef3c7;
  color: #92400e;
}

.data-table .stage-info {
  background: #e0f2fe;
  color: #075985;
}

.data-table .stage-purple {
  background: #ede9fe;
  color: #5b21b6;
}

.data-table .stage-teal {
  background: #ccfbf1;
  color: #115e59;
}

.data-table .json-btn {
  padding: 4px 8px;
  font-size: 11px;
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  cursor: pointer;
  color: var(--gray-600);
}

.data-table .json-btn:hover {
  background: var(--gray-200);
}

.data-table .empty-row td {
  text-align: center;
  color: var(--gray-500);
  padding: 40px;
}

/* JSON Modal */
.modal-lg {
  max-width: 700px;
}

.json-viewer {
  background: var(--gray-900);
  color: #a5f3fc;
  padding: 16px;
  border-radius: 8px;
  overflow: auto;
  max-height: 400px;
  font-family: monospace;
  font-size: 12px;
  margin: 16px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Stats Bar */
.stats-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.stat {
  background: white;
  padding: 16px 24px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  min-width: 120px;
  border-left: 4px solid var(--gray-300);
}

.stat:nth-child(1) {
  border-left-color: var(--primary);
}

.stat:nth-child(2) {
  border-left-color: var(--info);
}

.stat:nth-child(3) {
  border-left-color: var(--success);
}

.stat:nth-child(4) {
  border-left-color: var(--error);
}

.stat-value {
  display: block;
  font-size: 32px;
  font-weight: 700;
  color: var(--gray-900);
}

.stat:nth-child(1) .stat-value { color: var(--primary); }
.stat:nth-child(2) .stat-value { color: var(--info); }
.stat:nth-child(3) .stat-value { color: var(--success); }
.stat:nth-child(4) .stat-value { color: var(--error); }

.stat-label {
  font-size: 14px;
  color: var(--gray-500);
}

/* Task Grid */
.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 20px;
}

/* Empty State */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state h3 {
  color: var(--gray-700);
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--gray-500);
}

/* Task Card */
.task-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.task-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.task-card.error {
  border-left: 4px solid var(--error);
}

.task-card.complete {
  border-left: 4px solid var(--success);
}

.task-card.pending-payment {
  border-left: 4px solid #d97706;
  background: linear-gradient(to right, #fffbeb 0%, white 50px);
}

/* Error message display on task cards */
.error-message {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 10px 16px;
  font-size: 13px;
  border-radius: 0;
  margin: 0;
}

.card-header {
  padding: 16px;
  border-bottom: 1px solid var(--gray-100);
}

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--gray-900);
}

.card-header .email {
  font-size: 14px;
  color: var(--gray-500);
}

.card-header .task-id {
  font-size: 12px;
  color: var(--gray-400);
  font-family: monospace;
  margin-top: 4px;
}

/* Progress Tracker (Pizza Tracker) */
.progress-tracker {
  padding: 20px 16px;
}

.progress-steps {
  display: flex;
  justify-content: space-between;
  position: relative;
  margin-bottom: 8px;
}

.progress-steps::before {
  content: '';
  position: absolute;
  top: 12px;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gray-200);
  z-index: 0;
}

.progress-line {
  position: absolute;
  top: 12px;
  left: 0;
  height: 4px;
  background: var(--success);
  z-index: 1;
  transition: width 0.5s ease;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 2;
}

.step-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: var(--gray-200);
  color: var(--gray-400);
  margin-bottom: 6px;
  transition: all 0.3s;
}

.step.completed .step-icon {
  background: var(--success);
  color: white;
}

.step.active .step-icon {
  background: var(--primary);
  color: white;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.2);
  animation: pulse 2s infinite;
}

.step.error .step-icon {
  background: var(--error);
  color: white;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.2); }
  50% { box-shadow: 0 0 0 8px rgba(79, 70, 229, 0.1); }
}

.step-label {
  font-size: 10px;
  color: var(--gray-500);
  text-align: center;
  max-width: 60px;
}

.step.completed .step-label,
.step.active .step-label {
  color: var(--gray-700);
  font-weight: 500;
}

/* Card Footer */
.card-footer {
  padding: 12px 16px;
  background: var(--gray-50);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--gray-500);
}

.stage-badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-weight: 500;
  text-transform: uppercase;
  font-size: 10px;
}

.stage-badge.success {
  background: #d1fae5;
  color: #065f46;
}

.stage-badge.error {
  background: #fee2e2;
  color: #991b1b;
}

.stage-badge.active {
  background: #dbeafe;
  color: #1e40af;
}

.stage-badge.pending {
  background: var(--gray-200);
  color: var(--gray-600);
}

.stage-badge.warning {
  background: #fef3c7;
  color: #92400e;
}

.stage-badge.info {
  background: #e0f2fe;
  color: #075985;
}

.stage-badge.purple {
  background: #ede9fe;
  color: #5b21b6;
}

.stage-badge.teal {
  background: #ccfbf1;
  color: #115e59;
}

.stage-badge.payment {
  background: #fef3c7;
  color: #d97706;
  animation: pulse-payment 2s infinite;
}

@keyframes pulse-payment {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.open {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--gray-400);
}

.modal-close:hover {
  color: var(--gray-600);
}

form {
  padding: 20px;
}

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

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--gray-700);
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 14px;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1001;
}

.toast {
  background: var(--gray-800);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease;
  max-width: 350px;
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--error);
}

.toast.info {
  background: var(--info);
}

.toast.warning {
  background: var(--warning);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .task-grid {
    grid-template-columns: 1fr;
  }
  
  .stats-bar {
    flex-wrap: wrap;
  }
  
  .stat {
    flex: 1;
    min-width: 100px;
  }
  
  header {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }
  
  .header-actions {
    width: 100%;
    justify-content: center;
  }
}

/* ===================== */
/* CREATE TASK FORM      */
/* ===================== */

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #059669;
}

.modal-lg {
  max-width: 700px;
}

.form-section {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--gray-200);
}

.form-section:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
}

.form-section h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 16px;
}

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

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

.form-hint {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 12px;
}

/* Document Upload Area */
.doc-upload-area {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
}

.upload-dropzone {
  padding: 32px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  cursor: pointer;
  transition: all 0.2s;
}

.upload-dropzone:hover {
  background: var(--gray-100);
}

.upload-dropzone.drag-over {
  background: #ede9fe;
  border-color: var(--primary);
}

.dropzone-content {
  text-align: center;
}

.dropzone-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}

.dropzone-content p {
  color: var(--gray-600);
  margin-bottom: 4px;
}

.dropzone-hint {
  font-size: 13px;
  color: var(--gray-400);
}

/* Document List */
.doc-list {
  max-height: 250px;
  overflow-y: auto;
}

.doc-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  gap: 12px;
}

.doc-item:last-child {
  border-bottom: none;
}

.doc-icon {
  font-size: 24px;
}

.doc-info {
  flex: 1;
  min-width: 0;
}

.doc-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-size {
  font-size: 12px;
  color: var(--gray-500);
}

.doc-type-select {
  padding: 6px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 12px;
  background: white;
  color: var(--gray-700);
}

.doc-remove {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--gray-100);
  border-radius: 6px;
  cursor: pointer;
  color: var(--gray-500);
  font-size: 16px;
  transition: all 0.2s;
}

.doc-remove:hover {
  background: var(--error);
  color: white;
}

/* Empty doc list state */
.doc-list-empty {
  padding: 24px;
  text-align: center;
  color: var(--gray-400);
  font-size: 13px;
}

/* Textarea */
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.2s;
}

textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* Button loading state */
.btn-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-loading::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===================== */
/* SIGNER PORTAL         */
/* ===================== */

.signer-portal {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 24px;
}

.portal-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-200);
}

.portal-header h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}

.portal-description {
  color: var(--gray-500);
  font-size: 14px;
  line-height: 1.5;
}

.portal-content {
  max-width: 600px;
}

.portal-section {
  margin-bottom: 24px;
}

.portal-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.portal-select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 14px;
  background: white;
  cursor: pointer;
}

.portal-select:focus {
  outline: none;
  border-color: var(--primary);
}

.signer-info-card {
  background: var(--gray-50);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
}

.info-row {
  display: flex;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-200);
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  font-weight: 500;
  color: var(--gray-600);
  width: 100px;
  flex-shrink: 0;
}

.info-value {
  color: var(--gray-800);
  word-break: break-all;
}

.signer-link-box {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.signer-link-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 13px;
  font-family: monospace;
  background: var(--gray-50);
  color: var(--gray-700);
}

.portal-actions {
  text-align: center;
  padding: 24px;
  background: linear-gradient(135deg, #e0f2fe 0%, #ddd6fe 100%);
  border-radius: 12px;
}

.btn-lg {
  padding: 16px 32px;
  font-size: 16px;
  font-weight: 600;
}

.portal-note {
  margin-top: 16px;
  font-size: 13px;
  color: var(--gray-600);
  line-height: 1.6;
  text-align: left;
  background: white;
  padding: 12px 16px;
  border-radius: 8px;
  border-left: 3px solid var(--primary);
}

/* ===== Webhook Simulator Panel ===== */
.simulator-panel {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.simulator-header h2 {
  font-size: 24px;
  margin-bottom: 8px;
}

.simulator-description {
  color: var(--gray-600);
  margin-bottom: 16px;
  font-size: 14px;
}

.simulator-warning {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #f59e0b;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: #92400e;
}

.rescan-result {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
}

.rescan-result.success {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  border: 1px solid #10b981;
  color: #065f46;
}

.rescan-result.error {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  border: 1px solid #ef4444;
  color: #991b1b;
}

.simulator-content {
  margin-top: 24px;
}

.simulator-section {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--gray-200);
}

.simulator-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.simulator-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--gray-700);
}

.section-description {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 16px;
}

.task-info-mini {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.info-badge {
  display: inline-block;
  padding: 4px 12px;
  background: var(--gray-100);
  border-radius: 16px;
  font-size: 12px;
  color: var(--gray-700);
}

/* Workflow buttons */
.workflow-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.workflow-step {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-workflow {
  min-width: 220px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  background: var(--gray-100);
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-workflow:hover {
  background: var(--gray-200);
  border-color: var(--gray-300);
}

.btn-workflow.btn-success {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  border-color: var(--success);
  color: #065f46;
}

.btn-workflow.btn-success:hover {
  background: linear-gradient(135deg, #a7f3d0 0%, #6ee7b7 100%);
}

.btn-workflow.btn-danger {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  border-color: var(--error);
  color: #991b1b;
}

.btn-workflow.btn-danger:hover {
  background: linear-gradient(135deg, #fecaca 0%, #fca5a5 100%);
}

.btn-workflow.btn-info {
  background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
  border-color: var(--info);
  color: #075985;
}

.btn-workflow.btn-info:hover {
  background: linear-gradient(135deg, #bae6fd 0%, #7dd3fc 100%);
}

.btn-workflow.btn-purple {
  background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
  border-color: var(--purple);
  color: #5b21b6;
}

.btn-workflow.btn-purple:hover {
  background: linear-gradient(135deg, #ddd6fe 0%, #c4b5fd 100%);
}

.btn-workflow.btn-teal {
  background: linear-gradient(135deg, #ccfbf1 0%, #99f6e4 100%);
  border-color: var(--teal);
  color: #115e59;
}

.btn-workflow.btn-teal:hover {
  background: linear-gradient(135deg, #99f6e4 0%, #5eead4 100%);
}

.btn-workflow.btn-warning {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-color: var(--warning);
  color: #92400e;
}

.btn-workflow.btn-warning:hover {
  background: linear-gradient(135deg, #fde68a 0%, #fcd34d 100%);
}

.btn-workflow:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.step-desc {
  font-size: 13px;
  color: var(--gray-500);
}

/* Quick actions */
.quick-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.action-desc {
  font-size: 13px;
  color: var(--gray-500);
}

/* Simulation log */
.simulation-log {
  background: var(--gray-900);
  border-radius: 8px;
  padding: 16px;
  max-height: 300px;
  overflow-y: auto;
  font-family: 'Monaco', 'Consolas', monospace;
  font-size: 12px;
  margin-bottom: 12px;
}

.log-entry {
  padding: 4px 0;
  border-bottom: 1px solid var(--gray-700);
  color: var(--gray-300);
}

.log-entry:last-child {
  border-bottom: none;
}

.log-entry.log-info {
  color: #60a5fa;
}

.log-entry.log-success {
  color: #34d399;
}

.log-entry.log-warning {
  color: #fbbf24;
}

.log-entry.log-error {
  color: #f87171;
}

.log-timestamp {
  color: var(--gray-500);
  margin-right: 8px;
}

/* ===== Simulator Mini Tracker ===== */
.simulator-tracker {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
  border-radius: 12px;
  padding: 20px;
  margin-top: 12px;
}

.sim-tracker-steps {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px;
}

.sim-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
}

.sim-step-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--gray-300);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  margin-bottom: 6px;
  transition: all 0.3s ease;
}

.sim-step-label {
  font-size: 11px;
  color: var(--gray-500);
  text-align: center;
  font-weight: 500;
}

.sim-step.completed .sim-step-icon {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.sim-step.completed .sim-step-label {
  color: var(--success);
}

.sim-step.active .sim-step-icon {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  animation: pulse 1.5s infinite;
}

.sim-step.active .sim-step-label {
  color: var(--primary);
  font-weight: 600;
}

.sim-step.error .sim-step-icon {
  background: var(--error);
  border-color: var(--error);
  color: white;
}

.sim-step.error .sim-step-label {
  color: var(--error);
}

.sim-connector {
  flex: 1;
  height: 2px;
  background: var(--gray-300);
  min-width: 20px;
  margin-bottom: 20px;
  transition: background 0.3s ease;
}

.sim-connector.completed {
  background: var(--success);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(79, 70, 229, 0); }
}

/* Stage badge styling */
.stage-badge {
  background: var(--primary) !important;
  color: white !important;
}

/* ============ FHIR Preview Styles ============ */

.fhir-preview {
  border-top: 1px solid var(--gray-200);
  margin-top: 12px;
  padding-top: 12px;
  background: var(--gray-50);
  border-radius: 0 0 8px 8px;
  margin: 12px -16px -16px -16px;
  padding: 12px 16px 16px 16px;
}

.fhir-loading, .fhir-error, .fhir-empty {
  text-align: center;
  padding: 16px;
  color: var(--gray-500);
  font-size: 13px;
}

.fhir-error {
  color: var(--error);
}

.fhir-header {
  margin-bottom: 12px;
  padding: 8px 12px;
  background: white;
  border-radius: 6px;
  font-size: 13px;
  border: 1px solid var(--gray-200);
}

.fhir-header code {
  background: var(--gray-100);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Monaco', 'Consolas', monospace;
  font-size: 12px;
  color: var(--primary);
}

.fhir-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.fhir-tab {
  padding: 6px 12px;
  border: 1px solid var(--gray-300);
  background: white;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.fhir-tab:hover {
  background: var(--gray-100);
}

.fhir-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.fhir-tab-content {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  overflow: hidden;
}

.fhir-json {
  font-family: 'Monaco', 'Consolas', 'Courier New', monospace;
  font-size: 11px;
  line-height: 1.5;
  padding: 12px;
  margin: 0;
  overflow-x: auto;
  max-height: 300px;
  overflow-y: auto;
  background: #1e1e1e;
  color: #d4d4d4;
  white-space: pre-wrap;
  word-break: break-word;
}

.card-actions {
  display: flex;
  gap: 6px;
}

.external-id {
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 4px;
  font-family: 'Monaco', 'Consolas', monospace;
}

/* ============ Filter Toggles ============ */

.tracker-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}

.filter-toggles {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--gray-200);
}

.filter-label {
  font-size: 13px;
  color: var(--gray-500);
  margin-right: 4px;
}

.filter-toggle {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.filter-toggle input[type="radio"] {
  display: none;
}

.filter-toggle span {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 6px;
  transition: all 0.2s;
  color: var(--gray-600);
}

.filter-toggle:hover span {
  background: var(--gray-100);
}

.filter-toggle input[type="radio"]:checked + span {
  background: var(--primary);
  color: white;
}

/* Colored filter buttons when checked */
.filter-toggle input[value="active"]:checked + span {
  background: var(--info);
}

.filter-toggle input[value="complete"]:checked + span {
  background: var(--success);
}

.filter-toggle input[value="error"]:checked + span {
  background: var(--error);
}

.stats-bar {
  flex-wrap: wrap;
}

/* Revenue Summary Cards */
.revenue-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.revenue-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border-left: 4px solid var(--gray-400);
}

.revenue-card.revenue-m {
  border-left-color: var(--info);
}

.revenue-card.revenue-e {
  border-left-color: var(--purple);
}

.revenue-card.revenue-p {
  border-left-color: var(--teal);
}

.revenue-label {
  font-size: 14px;
  color: var(--gray-500);
  margin-bottom: 8px;
  font-weight: 500;
}

.revenue-amount {
  font-size: 32px;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 4px;
}

.revenue-pending {
  font-size: 13px;
  color: var(--warning);
}

.revenue-hint {
  font-size: 11px;
  color: #f59e0b;
  margin-top: 4px;
  opacity: 0.9;
}

.revenue-card.revenue-e .revenue-pending {
  color: var(--success);
}

/* Payment Status Badges */
.payment-status {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  display: inline-block;
}

.payment-status.requires_payment_method {
  background: #fef3c7;
  color: #92400e;
}

.payment-status.requires_capture {
  background: #dbeafe;
  color: #1e40af;
}

.payment-status.succeeded {
  background: #d1fae5;
  color: #065f46;
}

.payment-status.canceled {
  background: #f3f4f6;
  color: #6b7280;
}

.payment-status.refunded {
  background: #fce7f3;
  color: #9d174d;
}
