/* SSO Server Frontend Styles */

/* CSS Variables for theming */
:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --secondary-color: #64748b;
  --success-color: #059669;
  --warning-color: #d97706;
  --error-color: #dc2626;
  --background: #f8fafc;
  --surface: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --border-focus: #3b82f6;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px 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);
  --radius: 8px;
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  
  /* Additional color variables */
  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --warning-bg: #fffbeb;
  --warning-border: #fed7aa;
  --info-bg: #eff6ff;
  --info-border: #bfdbfe;
  --surface-secondary: #f1f5f9;
  --surface-primary: #ffffff;
  --surface-hover: #f8fafc;
  --surface-tertiary: #f1f5f9;
  --border-color: #e2e8f0;
}

/* Auto dark theme (browser preference) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --primary-color: #007acc;
    --primary-hover: #005a9e;
    --primary-light: #094771;
    --secondary-color: #999999;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --error-color: #f44336;
    --background: #1e1e1e;
    --surface: #252526;
    --text-primary: #cccccc;
    --text-secondary: #999999;
    --border: #404040;
    --border-focus: #007acc;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 1px 2px -1px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
    
    /* Additional dark theme colors */
    --error-bg: #2e1a1a;
    --error-border: #7f1d1d;
    --success-bg: #1a2e1a;
    --success-border: #065f46;
    --warning-bg: #2a1a00;
    --warning-border: #92400e;
    --info-bg: #0e2a42;
    --info-border: #094771;
    --surface-secondary: #2d2d2d;
    --surface-primary: #252526;
    --surface-hover: #2a2a2a;
    --surface-tertiary: #3d3d3d;
    --border-color: #404040;
  }
}

/* Manual dark theme override - Higher specificity */
html:root[data-theme="dark"] {
  --primary-color: #007acc;
  --primary-hover: #005a9e;
  --primary-light: #094771;
  --secondary-color: #999999;
  --success-color: #4caf50;
  --warning-color: #ff9800;
  --error-color: #f44336;
  --background: #1e1e1e;
  --surface: #252526;
  --text-primary: #cccccc;
  --text-secondary: #999999;
  --border: #404040;
  --border-focus: #007acc;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 1px 2px -1px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
  
  /* Additional dark theme colors */
  --error-bg: #2e1a1a;
  --error-border: #7f1d1d;
  --success-bg: #1a2e1a;
  --success-border: #065f46;
  --warning-bg: #2a1a00;
  --warning-border: #92400e;
  --info-bg: #0e2a42;
  --info-border: #094771;
  --surface-secondary: #2d2d2d;
  --surface-primary: #252526;
  --surface-hover: #2a2a2a;
  --surface-tertiary: #3d3d3d;
  --border-color: #404040;
}

/* Manual light theme override - Higher specificity */
html:root[data-theme="light"] {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --secondary-color: #64748b;
  --success-color: #059669;
  --warning-color: #d97706;
  --error-color: #dc2626;
  --background: #f8fafc;
  --surface: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --border-focus: #3b82f6;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px 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);
  
  /* Additional light theme colors */
  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --warning-bg: #fffbeb;
  --warning-border: #fed7aa;
  --info-bg: #eff6ff;
  --info-border: #bfdbfe;
  --surface-secondary: #f1f5f9;
  --surface-primary: #ffffff;
  --surface-hover: #f8fafc;
  --surface-tertiary: #f1f5f9;
  --border-color: #e2e8f0;
}

/* Theme Toggle Styles */
.theme-toggle-section {
  margin: 2rem 0;
}

.theme-toggle-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.theme-toggle-header h3 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.theme-toggle-header .icon {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.theme-option {
  display: flex;
  align-items: center;
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  user-select: none;
}

.theme-option:hover {
  border-color: var(--primary-color);
  background: var(--surface-secondary);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.theme-option.active {
  border-color: var(--primary-color);
  background: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.theme-option.active::after {
  content: '✓';
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 24px;
  height: 24px;
  background: var(--primary-color);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: bold;
  box-shadow: var(--shadow);
}

.theme-option-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  pointer-events: none; /* Prevent child elements from interfering with clicks */
}

.theme-option-icon {
  width: 24px;
  height: 24px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.theme-option-info h4 {
  margin: 0 0 0.25rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.theme-option-info p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background-color: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
}

/* General code and pre styling */
code, pre {
  background: var(--surface-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

code {
  padding: 2px 4px;
  font-size: 0.875em;
}

pre {
  padding: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}

pre code {
  background: none;
  border: none;
  padding: 0;
}

/* Profile Page Styles */
.profile-section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.profile-section-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
}

/* Payment Methods Styles */
.payment-methods-list {
  margin-bottom: 1.5rem;
}

.payment-method-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  background: var(--surface);
  transition: all 0.2s ease;
}

.payment-method-item:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow);
}

.payment-method-item.default {
  border-color: var(--primary-color);
  background: var(--primary-light);
}

.payment-method-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.card-details {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.card-row-primary {
  display: flex !important;
  align-items: center !important;
  gap: 0.75rem !important;
  margin: 0 !important;
  padding: 0 !important;
}

.card-row-secondary {
  display: flex !important;
  gap: 1rem !important;
  font-size: 0.875rem !important;
  color: var(--text-secondary) !important;
  margin-left: 2.5rem !important; /* Align with card number (32px icon + 0.75rem gap) */
  margin-top: 0.25rem !important;
  padding: 0 !important;
}

.card-brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.card-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.card-number {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 1rem;
}

.card-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.default-badge {
  background: var(--primary-color);
  color: white;
  padding: 0.125rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  margin-left: 0.5rem;
}

.payment-method-actions {
  display: flex;
  gap: 0.5rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}

.empty-state svg {
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

.empty-state h3 {
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

/* Stripe Payment Element Styles */
.stripe-element {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 1rem;
}

.stripe-element:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Loading and Error States */
.loading-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

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

.error-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}

.error-icon {
  margin-bottom: 1rem;
  color: var(--error-color);
}

.error-state h3 {
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.form-error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-color);
  padding: 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

.profile-section-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.profile-section-content {
  padding: 1.5rem;
}

/* Form Grid Layout */
.form-grid {
  display: grid;
  gap: 1rem;
}

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

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

.form-group.full-width {
  grid-column: 1 / -1;
}

/* Payment Methods List */
.payment-methods-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.payment-method-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
}

.payment-method-card:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow);
}

.payment-method-card.expired {
  opacity: 0.7;
  border-color: var(--error-color);
}

.payment-method-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.card-brand-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-size: 9px;
  font-weight: 600;
  text-align: center;
  color: white;
  background-color: var(--secondary-color);
  flex-shrink: 0;
}

.card-brand-abbrev {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.5px;
  line-height: 1;
}

.card-brand-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.card-brand-name {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
}

/* Remove any FontAwesome icon remnants */
.card-brand-icon i {
  display: none !important;
}

.card-brand-icon .fa-regular {
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 400;
}

.card-brand-icon .fa-brands {
  font-family: "Font Awesome 6 Brands" !important;
  font-weight: 400;
}

.card-brand-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.card-brand-name {
  font-weight: 500;
  color: var(--text-primary);
}

.card-brand-svg {
  width: 24px;
  height: 24px;
}

