/* ==========================================================================
   PANGUN AI-FMEA Dashboard Enterprise Stylesheet
   Theme: Dark Navy Industrial Engineering with Cyan & Electric-Blue Accents
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  --bg-dark: #070d19;
  --bg-card: #0c162d;
  --bg-card-hover: #101c38;
  --bg-input: #081020;
  --border-subtle: #182848;
  --border-focus: #00d2ff;
  --electric-blue: #0066ff;
  --electric-blue-hover: #0052cc;
  --cyan: #00d2ff;
  --cyan-glow: rgba(0, 210, 255, 0.35);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-label: #cbd5e1;
  --risk-low: #10b981;
  --risk-mod: #0ea5e9;
  --risk-high: #e6a100;
  --risk-crit: #ef4444;
}

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

html, body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle Industrial Background Grid */
.bg-grid-pattern {
  background-image: 
    linear-gradient(to right, rgba(24, 40, 72, 0.35) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(24, 40, 72, 0.35) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #070d19;
}
::-webkit-scrollbar-thumb {
  background: #1c2e50;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #274070;
}

/* Header */
.pangun-header {
  background: linear-gradient(180deg, #0a1329 0%, #070d19 100%);
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 24px;
}

.logo-badge {
  background: #ffffff;
  border: 1.5px solid #2563eb;
  border-radius: 8px;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.25);
}

/* Cards & Panels */
.fmea-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.fmea-panel:hover {
  border-color: rgba(0, 210, 255, 0.25);
}

/* Form Controls */
.field-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-label);
  margin-bottom: 5px;
  display: block;
}

.field-input, .field-select, .field-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  transition: all 0.2s ease;
  outline: none;
}

.field-input::placeholder, .field-textarea::placeholder {
  color: #475569;
}

.field-input:focus, .field-select:focus, .field-textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px var(--cyan-glow);
  background: #0a1428;
}

input[type="date"].field-input,
input[type="date"] {
  color-scheme: dark;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: brightness(0) invert(1);
  cursor: pointer;
  opacity: 0.9;
  transition: opacity 0.2s ease;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

/* Buttons */
.btn-electric {
  background: var(--electric-blue);
  color: #ffffff;
  font-weight: 600;
  font-size: 13px;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 10px rgba(0, 102, 255, 0.35);
}

.btn-electric:hover:not(:disabled) {
  background: var(--electric-blue-hover);
  box-shadow: 0 4px 16px rgba(0, 102, 255, 0.55);
  transform: translateY(-1px);
}

.btn-electric:active:not(:disabled) {
  transform: translateY(0);
}

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

.btn-electric.btn-generating,
.btn-outline.btn-generating {
  background: linear-gradient(135deg, #0052cc, #00d2ff, #0066ff, #00d2ff) !important;
  background-size: 300% 300% !important;
  animation: fluidGradient 2s ease infinite !important;
  box-shadow: 0 0 18px rgba(0, 210, 255, 0.6) !important;
  color: #ffffff !important;
  opacity: 1 !important;
  cursor: wait !important;
  border: none !important;
}

.btn-outline {
  background: rgba(12, 22, 45, 0.8);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  font-weight: 600;
  font-size: 13px;
  border-radius: 6px;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-outline:hover {
  border-color: var(--cyan);
  background: #11203f;
  color: #ffffff;
}

/* Tabs */
.tab-button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13.5px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-button:hover {
  background: #101c38;
  color: #ffffff;
  border-color: #274070;
}

.tab-button.active {
  background: var(--electric-blue);
  color: #ffffff;
  border-color: #3b82f6;
  box-shadow: 0 4px 16px rgba(0, 102, 255, 0.45);
}

.tab-number-pill {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.tab-button.active .tab-number-pill {
  background: #ffffff;
  color: var(--electric-blue);
}

/* Accordions */
.accordion-header {
  width: 100%;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0e1a35;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.accordion-header:hover {
  background: #122144;
  border-color: rgba(0, 210, 255, 0.3);
}

.accordion-badge {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--electric-blue);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 0 10px rgba(0, 102, 255, 0.4);
}

/* Slider Customization */
.custom-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: #182848;
  border-radius: 4px;
  outline: none;
  transition: background 0.2s;
}

.custom-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cyan);
  cursor: pointer;
  box-shadow: 0 0 12px var(--cyan-glow);
  transition: transform 0.15s, box-shadow 0.15s;
}

.custom-range::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 18px rgba(0, 210, 255, 0.8);
}

