/* Taurus.blue Simulation Platform - Design System */

/* Google Fonts - Load before CSS layers for optimal performance */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@700&family=Poppins:wght@400;600&display=swap');

/* ===== CSS Cascade Layers ===== */
/* Define explicit layer order for predictable cascade management */
@layer reset, tokens, base, components, utilities;

/* ===== Layer: Tokens ===== */
@layer tokens {
  /* ===== CSS Variables - Taurus Brand Colors ===== */
  :root {
  color-scheme: light;

  /* Primary Blue Palette */
  --taurus-blue-50: #e8ecf1;
  --taurus-blue-100: #c5cfdb;
  --taurus-blue-200: #9dafc4;
  --taurus-blue-300: #748fae;
  --taurus-blue-400: #4c6f97;
  --taurus-blue-500: #0F2439;  /* Primary — Taurus Blue */
  --taurus-blue-600: #0d1f31;
  --taurus-blue-700: #0a1927;
  --taurus-blue-800: #07131e;
  --taurus-blue-900: #040c14;

  /* Enhanced Color Semantics */
  --primary: #0F2439;
  --primary-hover: #1a3654;
  --primary-light: #e8ecf1;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --accent-light: #fef3c7;
  --success: #10b981;
  --success-light: #d1fae5;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;

  /* Neutral Colors */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Status Colors */
  --success-50: #ecfdf5;
  --success-500: #10b981;
  --success-600: #059669;
  --success-700: #047f59;  /* WCAG AA compliant - darker green for better contrast */
  --warning-50: #fffbeb;
  --warning-500: #f59e0b;
  --warning-600: #d97706;
  --warning-700: #ad5f04;  /* WCAG AA compliant - darker orange for better contrast */
  --error-50: #fef2f2;
  --error-500: #ef4444;
  --error-600: #dc2626;
  --error-700: #d12424;  /* WCAG AA compliant - darker red for better contrast */
  --info-50: #eff6ff;
  --info-500: #3b82f6;
  --info-600: #2563eb;

  /* Enhanced Surface Colors */
  --background: #fafbfc;
  --surface: #ffffff;
  --surface-hover: #f8f9fa;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --text-primary: #1A1A1A;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;

  /* Spacing Scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Typography - Enhanced with custom fonts */
  --font-heading: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Consolas, 'Liberation Mono', Menlo, Monaco, 'Courier New', monospace;

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

  /* Border Radius */
  --radius-sm: 0.25rem;
  --radius: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 300ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Z-index Scale */
  --z-base: 1;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 300;
  --z-toast: 400;
  --z-tooltip: 1070;
  }

  /* Dark Mode Variables */
  [data-theme="dark"] {
    color-scheme: dark;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --border: #334155;
    --border-light: #475569;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    --primary-light: #1e3a8a;
    --accent-light: #78350f;
    --success-light: #064e3b;
    --danger-light: #7f1d1d;
    --warning-light: #78350f;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
  }
}

/* ===== Layer: Reset ===== */
@layer reset {
  /* ===== Reset & Base ===== */
  *, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

  html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* ===== Layer: Base ===== */
@layer base {
  body {
    font-family: var(--font-body);
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--background);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  /* Enhanced Typography with Custom Fonts */
  h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.2;
    color: var(--text-primary);
  }

  a {
    color: var(--taurus-blue-600);
    text-decoration: none;
    transition: color var(--transition-fast);
  }

  a:hover {
    color: var(--taurus-blue-700);
  }

  /* ===== Accessibility ===== */

/* Skip to main content link for keyboard navigation */
.skip-to-main {
  position: absolute;
  left: -9999px;
  z-index: 999;
  padding: 1rem 1.5rem;
  background-color: var(--taurus-blue-600);
  color: white;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.skip-to-main:focus {
  left: 1rem;
  top: 1rem;
  outline: 3px solid var(--taurus-blue-300);
  outline-offset: 2px;
}

/* Screen reader only content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Focus visible styles for keyboard navigation */
*:focus-visible {
  outline: 2px solid var(--taurus-blue-500);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Specific focus styles for buttons */
button:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--taurus-blue-500);
  outline-offset: 2px;
}

/* Focus styles for form inputs */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--taurus-blue-500);
  outline-offset: 0;
  border-color: var(--taurus-blue-500);
}