.card-details {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.card-name {
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-number {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.card-expiry {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.default-badge {
  background: var(--success-color);
  color: white;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.expired-badge {
  background: var(--error-color);
  color: white;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.payment-method-actions {
  display: flex;
  gap: 0.5rem;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}

.empty-state svg {
  margin-bottom: 1rem;
}

.empty-state h3 {
  font-size: 1.125rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

/* Handle JavaScript-controlled modal display */
.modal[style*="display: block"],
.modal[style*="display: flex"] {
  opacity: 1 !important;
  visibility: visible !important;
}

.modal[style*="display: none"] {
  opacity: 0 !important;
  visibility: hidden !important;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(-20px);
  transition: transform 0.3s;
}

.modal.active .modal-content {
  transform: translateY(0);
}

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

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius);
  transition: background-color 0.2s;
}

.modal-close:hover {
  background: var(--background);
}

.modal-body {
  padding: 1.5rem;
}

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

/* Permissions Modal Styles */
.modal-wide .modal-content {
  max-width: 800px;
  width: 90vw;
}

.permissions-info {
  background: var(--primary-light);
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

.permissions-container {
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.permissions-app-section {
  border-bottom: 1px solid var(--border);
}

.permissions-app-section:last-child {
  border-bottom: none;
}

.permissions-app-header {
  padding: 1.5rem;
  background: var(--background);
  border-bottom: 1px solid var(--border);
}

.permissions-app-header h4 {
  margin: 0 0 0.5rem 0;
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 600;
}

.app-description {
  margin: 0 0 1rem 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.no-permissions {
  margin: 0;
  color: var(--text-secondary);
  font-style: italic;
}

.permissions-toggle-all {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  color: var(--primary-color);
  cursor: pointer;
}

.permissions-toggle-all input[type="checkbox"] {
  margin: 0;
}

.permissions-grid {
  padding: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 0.75rem;
}

.permission-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--surface);
}

.permission-item:hover {
  border-color: var(--primary-color);
  background: var(--primary-light);
}

.permission-item input[type="checkbox"] {
  margin: 0;
  margin-top: 0.125rem;
  flex-shrink: 0;
}

.permission-content {
  flex: 1;
}

.permission-name {
  display: block;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.permission-description {
  display: block;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Responsive adjustments for permissions modal */
@media (max-width: 768px) {
  .modal-wide .modal-content {
    max-width: 100%;
    width: 95vw;
    margin: 1rem;
  }
  
  .permissions-grid {
    grid-template-columns: 1fr;
  }
  
  .permissions-container {
    max-height: 400px;
  }
}

@media (max-width: 480px) {
  .permissions-app-header {
    padding: 1rem;
  }
  
  .permissions-grid {
    padding: 0.75rem;
  }
  
  .permission-item {
    padding: 0.5rem;
  }
}

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

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: box-shadow 0.2s ease;
}

.stat-card:hover {
  box-shadow: var(--shadow-lg);
}

.stat-icon {
  background: var(--primary-color);
  color: white;
  padding: 0.75rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-content {
  flex: 1;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Fix for error rate card - ensure text is visible */
.stat-card:nth-child(4) .stat-value {
  color: var(--error-color);
}

.stat-card:nth-child(4) .stat-icon {
  background: var(--error-color);
}

/* Card Number Input with Brand Detection */
.card-input-group {
  position: relative;
}

.card-brand-display {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
}

.card-input-group input {
  padding-right: 3rem;
}

/* Billing Address Toggle */
.billing-address-toggle {
  margin-bottom: 1rem;
}

.billing-address-form {
  display: none;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* Alert Messages */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s;
}

.alert.show {
  opacity: 1;
  transform: translateY(0);
}

.alert.success {
  background: var(--success-bg);
  border-color: var(--success-color);
  color: var(--success-color);
}

.alert.error {
  background: var(--error-bg);
  border-color: var(--error-color);
  color: var(--error-color);
}

/* Button Sizes */
.btn.btn-small {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
}

.btn.btn-large {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
  .form-grid.two-columns,
  .form-grid.three-columns {
    grid-template-columns: 1fr;
  }
  
  .payment-method-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .payment-method-actions {
    width: 100%;
    justify-content: flex-end;
  }
  
  .modal-content {
    width: 95%;
    margin: 1rem;
  }
  
  .modal-footer {
    flex-direction: column;
  }
}

/* Auth Layout Styles */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #43b14b 0%, #5ce1e6 100%);
}

.auth-card {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.1);
  overflow: hidden;
  max-width: 520px;
  width: 100%;
  margin: 20px;
}

.auth-card.wide {
  max-width: 600px;
}

.auth-header {
  text-align: center;
  padding: 24px 0 20px;
  background: #ffffff;
  border-radius: 12px;
}

.auth-header .logo {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 20px;
}

.logo img {
  height: 60px;
  width: auto;
  display: block;
}

/* Auth header logo theme support */
.auth-header .logo-dark-theme,
.auth-header .logo-light-theme {
  height: 60px;
  width: auto;
  display: block;
}

.auth-form-container {
  padding: 30px 50px 50px;
}

.form-floating > label {
  color: var(--text-secondary);
}

.btn-primary {
  /* Override Bootstrap 5 CSS custom properties for btn-primary */
  --bs-btn-bg: #43b14b;
  --bs-btn-border-color: #43b14b;
  --bs-btn-hover-bg: #3a9a42;
  --bs-btn-hover-border-color: #3a9a42;
  --bs-btn-active-bg: #3a9a42;
  --bs-btn-active-border-color: #3a9a42;
  --bs-btn-disabled-bg: #43b14b;
  --bs-btn-disabled-border-color: #43b14b;
  --bs-btn-focus-shadow-rgb: 67, 177, 75;
  background-color: #43b14b !important;
  border-color: #43b14b !important;
  border-radius: 8px;
  padding: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background-color: #3a9a42 !important;
  border-color: #3a9a42 !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(67, 177, 75, 0.3);
}

.btn-primary:focus,
.btn-primary:focus-visible {
  background-color: #3a9a42 !important;
  border-color: #3a9a42 !important;
  box-shadow: 0 0 0 0.2rem rgba(67, 177, 75, 0.25) !important;
}

.btn-primary:active,
.btn-primary.active {
  background-color: #3a9a42 !important;
  border-color: #3a9a42 !important;
}

.auth-footer {
  text-align: center;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #eee;
}

/* TOTP Styles */
.totp-input-group {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 20px 0;
}

.totp-digit {
  width: 45px;
  height: 45px;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
  background: var(--surface);
  color: var(--text-primary);
}

.totp-digit:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
}

/* Verification Status */
.verification-status {
  text-align: center;
  padding: 40px 0;
}

/* Loading Spinner Override */
.spinner-border {
  width: 1rem;
  height: 1rem;
}

/* Custom Form Styling */
.form-control:focus {
  border-color: #43b14b;
  box-shadow: 0 0 0 0.2rem rgba(67, 177, 75, 0.25);
}

.form-check-input:checked {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

.form-check-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
}

/* Layout components */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  box-shadow: var(--shadow);
}

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

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
  text-decoration: none;
}

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

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  transition: all 0.2s;
}

.nav-link:hover {
  color: var(--primary-color);
  background-color: var(--primary-light);
}

.nav-link.active {
  color: var(--primary-color);
  background-color: var(--primary-light);
}

/* Main content */
.main {
  flex: 1;
  padding: 2rem 0;
}

/* Auth layout */
.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2AA2DE, #1E8BC3);
  padding: 2rem;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* App Info Card for OAuth Login */
.app-info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.app-info-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.app-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  object-fit: cover;
  border: 1px solid var(--border);
}

.app-icon-placeholder {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.25rem;
  text-transform: uppercase;
}

.app-info-text h6 {
  margin: 0;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.875rem;
}

.app-info-text small {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

/* Forms */
.form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-label {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.875rem;
}

.form-input {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: all 0.2s;
  background: var(--surface);
}

.form-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

.form-input.error {
  border-color: var(--error-color);
}

.form-textarea {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: all 0.2s;
  background: var(--surface);
  resize: vertical;
  min-height: 100px;
  font-family: inherit;
  line-height: 1.5;
}

.form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

.form-textarea.error {
  border-color: var(--error-color);
}

.form-error {
  color: var(--error-color);
  font-size: 0.875rem;
  display: none;
}

.form-error.show {
  display: block;
}

.form-success {
  color: var(--success-color);
  font-size: 0.875rem;
  display: none;
}

.form-success.show {
  display: block;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
}

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

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

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

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
  border-color: var(--text-secondary);
}

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

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

.btn-full {
  width: 100%;
}

/* Links */
.link {
  color: var(--primary-color);
  text-decoration: none;
  font-size: 0.875rem;
}

.link:hover {
  text-decoration: underline;
}

.auth-links {
  text-align: center;
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card-header {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.card-description {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Unified Card System */
.page-section {
  margin-bottom: 2rem;
}

.unified-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.unified-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

.unified-card .card-header {
  background: var(--surface-secondary);
  padding: 1.5rem;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
}

.unified-card .card-body {
  padding: 1.5rem;
}

.unified-card .card-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.unified-card .card-description {
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.5;
}

/* Unified Card Header and Content */
.unified-card-header {
  background: var(--surface-secondary);
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.unified-card-title h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.25rem 0;
}

.unified-card-title p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 0;
}

.unified-card-actions {
  flex-shrink: 0;
}

.unified-card-content {
  padding: 0;
}

/* Unified Stats Grid */
.unified-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.unified-stat-card {
  background: var(--surface-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all 0.2s ease;
}

.unified-stat-card:hover {
  background: var(--surface-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.unified-stat-card .stat-icon {
  padding: 1rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.unified-stat-card .stat-icon-primary {
  background: linear-gradient(135deg, var(--primary-color) 0%, #3b82f6 100%);
}

.unified-stat-card .stat-icon-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.unified-stat-card .stat-icon-warning {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.unified-stat-card .stat-icon-info {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
}

.unified-stat-card .stat-content {
  flex: 1;
}

.unified-stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  line-height: 1;
}

.unified-stat-card .stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Unified Billing Grid */
.unified-billing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.unified-billing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.unified-billing-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.billing-card-header {
  padding: 1.5rem;
  background: var(--surface-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.billing-icon {
  padding: 0.75rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.billing-icon-primary {
  background: linear-gradient(135deg, var(--primary-color) 0%, #3b82f6 100%);
}

.billing-icon-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.billing-icon-info {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
}

.billing-card-title {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.billing-card-title h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.count-badge {
  background: var(--primary-color);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 600;
}

.outstanding-badge {
  background: #fef3c7;
  color: #92400e;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.billing-card-content {
  padding: 1.5rem;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.billing-card-footer {
  padding: 1rem 1.5rem;
  background: var(--surface-tertiary);
  border-top: 1px solid var(--border);
}

.subscription-preview, .invoice-preview-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: var(--surface-hover);
  border-radius: 8px;
  margin-bottom: 1rem;
}

.subscription-info, .invoice-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.product-name, .invoice-number {
  font-weight: 600;
  color: var(--text-primary);
}

.price, .amount {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.api-usage-stats {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.usage-metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--surface-secondary);
  border-radius: 8px;
}

.metric-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.metric-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.empty-state-mini {
  text-align: center;
  padding: 1rem;
}

.no-data {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-style: italic;
}

.more-items {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 0;
  text-align: center;
  font-style: italic;
}

.status {
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-active {
  background: #dcfce7;
  color: #166534;
}

.status-paid {
  background: #dcfce7;
  color: #166534;
}

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

.status-overdue {
  background: #fee2e2;
  color: #991b1b;
}

/* Alerts */
.alert {
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid;
  display: none;
}

.alert.show {
  display: block;
}

.alert-success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

.alert-error {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error-color);
}

.alert-warning {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning-color);
}

.alert-info {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--primary-color);
}

/* Form text styling for both light and dark modes */
.form-text {
  color: var(--text-secondary) !important;
  font-size: 0.875rem !important;
  margin-top: 0.25rem !important;
  line-height: 1.4 !important;
  display: block !important;
}

/* Ensure form-text visibility in light mode */
[data-theme="light"] .form-text,
[data-user-theme="light"] .form-text {
  color: #6c757d !important;
  opacity: 1 !important;
}

/* Ensure form-text visibility in dark mode */
[data-theme="dark"] .form-text,
[data-user-theme="dark"] .form-text {
  color: #adb5bd !important;
  opacity: 1 !important;
}

/* Auto mode - follow system preference */
@media (prefers-color-scheme: light) {
  [data-user-theme="auto"] .form-text {
    color: #6c757d !important;
    opacity: 1 !important;
  }
}

@media (prefers-color-scheme: dark) {
  [data-user-theme="auto"] .form-text {
    color: #adb5bd !important;
    opacity: 1 !important;
  }
}

/* Lockout Message Container - fixed height to prevent layout shifts */
.lockout-message-container {
  height: 56px !important; /* Slightly taller to accommodate border-radius */
  min-height: 56px !important; 
  max-height: 56px !important;
  position: relative;
  overflow: visible !important; /* Allow border-radius to show */
  margin-bottom: 1rem !important; /* Standard form spacing */
  padding: 2px 0 !important; /* Small padding to ensure border-radius shows */
}

.lockout-message-container .alert {
  position: absolute !important;
  width: calc(100% - 0px) !important; /* Full width within container */
  top: 2px !important; /* Slight offset to show top border-radius */
  left: 0 !important;
  margin: 0 !important; /* Remove all margins */
  padding: 0.75rem 1rem !important; /* Standard Bootstrap alert padding */
  transition: opacity 0.3s ease;
  display: flex !important; /* Use flexbox for centering */
  align-items: center !important; /* Vertical center */
  justify-content: flex-start !important; /* Horizontal alignment with icon */
  height: 52px !important; /* Alert height fits within container */
  box-sizing: border-box !important;
  line-height: 1.2 !important; /* Compact line height */
  font-size: 0.875rem !important; /* Slightly smaller text to fit */
  border-radius: 0.375rem !important; /* Ensure Bootstrap border-radius */
}

/* Ensure alert text colors are always proper for desktop view */
.lockout-message-container .alert-danger,
.lockout-message-container .alert-danger span,
.lockout-message-container .alert-danger button {
  color: #721c24 !important; /* Dark red text on light red background */
}

.lockout-message-container .alert-success,
.lockout-message-container .alert-success span,
.lockout-message-container .alert-success button {
  color: #0f5132 !important; /* Dark green text on light green background */
}

.lockout-message-container .alert-warning,
.lockout-message-container .alert-warning span,
.lockout-message-container .alert-warning button {
  color: #664d03 !important; /* Dark yellow text on light yellow background */
}

.lockout-message-container .alert.d-none {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
  z-index: -1 !important;
}

.lockout-message-container .alert:not(.d-none) {
  opacity: 1 !important;
  pointer-events: auto !important;
  visibility: visible !important;
  z-index: 1 !important;
}

/* Ensure only one message shows at a time */
#lockoutError:not(.d-none),
#lockoutWarning:not(.d-none),
#loginError:not(.d-none),
#loginSuccess:not(.d-none),
#registerError:not(.d-none),
#registerSuccess:not(.d-none) {
  display: flex !important; /* Use flexbox for centering */
  align-items: center !important; /* Vertical center */
  justify-content: flex-start !important; /* Horizontal alignment with icon */
  opacity: 1 !important;
  visibility: visible !important;
  position: absolute !important;
  top: 2px !important; /* Consistent offset */
  left: 0 !important;
  width: calc(100% - 0px) !important;
  height: 52px !important;
  margin: 0 !important;
  z-index: 1 !important;
  border-radius: 0.375rem !important; /* Preserve rounded corners */
}

/* Loading states */
.loading {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Two-factor authentication */
.totp-input {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin: 1rem 0;
}

.totp-digit {
  width: 3rem;
  height: 3rem;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.totp-digit:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

/* Profile management */
.profile-section {
  margin-bottom: 2rem;
}

.profile-section:last-child {
  margin-bottom: 0;
}

/* Side-by-side layout for profile info and address */
.profile-info-container {
  display: flex;
  gap: 2rem;
  margin-bottom: 2rem;
}

.profile-section-half {
  flex: 1;
  margin-bottom: 0;
}

.profile-info {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.info-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.info-value {
  font-size: 1rem;
  color: var(--text-primary);
}

/* Mobile-first responsive design with high specificity */
@media (max-width: 768px) {
  /* Force proper mobile layout */
  body {
    font-size: 16px !important; /* Prevents zoom on iOS */
  }
  
  .container {
    padding: 0 0.5rem !important;
  }
  
  /* Auth layout mobile optimizations - High specificity overrides */
  .auth-container {
    padding: 0.5rem !important;
    min-height: 100vh !important;
    align-items: flex-start !important;
    padding-top: 1rem !important;
    justify-content: flex-start !important;
  }
  
  .auth-card {
    margin: 0 !important;
    max-width: 100% !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15) !important;
    width: calc(100vw - 1rem) !important;
  }
  
  /* Drastically reduce header padding */
  .auth-header {
    padding: 1rem 1rem 0.5rem !important;
    margin-bottom: 0 !important;
  }
  
  .auth-header h1,
  .auth-header .h3 {
    font-size: 1.25rem !important;
    margin-bottom: 0.25rem !important;
    color: var(--text-primary) !important;
    font-weight: 600 !important;
  }
  
  .auth-header p {
    font-size: 0.875rem !important;
    color: var(--text-secondary) !important;
    margin-bottom: 0 !important;
    line-height: 1.3 !important;
  }
  
  /* Reduce form container padding significantly */
  .auth-form-container {
    padding: 1rem 1rem 1.5rem !important;
  }
  
  /* Make logo smaller */
  .logo img,
  .logo-image,
  .auth-header .logo img,
  .auth-header .logo-image {
    height: 40px !important;
    margin-bottom: 0.5rem !important;
  }
  
  /* App info card - make it more compact */
  .app-info-card {
    margin-bottom: 1rem !important;
    padding: 0.75rem !important;
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
  }
  
  .app-info-header {
    gap: 0.5rem !important;
  }
  
  .app-icon,
  .app-icon-placeholder {
    width: 32px !important;
    height: 32px !important;
  }
  
  .app-info-text h6 {
    color: var(--text-primary) !important;
    font-size: 0.875rem !important;
    margin-bottom: 0.125rem !important;
    font-weight: 600 !important;
  }
  
  .app-info-text small {
    color: var(--text-secondary) !important;
    font-size: 0.75rem !important;
  }
  
  /* Form improvements - reduce spacing */
  .form-floating {
    margin-bottom: 0.875rem !important;
  }
  
  .form-floating > .form-control {
    font-size: 16px !important; /* Prevents zoom on iOS */
    padding: 0.875rem 0.75rem !important;
    border: 1px solid var(--border) !important;
    background: var(--surface) !important;
    color: var(--text-primary) !important;
  }
  
  .form-floating > label {
    color: var(--text-secondary) !important;
    font-size: 0.875rem !important;
    padding: 0.875rem 0.75rem !important;
  }
  
  .form-control:focus ~ label,
  .form-control:not(:placeholder-shown) ~ label {
    color: var(--primary-color) !important;
    font-size: 0.75rem !important;
  }
  
  /* Fix the remember me / forgot password section */
  .d-flex.justify-content-between.align-items-center {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.5rem !important;
    margin-bottom: 1rem !important;
  }
  
  .form-check {
    order: 2 !important;
    margin-bottom: 0 !important;
  }
  
  .form-check-label {
    color: var(--text-primary) !important;
    font-size: 0.875rem !important;
  }
  
  .form-check-input {
    margin-right: 0.5rem !important;
  }
  
  /* Forgot password link */
  .d-flex.justify-content-between.align-items-center a {
    order: 1 !important;
    color: var(--primary-color) !important;
    text-decoration: none !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
  }
  
  .d-flex.justify-content-between.align-items-center a:hover {
    color: var(--primary-hover) !important;
    text-decoration: underline !important;
  }
  
  /* Button styling */
  .btn-primary {
    padding: 0.75rem !important;
    font-size: 1rem !important;
    margin-bottom: 1rem !important;
    background: var(--primary-color) !important;
    border: none !important;
    color: white !important;
  }
  
  .btn-primary:hover,
  .btn-primary:focus {
    background: var(--primary-hover) !important;
    color: white !important;
  }
  
  /* Auth footer - reduce spacing */
  .auth-footer {
    text-align: center !important;
    margin-top: 0.5rem !important;
    padding-top: 0.75rem !important;
    border-top: 1px solid var(--border) !important;
  }
  
  .auth-footer p {
    color: var(--text-secondary) !important;
    font-size: 0.875rem !important;
    margin-bottom: 0 !important;
  }
  
  .auth-footer a {
    color: var(--primary-color) !important;
    text-decoration: none !important;
    font-weight: 500 !important;
  }
  
  .auth-footer a:hover {
    color: var(--primary-hover) !important;
    text-decoration: underline !important;
  }
  
  /* Fix form-text visibility and styling */
  .form-text {
    color: var(--text-secondary) !important;
    font-size: 0.75rem !important;
    margin-top: 0.25rem !important;
    line-height: 1.3 !important;
    opacity: 1 !important;
    visibility: visible !important;
  }
  
  /* Mobile lockout message container adjustments */
  .lockout-message-container {
    height: auto !important;
    min-height: 52px !important;
    max-height: none !important;
    margin-bottom: 1rem !important;
    padding: 2px 0 !important;
    overflow: visible !important;
  }
  
  .lockout-message-container .alert {
    position: relative !important;
    font-size: 0.75rem !important;
    padding: 0.6rem 0.75rem !important;
    height: auto !important;
    min-height: 48px !important;
    line-height: 1.3 !important;
    border-radius: 6px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
  }
  
  /* Ensure alert text colors are always proper regardless of theme */
  .lockout-message-container .alert-danger,
  .lockout-message-container .alert-danger span,
  .lockout-message-container .alert-danger button {
    color: #721c24 !important; /* Dark red text on light red background */
  }
  
  .lockout-message-container .alert-success,
  .lockout-message-container .alert-success span,
  .lockout-message-container .alert-success button {
    color: #0f5132 !important; /* Dark green text on light green background */
  }
  
  .lockout-message-container .alert-warning,
  .lockout-message-container .alert-warning span, 
  .lockout-message-container .alert-warning button {
    color: #664d03 !important; /* Dark yellow text on light yellow background */
  }
  
  .lockout-message-container .alert span {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: nowrap !important;
  }
  
  /* Fix checkbox spacing to prevent overlap with error messages */
  .form-check {
    margin-bottom: 0.875rem !important;
    padding-left: 1.5em !important;
    clear: both !important;
  }
  
  .form-check + .form-check {
    margin-top: 0.625rem !important;
  }
  
  .form-check + .lockout-message-container {
    margin-top: 0.75rem !important;
  }
  
  /* TOTP mobile improvements */
  .totp-input-group {
    gap: 0.375rem !important;
    justify-content: center !important;
    margin-bottom: 1rem !important;
  }
  
  .totp-digit {
    width: 2.25rem !important;
    height: 2.25rem !important;
    text-align: center !important;
    font-size: 1.125rem !important;
    font-weight: 600 !important;
    border: 1px solid var(--border) !important;
    background: var(--surface) !important;
    color: var(--text-primary) !important;
  }
  
  .totp-digit:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2) !important;
  }
  
  /* Override any remaining Bootstrap dark text issues */
  .auth-card .text-muted,
  .auth-card .text-secondary,
  .text-muted,
  .text-secondary {
    color: var(--text-secondary) !important;
  }
  
  .auth-card .text-primary {
    color: var(--text-primary) !important;
  }
  
  /* Ensure all text elements have proper colors */
  .auth-card h1,
  .auth-card h2,
  .auth-card h3,
  .auth-card h4,
  .auth-card h5,
  .auth-card h6,
  .auth-card p,
  .auth-card span,
  .auth-card div {
    color: var(--text-primary) !important;
  }
  
  .auth-card small {
    color: var(--text-secondary) !important;
  }
  
  /* Navigation and other elements */
  .header-content {
    flex-direction: column !important;
    gap: 1rem !important;
  }
  
  .nav {
    justify-content: center !important;
    flex-wrap: wrap !important;
  }
  
  .profile-info {
    grid-template-columns: 1fr !important;
  }
  
  .profile-info-container {
    flex-direction: column !important;
    gap: 1rem !important;
  }
  
  .profile-section-half {
    margin-bottom: 1rem !important;
  }
}

/* Extra small screens (phones in portrait) - Ultra compact */
@media (max-width: 480px) {
  .auth-container {
    padding: 0.25rem !important;
    padding-top: 0.5rem !important;
  }
  
  .auth-card {
    width: calc(100vw - 0.5rem) !important;
    margin: 0.25rem auto !important;
  }
  
  .auth-header {
    padding: 0.75rem 0.75rem 0.25rem !important;
  }
  
  .auth-header h1,
  .auth-header .h3 {
    font-size: 1.125rem !important;
    margin-bottom: 0.125rem !important;
  }
  
  .auth-header p {
    font-size: 0.8125rem !important;
  }
  
  .auth-form-container {
    padding: 0.75rem 0.75rem 1rem !important;
  }
  
  .app-info-card {
    padding: 0.625rem !important;
    margin-bottom: 0.75rem !important;
  }
  
  .app-icon,
  .app-icon-placeholder {
    width: 28px !important;
    height: 28px !important;
  }
  
  .app-info-text h6 {
    font-size: 0.8125rem !important;
  }
  
  .app-info-text small {
    font-size: 0.6875rem !important;
  }
  
  /* Tighter form spacing */
  .form-floating {
    margin-bottom: 0.75rem !important;
  }
  
  .form-floating > .form-control {
    padding: 0.75rem 0.625rem !important;
  }
  
  .form-floating > label {
    padding: 0.75rem 0.625rem !important;
  }
  
  .btn-primary {
    padding: 0.625rem !important;
    margin-bottom: 0.75rem !important;
  }
  
  .d-flex.justify-content-between.align-items-center {
    gap: 0.375rem !important;
    margin-bottom: 0.75rem !important;
  }
  
  .auth-footer {
    margin-top: 0.25rem !important;
    padding-top: 0.5rem !important;
  }
  
  /* TOTP for small screens */
  .totp-input-group {
    gap: 0.25rem !important;
  }
  
  .totp-digit {
    width: 2rem !important;
    height: 2rem !important;
    font-size: 1rem !important;
  }
  
  /* Logo even smaller */
  .logo img,
  .logo-image,
  .auth-header .logo img,
  .auth-header .logo-image {
    height: 36px !important;
    margin-bottom: 0.25rem !important;
  }
}

/* Utility classes */
.hidden {
  display: none !important;
}

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

.text-sm {
  font-size: 0.875rem;
}

.text-muted {
  color: var(--text-secondary) !important;
}

.text-primary {
  color: var(--text-primary) !important;
}

.text-secondary {
  color: var(--text-secondary) !important;
}

/* Ensure Bootstrap classes work with our theme */
.btn-primary .text-muted,
.auth-footer .text-muted {
  color: var(--text-secondary) !important;
}

/* Fix any potential dark-on-dark issues */
.app-info-card .text-muted,
.app-info-card small {
  color: var(--text-secondary) !important;
}

.auth-header .text-muted {
  color: var(--text-secondary) !important;
}

/* Additional mobile-specific improvements */
@media (max-width: 768px) {
  /* Ensure proper text contrast on all elements */
  .auth-card * {
    color: var(--text-primary);
  }
  
  .auth-card .text-muted,
  .auth-card .text-secondary {
    color: var(--text-secondary) !important;
  }
  
  /* Improve link visibility */
  .auth-card a {
    color: var(--primary-color);
    font-weight: 500;
  }
  
  .auth-card a:hover {
    color: var(--primary-hover);
  }
  
  /* Make sure form labels are visible */
  .form-floating > label {
    color: var(--text-secondary) !important;
    font-size: 0.9rem;
  }
  
  .form-control:focus ~ label,
  .form-control:not(:placeholder-shown) ~ label {
    color: var(--primary-color) !important;
  }
  
  /* TOTP mobile improvements */
  .totp-input-group {
    gap: 0.5rem;
    justify-content: center;
  }
  
  .totp-digit {
    width: 2.5rem;
    height: 2.5rem;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 600;
  }
  
  /* Better button spacing */
  .btn {
    font-size: 1rem;
    padding: 0.75rem 1rem;
  }
}

.mb-4 {
  margin-bottom: 1rem;
}

.mt-4 {
  margin-top: 1rem;
}

/* Focus management for accessibility */
.focus-visible:focus {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* ===========================
   DASHBOARD LAYOUT STYLES
   =========================== */

/* Dashboard Layout Structure */
.dashboard-layout {
  background-color: var(--background);
  margin: 0;
  padding: 0;
}

.dashboard-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Side Navigation */
.side-nav {
  width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.side-nav-header {
  padding: 12px 16px 0px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 64px;
  flex-shrink: 0;
}

.side-nav .logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.side-nav .logo-image {
  width: 140px;
  height: 50px;
  flex-shrink: 0;
  object-fit: contain;
  transition: transform 0.2s ease;
}

.side-nav .logo-image:hover {
  transform: scale(1.05);
}

/* Theme-specific logo visibility */
.logo-dark-theme,
.logo-light-theme {
  width: 140px;
  height: 50px;
  object-fit: contain;
  transition: transform 0.2s ease;
}

/* Default state - show dark logo for light backgrounds */
.logo-dark-theme {
  display: block;
}

.logo-light-theme {
  display: none;
}

/* Dark theme explicit - show light logo, hide dark logo */
[data-theme="dark"] .logo-dark-theme,
html[data-theme="dark"] .admin-layout .logo-dark-theme {
  display: none !important;
}

[data-theme="dark"] .logo-light-theme,
html[data-theme="dark"] .admin-layout .logo-light-theme {
  display: block !important;
}

/* Light theme explicit - show dark logo, hide light logo */
[data-theme="light"] .logo-dark-theme,
html[data-theme="light"] .admin-layout .logo-dark-theme {
  display: block !important;
}

[data-theme="light"] .logo-light-theme,
html[data-theme="light"] .admin-layout .logo-light-theme {
  display: none !important;
}

/* Auto dark theme (browser preference) - show light logo, hide dark logo */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .logo-dark-theme,
  html:not([data-theme]) .admin-layout .logo-dark-theme {
    display: none !important;
  }
  
  :root:not([data-theme]) .logo-light-theme,
  html:not([data-theme]) .admin-layout .logo-light-theme {
    display: block !important;
  }
}

/* Auto light theme (browser preference) - show dark logo, hide light logo */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .logo-dark-theme,
  html:not([data-theme]) .admin-layout .logo-dark-theme {
    display: block !important;
  }
  
  :root:not([data-theme]) .logo-light-theme,
  html:not([data-theme]) .admin-layout .logo-light-theme {
    display: none !important;
  }
}

/* Admin-specific logo theme overrides with highest specificity */
.admin-side-nav .logo .logo-dark-theme {
  display: block;
}

.admin-side-nav .logo .logo-light-theme {
  display: none;
}

html[data-theme="dark"] .admin-side-nav .logo .logo-dark-theme {
  display: none !important;
}

html[data-theme="dark"] .admin-side-nav .logo .logo-light-theme {
  display: block !important;
}

html[data-theme="light"] .admin-side-nav .logo .logo-dark-theme {
  display: block !important;
}

html[data-theme="light"] .admin-side-nav .logo .logo-light-theme {
  display: none !important;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme]) .admin-side-nav .logo .logo-dark-theme {
    display: none !important;
  }
  
  html:not([data-theme]) .admin-side-nav .logo .logo-light-theme {
    display: block !important;
  }
}

@media (prefers-color-scheme: light) {
  html:not([data-theme]) .admin-side-nav .logo .logo-dark-theme {
    display: block !important;
  }
  
  html:not([data-theme]) .admin-side-nav .logo .logo-light-theme {
    display: none !important;
  }
}

.side-nav .logo svg {
  width: 48px;
  height: 48px;
  flex-shrink: 0; /* Don't let SVG shrink */
}

.side-nav .logo-text {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.side-nav-menu {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.nav-list {
  list-style: none;
  padding: 0 12px;
}

.nav-item {
  margin-bottom: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius);
  transition: all 0.2s ease;
  font-weight: 500;
}

.nav-link:hover {
  background-color: var(--primary-light);
  color: var(--primary-color);
  text-decoration: none;
}

.nav-link.active {
  background-color: var(--primary-color);
  color: white;
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-section {
  margin-top: 32px;
  padding: 0 12px;
}

.nav-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding: 0 16px;
}

.nav-section-divider {
  margin-top: 24px;
  margin-bottom: 8px;
  padding: 0;
  list-style: none;
}

.nav-section-divider .nav-section-title {
  margin-bottom: 8px;
}

.app-launcher-sidebar {
  padding: 0 16px;
}

.side-nav-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.nav-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar-small {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 14px;
}

.user-details {
  flex: 1;
  min-width: 0;
}

.user-details .user-name {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-details .user-email {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main Content Area */
.main-content {
  flex: 1;
  margin-left: 280px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top Navigation */
.top-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 20;
}

.top-nav-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.mobile-menu-toggle:hover {
  background-color: var(--primary-light);
  color: var(--primary-color);
}

.page-title-mobile {
  display: none;
}

.page-title-mobile h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.top-nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto; /* Ensure actions are on the right */
  height: 100%; /* Match parent height for proper centering */
}

.action-btn {
  background: none;
  border: none;
  padding: 8px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-btn:hover {
  background-color: var(--primary-light);
  color: var(--primary-color);
}

/* User Dropdown */
.user-dropdown {
  position: relative;
}

.user-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: none;
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
}

.user-dropdown-toggle:hover {
  background-color: var(--primary-light);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 14px;
}

.user-info-desktop {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.user-info-desktop .user-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.2;
}

.user-role {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.2;
}

.dropdown-arrow {
  transition: transform 0.2s ease;
}

.user-dropdown.active .dropdown-arrow {
  transform: rotate(180deg);
}

.user-dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s ease;
  z-index: 50;
  margin-top: 8px;
}

.user-dropdown-menu.active,
.user-dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-header {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.user-avatar-large {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 18px;
}

.dropdown-header .user-details {
  flex: 1;
}

.dropdown-header .user-name {
  display: block;
  font-weight: 600;
  font-size: 16px;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.dropdown-header .user-email {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s ease;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
}

.dropdown-item:hover {
  background-color: var(--primary-light);
  color: var(--primary-color);
  text-decoration: none;
}

.dropdown-divider {
  height: 1px;
  background-color: var(--border);
  margin: 8px 0;
}

/* Content Area */
.content-area {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
}

/* Dashboard Page Styles */
.dashboard-page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.page-header p {
  font-size: 16px;
  color: var(--text-secondary);
}

/* Card Grid and Status Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  margin-bottom: 40px;
}

.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: all 0.2s ease;
}

/* Subscription Grid and Cards */
.subscription-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.subscription-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.subscription-card:hover {
  border-color: var(--primary-color);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.subscription-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.subscription-title h3 {
  margin: 0 0 4px 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.subscription-description {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.subscription-body {
  padding: 20px;
}

.subscription-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}

.detail-row .label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
  min-width: 100px;
}

.detail-row .value {
  font-size: 0.875rem;
  color: var(--text-primary);
  font-weight: 500;
  text-align: right;
  flex: 1;
}

.subscription-actions {
  padding: 16px 20px 20px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  background: var(--surface-light);
}

.subscription-actions .btn {
  min-width: 100px;
}

/* Status badges for subscriptions */
.status-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

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

.status-cancelled {
  background: #fee2e2;
  color: #991b1b;
}

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

.status-pending {
  background: #e0e7ff;
  color: #3730a3;
}

/* Modal detail styles */
.detail-section {
  margin-bottom: 24px;
}

.detail-section h4 {
  margin: 0 0 16px 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.detail-grid {
  display: grid;
  gap: 12px;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.detail-item label {
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0;
  min-width: 120px;
}

.detail-item span {
  color: var(--text-primary);
  text-align: right;
  flex: 1;
}

/* Loading state */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

/* API Key Stats Modal */
.stats-overview {
  margin-bottom: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stats-grid .stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.stats-grid .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 4px;
}

.stats-grid .stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.top-endpoints h4 {
  margin: 0 0 16px 0;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.endpoints-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.endpoint-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface-secondary);
  border-radius: 6px;
}

.endpoint-path {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.endpoint-count {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.stats-note {
  margin-top: 24px;
  padding: 16px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 6px;
}

.stats-note p {
  margin: 0;
  font-size: 0.875rem;
  color: #92400e;
}

.status-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-color);
}

.status-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.status-icon.status-success {
  background-color: #dcfce7;
  color: var(--success-color);
}

.status-icon.status-warning {
  background-color: #fef3c7;
  color: var(--warning-color);
}

.status-icon.status-muted {
  background-color: #f1f5f9;
  color: var(--text-secondary);
}

.status-content h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.status-content p {
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Dashboard Sections */
.dashboard-section {
  margin-bottom: 40px;
}

.dashboard-section h2 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 20px;
}

/* Activity List - User Dashboard Style */
.unified-card-content .activity-list,
.activity-list {
  background: var(--surface) !important;
  border: none !important;
  border-radius: 0 !important;
  overflow: hidden !important;
  display: block !important;
  max-width: 100% !important;
  grid-template-columns: none !important;
  grid-template-rows: none !important;
  flex-direction: column !important;
}

.unified-card-content .activity-item,
.activity-item {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 12px 1.5rem !important;
  border-bottom: 1px solid var(--border) !important;
  transition: background-color 0.15s ease !important;
  width: 100% !important;
  grid-column: unset !important;
  grid-row: unset !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
}

.unified-card-content .activity-item:hover,
.activity-item:hover {
  background: var(--surface-hover) !important;
}

.unified-card-content .activity-item:last-child,
.activity-item:last-child {
  border-bottom: none !important;
}

.activity-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-tertiary);
  border-radius: 50%;
  color: var(--text-secondary);
  flex-shrink: 0;
}

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

.activity-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.activity-description {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0;
}

.activity-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 0;
}

.activity-type {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  background: var(--surface-tertiary);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.activity-time {
  font-weight: 500;
  color: var(--text-secondary);
}

.activity-user {
  color: var(--text-secondary);
}

.activity-user:before {
  content: "•";
  margin-right: 4px;
}

/* Loading and error states */
.loading-state, .error-state, .empty-state {
  padding: 3rem 2rem;
  text-align: center;
  color: var(--text-secondary);
}

.loading-state .loading-spinner {
  margin: 0 auto 1rem auto;
}

/* Action Grid */
.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.action-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  text-decoration: none;
  transition: all 0.2s ease;
  display: block;
}

.action-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-color);
  text-decoration: none;
  transform: translateY(-2px);
}

.action-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.action-card h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.action-card p {
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Mobile Overlay */
.mobile-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 25;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.mobile-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .main-content {
    margin-left: 0;
  }
  
  .side-nav {
    transform: translateX(-100%);
  }
  
  .side-nav.mobile-open {
    transform: translateX(0);
  }
  
  .mobile-menu-toggle {
    display: block;
  }
  
  .content-area {
    padding: 20px;
  }
}

@media (max-width: 768px) {
  .page-title-mobile {
    display: block;
  }
  
  .user-info-desktop {
    display: none;
  }
  
  .card-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .action-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .page-header h1 {
    font-size: 24px;
  }
  
  .content-area {
    padding: 16px;
  }
  
  .user-dropdown-menu {
    width: 260px;
  }
}

@media (max-width: 480px) {
  .top-nav {
    padding: 0 16px;
  }
  
  .status-card {
    padding: 20px;
  }
  
  .activity-item {
    padding: 16px;
  }
  
  .action-card {
    padding: 20px;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border: #000000;
    --text-secondary: #000000;
  }
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: none; /* Hidden by default */
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.modal.show {
  display: flex !important; /* Show when .show class is added */
  visibility: visible !important;
  opacity: 1 !important;
  animation: fadeIn 0.2s ease-out;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideIn 0.3s ease-out;
  margin: auto;
  position: relative;
}

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

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.modal-close:hover {
  background-color: var(--primary-light);
  color: var(--primary-color);
}

.modal-body {
  padding: 24px;
}

.qr-code-container {
  display: flex;
  justify-content: center;
  margin: 20px 0;
  padding: 20px;
  background-color: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.qr-code-container img {
  max-width: 200px;
  width: 100%;
  height: auto;
  border-radius: 4px;
}

.manual-setup {
  margin: 20px 0;
  padding: 16px;
  background-color: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.manual-setup label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.manual-setup code {
  display: block;
  padding: 12px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 14px;
  word-break: break-all;
  user-select: all;
  cursor: text;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.modal-actions .btn {
  min-width: 120px;
  text-align: center;
}

.warning-icon {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 16px;
}

.warning-icon svg {
  color: #f59e0b;
  filter: drop-shadow(0 1px 2px rgba(245, 158, 11, 0.3));
}

.totp-verify-form {
  margin-top: 20px;
}

.totp-input-group {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
}

.totp-digit {
  width: 45px;
  height: 45px;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color 0.2s ease;
}

.totp-digit:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.totp-digit:valid {
  border-color: var(--success-color);
}

/* Modal animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .modal {
    animation: none;
  }

  .modal-content {
    animation: none;
  }
}

/* App Launcher Overlay Styles */
.app-launcher-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
  animation: fadeIn 0.2s ease-out;
  overflow-y: auto;
}

.app-launcher-overlay.hidden {
  display: none;
}

.app-launcher-content {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow: hidden;
  animation: slideIn 0.3s ease-out;
  margin: auto;
  position: relative;
}

.app-launcher-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.app-launcher-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.app-launcher-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.app-launcher-close:hover {
  background-color: var(--primary-light);
  color: var(--primary-color);
}

.app-launcher-grid {
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 20px;
  max-height: 400px;
  overflow-y: auto;
}

.app-launcher-loading {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-secondary);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 12px;
}

.app-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.2s ease;
  cursor: pointer;
}

.app-item:hover {
  background-color: var(--primary-light);
  text-decoration: none;
  transform: translateY(-2px);
}

.app-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-color);
  color: white;
  flex-shrink: 0;
}

.app-icon img {
  width: 32px;
  height: 32px;
  border-radius: 4px;
}

.app-icon svg {
  width: 24px;
  height: 24px;
}

.app-name {
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  line-height: 1.2;
  max-width: 100px;
  word-wrap: break-word;
}

.app-description {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.2;
  max-width: 100px;
  word-wrap: break-word;
  display: none; /* Hidden by default, can be shown on larger screens */
}

/* Responsive design for app launcher */
@media (min-width: 768px) {
  .app-launcher-content {
    max-width: 700px;
  }
  
  .app-launcher-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 24px;
  }
  
  .app-description {
    display: block;
  }
}

@media (max-width: 480px) {
  .app-launcher-overlay {
    padding-top: 20px;
  }
  
  .app-launcher-content {
    width: 95%;
    max-height: 90vh;
  }
  
  .app-launcher-header {
    padding: 16px;
  }
  
  .app-launcher-grid {
    padding: 16px;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 16px;
  }
}

/* Admin Dashboard Styles */
.admin-layout {
  --primary-color: #6366f1;
  --primary-dark: #4338ca;
  --primary-light: #e0e7ff;
  --admin-bg: #f8fafc;
}

.admin-side-nav .brand-text {
  color: var(--primary-color);
  font-weight: 600;
}

.admin-top-nav {
  color: var(--text-primary);
}

.admin-top-nav .page-title h1 {
  color: var(--text-primary);
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.admin-badge {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  margin-left: 1rem;
}

.admin-badge-small {
  background: var(--primary-color);
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: 0.75rem;
  font-size: 0.65rem;
  font-weight: 500;
  margin-top: 0.25rem;
  display: inline-block;
}

.admin-role {
  color: var(--primary-color) !important;
  font-weight: 600;
}

.user-role.admin-role {
  color: var(--primary-color) !important;
}

.admin-content {
  background: var(--admin-bg);
  min-height: calc(100vh - 80px);
  padding: 2rem;
}

.admin-header {
  margin-bottom: 2rem;
}

.admin-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.5rem 0;
}

.admin-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin: 0;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.admin-stat-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -1px rgb(0 0 0 / 0.06);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.admin-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 10px 10px -5px rgb(0 0 0 / 0.04);
}

.admin-stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--primary-color);
}

.admin-stat-card:nth-child(2)::before {
  background: #059669;
}

.admin-stat-card:nth-child(3)::before {
  background: #d97706;
}

.admin-stat-card:nth-child(4)::before {
  background: #dc2626;
}

.admin-stat-icon {
  width: 60px;
  height: 60px;
  background: var(--primary-light);
  color: var(--primary-color);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.admin-stat-card:nth-child(2) .admin-stat-icon {
  background: #d1fae5;
  color: #059669;
}

.admin-stat-card:nth-child(3) .admin-stat-icon {
  background: #fed7aa;
  color: #d97706;
}

.admin-stat-card:nth-child(4) .admin-stat-icon {
  background: #fecaca;
  color: #dc2626;
}

.admin-stat-info {
  flex: 1;
}

.admin-stat-number {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  line-height: 1;
}

.admin-stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.admin-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -1px rgb(0 0 0 / 0.06);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: all 0.3s ease;
}

.admin-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 10px 10px -5px rgb(0 0 0 / 0.04);
}

.admin-card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 2rem;
}

.admin-card-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.admin-card-body {
  padding: 2rem;
}

.admin-card-body p {
  color: var(--text-secondary);
  margin: 0 0 1.5rem 0;
  line-height: 1.6;
}

.admin-dashboard {
  width: 100%;
  max-width: none;
  margin: 0;
}

.admin-section {
  display: none;
}

.admin-section.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  transition: all 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 10px 10px -5px rgb(0 0 0 / 0.04);
}

.stat-card:nth-child(2) {
  background: linear-gradient(135deg, #059669, #047857);
}

.stat-card:nth-child(3) {
  background: linear-gradient(135deg, #d97706, #b45309);
}

.stat-card:nth-child(4) {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.stat-icon {
  background: rgba(255, 255, 255, 0.2);
  padding: 1rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-content h3 {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0;
  line-height: 1;
}

.stat-content p {
  margin: 0.5rem 0 0 0;
  opacity: 0.9;
  font-size: 1rem;
}

.admin-card {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 2rem;
  overflow: hidden;
}

.admin-card .card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  justify-content: between;
}

.admin-card .card-header h4 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-card .card-body {
  padding: 2rem;
}

.card-actions {
  margin-left: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.admin-table th,
.admin-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  background: var(--background);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-table tbody tr:hover {
  background: var(--background);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.settings-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

/* App Launcher Styles */
.app-launcher-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.app-launcher-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.app-launcher-content {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow: hidden;
  transform: scale(0.9);
  transition: all 0.3s ease;
}

.app-launcher-overlay:not(.hidden) .app-launcher-content {
  transform: scale(1);
}

.app-launcher-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
}

.app-launcher-header h3 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.app-launcher-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-launcher-close:hover {
  background: var(--background);
  color: var(--text-primary);
}

.app-launcher-grid {
  padding: 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1.5rem;
  max-height: 50vh;
  overflow-y: auto;
}

.app-launcher-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 1rem;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.app-launcher-item:hover {
  background: var(--background);
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

.app-launcher-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-launcher-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.app-launcher-icon-placeholder {
  width: 100%;
  height: 100%;
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 600;
}

.app-launcher-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  text-align: center;
  line-height: 1.3;
}

.app-launcher-loading,
.app-launcher-empty,
.app-launcher-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  text-align: center;
  color: var(--text-secondary);
}

.app-launcher-loading .loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

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

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-primary);
}

.form-control {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: border-color 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  background-color: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.form-check-input {
  width: 1.25rem;
  height: 1.25rem;
  cursor: pointer;
}

.form-check-label {
  cursor: pointer;
  margin-bottom: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

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

.btn-secondary:hover {
  background: #475569;
}

.loading-spinner {
  width: 2rem;
  height: 2rem;
  border: 2px solid var(--border);
  border-top: 2px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 2rem auto;
}

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

.activity-list {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.hidden {
  display: none !important;
}

/* Admin navigation active states */
.admin-side-nav .nav-link.active {
  background: var(--primary-light);
  color: var(--primary-color);
}

.admin-side-nav .nav-link.active .nav-icon {
  color: var(--primary-color);
}

/* Responsive adjustments for admin */
@media (max-width: 768px) {
  .admin-content {
    padding: 1rem;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .settings-grid {
    grid-template-columns: 1fr;
  }
  
  .admin-card .card-header {
    padding: 1rem;
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }
  
  .card-actions {
    margin-left: 0;
    width: 100%;
  }
  
  .settings-actions {
    flex-direction: column;
  }
}

/* Admin Dashboard Sections */
.admin-section {
  margin-bottom: 2rem;
}

.admin-section-header {
  margin-bottom: 1rem;
}

.admin-section-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

/* Activity Items */
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

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

.activity-icon {
  width: 40px;
  height: 40px;
  background: var(--primary-light);
  color: var(--primary-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.activity-content {
  flex: 1;
}

.activity-description {
  margin: 0 0 0.25rem 0;
  color: var(--text-primary);
  font-weight: 500;
}

.activity-time {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* System Health */
.system-health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.health-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: var(--background);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.health-label {
  font-weight: 500;
  color: var(--text-primary);
}

.health-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.health-status-ok {
  color: #059669;
}

.health-status-warning {
  color: #d97706;
}

.health-status-error {
  color: #dc2626;
}

/* Modal Improvements */
.modal-dialog {
  max-width: 600px; /* Make modals wider */
}

.modal-lg {
  max-width: 900px; /* Large modals even wider */
}

.modal-xl {
  max-width: 1200px; /* Extra large modals */
}

/* Better spacing for modal content */
.modal-body {
  padding: 2rem;
}

.modal-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
}

.modal-footer {
  padding: 1rem 2rem;
  border-top: 1px solid var(--border);
}

/* Fix admin layout description text */
.app-launcher-description {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  line-height: 1.2;
}

/* Activity List Styles */
.activity-list {
  padding: 0;
  margin: 0;
}

.activity-item {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #e9ecef;
}

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

.activity-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--surface-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  flex-shrink: 0;
}

.activity-icon i {
  font-size: 16px;
}

.activity-icon .text-success {
  color: #198754 !important;
}

.activity-icon .text-primary {
  color: #0d6efd !important;
}

.activity-icon .text-info {
  color: #0dcaf0 !important;
}

.activity-content {
  flex: 1;
}

.activity-title {
  font-weight: 500;
  color: #212529;
  margin-bottom: 2px;
}

.activity-time {
  font-size: 0.875rem;
  color: #6c757d;
}

/* Health Status Styles */
.health-status-warning {
  color: #fd7e14 !important;
}

.health-status-warning i {
  color: #fd7e14;
}

/* Admin Layout Styles */
.admin-layout {
  background-color: var(--background);
}

.admin-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
  color: white;
  border-radius: 6px;
  margin: 0 16px 16px;
  font-size: 0.875rem;
  font-weight: 500;
}

.admin-badge svg {
  width: 16px;
  height: 16px;
}

.admin-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
  color: white;
  border-radius: 50%;
  margin-right: 12px;
}

.nav-divider {
  height: 1px;
  background-color: var(--border);
  margin: 16px 0;
}

.nav-link-secondary {
  color: var(--text-secondary);
  opacity: 0.8;
}

.nav-link-secondary:hover {
  opacity: 1;
  color: var(--primary-color);
}

.nav-link-admin {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.1) 0%, rgba(29, 78, 216, 0.1) 100%);
  border-left: 3px solid var(--primary-color);
}

.nav-link-admin:hover {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.15) 0%, rgba(29, 78, 216, 0.15) 100%);
  color: var(--primary-color);
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.user-role-badge {
  display: inline-block;
  padding: 2px 8px;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
  color: white;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: 4px;
}

/* Admin Dashboard Styles */
.admin-dashboard .stat-number {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin: 8px 0;
}

.stat-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 0;
}

.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.quick-action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.quick-action-card:hover {
  color: var(--text-primary);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-color);
}