.range-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 600;
  color: #64748b;
  font-family: 'JetBrains Mono', monospace;
}

.range-val-box {
  width: 44px;
  height: 38px;
  background: #091224;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 24px;
  font-family: 'JetBrains Mono', monospace;
  color: #ffffff;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

/* RPN Display Card */
.rpn-card {
  background: linear-gradient(145deg, #0c1834 0%, #081022 100%);
  border: 1.5px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 150px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.rpn-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  margin-bottom: 6px;
}

.rpn-number {
  font-size: 44px;
  font-weight: 900;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1;
  color: #ffffff;
  margin-bottom: 10px;
}

.risk-badge {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 14px;
  border-radius: 6px;
  display: inline-block;
}

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

.risk-badge.moderate {
  background: rgba(14, 165, 233, 0.18);
  color: #38bdf8;
  border: 1px solid rgba(14, 165, 233, 0.4);
}

.risk-badge.high {
  background: #e6a100;
  color: #000000;
  font-weight: 900;
  box-shadow: 0 0 12px rgba(230, 161, 0, 0.4);
}

.risk-badge.critical {
  background: #ef4444;
  color: #ffffff;
  font-weight: 900;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.6);
  animation: pulse-crit 2s infinite ease-in-out;
}

@keyframes pulse-crit {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}

/* AI Recommendation Box */
.ai-recommendation-box {
  background: rgba(10, 20, 42, 0.85);
  border: 1px solid rgba(0, 210, 255, 0.25);
  border-radius: 8px;
  padding: 14px 18px;
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4), 0 0 16px rgba(0, 210, 255, 0.05);
}

.ai-recommendation-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-recommendation-text {
  flex: 1;
  background: transparent;
  border: 1px dashed rgba(24, 40, 72, 0.8);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.5;
  color: #cbd5e1;
  resize: vertical;
  min-height: 52px;
  outline: none;
  font-family: inherit;
}

.ai-recommendation-text:focus {
  border-color: var(--cyan);
  background: rgba(12, 24, 50, 0.6);
}

/* ========================================================
   FLUID AI LOADING ANIMATIONS & KEYFRAMES
   ======================================================== */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes ping {
  75%, 100% {
    transform: scale(2);
    opacity: 0;
  }
}

@keyframes fluidGlow {
  0%, 100% {
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.3), inset 0 0 8px rgba(0, 210, 255, 0.15);
    border-color: rgba(0, 210, 255, 0.5);
  }
  50% {
    box-shadow: 0 0 24px rgba(0, 210, 255, 0.7), inset 0 0 16px rgba(0, 210, 255, 0.3);
    border-color: #00d2ff;
  }
}

@keyframes fluidGradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes fluidShimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(250%);
  }
}

@keyframes fluidPulseText {
  0%, 100% { opacity: 0.75; transform: scale(0.98); }
  50% { opacity: 1; transform: scale(1.02); }
}

.animate-spin {
  animation: spin 0.8s linear infinite !important;
  transform-origin: center;
}

.animate-pulse {
  animation: fluidPulseText 1.5s ease-in-out infinite !important;
}

/* AI Recommendation Box Loading State */
.ai-recommendation-box.is-generating {
  border-color: var(--cyan) !important;
  animation: fluidGlow 2s ease-in-out infinite;
  background: linear-gradient(135deg, rgba(8, 18, 38, 0.95), rgba(12, 32, 65, 0.95), rgba(8, 18, 38, 0.95));
  background-size: 200% 200%;
  position: relative;
  overflow: hidden;
}

.ai-recommendation-box.is-generating::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #00d2ff, #3b82f6, #00d2ff, transparent);
  background-size: 200% 100%;
  animation: fluidGradient 1.5s linear infinite;
  z-index: 2;
}

.ai-fluid-loader {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(6, 14, 30, 0.85);
  border: 1px solid rgba(0, 210, 255, 0.35);
  border-radius: 6px;
  min-height: 52px;
  box-shadow: inset 0 0 12px rgba(0, 210, 255, 0.08);
}

.ai-fluid-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: #38bdf8;
  letter-spacing: 0.02em;
}

