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

:root {
  /* Primary - Business Purple */
  --primary-color: #391e5c;
  --primary-hover: #4a2875;
  --primary-dark: #2d1849;
  --primary-light: #ede8f2;

  /* Secondary - Business Grey */
  --secondary-color: #7f8080;
  --secondary-hover: #6a6b6b;

  /* Semantic colors */
  --danger-color: #ef4444;
  --danger-hover: #dc2626;
  --success-color: #10b981;
  --success-hover: #059669;
  --warning-color: #f59e0b;
  --warning-hover: #d97706;

  /* Neutral scale */
  --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;

  /* Background & text */
  --bg-light: #f8fafc;
  --bg-dark: #1e293b;
  --text-dark: #111827;
  --text-light: #6b7280;
  --border-color: #e5e7eb;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  /* Border radius */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition: 200ms ease;
  --transition-slow: 300ms ease;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--gray-50);
  color: var(--text-dark);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* Screens */
.screen {
  display: none;
}

.screen.active {
  display: block;
}

/* Login Screen */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #391e5c 0%, #2d1849 100%);
  position: relative;
  overflow: hidden;
}

.login-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.login-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl), 0 0 40px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 440px;
  overflow: hidden;
  position: relative;
  z-index: 1;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.login-header {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  padding: 2.5rem 2rem;
  text-align: center;
}

.login-header h1 {
  font-size: 1.75rem;
  color: white;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.025em;
}

.login-body {
  padding: 2.5rem 2.5rem 3rem;
}

.login-body form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.input-with-icon {
  display: flex;
  align-items: center;
  gap: 0;
  position: relative;
}

.input-icon {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  z-index: 1;
}

.input-with-icon input {
  width: 100%;
  padding: 0.875rem 1rem 0.875rem 60px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  transition: var(--transition);
  background: white;
}

.input-with-icon input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(57, 30, 92, 0.1);
}

.input-with-icon input::placeholder {
  color: var(--gray-400);
}

.login-btn {
  margin-top: 0.75rem;
  padding: 1rem 1.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.75px;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 14px 0 rgba(57, 30, 92, 0.4);
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px 0 rgba(57, 30, 92, 0.5);
}

.login-btn:active {
  transform: translateY(0);
}

.subtitle {
  color: var(--text-light);
  font-size: 1.125rem;
  margin-bottom: 2rem;
}

.login-card .form-group label {
  font-size: 0.9375rem;
  font-weight: 600;
}

.login-card .form-input {
  padding: 0.875rem 1rem;
  font-size: 0.9375rem;
}