/* Focus styles for links */
a:focus-visible {
  outline: 2px solid var(--taurus-blue-500);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Focus styles for navigation items */
.nav-item:focus-visible {
  outline: 2px solid var(--taurus-blue-300);
  outline-offset: -2px;
}

/* Enhanced focus ring for cards and interactive elements */
.card:focus-within,
.quick-action-card:focus-visible {
  outline: 2px solid var(--taurus-blue-500);
  outline-offset: 2px;
}

/* ===== Layout ===== */
.app-container {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: linear-gradient(180deg, var(--taurus-blue-800) 0%, var(--taurus-blue-900) 100%);
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: var(--z-sticky);
  transition: transform var(--transition-slow);
}

.sidebar.collapsed {
  transform: translateX(-260px);
}

.sidebar-header {
  padding: var(--space-6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: white;
}

.sidebar-logo svg,
.sidebar-logo img {
  width: 36px;
  height: 36px;
}

.sidebar-logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: white;
}

.sidebar-logo-text span {
  color: #6bb5e8;
}

.sidebar-nav {
  padding: var(--space-4);
}

.nav-section {
  margin-bottom: var(--space-6);
}

.nav-section-title {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--taurus-blue-300);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  color: rgba(255, 255, 255, 0.8);
  font-weight: 500;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
  cursor: pointer;
  margin-bottom: var(--space-1);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.nav-item.active {
  background: var(--taurus-blue-500);
  color: white;
  box-shadow: var(--shadow-md);
}

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

.nav-item .badge {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: auto;
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
}

.user-info-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius-sm);
  padding: var(--space-1);
  margin: calc(-1 * var(--space-1));
  transition: background var(--transition-fast);
}

.user-info-link:hover {
  background: rgba(255, 255, 255, 0.08);
}

.user-info-link:focus-visible {
  outline: 2px solid var(--taurus-blue-400);
  outline-offset: 2px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--taurus-blue-500);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
}

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

.user-name {
  font-weight: 600;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.75rem;
  color: var(--taurus-blue-300);
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 260px;
  transition: margin-left var(--transition-slow);
}

.main-content.expanded {
  margin-left: 0;
}

.top-bar {
  background: var(--surface);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  padding: var(--space-2);
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: var(--radius);
}

.menu-toggle:hover {
  background: var(--surface-hover);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.875rem;
  color: var(--text-muted);
}

.breadcrumb-item {
  color: var(--text-muted);
}

.breadcrumb-item.active {
  color: var(--text-primary);
  font-weight: 500;
}

.breadcrumb-separator {
  color: var(--border);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.api-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.75rem;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--success-50);
  color: var(--success-600);
}

.api-status.error {
  background: var(--error-50);
  color: var(--error-600);
}

.api-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes floatAnimation {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.page-content {
  padding: var(--space-6);
  max-width: 1600px;
  margin: 0 auto;
}

.page-header {
  margin-bottom: var(--space-6);
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

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

/* ===== Layer: Components ===== */
@layer components {
  /* ===== Cards ===== */
  .card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

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

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

.card-body {
  padding: var(--space-5);
}

.card-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-light);
  background: var(--surface-hover);
}

/* ===== Profile Page ===== */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: var(--space-5);
  max-width: 900px;
}

.form-actions {
  padding-top: var(--space-4);
}

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

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

.stat-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
}

.stat-card-icon.blue { background: var(--taurus-blue-100); color: var(--taurus-blue-600); }
.stat-card-icon.green { background: var(--success-50); color: var(--success-700); }  /* Updated for WCAG AA */
.stat-card-icon.yellow { background: var(--warning-50); color: var(--warning-700); }  /* Updated for WCAG AA */
.stat-card-icon.red { background: var(--error-50); color: var(--error-700); }  /* Updated for WCAG AA */
.stat-card-icon.purple { background: #f3e8ff; color: #9333ea; }

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

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

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

.stat-trend {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.75rem;
  margin-top: var(--space-2);
}

.stat-trend.up { color: var(--success-600); }
.stat-trend.down { color: var(--error-600); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  font-family: var(--font-body);
  position: relative;
  overflow: hidden;
}

/* Ripple Effect */
.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s ease, height 0.6s ease;
}