.ai-fluid-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00d2ff;
  box-shadow: 0 0 8px #00d2ff;
  display: inline-block;
  animation: ping 1.2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.ai-fluid-track {
  width: 100%;
  height: 4px;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
}

.ai-fluid-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 45%;
  background: linear-gradient(90deg, transparent, #00d2ff, #3b82f6, transparent);
  border-radius: 9999px;
  animation: fluidShimmer 1.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  box-shadow: 0 0 12px rgba(0, 210, 255, 0.85);
}

/* Skeleton loader for AI Recommendations Section */
.ai-skeleton-container {
  margin-top: 20px;
  padding: 18px 20px;
  background: rgba(8, 16, 34, 0.85);
  border: 1px solid rgba(0, 210, 255, 0.35);
  border-radius: 10px;
  animation: fluidGlow 2.5s ease-in-out infinite;
}

.ai-skeleton-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 700;
  color: #38bdf8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 14px;
}

.ai-skeleton-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-skeleton-card {
  background: rgba(10, 20, 42, 0.85);
  border: 1px solid rgba(24, 40, 72, 0.8);
  border-radius: 8px;
  padding: 14px 18px;
  position: relative;
  overflow: hidden;
}

.ai-skeleton-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(0, 210, 255, 0.12), transparent);
  transform: translateX(-100%);
  animation: fluidShimmer 1.6s infinite;
}

.ai-skeleton-badge {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #0d214a;
  border: 1px solid #1e3a8a;
  color: #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
}

.ai-skeleton-line {
  background: rgba(30, 41, 59, 0.7);
  border-radius: 4px;
}

/* Print Controls Bottom Bar */
.print-bar {
  background: #091224;
  border-top: 1px solid var(--border-subtle);
  padding: 14px 24px;
  position: sticky;
  bottom: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.45);
}

/* ==========================================================================
   AI RECOMMENDATIONS, ANALYTICS DASHBOARD, & HISTORY STYLES
   ========================================================================== */

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

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.section-counter {
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
}

/* AI Recommendation Results Card */
.ai-results-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-result-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.2s ease;
}

.ai-result-card:hover {
  border-color: rgba(0, 210, 255, 0.35);
  box-shadow: 0 4px 20px rgba(0, 102, 255, 0.12);
}

.ai-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.ai-rank-badge {
  background: var(--electric-blue);
  color: #ffffff;
  font-weight: 800;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-action-title {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.3;
}

.ai-dept-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.ai-meta-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-confidence-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: #e2e8f0;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-reduction-pill {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.35);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.ai-icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.ai-icon-btn:hover {
  background: rgba(0, 210, 255, 0.15);
  color: var(--cyan);
}

.ai-icon-btn.active {
  color: var(--cyan);
  background: rgba(0, 210, 255, 0.2);
}

/* Analytics Dashboard 3-Column Grid */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 960px) {
  .analytics-grid {
    grid-template-columns: 1fr;
  }
}

.analytics-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
}