/* Header */
.app-header {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 1rem 0;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-content h1 {
  font-size: 1.375rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.025em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-name {
  color: var(--gray-600);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  background: var(--gray-100);
  border-radius: var(--radius-full);
}

/* Tab Navigation */
.tab-navigation {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 0;
}

.tab-navigation .container {
  display: flex;
  gap: 0.5rem;
}

.tab-btn {
  background: none;
  border: none;
  padding: 1rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  position: relative;
}

.tab-btn:hover {
  color: var(--primary-color);
}

.tab-btn.active {
  color: var(--primary-color);
  font-weight: 600;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
  border-radius: 2px 2px 0 0;
}

/* Tab Content */
.tab-content {
  display: none;
  padding: 2rem 0;
}

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

/* Buttons */
.btn {
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
  color: white;
  box-shadow: 0 2px 8px rgba(57, 30, 92, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(57, 30, 92, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background-color: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}

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

.btn-danger {
  background: linear-gradient(135deg, var(--danger-color), var(--danger-hover));
  color: white;
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.btn-small {
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

/* Disabled button states */
.btn:disabled,
.btn.btn-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary:disabled,
.btn-primary.btn-disabled {
  background: var(--gray-400);
  box-shadow: none;
}

.btn-secondary:disabled,
.btn-secondary.btn-disabled {
  background-color: var(--gray-100);
  color: var(--gray-400);
  border-color: var(--gray-200);
}

/* Disabled form controls */
.form-select:disabled,
.form-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: var(--gray-100);
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--gray-700);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  transition: var(--transition);
  background: white;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(57, 30, 92, 0.1);
}

.form-textarea {
  resize: vertical;
  font-family: inherit;
}

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

/* Actions Header */
.actions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.actions-controls {
  display: flex;
  gap: 0.75rem;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
}

.actions-controls .form-select,
.actions-controls .form-input {
  max-width: 200px;
  padding: 0.625rem 1rem;
  border-radius: var(--radius-sm);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: white;
  padding: 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  border: 1px solid var(--gray-100);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card.stat-warning::before {
  background: linear-gradient(90deg, var(--warning-color), var(--warning-hover));
}

.stat-value {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1;
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--gray-500);
  margin-top: 0.5rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Tables */
.table-container {
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  overflow-x: auto;
  border: 1px solid var(--gray-100);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: linear-gradient(to bottom, var(--gray-50), var(--gray-100));
}

th {
  padding: 0.875rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-600);
  border-bottom: 2px solid var(--gray-200);
  position: sticky;
  top: 0;
  background: var(--gray-50);
  z-index: 10;
}

td {
  padding: 1rem;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.875rem;
}

tbody tr:hover {
  background-color: var(--gray-50);
}

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

/* Expandable Rows */
.expand-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  color: var(--primary-color);
  font-size: 1.25rem;
  line-height: 1;
  transition: var(--transition);
}

.expand-btn:hover {
  color: var(--primary-hover);
}

.expand-btn.expanded {
  transform: rotate(90deg);
}

.detail-row {
  display: none;
}

.detail-row.show {
  display: table-row;
}

.detail-row td {
  background-color: var(--gray-50);
  padding: 1.5rem;
}

.detail-content {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 1rem;
  font-size: 0.875rem;
}

.detail-label {
  font-weight: 600;
  color: var(--gray-700);
}

.detail-value {
  color: var(--gray-600);
  white-space: pre-wrap;
}

.loading {
  text-align: center;
  color: var(--gray-500);
  padding: 3rem !important;
}

.empty-state {
  text-align: center;
  color: var(--gray-500);
  padding: 3rem !important;
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-open {
  background-color: #e0e7ff;
  color: #4338ca;
}

.status-in_progress {
  background-color: #fef3c7;
  color: #b45309;
}

.status-hold {
  background-color: #fce7f3;
  color: #be185d;
}

.status-completed {
  background-color: #d1fae5;
  color: #047857;
}

.status-active {
  background-color: #d1fae5;
  color: #047857;
}

.status-inactive {
  background-color: #fee2e2;
  color: #b91c1c;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 0.5rem;
}

/* Section Header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.section-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.025em;
}

/* Communities Grid */
.communities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.community-card {
  background: white;
  padding: 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.community-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
}

.community-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.community-card h3 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 0.5rem;
}

.community-code {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: linear-gradient(135deg, var(--primary-light), #e0e7ff);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 0.75rem;
}

.community-description {
  font-size: 0.875rem;
  color: var(--gray-600);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.community-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--gray-500);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  overflow-y: auto;
  padding: 2rem;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn var(--transition-fast);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal.active .modal-content {
  animation: slideUp var(--transition);
}

.modal-content {
  background: white;
  border-radius: var(--radius-lg);
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--gray-100);
}

.modal-small {
  max-width: 500px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--gray-100);
  background: var(--gray-50);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-900);
}

.modal-header .modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--gray-400);
  cursor: pointer;
  padding: 0;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.modal-header .modal-close:hover {
  background-color: var(--gray-200);
  color: var(--gray-700);
}

.modal-content form {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--gray-100);
}

/* Error Message */
.error-message {
  color: var(--danger-color);
  font-size: 0.875rem;
  padding: 0.875rem 1rem;
  background-color: #fef2f2;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--danger-color);
  display: none;
  margin: -0.5rem 0 0;
}

.error-message.active {
  display: block;
}

/* Responsive */
@media (max-width: 768px) {
  .login-card {
    max-width: 95%;
    margin: 1rem;
  }

  .login-header {
    padding: 2rem 1.5rem;
  }

  .login-header h1 {
    font-size: 1.5rem;
  }

  .login-body {
    padding: 2rem 1.5rem;
  }

  .header-content {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }

  .actions-header {
    flex-direction: column;
    align-items: stretch;
  }

  .actions-controls {
    flex-direction: column;
  }

  .actions-controls .form-select,
  .actions-controls .form-input {
    max-width: 100%;
  }

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

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .communities-grid {
    grid-template-columns: 1fr;
  }

  .table-container {
    overflow-x: auto;
  }

  table {
    min-width: 800px;
  }
}