.quick-action-icon {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--primary-light) 0%, rgba(37, 99, 235, 0.1) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: var(--primary-color);
}

.quick-action-card h4 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.quick-action-card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 0;
}

/* Admin Page Styles */
.admin-page {
  padding: 0;
}

.page-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Table Styles */
.table-container {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-top: 24px;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-secondary);
}

.table-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.table-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box input {
  padding: 8px 16px 8px 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  width: 250px;
  background: var(--surface);
  color: var(--text-primary);
}

.search-box svg {
  position: absolute;
  left: 12px;
  color: var(--text-secondary);
}

.filter-select {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text-primary);
  min-width: 120px;
  cursor: pointer;
}

/* Ensure select dropdown arrows are visible in dark mode */
.filter-select option {
  background: var(--surface);
  color: var(--text-primary);
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  padding: 16px 24px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:hover {
  background: var(--surface-secondary);
}

/* API Keys Table Styles */
.api-keys-table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  width: 100%;
}

.api-keys-table .table-header {
  background: var(--surface-secondary);
  border-bottom: 1px solid var(--border);
  width: 100%;
}

.api-keys-table .table-row {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr 1fr 1fr 1fr;
  gap: 16px;
  padding: 16px 24px;
  align-items: center;
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.2s;
  width: 100%;
}