.analytics-card-title {
  font-size: 11px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

/* Analysis History */
.history-list {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  overflow: hidden;
  max-height: 420px;
  overflow-y: auto;
}

.history-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(24, 40, 72, 0.6);
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.history-item:hover {
  background: rgba(0, 210, 255, 0.05);
}

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

.history-rpn-col {
  width: 64px;
  text-align: center;
  flex-shrink: 0;
}

.history-rpn-val {
  font-size: 18px;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: #ffffff;
  display: block;
}

.history-rpn-badge {
  font-size: 9px;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.04em;
  display: block;
  margin-top: 2px;
}

.history-title {
  font-size: 13.5px;
  font-weight: 600;
  color: #f1f5f9;
}

.history-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.history-tags {
  display: flex;
  gap: 10px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
}

/* Floating AI Chat Assistant */
.floating-chat-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0066ff 0%, #00d2ff 100%);
  color: #ffffff;
  border: none;
  box-shadow: 0 0 20px rgba(0, 210, 255, 0.45);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.floating-chat-trigger:hover {
  transform: scale(1.06);
  box-shadow: 0 0 26px rgba(0, 210, 255, 0.65);
}

.floating-chat-window {
  position: fixed;
  bottom: 88px;
  right: 24px;
  width: 360px;
  height: 520px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 120px);
  background: #091326;
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(0, 210, 255, 0.15);
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ==========================================================================
   OFFICIAL EXCEL-STYLE FMEA PRINT & PDF SPECIFIC STYLESHEET
   Requirements: Exact replica of official Excel FMEA Report:
   - Landscape layout
   - Top PANGUN LOGO branding
   - Dark Navy Blue (#002060) title banner & section headers
   - 8-cell Project Metadata Table (Rows 6-8)
   - 23-column Industrial FMEA Grid Table with Sections 1 to 6
   - 3-Level Effect Hierarchy (Local, Next Level, Higher Level)
   - Clean, crisp printable borders & typography
   ========================================================================== */

@page {
  size: A4 landscape;
  margin: 5mm 6mm;
}

@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  body, html {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 7pt !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .no-print {
    display: none !important;
  }

  .print-only {
    display: block !important;
  }

  .fmea-print-document {
    background: #ffffff !important;
    color: #000000 !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .fmea-print-logo-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    margin-bottom: 4px !important;
  }

  .fmea-print-logo-text {
    font-size: 11pt !important;
    font-weight: 900 !important;
    letter-spacing: 0.05em !important;
    color: #002060 !important;
    text-transform: uppercase !important;
  }

  .fmea-report-banner {
    background-color: #ffffff !important;
    color: #002060 !important;
    font-size: 13pt !important;
    font-weight: 900 !important;
    text-align: center !important;
    letter-spacing: 0.08em !important;
    padding: 4px 0 !important;
    border: 1px solid #002060 !important;
    margin-bottom: 0 !important;
  }

  .fmea-meta-table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin-bottom: 0 !important;
    border: 1px solid #002060 !important;
    font-size: 6.8pt !important;
    table-layout: fixed !important;
  }

  .fmea-meta-table td {
    border: 1px solid #002060 !important;
    padding: 2.5px 4px !important;
    vertical-align: middle !important;
    line-height: 1.15 !important;
  }

  .fmea-meta-table td.meta-label {
    background-color: #ffffff !important;
    color: #002060 !important;
    font-weight: 700 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .fmea-meta-table td.meta-value {
    background-color: #ffffff !important;
    color: #000000 !important;
    font-weight: 500 !important;
  }

  .fmea-grid-table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin-top: 0 !important;
    border: 1px solid #002060 !important;
    font-size: 6.2pt !important;
    table-layout: fixed !important;
  }

  .fmea-grid-table th {
    background-color: #ffffff !important;
    color: #002060 !important;
    border: 1px solid #002060 !important;
    padding: 3px 2px !important;
    font-weight: 700 !important;
    text-align: center !important;
    vertical-align: middle !important;
    line-height: 1.15 !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
  }

  .fmea-focus-headers th {
    background-color: #ffffff !important;
    color: #002060 !important;
    border-top: 1px solid #002060 !important;
    font-size: 6.5pt !important;
    padding: 2px 2px !important;
  }

  .fmea-section-headers th {
    background-color: #ffffff !important;
    color: #002060 !important;
    border-top: 1px solid #002060 !important;
    font-size: 6.8pt !important;
    font-weight: 800 !important;
    padding: 2px 2px !important;
  }

  .fmea-grid-table td {
    border: 1px solid #000000 !important;
    padding: 2.5px 2px !important;
    vertical-align: top !important;
    color: #000000 !important;
    line-height: 1.15 !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
  }

  .fmea-grid-table td.num-cell {
    text-align: center !important;
    font-weight: 700 !important;
  }

  .effect-label {
    font-weight: 800 !important;
    color: #002060 !important;
    display: block !important;
    font-size: 6pt !important;
    margin-bottom: 1px !important;
  }

  .fmea-signoff-box {
    margin-top: 8px !important;
    border: 1px solid #002060 !important;
    padding: 6px 10px !important;
    page-break-inside: avoid !important;
    font-size: 6.5pt !important;
  }

  .signoff-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 32px !important;
  }
}

@media screen {
  .print-only {
    display: none !important;
  }
}

/* Modal for Screen Preview of the Excel Print Document */
.fmea-preview-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.88);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.fmea-preview-modal-box {
  background: #091326;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  width: 98vw;
  max-width: 1440px;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 30px rgba(0, 210, 255, 0.15);
}