#password-label {
  font-weight: normal;
  font-size: 0.75rem;
  color: var(--gray-500);
  text-transform: none;
}

/* Loading Spinner */
.spinner {
  border: 4px solid var(--gray-200);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}


/* Print Styles */
@media print {
  /* Hide everything except print view */
  #app-screen,
  #login-screen {
    display: none !important;
  }

  #print-view {
    display: block !important;
  }
  /* Hide non-printable elements */
  .app-header,
  .tab-navigation,
  .actions-header,
  .stats-grid,
  .expand-btn,
  .action-buttons,
  .modal {
    display: none !important;
  }

  /* Reset page styling */
  body {
    background-color: white;
    color: #391e5c;
  }

  .container {
    max-width: 100%;
    padding: 0;
  }

  /* Table styling for print */
  .table-container {
    box-shadow: none;
    overflow: visible;
  }

  table {
    width: 100%;
    page-break-inside: auto;
    font-size: 10pt;
  }

  thead {
    background-color: #ede8f2 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  th {
    background-color: #ede8f2 !important;
    color: #391e5c !important;
    border: 1px solid #391e5c !important;
    padding: 6px !important;
    position: static !important;
    font-size: 9pt;
  }

  td {
    border: 1px solid #391e5c !important;
    padding: 6px !important;
    font-size: 9pt;
    vertical-align: top;
    color: #391e5c;
  }

  tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }

  /* Checkbox and Actions columns are hidden via Tabulator's print:false setting */

  /* Show all detail rows by default in print (overrides screen display: none) */
  .detail-row {
    display: table-row !important;
  }

  /* Detail row styling */
  .detail-row td {
    background-color: #f9f9f9 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .detail-content {
    display: block;
    font-size: 9pt;
    padding: 10px;
  }

  .detail-label {
    font-weight: bold;
    margin-top: 12px;
    margin-bottom: 4px;
    color: #391e5c;
  }

  .detail-label:first-child {
    margin-top: 0;
  }

  .detail-value {
    margin-bottom: 10px;
    color: #391e5c;
    white-space: pre-wrap;
    line-height: 1.4;
  }

  /* Action Item column - always show abbreviated in main table row */
  td:nth-child(3) > div {
    max-width: 350px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  /* Hide detail rows for short format (overrides inline styles with !important) */
  body.print-short .detail-row {
    display: none !important;
  }

  /* Status badges */
  .status-badge {
    border: 1px solid #391e5c;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Page header for print */
  @page {
    margin: 0.5in;
  }

  /* Add print title */
  .tab-content.active::before {
    content: "Action List Report";
    display: block;
    font-size: 18pt;
    font-weight: bold;
    margin-bottom: 15px;
    text-align: center;
    color: #391e5c;
  }
}

/* Tabulator Custom Styling */
#actions-table {
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  min-height: 400px;
  border: 1px solid var(--gray-100);
  overflow: hidden;
}

.tabulator-detail-row {
  padding: 16px 20px;
  background: linear-gradient(to bottom, var(--gray-50), white);
  border-top: 1px solid var(--gray-200);
}

.tabulator-detail-row .detail-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 13px;
}