.api-keys-table .table-header .table-row {
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--background);
  border-bottom: 1px solid var(--border);
  width: 100%;
}

.api-keys-table .table-body .table-row:hover {
  background: var(--background);
}

.api-keys-table .table-body .table-row:last-child {
  border-bottom: none;
}

.api-keys-table .table-body {
  width: 100%;
}

.api-keys-table .table-cell {
  display: flex;
  align-items: center;
  font-size: 0.875rem;
  width: 100%;
}

.key-info {
  flex: 1;
}

.key-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.key-description {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.key-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.key-preview code {
  background: var(--surface-secondary);
  padding: 4px 8px;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-primary);
  flex: 1;
}

.key-actions {
  display: flex;
  gap: 8px;
}

.action-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.request-count {
  font-weight: 600;
  color: var(--text-primary);
}

/* Responsive table */
@media (max-width: 768px) {
  .api-keys-table .table-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .api-keys-table .table-cell {
    justify-content: space-between;
  }
  
  .api-keys-table .table-cell::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: 8px;
  }
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-name {
  font-weight: 500;
  color: var(--text-primary);
}

.user-id {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.role-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.role-badge {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: capitalize;
}

.role-badge.role-admin {
  background: #fee2e2;
  color: #dc2626;
}

.role-badge.role-user {
  background: #e0f2fe;
  color: #0277bd;
}

.status-badge {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: capitalize;
}

.status-badge.status-active,
.status-badge.status-enabled,
.status-badge.status-success {
  background: #dcfce7;
  color: #059669;
}

.status-badge.status-inactive,
.status-badge.status-disabled,
.status-badge.status-failed {
  background: #fee2e2;
  color: #dc2626;
}

.status-badge.status-verified {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-badge.status-unverified {
  background: #fef3c7;
  color: #d97706;
}

.action-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal.active .modal-content {
  transform: scale(1);
}

.modal-large {
  max-width: 800px;
}

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

.modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--border);
  color: var(--text-primary);
}

