/* Import Google Font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* Import Modular Styles */
@import url('src/styles/inspection.css');
@import url('src/styles/spc.css');
@import url('src/styles/digitalThread.css');
@import url('src/styles/aiAssistant.css');
@import url('src/styles/enterprise.css');
@import url('src/styles/aboutXelify.css');

/* Color Variables & Design Tokens */
:root {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-glass: rgba(255, 255, 255, 0.88);
  --border-color: #e2e8f0;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  
  --color-brand: #2563eb;
  --color-brand-hover: #1d4ed8;
  --color-brand-light: #eff6ff;
  --color-brand-gradient: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  
  --color-success: #10b981;
  --color-success-bg: #ecfdf5;
  --color-success-border: #a7f3d0;
  
  --color-warning: #f59e0b;
  --color-warning-bg: #fffbeb;
  --color-warning-border: #fde68a;
  
  --color-danger: #ef4444;
  --color-danger-bg: #fef2f2;
  --color-danger-border: #fca5a5;

  --color-info: #06b6d4;
  --color-info-bg: #ecfeff;
  --color-info-border: #cffafe;
  
  --font-sans: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 14px -1px rgba(15, 23, 42, 0.08), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 25px -3px rgba(15, 23, 42, 0.1), 0 4px 10px -2px rgba(15, 23, 42, 0.04);
  --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.25);
  
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --sidebar-width: 255px;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Sleek Dark Theme Tokens */
body.dark-mode {
  --bg-primary: #090d16;
  --bg-secondary: #111827;
  --bg-tertiary: #1f2937;
  --bg-glass: rgba(17, 24, 39, 0.88);
  --border-color: #2d3748;
  
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-tertiary: #64748b;
  
  --color-brand: #3b82f6;
  --color-brand-hover: #60a5fa;
  --color-brand-light: rgba(59, 130, 246, 0.15);
  --color-brand-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 25px rgba(59, 130, 246, 0.3);
}

/* Dark Mode Variables */
.dark-theme {
  --bg-primary: #090d16;
  --bg-secondary: #111827;
  --bg-tertiary: #1f2937;
  --border-color: #374151;
  
  --text-primary: #f9fafb;
  --text-secondary: #d1d5db;
  --text-tertiary: #6b7280;
  
  --color-brand: #3b82f6;
  --color-brand-hover: #60a5fa;
  --color-brand-light: #1e3a8a;
  
  --color-success: #34d399;
  --color-success-bg: #064e3b;
  --color-success-border: #065f46;
  
  --color-warning: #fbbf24;
  --color-warning-bg: #78350f;
  --color-warning-border: #92400e;
  
  --color-danger: #f87171;
  --color-danger-bg: #7f1d1d;
  --color-danger-border: #991b1b;

  --color-info: #22d3ee;
  --color-info-bg: #083344;
  --color-info-border: #155e75;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* App Layout Grid */
.app-container {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: 64px 1fr;
  grid-template-areas: 
    "sidebar topbar"
    "sidebar main";
  height: 100vh;
  width: 100vw;
}

/* Left Sidebar Styles */
.sidebar {
  grid-area: sidebar;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  transition: border-color 0.3s ease;
}

.logo-container {
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-color);
}