.fmea-preview-modal-header {
  padding: 12px 20px;
  background: #0d1b38;
  border-bottom: 1px solid #1e3a8a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.fmea-preview-modal-body {
  padding: 16px;
  overflow: auto;
  flex: 1;
  background: #ffffff;
  color: #000000;
}

/* ========================================================
   DYNAMIC MOVING AI LOADING SCREEN (MODAL & HUD)
   ======================================================== */
.ai-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 9, 22, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeInModal 0.2s ease-out;
}

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

.ai-modal-box {
  background: linear-gradient(145deg, #071329, #0d2146);
  border: 1px solid rgba(0, 210, 255, 0.45);
  border-radius: 16px;
  width: 100%;
  max-width: 490px;
  padding: 32px 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85), 0 0 45px rgba(0, 210, 255, 0.25);
  position: relative;
  overflow: hidden;
  animation: zoomInModal 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes zoomInModal {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.ai-modal-box::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #00d2ff, #3b82f6, #00d2ff, transparent);
  background-size: 200% 100%;
  animation: fluidGradient 2s linear infinite;
}

/* AI Neural Orb */
.ai-orb-wrapper {
  position: relative;
  width: 86px;
  height: 86px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-orb-ring-1 {
  position: absolute;
  inset: 0;
  border: 2px dashed rgba(0, 210, 255, 0.7);
  border-radius: 50%;
  animation: spin 3s linear infinite;
}

.ai-orb-ring-2 {
  position: absolute;
  inset: 9px;
  border: 2px solid transparent;
  border-top-color: #38bdf8;
  border-bottom-color: #3b82f6;
  border-radius: 50%;
  animation: spinReverse 2.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.ai-orb-ring-3 {
  position: absolute;
  inset: 18px;
  border: 1.5px dashed rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  animation: spin 4s linear infinite;
}

.ai-orb-center {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle, #00d2ff 0%, #0066ff 70%);
  box-shadow: 0 0 20px #00d2ff, 0 0 35px rgba(0, 210, 255, 0.6);
  animation: pulseScale 1.5s ease-in-out infinite;
}

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

@keyframes pulseScale {
  0%, 100% { transform: scale(0.92); opacity: 0.85; }
  50% { transform: scale(1.08); opacity: 1; }
}

/* Equalizer Moving Bars */
.ai-equalizer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 24px;
  margin-bottom: 16px;
}

.ai-eq-bar {
  width: 3.5px;
  background: linear-gradient(180deg, #00d2ff, #3b82f6);
  border-radius: 2px;
  animation: eqWave 1.2s ease-in-out infinite;
}

.ai-eq-bar-1 { animation-delay: 0.0s; }
.ai-eq-bar-2 { animation-delay: 0.15s; }
.ai-eq-bar-3 { animation-delay: 0.3s; }
.ai-eq-bar-4 { animation-delay: 0.45s; }
.ai-eq-bar-5 { animation-delay: 0.2s; }
.ai-eq-bar-6 { animation-delay: 0.35s; }
.ai-eq-bar-7 { animation-delay: 0.1s; }
.ai-eq-bar-8 { animation-delay: 0.25s; }

@keyframes eqWave {
  0%, 100% { height: 4px; }
  50% { height: 22px; }
}

/* Step Card */
.ai-modal-step-card {
  width: 100%;
  background: rgba(6, 14, 30, 0.75);
  border: 1px solid rgba(0, 210, 255, 0.3);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  margin-bottom: 16px;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.4);
}

.ai-modal-step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00d2ff;
  box-shadow: 0 0 8px #00d2ff;
  animation: ping 1.2s cubic-bezier(0, 0, 0.2, 1) infinite;
  flex-shrink: 0;
}

.ai-modal-step-text {
  font-size: 12.5px;
  font-weight: 500;
  color: #38bdf8;
  text-align: left;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Progress Track */
.ai-modal-progress-track {
  width: 100%;
  height: 6px;
  background: rgba(15, 23, 42, 0.95);
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(30, 58, 138, 0.4);
}

.ai-modal-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #0052cc, #00d2ff, #38bdf8);
  border-radius: 9999px;
  box-shadow: 0 0 12px rgba(0, 210, 255, 0.9);
  transition: width 0.15s ease;
  position: relative;
}

.ai-modal-progress-bar::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: fluidShimmer 1.2s infinite;
}