.btn:active::before {
  width: 300px;
  height: 300px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--surface-hover);
  color: var(--text-muted);
  border-color: var(--border);
}

.btn:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn:not(:disabled):active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn svg {
  width: 18px;
  height: 18px;
}

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

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

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

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

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

.btn-danger:hover:not(:disabled) {
  background: var(--error-500);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-primary);
}

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

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

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

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

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: 0.75rem;
}

.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: 1rem;
}

.btn-icon {
  padding: var(--space-2);
}

.btn-icon[aria-pressed="true"],
.btn-ghost[aria-pressed="true"] {
  background: var(--primary-light);
  color: var(--primary);
}

.btn-icon[aria-pressed="true"]:hover:not(:disabled),
.btn-ghost[aria-pressed="true"]:hover:not(:disabled) {
  background: var(--primary-light);
  color: var(--primary);
  filter: brightness(1.1);
}

.btn-group {
  display: flex;
  gap: var(--space-2);
}

/* Button Loading States */
.btn.loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  top: 50%;
  left: 50%;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}

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

/* ===== Forms ===== */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.form-label.required::after {
  content: " *";
  color: var(--error-500);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--taurus-blue-500);
  box-shadow: 0 0 0 3px var(--taurus-blue-100);
}

.form-input.error,
.form-select.error,
.form-textarea.error {
  border-color: var(--error-500);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
  background: var(--surface-hover);
  cursor: not-allowed;
}

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

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.char-counter {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  display: inline-block;
  margin-left: var(--space-2);
  transition: color var(--transition-fast);
}

.char-counter::before {
  content: '•';
  margin-right: var(--space-2);
  color: var(--text-muted);
}

.form-error {
  font-size: 0.75rem;
  color: var(--error-500);
  margin-top: var(--space-1);
}

.form-checkbox,
.form-radio {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.form-checkbox input,
.form-radio input {
  width: 16px;
  height: 16px;
  accent-color: var(--taurus-blue-600);
}

/* ===== Tables ===== */
.table-container {
  overflow-x: auto;
}

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

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

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

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

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

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-full);
}