.modal-form {
  padding: 24px;
}

/* Modal form styling improvements */
.modal-form input[type="text"],
.modal-form input[type="email"],
.modal-form input[type="password"],
.modal-form select,
.modal-form textarea {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.2s;
  background: var(--surface);
  color: var(--text-primary);
  width: 100%;
  box-sizing: border-box;
}

.modal-form input[type="text"]:focus,
.modal-form input[type="email"]:focus,
.modal-form input[type="password"]:focus,
.modal-form select:focus,
.modal-form textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

.modal-form select[multiple] {
  min-height: 80px;
}

.modal-body {
  padding: 24px;
}

/* Applications Table */
.applications-container {
  margin-top: 24px;
}

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

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

.applications-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* The grid div now holds a table, not a CSS grid */
.applications-grid {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.apps-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.apps-table thead tr {
  border-bottom: 1px solid var(--border);
}

.apps-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  white-space: nowrap;
}

.apps-table td {
  padding: 10px 14px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

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

.app-row {
  transition: background 0.15s;
}

.app-row:hover {
  background: var(--surface-hover, rgba(255,255,255,0.04));
}

.app-row-disabled {
  opacity: 0.5;
}

.app-row-disabled .app-row-name {
  text-decoration: line-through;
  text-decoration-color: var(--text-secondary);
}

/* Column widths */
.apps-table .col-icon  { width: 40px; padding-right: 4px; }
.apps-table .col-name  { min-width: 180px; }
.apps-table .col-group { width: 110px; }
.apps-table .col-roles { width: 200px; }
.apps-table .col-vis   { width: 90px; }
.apps-table .col-status{ width: 60px; text-align: center; }
.apps-table .col-actions { width: 130px; white-space: nowrap; }

/* Icon cell */
.app-table-icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  object-fit: cover;
  display: block;
}