.tabulator-detail-row .detail-label {
  font-weight: 700;
  color: var(--primary-color);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.tabulator-detail-row .detail-value {
  color: var(--gray-700);
  line-height: 1.5;
}

.tabulator .tabulator-row {
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
  transition: var(--transition-fast);
}

.tabulator .tabulator-row:hover {
  background-color: var(--gray-50) !important;
}

.tabulator .tabulator-row.tabulator-selected {
  background-color: var(--primary-light) !important;
}

.tabulator .tabulator-header {
  background: linear-gradient(to bottom, var(--gray-50), var(--gray-100));
  border-bottom: 2px solid var(--gray-200);
}

.tabulator .tabulator-header .tabulator-col {
  background: transparent;
  border-right: 1px solid var(--gray-200);
}

.tabulator .tabulator-header .tabulator-col-title {
  font-weight: 700;
  color: var(--gray-600);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tabulator .tabulator-cell {
  padding: 12px 14px;
  font-size: 13px;
}

/* Actions Taken - Enhanced UI */
.actions-input-container {
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--gray-50);
}

.actions-history {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.actions-history:empty {
  display: none;
}

.action-entry {
  background: white;
  border-left: 3px solid var(--primary-color);
  padding: 12px 16px;
  margin-bottom: 10px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.action-entry-content {
  flex: 1;
  min-width: 0;
}

.action-entry-buttons {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.btn-edit-entry,
.btn-delete-entry {
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
  border: none;
  transition: var(--transition-fast);
}

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

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

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

.btn-delete-entry:hover {
  background: var(--danger-hover);
  box-shadow: var(--shadow-sm);
}

.action-entry:last-child {
  margin-bottom: 0;
}

.action-entry-date {
  font-weight: 700;
  color: var(--primary-color);
  font-size: 12px;
  margin-bottom: 6px;
}

.action-entry-text {
  color: var(--gray-700);
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.5;
}

.new-action-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
}

.entry-buttons {
  display: flex;
  gap: 8px;
}

.actions-history:empty + .new-action-row {
  padding-top: 0;
  border-top: none;
}

.action-date-input {
  width: auto;
  max-width: 160px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--gray-700);
}

.action-date-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(57, 30, 92, 0.1);
}

#new-action-text {
  resize: vertical;
  min-height: 50px;
}

#add-action-btn {
  align-self: flex-start;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
}

.text-muted {
  color: var(--gray-500);
  font-style: italic;
}