.badge-blue { background: var(--taurus-blue-100); color: var(--taurus-blue-700); }
.badge-green { background: var(--success-50); color: var(--success-700); }  /* Updated for WCAG AA (4.76:1) */
.badge-yellow { background: var(--warning-50); color: var(--warning-700); }  /* Updated for WCAG AA (4.59:1) */
.badge-red { background: var(--error-50); color: var(--error-700); }  /* Updated for WCAG AA (4.81:1) */
.badge-gray { background: var(--surface-hover); color: var(--text-secondary); }
.badge-purple { background: #f3e8ff; color: #9333ea; }
.badge-teal { background: #ccfbf1; color: #0f766e; }
.badge-indigo { background: #e0e7ff; color: #4338ca; }
.badge-orange { background: #fff7ed; color: #c2410c; }

/* ===== Modals ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
  animation: fadeInBackdrop 0.3s ease;
}

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

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUpSpring 0.4s var(--transition-spring);
}

@keyframes slideUpSpring {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

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

.modal.modal-xl {
  max-width: 900px;
}

.modal-header {
  padding: var(--space-5);
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--surface) 100%);
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.modal-close {
  background: transparent;
  border: 2px solid transparent;
  padding: var(--space-2);
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: var(--radius);
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--danger-light);
  color: var(--danger);
  border-color: var(--danger);
  transform: rotate(90deg);
}

.modal-body {
  padding: var(--space-5);
  overflow-y: auto;
  max-height: calc(90vh - 140px);
}

.modal-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 2px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  background: var(--surface-hover);
}

/* ===== Toast Notifications ===== */
.toast-container {
  position: fixed;
  top: 5rem;
  right: 1.5rem;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) 1.5rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  min-width: 300px;
  max-width: 400px;
  pointer-events: auto;
  animation: toastSlideIn 0.4s var(--transition-spring);
}

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

.toast.toast-success,
.toast.success {
  border-color: var(--success);
  background: var(--success-light);
}

.toast.toast-error,
.toast.error {
  border-color: var(--danger);
  background: var(--danger-light);
}

.toast.toast-warning,
.toast.warning {
  border-color: var(--warning);
  background: var(--warning-light);
}

.toast.toast-info,
.toast.info {
  border-color: var(--primary);
  background: var(--primary-light);
}

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

.toast-success .toast-icon,
.toast.success .toast-icon {
  color: var(--success);
}

.toast-error .toast-icon,
.toast.error .toast-icon {
  color: var(--danger);
}

.toast-warning .toast-icon,
.toast.warning .toast-icon {
  color: var(--warning);
}

.toast-info .toast-icon,
.toast.info .toast-icon {
  color: var(--primary);
}

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

.toast-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.toast-message {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.toast-close {
  background: transparent;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: 4px;
  transition: all var(--transition);
  flex-shrink: 0;
}

.toast-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}

/* ===== Loading Overlay ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998; /* Just below modals (9999) */
  animation: fadeIn 0.2s ease;
}

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

.loading-overlay-content {
  background: var(--surface);
  padding: var(--space-8);
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: var(--shadow-2xl);
  min-width: 200px;
}

.loading-overlay-message {
  margin-top: var(--space-4);
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===== Tabs ===== */
.tabs {
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: var(--space-6);
  margin-bottom: var(--space-5);
}

.tab {
  padding: var(--space-3) 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.tab.active {
  color: var(--taurus-blue-600);
  border-bottom-color: var(--taurus-blue-600);
}

.tab-content {
  display: none;
}

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

/* ===== Empty States ===== */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-4);
  color: var(--text-muted);
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.empty-state-description {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  margin-bottom: var(--space-6);
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.6;
}

.empty-state-compact {
  padding: 2rem 1rem;
}

.empty-icon {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  display: inline-block;
  animation: floatAnimation 3s ease-in-out infinite;
}

/* Enhanced Form States */
.form-input.success,
.form-textarea.success {
  border-color: var(--success);
  background: var(--success-light);
}

.form-input.success:focus,
.form-textarea.success:focus {
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

.form-error-message {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--danger);
  font-weight: 500;
  animation: slideDown 0.2s ease;
}

.form-group.has-error .form-label {
  color: var(--danger);
}

/* ===== Loading States ===== */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--taurus-blue-600);
  border-radius: 50%;
  animation: spin 0.8s linear infinite, fade-in 0s 0.2s both;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.loading-skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--border-light) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Dropdowns ===== */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all var(--transition-fast);
}

.dropdown.active .dropdown-menu,
.dropdown:focus-within .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(4px);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: 0.875rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.dropdown-item:hover {
  background: var(--surface-hover);
}

.dropdown-item.danger {
  color: var(--error-600);
}

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

/* ===== Search ===== */
.search-box {
  position: relative;
}

.search-box input {
  padding-left: 40px;
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);  /* Changed from gray-400 for better contrast (WCAG AA) */
}

/* ===== Data Grid ===== */
.data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-4);
}

.data-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: var(--space-5);
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
}

.data-card:hover {
  box-shadow: var(--shadow-md);
}

.data-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.data-card-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 1rem;
}

.data-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  font-size: 0.875rem;
  color: var(--text-muted);
  flex: 1;
}

.data-card-meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.data-card-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-light);
}

/* ===== Form Grid ===== */
.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}

.form-row.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

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

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-260px);
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .menu-toggle {
    display: flex;
  }

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

@media (max-width: 768px) {
  .page-content {
    padding: var(--space-4);
  }

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

  .modal {
    margin: var(--space-4);
    max-height: calc(100vh - var(--space-8));
  }

  .toast-container {
    right: 1rem;
    left: 1rem;
  }

  .toast {
    min-width: auto;
    max-width: 100%;
  }
}

/* ===== Pagination Controls ===== */
.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-4) 0;
}

.pagination-controls:empty {
  display: none;
}

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

/* ===== Layer: Utilities ===== */
@layer utilities {
  /* ===== Utilities ===== */
  .text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-small { font-size: 0.75rem; }
.text-bold { font-weight: 600; }

.flex { display: flex; }
.flex-1 { flex: 1; }
.flex-center { align-items: center; justify-content: center; }
.flex-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.hidden { display: none !important; }
.visible { visibility: visible; }
.invisible { visibility: hidden; }

/* Additional flexbox utilities */
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }

/* Line clamping utility */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* List utilities */
.list-none { list-style: none; }
.list-style-none { list-style-type: none; }

/* Breadcrumb list */
.breadcrumb-list {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: var(--space-2);
}

/* ===== Login Page ===== */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--taurus-blue-800) 0%, var(--taurus-blue-900) 100%);
  padding: var(--space-4);
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 400px;
  overflow: hidden;
}

.login-header {
  padding: var(--space-8) var(--space-6);
  text-align: center;
  color: var(--taurus-blue-500);
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.login-logo svg,
.login-logo img {
  width: 48px;
  height: 48px;
}

.login-logo-text {
  font-size: 1.5rem;
  font-weight: 700;
}

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

.login-body {
  padding: var(--space-6);
}

.login-footer {
  text-align: center;
  padding: var(--space-4) var(--space-6) var(--space-6);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ===== Quick Actions ===== */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

.quick-action-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.quick-action-card:hover {
  border-color: var(--taurus-blue-300);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.quick-action-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
  font-size: 1.5rem;
}

.quick-action-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.quick-action-description {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Inject Type Icons */
.inject-type-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.inject-type-email { background: var(--info-50); color: var(--info-600); }
.inject-type-sms { background: var(--success-50); color: var(--success-600); }
.inject-type-webhook { background: #fae8ff; color: #a855f7; }

/* ===== Scenario Status Indicator ===== */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.75rem;
}

.status-draft { background: var(--surface-hover); color: var(--text-secondary); }
.status-active { background: var(--success-50); color: var(--success-600); }
.status-paused { background: var(--warning-50); color: var(--warning-600); }
.status-completed { background: var(--info-50); color: var(--info-600); }
.status-archived { background: var(--surface-hover); color: var(--text-muted); }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-active .status-dot {
  animation: pulse 2s infinite;
}

/* ===== Code/JSON Viewer ===== */
.code-block {
  background: #111827;
  color: #f3f4f6;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ===== Progress Bar ===== */
.progress-bar {
  height: 8px;
  background: var(--surface-hover);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--taurus-blue-500);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.progress-bar-fill.success { background: var(--success-500); }
.progress-bar-fill.warning { background: var(--warning-500); }
.progress-bar-fill.error { background: var(--error-500); }

/* ===== Toggle Switch ===== */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border);
  transition: var(--transition);
  border-radius: var(--radius-full);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: var(--transition);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

.toggle input:checked + .toggle-slider {
  background-color: var(--taurus-blue-600);
}

.toggle input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* ===== File Upload Zone ===== */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--taurus-blue-400);
  background: var(--taurus-blue-50);
}

.upload-zone-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-4);
  color: var(--text-muted);  /* Changed from gray-400 for better contrast (WCAG AA) */
}

.upload-zone-text {
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.upload-zone-hint {
  font-size: 0.75rem;
  color: var(--text-muted);  /* Changed from gray-400 for better contrast (WCAG AA) */
}

/* ===== Attachment List ===== */
.attachment-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.attachment-item-icon {
  flex-shrink: 0;
  color: var(--text-muted);
}

.attachment-item-name {
  flex: 1;
  min-width: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-item-size {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ===== Delivery Log Item ===== */
.delivery-log-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-light);
}

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

.delivery-log-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}

.delivery-log-status.sent { background: var(--info-500); }
.delivery-log-status.delivered { background: var(--success-500); }
.delivery-log-status.failed { background: var(--error-500); }
.delivery-log-status.pending { background: var(--warning-500); }

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

.delivery-log-title {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.delivery-log-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.delivery-log-time {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ===== State Badge ===== */
.state-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  border-radius: 20px;
  background: var(--border-light);
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  line-height: 1;
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.3s ease;
}

.state-badge[data-state="design"] {
  background: var(--primary-light);
  color: var(--primary);
}

.state-badge[data-state="running"] {
  background: var(--success-light);
  color: var(--success);
  animation: pulse-badge 2s ease-in-out infinite;
}

.state-badge[data-state="paused"] {
  background: var(--warning-light);
  color: var(--warning);
}

.state-badge[data-state="stopped"],
.state-badge[data-state="completed"] {
  background: var(--danger-light);
  color: var(--danger);
}

/* ===== Auto-save Indicator ===== */
.autosave-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--surface-hover);
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.autosave-icon {
  color: var(--success);
  flex-shrink: 0;
  transition: transform var(--transition);
}