.app-table-icon-fallback {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

/* Name + description stacked */
.app-row-name {
  display: block;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.app-row-desc {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.3;
  max-width: 340px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Group badge */
.group-badge {
  padding: 2px 8px;
  background: var(--primary-color-muted, rgba(99,102,241,.15));
  color: var(--primary-color);
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

/* Role badges */
.role-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: lowercase;
  background: var(--surface-alt, rgba(255,255,255,0.08));
  color: var(--text-secondary);
  border: 1px solid var(--border);
  margin: 1px 2px 1px 0;
}

.role-badge-any {
  color: var(--text-secondary);
  font-style: italic;
  border-style: dashed;
}

/* Visibility badge */
.vis-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.vis-public  { background: rgba(5,150,105,.15);  color: #10b981; }
.vis-private { background: rgba(217,119,6,.15);  color: #f59e0b; }

/* Status dot */
.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot-on  { background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.2); }
.status-dot-off { background: var(--text-secondary); opacity: 0.5; }

/* Table action buttons — compact icon buttons */
.tbl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  margin-right: 3px;
  padding: 0;
  vertical-align: middle;
  text-decoration: none;
}

.tbl-btn:hover                { background: var(--surface-hover, rgba(255,255,255,.06)); color: var(--text-primary); }
.tbl-btn.btn-secondary:hover  { border-color: var(--primary-color); color: var(--primary-color); }
.tbl-btn.btn-info:hover       { border-color: #38bdf8; color: #38bdf8; }
.tbl-btn.btn-warning:hover    { border-color: #f59e0b; color: #f59e0b; }
.tbl-btn.btn-success:hover    { border-color: #10b981; color: #10b981; }
.tbl-btn.btn-danger:hover     { border-color: #ef4444; color: #ef4444; }

/* legacy selectors kept for safety */
.app-name  { font-weight: 600; color: var(--text-primary); }
.app-roles { font-size: 0.75rem; color: var(--text-secondary); }

/* Audit Logs Styles */
.filters-section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 24px;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  align-items: end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.filter-input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text-primary);
}

/* Date input specific styling for dark mode support */
.filter-input[type="date"] {
  background: var(--surface);
  color: var(--text-primary);
  color-scheme: light dark; /* Allows browser to adapt date picker theme */
}

/* Dark mode date picker styling */
html[data-theme="dark"] .filter-input[type="date"] {
  color-scheme: dark;
}

/* Auto theme date picker styling */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .filter-input[type="date"] {
    color-scheme: dark;
  }
}

/* Ensure placeholder text is visible in dark mode */
.filter-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

/* Focus states for better accessibility */
.filter-input:focus,
.filter-select:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
  border-color: var(--primary-color);
}

/* Webkit-specific date picker styling for better dark mode support */
.filter-input[type="date"]::-webkit-calendar-picker-indicator {
  filter: var(--date-picker-icon-filter, none);
  cursor: pointer;
}

/* Dark mode date picker icon filter */
html[data-theme="dark"] .filter-input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
}

/* Auto theme date picker icon filter */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .filter-input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
  }
}