/* Community Header */
.community-header {
  margin-bottom: 1.5rem;
  padding: 1.25rem 1.5rem;
  background: linear-gradient(135deg, #391e5c 0%, #2d1849 100%);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.community-header h2 {
  margin: 0;
  color: white;
  font-size: 1.375rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: -0.025em;
}


/* Additional utility classes */
.filter-label {
  font-weight: 600;
  color: var(--gray-700);
  font-size: 0.875rem;
  margin-right: 0.5rem;
  white-space: nowrap;
}

.actions-buttons {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.table-wrapper {
  position: relative;
}

.loading-overlay {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  background: white;
  padding: 2rem 3rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-100);
}

.loading-overlay.active {
  display: block;
}

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

.loading-text {
  margin-top: 1rem;
  color: var(--gray-500);
  font-size: 0.875rem;
}

.community-access-hidden {
  display: none;
}

.community-checkboxes {
  max-height: 200px;
  overflow-y: auto;
  border: 2px solid var(--gray-200);
  padding: 1rem;
  border-radius: var(--radius-sm);
  background: var(--gray-50);
}

.help-text {
  color: var(--gray-500);
  margin-top: 0.5rem;
  display: block;
  font-size: 0.8125rem;
}

/* ============ EMAIL IMPORT STYLES ============ */

.email-import-step {
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.step-header {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: white;
  font-weight: 700;
  font-size: 1rem;
}

.step-header h3 {
  margin: 0;
  color: white;
  font-size: 1.125rem;
  font-weight: 600;
}

.step-content {
  padding: 1.5rem;
}

.email-status {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.email-status:empty {
  display: none;
}

.email-status .loading {
  color: var(--gray-600);
}

.email-status .success {
  color: var(--success-color);
  background: rgba(16, 185, 129, 0.1);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
}

.email-status .error {
  color: var(--danger-color);
  background: rgba(239, 68, 68, 0.1);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
}

.email-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
}

#email-total-count {
  font-weight: 600;
  color: var(--gray-700);
}

.email-group {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.email-group-header {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.email-group-name {
  font-weight: 600;
  font-size: 1rem;
}

.email-group-count {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
}

.email-group-body {
  padding: 0.5rem;
}

.email-card {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
  transition: background-color 0.15s ease;
}

.email-card:last-child {
  border-bottom: none;
}

.email-card:hover {
  background: var(--gray-100);
}

/* Alternating email colors */
.email-card-alt {
  background: var(--gray-50);
}

.email-card-alt:hover {
  background: var(--gray-100);
}

/* Skipped emails */
.email-card.skipped,
.email-thread.skipped {
  opacity: 0.5;
  background: var(--gray-100);
}

.email-thread.skipped .email-thread-header {
  pointer-events: none;
}

/* Processing state */
.email-thread.processing {
  opacity: 0.7;
  pointer-events: none;
}

.email-thread.processing .email-thread-actions {
  background: var(--gray-100);
}

/* Processed state */
.email-thread.processed {
  background: rgba(16, 185, 129, 0.05);
  border-color: var(--success-color);
}

.email-thread.processed .email-thread-header {
  background: rgba(16, 185, 129, 0.1);
}

/* Status text styles */
.processing-text {
  color: var(--gray-600);
  font-style: italic;
}

.processed-text {
  color: var(--success-color);
  font-weight: 600;
}

.skipped-text {
  color: var(--gray-500);
  font-style: italic;
}

.error-text {
  color: var(--danger-color);
  font-size: 0.8125rem;
  margin-left: 0.5rem;
}

/* Thread status badges */
.thread-status-badge {
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
}

.thread-status-badge.processed {
  background: var(--gray-200);
  color: var(--gray-600);
}

.thread-status-badge.new-messages {
  background: #fef3c7;
  color: #d97706;
}

/* Fully processed threads */
.email-thread.fully-processed {
  opacity: 0.6;
}

.email-thread.fully-processed .email-thread-header {
  background: var(--gray-100);
}

.already-processed-text {
  color: var(--gray-500);
  font-size: 0.8125rem;
  font-style: italic;
}

/* Partially processed threads */
.email-thread.partially-processed {
  border-color: #f59e0b;
  border-width: 2px;
}

.email-thread.partially-processed .email-thread-header {
  background: #fffbeb;
}

.partial-thread-info {
  color: var(--gray-600);
  font-size: 0.8125rem;
  margin-right: 0.5rem;
}

/* Already processed emails within threads */
.email-already-processed {
  opacity: 0.6;
  background: var(--gray-100) !important;
}

.email-processed-badge {
  background: var(--gray-200);
  color: var(--gray-600);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  font-weight: 500;
  margin-left: 0.5rem;
}

.email-card.skipped::after {
  content: 'SKIPPED';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: 700;
  color: var(--gray-400);
  font-size: 1rem;
}

.email-card {
  position: relative;
}

/* Skip buttons */
.btn-skip {
  background: var(--gray-200);
  border: none;
  color: var(--gray-600);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.btn-skip:hover {
  background: #ef4444;
  color: white;
}

.btn-skip-thread {
  background: white;
  border: 1px solid var(--gray-400);
  color: var(--gray-600);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-skip-thread:hover {
  background: var(--gray-100);
  border-color: var(--gray-500);
  color: var(--gray-700);
}

.email-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.email-from {
  font-weight: 600;
  color: var(--gray-700);
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.email-date {
  color: var(--gray-500);
  font-size: 0.8125rem;
  white-space: nowrap;
}

.email-recipients {
  background: var(--gray-50);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  font-size: 0.8125rem;
}

.email-to,
.email-cc {
  color: var(--gray-600);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-to strong,
.email-cc strong {
  color: var(--gray-700);
  margin-right: 0.25rem;
}

.email-cc {
  margin-top: 0.25rem;
}

/* Email Thread Styles */
.email-thread {
  border: 1px solid var(--gray-300);
  border-left: 4px solid var(--primary-color);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Alternating thread colors for better distinction */
.email-thread:nth-child(odd) {
  background: white;
  border-left-color: var(--primary-color);
}

.email-thread:nth-child(even) {
  background: var(--gray-50);
  border-left-color: #6366f1;
}

.email-thread:nth-child(even) .email-thread-header {
  background: var(--gray-100);
}

.email-thread:nth-child(even) .email-thread-actions {
  background: var(--gray-50);
}

.email-thread-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--gray-50);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.email-thread-header:hover {
  background: var(--gray-100);
}

.thread-icon {
  color: var(--gray-500);
  font-size: 0.75rem;
  width: 1rem;
}

.thread-subject {
  flex: 1;
  font-weight: 500;
  color: var(--gray-800);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-count {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
}

.thread-date {
  color: var(--gray-500);
  font-size: 0.8125rem;
  white-space: nowrap;
}

.email-thread-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: white;
  border-top: 1px solid var(--gray-100);
}

.email-thread-actions .form-select {
  font-size: 0.875rem;
  padding: 0.375rem 0.75rem;
  min-width: 180px;
}

.thread-link-options,
.thread-create-options {
  flex: 1;
  min-width: 200px;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.thread-link-options select,
.thread-create-options select {
  flex: 1;
}

.btn-link-now,
.btn-create-now {
  white-space: nowrap;
}

.email-thread-preview {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--gray-100);
  background: white;
}

.email-thread-preview .email-from {
  font-size: 0.8125rem;
  color: var(--gray-600);
  margin-bottom: 0.25rem;
}

.email-thread-preview .email-preview {
  font-size: 0.8125rem;
  color: var(--gray-500);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-card-simple {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--gray-100);
}

.email-card-simple:last-child {
  border-bottom: none;
}

.email-card-simple.email-card-alt {
  background: var(--gray-50);
}

.email-thread-body {
  border-top: 1px solid var(--gray-200);
}

.email-thread-body .email-card,
.email-thread-body .email-card-simple {
  border: none;
  border-bottom: 1px solid var(--gray-100);
  border-radius: 0;
  margin-bottom: 0;
}

.email-thread-body .email-card:last-child,
.email-thread-body .email-card-simple:last-child {
  border-bottom: none;
}

.loading-thread {
  padding: 1.5rem;
  text-align: center;
  color: var(--gray-500);
  font-style: italic;
  background: var(--gray-50);
  border-radius: 4px;
  margin: 0.5rem;
}

.email-original-badge {
  background: var(--primary-color);
  color: white;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 500;
  margin-left: 0.5rem;
}

.email-original {
  background: #f0e6f6 !important;
  border-left: 3px solid var(--primary-color);
}

.email-body-full {
  color: var(--gray-700);
  font-size: 0.875rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  padding: 0.75rem;
  background: var(--gray-50);
  border-radius: 4px;
  margin-top: 0.5rem;
  max-height: 400px;
  overflow-y: auto;
}

.email-subject {
  font-weight: 500;
  color: var(--gray-800);
  margin-bottom: 0.5rem;
  font-size: 0.9375rem;
}

.email-preview {
  color: var(--gray-600);
  font-size: 0.8125rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 1rem;
}

.email-card-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.email-action-select {
  min-width: 200px;
}

.email-link-options,
.email-create-options {
  flex: 1;
  min-width: 200px;
}

.email-link-target,
.email-create-community {
  width: 100%;
}

.email-actions-footer {
  padding: 1.5rem;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
}

.results-summary {
  display: flex;
  gap: 2rem;
  justify-content: center;
  margin: 2rem 0;
  flex-wrap: wrap;
}

.result-stat {
  text-align: center;
  padding: 1.5rem 2rem;
  background: var(--gray-50);
  border-radius: var(--radius-md);
  min-width: 150px;
}

.result-stat.result-linked {
  background: rgba(59, 130, 246, 0.1);
}

.result-stat.result-created {
  background: rgba(16, 185, 129, 0.1);
}

.result-stat.result-skipped {
  background: rgba(156, 163, 175, 0.1);
}

.result-value {
  display: block;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary-color);
  line-height: 1;
  margin-bottom: 0.5rem;
}

.result-linked .result-value {
  color: #3b82f6;
}

.result-created .result-value {
  color: var(--success-color);
}

.result-skipped .result-value {
  color: var(--gray-500);
}

.result-label {
  color: var(--gray-600);
  font-size: 0.875rem;
  font-weight: 500;
}

.results-actions {
  text-align: center;
  margin-top: 1.5rem;
}

.result-errors {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 1rem 1.5rem;
  margin: 1rem 0;
}

.result-errors h4 {
  color: var(--danger-color);
  margin: 0 0 0.75rem 0;
  font-size: 0.9375rem;
}

.result-errors ul {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--gray-700);
  font-size: 0.875rem;
}

.result-errors li {
  margin-bottom: 0.25rem;
}

.no-emails {
  text-align: center;
  padding: 3rem;
  color: var(--gray-500);
  font-size: 1rem;
}