.logo {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--color-brand);
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-links {
  list-style: none;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.nav-item:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav-item.active {
  background-color: var(--color-brand-light);
  color: var(--color-brand);
}

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

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

.nav-category {
  padding: 0 14px 6px 14px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  font-weight: 600;
}

/* Sidebar Footer Branding */
.sidebar-footer {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid var(--border-color);
  font-size: 0.73rem;
  line-height: 1.45;
  color: var(--text-secondary);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  background: transparent;
}

.sidebar-footer svg {
  color: var(--color-brand, #2563eb);
  flex-shrink: 0;
  margin-top: 2px;
  transition: color 0.25s ease, stroke 0.25s ease;
}

.sidebar-footer span {
  color: var(--text-secondary);
  transition: color 0.25s ease;
}

.sidebar-footer strong {
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: 0.2px;
  transition: color 0.25s ease;
}

/* ON HOVER: TURN ALL TEXT AND COMPANY NAME VIBRANT BLUE */
.sidebar-footer:hover,
.sidebar-footer:hover span,
.sidebar-footer:hover strong {
  color: #2563eb !important;
}

.sidebar-footer:hover svg {
  color: #2563eb !important;
  stroke: #2563eb !important;
}

.sidebar-footer:hover {
  background-color: var(--color-brand-light, rgba(37, 99, 235, 0.08));
}

.dark-theme .sidebar-footer:hover,
.dark-theme .sidebar-footer:hover span,
.dark-theme .sidebar-footer:hover strong,
[data-theme="dark"] .sidebar-footer:hover,
[data-theme="dark"] .sidebar-footer:hover span,
[data-theme="dark"] .sidebar-footer:hover strong {
  color: #60a5fa !important;
}

.dark-theme .sidebar-footer:hover svg,
[data-theme="dark"] .sidebar-footer:hover svg {
  color: #60a5fa !important;
  stroke: #60a5fa !important;
}

/* Top Navigation Bar */
.topbar {
  grid-area: topbar;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  transition: border-color 0.3s ease;
}

.search-box {
  display: flex;
  align-items: center;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 6px 12px;
  width: 320px;
  gap: 8px;
}

.search-box input {
  background: none;
  border: none;
  outline: none;
  width: 100%;
  color: var(--text-primary);
  font-size: 0.875rem;
}

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

.selector-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-select {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}

.topbar-select:hover {
  border-color: var(--text-tertiary);
}

.action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: var(--transition);
}

.action-btn:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.notification-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background-color: var(--color-danger);
  border-radius: 50%;
}

.badge {
  position: relative;
  top: auto;
  right: auto;
  width: auto;
  height: auto;
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  font-size: 0.725rem;
  font-weight: 700;
  border-radius: 12px;
  white-space: nowrap;
  line-height: 1.2;
  box-sizing: border-box;
}

.badge-primary {
  background: rgba(37, 99, 235, 0.12);
  color: var(--color-brand);
  border: 1px solid rgba(37, 99, 235, 0.3);
}

.badge-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.badge-success {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 500;
}

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

/* Main Content Panel */
.main-content {
  grid-area: main;
  overflow-y: auto;
  padding: 24px 24px 100px 24px;
  position: relative;
}

/* Page Containers */
.page {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.page.active {
  display: block;
}

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

/* Header Sections */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

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

.page-title p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--color-brand-gradient);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.btn-secondary {
  background-color: var(--bg-secondary);
  border-color: var(--border-color);
  color: var(--text-secondary);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--text-tertiary);
  transform: translateY(-1px);
}

/* KPI Card Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.kpi-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(37, 99, 235, 0.3);
}

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

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 12px;
}

.kpi-header svg {
  color: var(--text-tertiary);
  width: 20px;
  height: 20px;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
}

.kpi-footer {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.trend-up {
  color: var(--color-success);
  font-weight: 600;
}

.trend-down {
  color: var(--color-danger);
  font-weight: 600;
}

/* Dashboards Content Split */
.dashboard-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.dashboard-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Risk Matrix Heatmap */
.risk-matrix {
  display: grid;
  grid-template-columns: 40px repeat(5, 1fr);
  grid-template-rows: repeat(5, 50px) 30px;
  gap: 6px;
  margin-top: 10px;
  font-size: 0.8rem;
  font-weight: 600;
}

.matrix-y-label {
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  grid-column: 1;
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.matrix-cell {
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #1e293b;
  position: relative;
  cursor: pointer;
  transition: var(--transition);
}

.matrix-cell:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
  z-index: 10;
}

.matrix-cell .cell-count {
  font-size: 1.1rem;
  font-weight: 700;
}