.filter-actions {
  display: flex;
  gap: 8px;
}

/* Invoice Filter Card */
.filter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

.filter-card h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.filter-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.filter-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  align-items: end;
}

.audit-table {
  font-size: 0.8rem;
}

.audit-table .log-row.log-failed {
  background-color: var(--error-bg);
}

.timestamp-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.timestamp-date {
  font-weight: 500;
}

.timestamp-time {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.event-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: capitalize;
  background: var(--surface-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.ip-address {
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 0.8rem;
}

.log-details {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Pagination Styles */
.pagination-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface-secondary);
}

.pagination-info {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.pagination-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.page-numbers {
  display: flex;
  gap: 4px;
}

.page-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.page-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary-color);
}

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

/* Log Details Modal */
.log-details-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 16px;
  align-items: start;
}

.detail-item {
  display: contents;
}

.detail-item.full-width {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: 1fr 2fr;
  gap: 16px;
}

.detail-item label {
  font-weight: 600;
  color: var(--text-secondary);
  padding: 8px 0;
}

.detail-item span {
  padding: 8px 0;
  word-break: break-word;
}

/* JSON Details in Audit Log Modal */
.json-details {
  background: var(--surface-secondary);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: var(--radius);
  overflow-x: auto;
  white-space: pre-wrap;
  font-family: 'Monaco', 'Consolas', 'Courier New', monospace;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-primary);
  max-height: 300px;
  overflow-y: auto;
}

/* Settings Styles */
.settings-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  grid-auto-rows: min-content;
  gap: 1.5rem;
  max-width: none;
  width: 100%;
  align-items: start;
}

.settings-section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  height: fit-content;
}

.section-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-secondary);
}

.section-header h3 {
  margin: 0 0 0.25rem 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.section-header p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.8125rem;
}

.settings-form {
  padding: 1.25rem 1.5rem;
}

/* Settings Form Inputs - Consistent with rest of app */
.settings-form input[type="text"],
.settings-form input[type="email"],
.settings-form input[type="password"],
.settings-form input[type="number"],
.settings-form input[type="url"],
.settings-form textarea,
.settings-form select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text-primary);
  transition: all 0.2s ease;
  font-family: inherit;
  box-sizing: border-box;
}

.settings-form textarea {
  resize: vertical;
  min-height: 80px;
}

.settings-form select {
  cursor: pointer;
  background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%23666" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6,9 12,15 18,9"/></svg>');
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px;
  padding-right: 2.5rem;
  appearance: none;
}

.settings-form input[type="text"]:focus,
.settings-form input[type="email"]:focus,
.settings-form input[type="password"]:focus,
.settings-form input[type="number"]:focus,
.settings-form input[type="url"]:focus,
.settings-form textarea:focus,
.settings-form select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Dark mode input styling */
html[data-theme="dark"] .settings-form input[type="text"],
html[data-theme="dark"] .settings-form input[type="email"],
html[data-theme="dark"] .settings-form input[type="password"],
html[data-theme="dark"] .settings-form input[type="number"],
html[data-theme="dark"] .settings-form input[type="url"],
html[data-theme="dark"] .settings-form textarea {
  background: var(--surface-tertiary);
  border-color: var(--border);
  color: var(--text-primary);
}

html[data-theme="dark"] .settings-form select.form-control,
html[data-theme="dark"] .settings-form select {
  background: var(--surface-tertiary);
  border-color: var(--border);
  color: var(--text-primary);
  background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%23999" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6,9 12,15 18,9"/></svg>') !important;
  background-repeat: no-repeat !important;
  background-position: right 0.75rem center !important;
  background-size: 16px !important;
}

.settings-form .form-group {
  margin-bottom: 1.25rem;
}

.settings-form .form-group:last-child {
  margin-bottom: 0;
}

.settings-form label {
  display: block;
  margin-bottom: 0.375rem;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.8125rem;
}

.settings-form small {
  display: block;
  margin-top: 0.375rem;
  color: var(--text-secondary);
  font-size: 0.6875rem;
  line-height: 1.3;
}

.color-input-group {
  display: flex;
  gap: 12px;
  align-items: center;
}

.color-input-group input[type="color"] {
  width: 50px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: var(--surface);
}

.color-input-group input[type="text"] {
  flex: 1;
}

/* Settings page checkbox styling */
.settings-form .checkbox-label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  margin-bottom: 0;
  font-weight: 500;
  color: var(--text-primary);
}

.settings-form .checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  appearance: none;
  margin: 0;
}

.settings-form .checkbox-label input[type="checkbox"]:checked {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.settings-form .checkbox-label input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 12px;
  font-weight: bold;
}

.settings-form .checkbox-label input[type="checkbox"]:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Form actions */
.settings-form .form-actions {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* Responsive grid for settings */
@media (max-width: 768px) {
  .settings-container {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .settings-form {
    padding: 1rem;
  }
  
  .section-header {
    padding: 1rem;
  }
}

@media (min-width: 1200px) {
  .settings-container {
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
  }
}

/* Loading States */
.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-spinner.small {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

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

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-secondary);
}

.loading-state p {
  margin-top: 12px;
  margin-bottom: 0;
}

.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--error-color);
  text-align: center;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-secondary);
  text-align: center;
}

.empty-state svg {
  margin-bottom: 16px;
  color: var(--text-secondary);
  opacity: 0.5;
}

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

/* Button Loading States */
.btn-spinner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-spinner.hidden {
  display: none;
}

.btn-text.hidden {
  display: none;
}

/* Notifications */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: var(--radius);
  color: white;
  font-weight: 500;
  z-index: 1001;
  animation: slideIn 0.3s ease;
}

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

.notification-error {
  background: var(--error-color);
}

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

.notification-info {
  background: var(--primary-color);
}

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

/* Mobile Responsive */
@media (max-width: 768px) {
  .quick-actions-grid {
    grid-template-columns: 1fr;
  }
  
  .applications-grid {
    grid-template-columns: 1fr;
  }
  
  .filters-grid {
    grid-template-columns: 1fr;
  }
  
  .page-actions {
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
  }
  
  .table-controls {
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
  }
  
  .search-box input {
    width: 100%;
  }
  
  .pagination-container {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }
  
  .log-details-grid {
    grid-template-columns: 1fr;
  }
  
  .detail-item.full-width {
    grid-template-columns: 1fr;
  }
  
  .settings-container {
    max-width: 100%;
  }
}

/* Phone verification styles */
.phone-input-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.phone-input-group .form-input {
  flex: 1;
}

.phone-input-group .btn {
  flex-shrink: 0;
  min-width: 80px;
}

.sms-input-group {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 16px 0;
}

.sms-digit {
  width: 50px;
  height: 50px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.sms-digit:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.sms-digit.filled {
  border-color: var(--primary-color);
  background: var(--primary-light);
}

/* ===== PAYMENT METHODS STYLES ===== */

/* Payment Element Styles */
.stripe-element {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 16px;
}

.stripe-element:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Loading and Error States */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  text-align: center;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

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

.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  text-align: center;
}

.error-icon {
  color: var(--error-color);
  margin-bottom: 16px;
}

.error-state h3 {
  margin-bottom: 8px;
  color: var(--text-primary);
}

.error-state p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* Payment Methods List */
.payment-methods-list {
  min-height: 120px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  text-align: center;
  color: var(--text-secondary);
}

.empty-state svg {
  margin-bottom: 16px;
  color: var(--text-secondary);
}

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

.payment-method-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  background: var(--surface);
  transition: all 0.2s ease;
}

.payment-method-item:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow);
}

.payment-method-item.default {
  border-color: var(--primary-color);
  background: var(--primary-light);
}

.payment-method-info {
  flex: 1;
}

/* Use the new layout - remove old conflicting rules */

/* Use the new layout - remove old conflicting rules */

.card-info {
  flex: 1;
}

.card-number {
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.default-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--primary-color);
  color: white;
  font-size: 11px;
  font-weight: 500;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-secondary);
}

.card-meta span {
  display: flex;
  align-items: center;
}

.nickname {
  font-style: italic;
  color: var(--primary-color);
}

.payment-method-actions {
  display: flex;
  gap: 8px;
}

.payment-actions {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Form Error Messages */
.form-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--error-color);
  padding: 12px;
  border-radius: var(--radius);
  margin-top: 12px;
  font-size: 14px;
}

/* Submit Button States */
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn:disabled:hover {
  background-color: initial;
  transform: none;
}

/* Toast Messages */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  padding: 16px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: none;
  max-width: 400px;
  font-weight: 500;
}

.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: var(--success-color);
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--error-color);
}

/* Modal Improvements for Payment */
.modal-content {
  max-width: 500px;
  width: 90%;
}

.modal-body {
  max-height: 80vh;
  overflow-y: auto;
}

/* Responsive Design */
@media (max-width: 768px) {
  .payment-method-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .payment-method-actions {
    width: 100%;
    justify-content: flex-end;
  }
  
  .card-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}