.autosave-text {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-weight: 500;
  line-height: 1;
}

.autosave-indicator.saving .autosave-icon {
  color: var(--warning);
  animation: rotate 1s linear infinite;
}

.autosave-indicator.error .autosave-icon {
  color: var(--danger);
  animation: shake 0.5s ease;
}

/* ===== Theme Toggle ===== */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.75rem;
  font-weight: 500;
}

.theme-toggle svg {
  flex-shrink: 0;
}

.theme-toggle-label {
  display: none;
}

@media (min-width: 640px) {
  .theme-toggle-label {
    display: inline;
  }
}

.theme-toggle:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}
}

/* ===== Loading Skeleton Screens ===== */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--border) 0%,
    var(--border-light) 50%,
    var(--border) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton-text {
  height: 1rem;
  margin-bottom: 0.5rem;
}

.skeleton-text.skeleton-text-sm {
  height: 0.75rem;
}

.skeleton-text.skeleton-text-lg {
  height: 1.25rem;
}

.skeleton-title {
  height: 1.5rem;
  width: 60%;
  margin-bottom: 1rem;
}

.skeleton-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-full);
}

.skeleton-avatar-sm {
  width: 2rem;
  height: 2rem;
}

.skeleton-avatar-lg {
  width: 3rem;
  height: 3rem;
}

.skeleton-button {
  height: 2.25rem;
  width: 5rem;
  border-radius: var(--radius);
}

.skeleton-card {
  padding: 1.5rem;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.skeleton-table-row {
  display: table-row;
}

.skeleton-table-cell {
  display: table-cell;
  padding: 0.75rem 1rem;
}

/* Skeleton variants */
.skeleton-line {
  height: 1rem;
  border-radius: var(--radius-sm);
}

.skeleton-line-short {
  width: 40%;
}

.skeleton-line-medium {
  width: 60%;
}

.skeleton-line-long {
  width: 80%;
}

/* Hide skeleton when content loads */
.skeleton-container.loaded .skeleton {
  display: none;
}

/* ===== Utility Classes ===== */
/* Replaces common inline styles for better performance and smaller HTML payload */

/* Padding Utilities */
.p-compact {
  padding: 1rem 1.25rem;
}

.p-card {
  padding: 1.25rem;
}

.p-card-sm {
  padding: 1rem;
}

.p-loading {
  padding: 3rem;
}

/* Alignment Utilities */
.items-start {
  align-items: flex-start;
}

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

.items-wrap {
  flex-wrap: wrap;
}

/* Width Utilities */
.w-auto {
  width: auto;
}

.w-full {
  width: 100%;
}

.min-w-search {
  min-width: 250px;
}

.min-w-card {
  min-width: 400px;
}

/* Margin Utilities */
.m-center {
  margin-left: auto;
  margin-right: auto;
}

.m-loading {
  margin: 3rem auto;
}

.m-spinner {
  margin: 0 auto;
}

.m-card {
  margin: 2rem auto;
}

/* Text Alignment Utilities */
.text-center {
  text-align: center;
}

/* Grid Utilities */
.grid-full {
  grid-column: 1 / -1;
}

/* Icon Sizing Utilities */
.icon-external {
  width: 14px;
  height: 14px;
  margin-left: auto;
}

.icon-sm {
  width: 16px;
  height: 16px;
}

.icon-md {
  width: 18px;
  height: 18px;
}

.icon-lg {
  width: 20px;
  height: 20px;
}

.icon-xl {
  width: 24px;
  height: 24px;
}

/* Combined Utilities for Common Patterns */
.filter-bar {
  padding: 1rem 1.25rem;
}

.filter-controls {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  flex-wrap: wrap;
}

.page-header-split {
  align-items: flex-start;
}

.stat-card-padded {
  padding: 1.25rem;
}

.stat-card-compact {
  padding: 1rem;
}

/* Noscript Warning (repeated across pages) */
.noscript-warning {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--error-600);
  color: white;
  padding: 1rem;
  text-align: center;
  z-index: 10000;
}

/* Loading State Utilities */
.loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
}