.matrix-cell .cell-label {
  font-size: 0.6rem;
  opacity: 0.8;
}

.severity-1 { background-color: #d1fae5; }
.severity-2 { background-color: #a7f3d0; }
.severity-3 { background-color: #fef08a; }
.severity-4 { background-color: #fed7aa; }
.severity-5 { background-color: #fca5a5; }
.severity-6 { background-color: #f87171; color: white; }
.severity-7 { background-color: #ef4444; color: white; }

/* Dynamic Risk levels */
.risk-low { background-color: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.risk-med { background-color: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.risk-high { background-color: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; animation: pulse-border 2s infinite; }

@keyframes pulse-border {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Activity Feed & Checklist */
.activity-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.activity-item {
  display: flex;
  gap: 12px;
  font-size: 0.85rem;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

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

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

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

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

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

/* Product Master Card Split */
.product-master-layout {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 24px;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.detail-table th, .detail-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.detail-table th {
  color: var(--text-secondary);
  font-weight: 600;
  width: 140px;
}

.detail-table td {
  color: var(--text-primary);
  font-weight: 500;
}

/* Spreadsheet Styled Data Grids */
.grid-container {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background-color: var(--bg-secondary);
  margin-bottom: 24px;
}

.data-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
  white-space: nowrap;
}

.data-grid th {
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 5;
}

.data-grid td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  color: var(--text-primary);
  font-weight: 400;
}

.data-grid tr:hover {
  background-color: var(--bg-tertiary);
}

.data-grid td[contenteditable="true"] {
  outline: none;
  cursor: text;
  background-color: rgba(37, 99, 235, 0.02);
}

.data-grid td[contenteditable="true"]:focus {
  background-color: #ffffff;
  box-shadow: inset 0 0 0 2px var(--color-brand);
}

/* Status Indicators inside table */
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.status-success { background-color: var(--color-success-bg); color: var(--color-success); border: 1px solid var(--color-success-border); }
.status-warning { background-color: var(--color-warning-bg); color: var(--color-warning); border: 1px solid var(--color-warning-border); }
.status-danger { background-color: var(--color-danger-bg); color: var(--color-danger); border: 1px solid var(--color-danger-border); }
.status-info { background-color: var(--color-info-bg); color: var(--color-info); border: 1px solid var(--color-info-border); }

/* SOP Document view styling */
.sop-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

.sop-document {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow-sm);
}

.sop-meta {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
  margin-bottom: 24px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

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

.sop-section h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sop-list {
  list-style-type: decimal;
  padding-left: 20px;
}

.sop-list li {
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.sop-safety-box {
  background-color: var(--color-warning-bg);
  border: 1px solid var(--color-warning-border);
  color: var(--text-primary);
  padding: 16px;
  border-radius: var(--radius);
  margin-bottom: 24px;
}

.sop-checklist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.sop-checklist-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-brand);
}

/* Utility Layouts */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.gap-24 {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* ==========================================================================
   PFMEA MULTI-FORMAT ENTERPRISE OS STYLES (10 VIEWS)
   ========================================================================== */

/* 1. View Switcher Toolbar & Quick Stats */
.pfmea-quick-stats-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  margin-bottom: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: 5px 12px;
  border-radius: 20px;
  font-weight: 500;
}

.stat-pill strong {
  color: var(--text-primary);
  font-weight: 700;
}

.stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-high { background: var(--color-danger); box-shadow: 0 0 6px var(--color-danger); }
.dot-med { background: var(--color-warning); box-shadow: 0 0 6px var(--color-warning); }
.dot-low { background: var(--color-success); box-shadow: 0 0 6px var(--color-success); }

.pfmea-view-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}

.pfmea-view-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.pfmea-view-tab:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
  transform: translateY(-1px);
}

.pfmea-view-tab.active {
  color: #ffffff;
  background: var(--color-brand-gradient);
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* Contenteditable cell visual editing affordance */
td.pfmea-edit {
  position: relative;
  cursor: pointer;
  transition: var(--transition);
}

td.pfmea-edit:hover {
  outline: 2px dashed var(--color-brand);
  outline-offset: -2px;
  background: rgba(37, 99, 235, 0.08) !important;
}

td.pfmea-edit:focus {
  outline: 2px solid var(--color-brand);
  background: var(--bg-secondary) !important;
  box-shadow: var(--shadow-glow);
}

/* Risk Badges & Color Coding */
.badge-risk {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-risk-low {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-risk-medium {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-risk-high {
  background: rgba(249, 115, 22, 0.12);
  color: #f97316;
  border: 1px solid rgba(249, 115, 22, 0.3);
}

.badge-risk-critical {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
  animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
  70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Spreadsheet Grid Frozen Columns */
.pfmea-spreadsheet-grid th.sticky-col,
.pfmea-spreadsheet-grid td.sticky-col {
  position: sticky;
  left: 0;
  background: var(--bg-secondary);
  z-index: 2;
  box-shadow: 2px 0 5px rgba(0,0,0,0.05);
}

.pfmea-spreadsheet-grid tr:hover td.sticky-col {
  background: var(--bg-tertiary);
}

/* 2. Card View Layout */
.pfmea-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.pfmea-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.pfmea-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-brand);
}

.pfmea-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.pfmea-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.pfmea-card-body {
  font-size: 0.825rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.pfmea-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  font-size: 0.775rem;
  color: var(--text-tertiary);
}

/* 3. Kanban View Layout */
.pfmea-kanban-board {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 12px;
}

@media (max-width: 1400px) {
  .pfmea-kanban-board {
    grid-template-columns: repeat(6, 280px);
  }
}

.pfmea-kanban-col {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  min-height: 600px;
}

.pfmea-kanban-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border-color);
}

.pfmea-kanban-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.pfmea-kanban-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: calc(var(--radius) - 2px);
  padding: 12px;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: all 0.15s ease;
}

.pfmea-kanban-card:hover {
  border-color: var(--color-brand);
  box-shadow: var(--shadow-sm);
}

/* 4. Timeline View Layout */
.pfmea-timeline-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
  max-height: 620px;
  overflow-y: auto;
}

.timeline-row {
  display: grid;
  grid-template-columns: 240px 1fr 120px;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
}

.timeline-bar-wrapper {
  position: relative;
  height: 24px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  overflow: hidden;
}

.timeline-bar {
  position: absolute;
  height: 100%;
  border-radius: 12px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 0.725rem;
  font-weight: 700;
  color: #ffffff;
  transition: width 0.4s ease;
}

/* 5. Heatmap Matrix Grid Layout */
.heatmap-matrix-grid {
  display: grid;
  grid-template-columns: 40px repeat(10, 1fr);
  grid-template-rows: 40px repeat(10, 1fr);
  gap: 4px;
  margin-top: 12px;
}

.heatmap-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 48px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.heatmap-cell:hover {
  transform: scale(1.08);
  z-index: 5;
  box-shadow: var(--shadow-md);
}

.heatmap-header-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

/* 7. Hierarchy Tree View */
.tree-node {
  margin-left: 20px;
  border-left: 2px dashed var(--border-color);
  padding-left: 14px;
  margin-top: 8px;
}

.tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tree-item:hover {
  background: var(--bg-tertiary);
  border-color: var(--color-brand);
}

/* 8. Digital Thread Diagram Flow */
.digital-thread-diagram {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow-x: auto;
  padding: 20px 10px;
}

.thread-node {
  min-width: 140px;
  padding: 14px 16px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  text-align: center;
  font-size: 0.825rem;
  font-weight: 700;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: all 0.2s ease;
}

.thread-node.active-link {
  border-color: var(--color-brand);
  background: rgba(37, 99, 235, 0.06);
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.2);
}

.thread-arrow {
  color: var(--text-tertiary);
  font-weight: 700;
  font-size: 1.2rem;
}

/* 10. Slide-Over Detail Drawer Panel */
.pfmea-drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 1050;
  animation: fadeIn 0.2s ease;
}

.pfmea-detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 580px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.2);
  z-index: 1060;
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.25s ease;
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.pfmea-drawer-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  background: var(--bg-primary);
  gap: 16px;
  position: relative;
}

.pfmea-drawer-header-content {
  flex: 1;
  min-width: 0;
}

.pfmea-drawer-header-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.pfmea-drawer-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 20px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
}

.pfmea-drawer-tab {
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.pfmea-drawer-tab.active {
  color: var(--color-brand);
  background: var(--bg-secondary);
  box-shadow: var(--shadow-xs);
}

.pfmea-drawer-body {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.drawer-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  margin-bottom: 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-color);
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 480px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

.cinematic-demo-bar {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 580px;
  max-width: 90vw;
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDown {
  from { transform: translate(-50%, -20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.cinematic-demo-content {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
}

.cinematic-demo-badge {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.cinematic-step-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #f8fafc;
}

.cinematic-step-desc {
  font-size: 0.775rem;
  color: #94a3b8;
}

.cinematic-demo-progress-track {
  width: 120px;
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  overflow: hidden;
}

.cinematic-demo-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6 0%, #10b981 100%);
  transition: width 0.4s ease;
}

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

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

/* BRANDING WATERMARK FOOTER */
.powered-by-watermark {
  position: fixed;
  bottom: 14px;
  right: 84px;
  z-index: 95;
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1;
  color: var(--text-secondary, #475569);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-color, #e2e8f0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  pointer-events: auto;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.powered-by-watermark span,
.powered-by-watermark strong,
.powered-by-watermark svg {
  transition: color 0.25s ease, stroke 0.25s ease;
}

.powered-by-watermark svg {
  color: var(--color-brand, #2563eb);
  flex-shrink: 0;
}

.powered-by-watermark strong {
  color: var(--text-primary, #0f172a);
  font-weight: 700;
  letter-spacing: 0.3px;
}

/* HOVER STATE: Turn everything blue on mouse hover */
.powered-by-watermark:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.2);
  border-color: #2563eb !important;
  background: rgba(239, 246, 255, 0.95);
  color: #2563eb !important;
}

.powered-by-watermark:hover span,
.powered-by-watermark:hover strong {
  color: #2563eb !important;
}

.powered-by-watermark:hover svg {
  color: #2563eb !important;
  stroke: #2563eb !important;
}

/* DARK THEME WATERMARK & HOVER STYLES */
.dark-theme .powered-by-watermark,
[data-theme="dark"] .powered-by-watermark {
  background: rgba(17, 24, 39, 0.9);
  color: #94a3b8;
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.dark-theme .powered-by-watermark strong,
[data-theme="dark"] .powered-by-watermark strong {
  color: #f8fafc;
}

.dark-theme .powered-by-watermark:hover,
[data-theme="dark"] .powered-by-watermark:hover {
  background: rgba(30, 58, 138, 0.6) !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.35);
  color: #60a5fa !important;
}

.dark-theme .powered-by-watermark:hover span,
.dark-theme .powered-by-watermark:hover strong,
[data-theme="dark"] .powered-by-watermark:hover span,
[data-theme="dark"] .powered-by-watermark:hover strong {
  color: #60a5fa !important;
}

.dark-theme .powered-by-watermark:hover svg,
[data-theme="dark"] .powered-by-watermark:hover svg {
  color: #60a5fa !important;
  stroke: #60a5fa !important;
}

@media (max-width: 768px) {
  .powered-by-watermark {
    bottom: 8px;
    right: 12px;
    font-size: 0.65rem;
    padding: 4px 10px;
  }
}