/* ===== ADDITIONAL UNIFIED TABLE STYLES ===== */
.unified-table {
    width: 100%;
    border-collapse: collapse;
}

.unified-table-header {
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.unified-table-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    padding: 16px 0;
    border-bottom: 1px solid #f3f4f6;
    transition: background-color 0.2s ease;
}

.unified-table-row:hover {
    background: #f9fafb;
}

.unified-table-header .unified-table-row {
    padding: 12px 0;
    background: transparent;
}

.unified-table-header .unified-table-row:hover {
    background: transparent;
}

.unified-table-cell {
    padding: 0 16px;
    display: flex;
    align-items: center;
    min-height: 40px;
}

.unified-table-header .unified-table-cell {
    font-weight: 600;
    color: #374151;
    font-size: 0.875rem;
    min-height: auto;
}

/* Empty state */
.unified-empty-state {
    text-align: center;
    padding: 48px 24px;
}

.empty-state-icon {
    margin: 0 auto 16px auto;
    color: #9ca3af;
}

.unified-empty-state h3 {
    margin: 0 0 8px 0;
    color: #374151;
    font-size: 1.125rem;
    font-weight: 600;
}

.unified-empty-state p {
    margin: 0 0 24px 0;
    color: #6b7280;
}

/* ===== ADDITIONAL BILLING COMPONENTS ===== */
.unified-billing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
}

.unified-billing-card {
    background: var(--surface-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.billing-card-header {
    padding: 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.billing-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.billing-icon-primary {
    background: #dbeafe;
    color: #2563eb;
}

.billing-icon-info {
    background: #e0f2fe;
    color: #0891b2;
}

.billing-icon-success {
    background: #dcfce7;
    color: #16a34a;
}

.billing-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.billing-card-title h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
}

.count-badge {
    background: #3b82f6;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
}

.outstanding-badge {
    background: #dc2626;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
}

.billing-card-content {
    padding: 20px;
}

.billing-card-footer {
    padding: 16px 20px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

/* Billing card content components */
.subscription-preview,
.invoice-preview {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.subscription-preview .subscription-info,
.invoice-preview .invoice-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.product-name,
.invoice-number {
    font-weight: 600;
    color: #111827;
}

.price,
.amount {
    color: #059669;
    font-weight: 600;
}

.api-usage-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.metric-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.metric-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.invoice-preview-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.more-items {
    color: #6b7280;
    font-size: 0.875rem;
    margin: 8px 0 0 0;
}

.empty-state-mini {
    text-align: center;
    padding: 16px;
}

.empty-state-mini .no-data {
    color: #6b7280;
    margin: 0 0 12px 0;
    font-size: 0.875rem;
}

@media (max-width: 768px) {
    .unified-billing-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .billing-card-header {
        padding: 16px;
    }
    
    .billing-card-content {
        padding: 16px;
    }
    
    .billing-card-footer {
        padding: 12px 16px;
    }
}

/* ===== UNIFIED STATS GRID ===== */
.unified-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.unified-stat-card {
    background: var(--surface-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: all 0.2s ease;
}

.unified-stat-card:hover {
    background: var(--surface-hover);
    border-color: var(--border-color);
}

.stat-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon-primary {
    background: #dbeafe;
    color: #2563eb;
}

.stat-icon-success {
    background: #dcfce7;
    color: #16a34a;
}

.stat-icon-warning {
    background: #fef3c7;
    color: #d97706;
}

.stat-icon-info {
    background: #e0f2fe;
    color: #0891b2;
}

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

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 4px;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 2px;
}

.stat-detail {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 4px;
}

.stat-actions {
    margin-top: 8px;
}

@media (max-width: 768px) {
    .unified-stats-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .unified-stat-card {
        padding: 16px;
        gap: 12px;
    }
    
    .stat-icon {
        width: 32px;
        height: 32px;
    }
    
    .stat-value {
        font-size: 1.25rem;
    }
}

/* ===== CONTENT CONTAINER ===== */
.content-container {
    width: 100%;
    max-width: none;
    padding: 0;
    margin: 0;
}

.content-container .page-header {
    margin-bottom: 32px;
}

.content-container .page-section {
    margin-bottom: 32px;
}

.content-container .page-section:last-child {
    margin-bottom: 0;
}

/* ===== PROFILE PAGE FORMS ===== */
.profile-info-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin-bottom: 32px;
}

.profile-section-half {
    min-height: 100%;
}

.profile-section-half .unified-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.profile-section-half .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.profile-section-half .profile-form,
.profile-section-half .address-form {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.profile-section-half .form-actions {
    margin-top: auto;
}

.profile-form,
.address-form {
    padding: 0;
}

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

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--surface);
    transition: all 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input:disabled,
.form-input[readonly] {
    background: var(--surface-secondary);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.form-help {
    display: block;
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-actions {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #e5e7eb;
}

.phone-input-group {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.phone-input-group .form-input {
    flex: 1;
}

@media (max-width: 768px) {
    .profile-info-container {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .phone-input-group {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
}

/* ===== SECURITY PAGE LAYOUT ===== */
.security-info-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin-bottom: 32px;
}

.security-section-half {
    min-height: 100%;
}

.security-section-half .unified-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.security-section-half .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.security-section-half .security-form {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.security-section-half .form-actions {
    margin-top: auto;
}

.security-section-half .totp-status {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

@media (max-width: 768px) {
    .security-info-container {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}

/* API Keys Page Styles */
.key-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.key-name {
    font-weight: 500;
    color: var(--text-primary);
}

.key-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.key-preview {
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.875rem;
    background: var(--surface-secondary);
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    display: inline-block;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.request-count {
    font-weight: 500;
    color: var(--text-primary);
}

.action-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.action-buttons .btn {
    padding: 6px 8px;
    min-width: auto;
}

/* Standard HTML Table Styles for unified-table */
.unified-table table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

.unified-table table th {
    background: var(--surface-secondary);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.unified-table table td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.unified-table table tr:hover {
    background: var(--surface-secondary);
}

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

.security-notice {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: var(--radius);
    margin-top: 16px;
}

.notice-icon {
    color: #d97706;
    flex-shrink: 0;
}

.notice-content {
    color: #92400e;
    font-size: 0.875rem;
}

.key-display {
    margin: 24px 0;
}

.key-display label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.key-copy-group {
    display: flex;
    gap: 8px;
}

.key-copy-group input {
    flex: 1;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    background: #f8fafc;
    border: 2px solid var(--border);
    padding: 12px;
    border-radius: var(--radius);
    font-size: 0.875rem;
}

.key-copy-group input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.success-message {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #dcfce7;
    border: 1px solid #16a34a;
    border-radius: var(--radius);
    margin-bottom: 24px;
}

.success-icon {
    color: #16a34a;
    flex-shrink: 0;
}

.warning-message {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: #fef2f2;
    border: 1px solid #ef4444;
    border-radius: var(--radius);
}

.warning-icon {
    color: #ef4444;
    flex-shrink: 0;
}

.security-warning {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin: 24px 0;
}

.security-warning p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0;
}

/* Modal Positioning Fix */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.modal-show {
    opacity: 1;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-show .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 24px 24px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--border);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 0 24px 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Notification System */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    max-width: 400px;
    min-width: 300px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary-color);
    z-index: 9999;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    opacity: 1;
}

.notification.notification-show {
    transform: translateX(0);
}

.notification.notification-success {
    border-left-color: var(--success-color);
}

.notification.notification-error {
    border-left-color: var(--error-color);
}

.notification.notification-warning {
    border-left-color: var(--warning-color);
}

.notification-content {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.notification-message {
    flex: 1;
    color: var(--text-primary);
    font-size: 0.875rem;
    line-height: 1.4;
}

.notification-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.notification-close:hover {
    background: var(--border);
    color: var(--text-primary);
}

/* Modal form input styling for admin pages */
.modal .form-group input:not(.form-input),
.modal .form-group textarea:not(.form-input),
.modal .form-group select:not(.form-input) {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px;
  background-color: var(--surface-primary, #ffffff);
  color: var(--text-primary, #1f2937);
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.modal .form-group input:not(.form-input):focus,
.modal .form-group textarea:not(.form-input):focus,
.modal .form-group select:not(.form-input):focus {
  outline: none;
  border-color: var(--primary-color, #3b82f6);
  box-shadow: 0 0 0 3px var(--primary-color-alpha, rgba(59, 130, 246, 0.1));
}

/* Scrollbar theming for dark mode */
[data-theme="dark"] *::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

[data-theme="dark"] *::-webkit-scrollbar-track {
  background: var(--surface-primary);
}

[data-theme="dark"] *::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

[data-theme="dark"] *::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

[data-theme="dark"] * {
  scrollbar-color: var(--border-color) var(--surface-primary);
}

/* Auto theme with dark preference */
@media (prefers-color-scheme: dark) {
  :not([data-theme="light"]) *::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  :not([data-theme="light"]) *::-webkit-scrollbar-track {
    background: var(--surface-primary);
  }

  :not([data-theme="light"]) *::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
  }

  :not([data-theme="light"]) *::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
  }

  :not([data-theme="light"]) * {
    scrollbar-color: var(--border-color) var(--surface-primary);
  }
}

/* Warning text for insecure redirect toggle */
.warning-text {
  display: block;
  font-size: 12px;
  color: var(--warning-color);
  margin-top: 4px;
  font-weight: 500;
}

.form-group .warning-text {
  margin-left: 24px; /* Align with checkbox text */
}

/* ==============================
   Auth header banner
   Light mode: soft grey surface
   Dark mode: pure black
   ============================== */

/* Manual dark theme */
html[data-theme="dark"] .auth-header {
  background: #000000 !important;
}

/* System/auto dark preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .auth-header {
    background: #000000 !important;
  }
}

/* ==============================
   Dark mode — black top banner
   Matches IDE / Builder header
   ============================== */

/* Manual dark theme */
html[data-theme="dark"] .top-nav,
html[data-theme="dark"] .side-nav-header {
  background: #000000;
  border-color: #2a2a2a;
}

/* System/auto dark preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .top-nav,
  :root:not([data-theme]) .side-nav-header {
    background: #000000;
    border-color: #2a2a2a;
  }
}

/* ==============================
   Auth pages: keep inputs white in dark mode
   Auth card is semi-dark, inputs should stay light
   ============================== */

html[data-theme="dark"] .auth-card .form-control,
html[data-theme="dark"] .auth-card .form-floating > .form-control {
  background: #ffffff !important;
  color: #1a1a1a !important;
  border-color: #d0d0d0 !important;
}

html[data-theme="dark"] .auth-card .form-floating > label {
  color: #555555 !important;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .auth-card .form-control,
  :root:not([data-theme]) .auth-card .form-floating > .form-control {
    background: #ffffff !important;
    color: #1a1a1a !important;
    border-color: #d0d0d0 !important;
  }

  :root:not([data-theme]) .auth-card .form-floating > label {
    color: #555555 !important;
  }
}