.spinner-sm {
  width: 18px;
  height: 18px;
  border-width: 2px;
}

/* ===== Search Highlighting ===== */
mark {
  background-color: var(--warning-100);
  color: var(--text-primary);
  padding: 0 0.125rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

/* ===== Command Center Components ===== */

/* Page Mode Indicator */
.page-mode-indicator {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  background: var(--primary-light);
  border-radius: 20px;
  border: 2px solid var(--primary);
}

.mode-icon {
  color: var(--primary);
  flex-shrink: 0;
}

.mode-icon-control {
  color: var(--success);
}

.mode-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* View Toggle */
.view-toggle {
  display: inline-flex;
  background: var(--surface-hover);
  border-radius: var(--radius);
  padding: 0.25rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.toggle-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.toggle-btn:hover:not(.active) {
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary);
}

.toggle-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Radio Group */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.radio-label {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  cursor: pointer;
  padding: 1.25rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
  background: var(--surface);
}

.radio-label:hover {
  border-color: var(--primary);
  background: var(--surface-hover);
  box-shadow: var(--shadow-sm);
}

.radio-label input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-custom {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
  margin-top: 2px;
  transition: all var(--transition);
}

.radio-label input[type="radio"]:checked ~ .radio-custom {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.radio-label input[type="radio"]:checked ~ .radio-custom::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  background: var(--primary);
  border-radius: 50%;
  animation: radioPopIn 0.3s var(--transition-spring);
}

@keyframes radioPopIn {
  from {
    transform: translate(-50%, -50%) scale(0);
  }
  to {
    transform: translate(-50%, -50%) scale(1);
  }
}

.radio-label input[type="radio"]:checked ~ div {
  color: var(--text-primary);
}

/* Keyboard Shortcut Hints */
.keyboard-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-left: auto;
}

/* Timeline Mode Badge */
.timeline-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 600;
  margin-left: 1rem;
}

.timeline-mode-badge.relative {
  background: var(--primary-light);
  color: var(--primary);
}

.timeline-mode-badge.absolute {
  background: var(--border-light);
  color: var(--text-primary);
}

/* ===== Accessibility: Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  /* Disable skeleton animation */
  .skeleton {
    animation: none;
    background: var(--border);
  }

  /* Preserve status indicator pulse for critical information */
  .status-active .status-dot {
    animation: none;
  }
}

/* ===== Markdown Editor & Preview ===== */
.markdown-editor {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.markdown-editor .form-textarea {
  border: none;
  border-radius: 0;
  border-top: 1px solid var(--border);
}

.markdown-toolbar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 0.5rem;
  background: var(--surface-hover);
}

.md-tab {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
}

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

.md-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.md-hint {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.markdown-preview {
  padding: 0.75rem;
  min-height: 120px;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-primary);
  border-top: 1px solid var(--border);
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
  margin: 0.75em 0 0.5em;
  line-height: 1.3;
}

.markdown-preview h1 { font-size: 1.4em; }
.markdown-preview h2 { font-size: 1.2em; }
.markdown-preview h3 { font-size: 1.05em; }

.markdown-preview p {
  margin: 0.5em 0;
}

.markdown-preview ul,
.markdown-preview ol {
  padding-left: 1.5em;
  margin: 0.5em 0;
}

.markdown-preview code {
  padding: 0.15em 0.4em;
  font-size: 0.85em;
  background: var(--surface-hover);
  border-radius: 3px;
}

.markdown-preview pre {
  padding: 0.75em;
  background: var(--surface-hover);
  border-radius: 6px;
  overflow-x: auto;
}

.markdown-preview pre code {
  padding: 0;
  background: none;
}

.markdown-preview table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.5em 0;
}

.markdown-preview th,
.markdown-preview td {
  padding: 0.4em 0.75em;
  border: 1px solid var(--border);
  text-align: left;
}

.markdown-preview th {
  background: var(--surface-hover);
  font-weight: 600;
}

.markdown-preview blockquote {
  margin: 0.5em 0;
  padding: 0.25em 0.75em;
  border-left: 3px solid var(--primary);
  color: var(--text-muted);
}

.markdown-preview a {
  color: var(--primary);
  text-decoration: underline;
}

.markdown-preview img {
  max-width: 100%;
  height: auto;
}
