/* ==========================================================================
   MODULE 06: PROGRESS SPM - SCOPED DESIGN SYSTEM & POLARIS COMPONENT STYLES
   ========================================================================== */

#view-progress {
  display: none;
  flex-direction: column;
  height: 100%;
  width: 100%;
  overflow: hidden;
  position: relative;
  background-color: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  gap: 10px;
  box-sizing: border-box;
}

#view-progress.active {
  display: flex;
}

#view-progress .sn-workspace-grid {
  flex: 1;
  min-height: 0;
  height: calc(100% - 52px);
  overflow: hidden;
}

/* ==========================================================================
   MODULE 06: PROGRESS SPM - DESIGN SYSTEM TOKENS & THEME ADAPTATION
   (Defined in root scope so custom properties inherit into @scope blocks)
   ========================================================================== */

#view-progress,
#progress-modals,
[data-theme="dark"] #view-progress,
[data-theme="dark"] #progress-modals {
  /* Brand & Shell Colors */
  --sn-nav-bg: var(--bg-surface, #111827);
  --sn-nav-text: var(--text-primary, #f9fafb);
  --sn-nav-border: var(--border-subtle, #2d3748);
  --sn-brand-green: #10b981;
  --sn-brand-green-hover: #059669;
  --sn-brand-green-subtle: rgba(16, 185, 129, 0.15);
  --sn-accent-teal: #0284c7;

  /* Canvas & Neutral Surface Colors (Dark Baseline Mapped to Nexus) */
  --sn-bg-canvas: var(--bg-canvas, #0b0f17);
  --sn-surface-card: var(--bg-surface, #111827);
  --sn-surface-alt: var(--bg-elevated, #1f2937);
  --sn-border-subtle: var(--border-subtle, #2d3748);
  --sn-border-medium: var(--border-medium, #374151);
  --sn-border-dark: #4b5563;

  /* Typography */
  --sn-text-main: var(--text-primary, #f9fafb);
  --sn-text-muted: var(--text-secondary, #9ca3af);
  --sn-text-subtle: var(--text-muted, #6b7280);
  --sn-font-family: var(--font-sans);
  --sn-font-mono: var(--font-mono);

  /* RAG Traffic Light Palette */
  --rag-green-bg: var(--rag-green-bg, rgba(16, 185, 129, 0.12));
  --rag-green-border: var(--rag-green-border, rgba(16, 185, 129, 0.3));
  --rag-green-text: #34d399;
  --rag-green-glow: rgba(16, 185, 129, 0.25);

  --rag-yellow-bg: var(--rag-amber-bg, rgba(245, 158, 11, 0.12));
  --rag-yellow-border: var(--rag-amber-border, rgba(245, 158, 11, 0.3));
  --rag-yellow-text: #fbbf24;
  --rag-yellow-glow: rgba(245, 158, 11, 0.25);

  --rag-red-bg: var(--rag-red-bg, rgba(239, 68, 68, 0.12));
  --rag-red-border: var(--rag-red-border, rgba(239, 68, 68, 0.3));
  --rag-red-text: #f87171;
  --rag-red-glow: rgba(239, 68, 68, 0.25);

  /* Shadows & Elevations */
  --sn-shadow-sm: var(--shadow-sm, 0 1px 2px 0 rgba(0, 0, 0, 0.3));
  --sn-shadow-md: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.4));
  --sn-shadow-lg: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.5));
  --sn-shadow-card: var(--shadow-sm, 0 1px 2px 0 rgba(0, 0, 0, 0.3));

  /* Dimensions */
  --sn-radius-sm: var(--radius-sm, 3px);
  --sn-radius-md: var(--radius-md, 6px);
  --sn-radius-lg: var(--radius-lg, 8px);
  --sn-radius-pill: 9999px;
  --sn-header-height: 42px;
}

/* Light Theme Overrides for Progress SPM */
[data-theme="light"] #view-progress,
[data-theme="light"] #progress-modals {
  --sn-nav-bg: var(--bg-surface, #ffffff);
  --sn-nav-text: var(--text-primary, #0f172a);
  --sn-nav-border: var(--border-subtle, #e2e8f0);
  --sn-bg-canvas: var(--bg-canvas, #f8fafc);
  --sn-surface-card: var(--bg-surface, #ffffff);
  --sn-surface-alt: var(--bg-elevated, #f1f5f9);
  --sn-border-subtle: var(--border-subtle, #e2e8f0);
  --sn-border-medium: var(--border-medium, #cbd5e1);
  --sn-border-dark: #94a3b8;
  --sn-text-main: var(--text-primary, #0f172a);
  --sn-text-muted: var(--text-secondary, #475569);
  --sn-text-subtle: #64748b;

  --rag-green-bg: #ecfdf5;
  --rag-green-border: #10b981;
  --rag-green-text: #065f46;

  --rag-yellow-bg: #fffbeb;
  --rag-yellow-border: #f59e0b;
  --rag-yellow-text: #92400e;

  --rag-red-bg: #fef2f2;
  --rag-red-border: #ef4444;
  --rag-red-text: #991b1b;
}

[data-theme="light"] #view-progress .sn-header {
  background-color: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-subtle, #e2e8f0);
}

@scope (#view-progress, #progress-modals) {
/* Base Resets */

#view-progress *, #view-progress *::before, #view-progress *::after, #progress-modals *, #progress-modals *::before, #progress-modals *::after {

  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
#view-progress {

  font-family: var(--sn-font-family);
  background-color: var(--sn-bg-canvas);
  color: var(--sn-text-main);
  line-height: 1.5;
  font-size: 13.5px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   1. Progress SPM Sub-Toolbar
   ========================================================================== */
.sn-header {
  height: 42px;
  min-height: 42px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  gap: 10px;
  position: relative;
  z-index: 30;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.sn-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sn-logo,
.sn-breadcrumb .crumb,
.sn-breadcrumb .sep {
  display: none !important;
}

.sn-breadcrumb {
  display: flex;
  align-items: center;
  padding-left: 0;
  border-left: none;
}

.sn-breadcrumb .sep {
  color: #475569;
}

.sn-project-switcher-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.crumb-proj-label {
  color: var(--sn-text-subtle);
  font-size: 12px;
  font-weight: 500;
}

.sn-select-project {
  background: var(--sn-surface-card);
  color: var(--sn-text-main);
  border: 1px solid var(--sn-border-medium);
  border-radius: var(--sn-radius-md);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  max-width: 320px;
  transition: all 0.2s;
}

.sn-select-project:hover, .sn-select-project:focus {
  border-color: var(--sn-brand-green);
  box-shadow: 0 0 0 2px rgba(0, 163, 104, 0.2);
}

.sn-btn-add-proj {
  background: rgba(0, 163, 104, 0.15);
  border: 1px solid rgba(0, 163, 104, 0.4);
  color: var(--sn-brand-green);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--sn-radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.sn-btn-add-proj:hover {
  background: var(--sn-brand-green);
  color: #ffffff;
}

.sn-breadcrumb .current-proj {
  color: var(--sn-text-main);
  font-weight: 500;
}

.sn-breadcrumb .active-crumb {
  color: var(--sn-brand-green);
  font-weight: 600;
}

.sn-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Live API Connection Badge */
.sn-badge-button {
  background: var(--sn-surface-alt);
  border: 1px solid var(--sn-border-subtle);
  color: var(--sn-text-main);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--sn-radius-pill);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sn-badge-button:hover {
  background: var(--bg-hover);
  border-color: var(--sn-border-medium);
}

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

.dot-green {
  background-color: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.dot-amber {
  background-color: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
}

.dot-red {
  background-color: #ef4444;
  box-shadow: 0 0 8px #ef4444;
}

/* Scenario Dropdown */
.sn-scenario-dropdown-wrap {
  position: relative;
}

.sn-select-scenario {
  background-color: var(--sn-surface-card);
  color: var(--sn-text-main);
  border: 1px solid var(--sn-border-medium);
  border-radius: var(--sn-radius-md);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.sn-select-scenario:hover {
  border-color: var(--sn-brand-green);
}

.sn-select-scenario:focus {
  border-color: var(--sn-brand-green);
}

/* ==========================================================================
   2. Workspace Grid Layout (Left Ingestion 330px + Right Status Report)
   ========================================================================== */
.sn-workspace-grid {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 10px;
  padding: 0;
  margin: 0;
  max-width: 100%;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

@media (max-width: 900px) {
  .sn-workspace-grid {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
}

/* ==========================================================================
   3. Left Pane: Ingestion Card & Inputs
   ========================================================================== */
.sn-left-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  width: 330px;
  min-width: 300px;
}

.sn-panel-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: static;
}

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

.sn-panel-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--sn-text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sn-panel-desc {
  color: var(--sn-text-muted);
  font-size: 12.5px;
  line-height: 1.45;
}

/* Tab Switcher */
.sn-tab-bar {
  display: flex;
  background: var(--sn-surface-alt);
  border: 1px solid var(--sn-border-subtle);
  border-radius: var(--sn-radius-md);
  padding: 3px;
  gap: 4px;
}

.sn-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--sn-text-subtle);
  border-radius: var(--sn-radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.sn-tab.active {
  background: var(--sn-surface-card);
  color: var(--sn-text-main);
  box-shadow: var(--sn-shadow-sm);
}

.sn-tab-content {
  display: none;
}

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

/* Drag-and-Drop Dropzone */
.sn-dropzone {
  border: 2px dashed var(--sn-border-medium);
  background: var(--sn-surface-alt);
  border-radius: var(--sn-radius-lg);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.sn-dropzone:hover, .sn-dropzone.dragover {
  border-color: var(--sn-brand-green);
  background: rgba(16, 185, 129, 0.08);
}

.dropzone-file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dropzone-icon {
  font-size: 32px;
  margin-bottom: 6px;
}

.dropzone-primary-text {
  font-size: 13px;
  color: var(--sn-text-main);
  margin-bottom: 4px;
}

.dropzone-sub-text {
  font-size: 11.5px;
  color: var(--sn-text-subtle);
  margin-bottom: 12px;
}

.dropzone-badges {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tech-tag {
  background: #e2e8f0;
  color: #334155;
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--sn-radius-pill);
}

/* Uploaded file details */
.uploaded-file-details {
  border: 1px solid var(--sn-border-subtle);
  border-radius: var(--sn-radius-md);
  padding: 12px;
  background: var(--sn-surface-card);
}

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

.file-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-ext-icon {
  background: #e0f2fe;
  color: #0284c7;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 8px;
  border-radius: var(--sn-radius-sm);
}

.file-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--sn-text-main);
}

.file-size {
  font-size: 11px;
  color: var(--sn-text-subtle);
}

.file-preview-box {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--sn-border-subtle);
}

.preview-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--sn-text-muted);
  margin-bottom: 4px;
}

.preview-content {
  background: var(--sn-surface-alt);
  border: 1px solid var(--sn-border-subtle);
  border-radius: var(--sn-radius-sm);
  padding: 8px;
  font-size: 11.5px;
  color: var(--sn-text-main);
  max-height: 120px;
  overflow-y: auto;
  white-space: pre-wrap;
  font-family: var(--sn-font-mono);
}

/* PII Sanitizer Box */
.sn-sanitizer-box {
  background: var(--sn-surface-alt);
  border: 1px solid var(--sn-border-subtle);
  border-radius: var(--sn-radius-md);
  padding: 12px;
}

.sanitizer-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.sn-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--sn-text-main);
}

.checkbox-title strong {
  color: #0f172a;
}

.sn-badge-counter {
  background: #dbeafe;
  color: #1e40af;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--sn-radius-pill);
}

.sanitizer-help {
  font-size: 11px;
  color: var(--sn-text-subtle);
  line-height: 1.4;
}

/* Primary CTA Button */
.sn-cta-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sn-btn-lg {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
}

.sn-btn-block {
  width: 100%;
}

.generation-timer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: var(--sn-text-muted);
  padding: 4px;
}

.pulse-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--sn-brand-green);
  animation: pulseAnim 1.2s infinite;
}

@keyframes pulseAnim {
  0% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.4); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.6; }
}

.cta-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

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

.sn-governance-notice {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  border-left: 3px solid #f59e0b;
  border-radius: var(--sn-radius-md);
  padding: 10px 12px;
  font-size: 11.5px;
  color: #92400e;
  line-height: 1.45;
  display: flex;
  gap: 8px;
}

.notice-icon {
  font-size: 14px;
  flex-shrink: 0;
}

/* ==========================================================================
   4. Right Pane: ServiceNow Form & Polaris Sections
   ========================================================================== */
.sn-right-pane {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  overflow-y: auto;
  min-width: 0;
  padding-right: 4px;
}

/* AI Attribution Banner */
.sn-ai-banner {
  background: linear-gradient(135deg, #0b1a28 0%, #162a3f 100%);
  color: #ffffff;
  border: 1px solid #2a4365;
  border-radius: var(--sn-radius-lg);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--sn-shadow-md);
  animation: slideDown 0.3s ease;
}

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

.ai-banner-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-banner-icon {
  font-size: 24px;
}

.ai-banner-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #38bdf8;
}

.ai-banner-subtitle {
  font-size: 12px;
  color: #cbd5e1;
}

.sn-btn-text-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
}

.sn-btn-text-close:hover {
  color: #ffffff;
}

/* Record Card */
.sn-record-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.record-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.record-table-tag {
  background: var(--sn-surface-alt);
  border: 1px solid var(--sn-border-subtle);
  color: var(--sn-text-subtle);
  font-family: var(--sn-font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--sn-radius-sm);
}

.record-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--sn-text-main);
}

.sn-status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--sn-radius-pill);
}

.status-draft {
  background: #e0f2fe;
  color: #0369a1;
}

.status-published {
  background: #dcfce7;
  color: #15803d;
}

/* ==========================================================================
   Project Status Version History Bar & Timeline
   ========================================================================== */
.sn-version-history-bar {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ver-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.ver-bar-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ver-icon {
  font-size: 15px;
}

.ver-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.ver-hint {
  font-size: 11px;
  color: var(--sn-text-subtle);
}

.ver-empty-hint {
  font-size: 12px;
  color: #64748b;
  font-style: italic;
  padding: 6px 0;
}

.version-chips-scroll {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.version-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--sn-surface-card);
  border: 1px solid var(--sn-border-medium);
  border-radius: var(--sn-radius-pill);
  padding: 5px 10px 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--sn-text-main);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.version-chip:hover {
  border-color: var(--sn-brand-green);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.version-chip.active {
  background: #ecfdf5;
  border-color: var(--sn-brand-green);
  color: #065f46;
  box-shadow: 0 0 0 1px var(--sn-brand-green);
}

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

.dot-green {
  background-color: #10b981;
}

.dot-yellow {
  background-color: #f59e0b;
}

.dot-red {
  background-color: #ef4444;
}

.chip-label {
  font-weight: 600;
}

.chip-del-btn {
  background: none;
  border: none;
  font-size: 12px;
  cursor: pointer;
  color: #94a3b8;
  padding: 2px 4px;
  border-radius: 3px;
  margin-left: 4px;
  transition: all 0.15s;
}

.chip-del-btn:hover {
  color: #dc2626;
  background: #fee2e2;
}

.grid-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 900px) {
  .grid-row-3 {
    grid-template-columns: 1fr;
  }
}

/* Sections */
.sn-form-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-bottom: 1px solid var(--sn-border-subtle);
  padding-bottom: 22px;
}

.sn-form-section:last-of-type {
  border-bottom: none;
}

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

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: #1e293b;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.section-hint {
  font-size: 11.5px;
  color: var(--sn-text-subtle);
}

.mandatory-star {
  font-size: 11.5px;
  color: #dc2626;
  font-weight: 600;
}

/* Grid Layouts inside Form */
.grid-row-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.grid-row-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

@media (max-width: 900px) {
  .grid-row-4, .grid-row-2 {
    grid-template-columns: 1fr;
  }
}

/* KPI Mini Cards */
.sn-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 4px;
}

@media (max-width: 900px) {
  .sn-kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

.kpi-mini-card {
  background: var(--sn-surface-alt);
  border: 1px solid var(--sn-border-subtle);
  border-radius: var(--sn-radius-md);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kpi-label {
  font-size: 11px;
  color: var(--sn-text-subtle);
  font-weight: 500;
}

.kpi-val {
  font-size: 14px;
  font-weight: 700;
  color: var(--sn-text-main);
}

.kpi-green {
  color: var(--sn-brand-green);
}

/* Form Fields & Controls */
.sn-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sn-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--sn-text-main);
}

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

.field-desc {
  font-size: 11px;
  color: var(--sn-text-subtle);
  line-height: 1.4;
}

.sn-input, .sn-textarea, .sn-select {
  width: 100%;
  border: 1px solid var(--sn-border-medium);
  border-radius: var(--sn-radius-md);
  padding: 8px 11px;
  font-size: 13px;
  color: var(--sn-text-main);
  background: var(--sn-surface-card);
  outline: none;
  font-family: inherit;
  transition: all 0.2s ease;
}

.sn-input:focus, .sn-textarea:focus, .sn-select:focus {
  border-color: var(--sn-brand-green);
  box-shadow: 0 0 0 2px rgba(0, 163, 104, 0.15);
}

.font-mono {
  font-family: var(--sn-font-mono) !important;
}

/* ==========================================================================
   5. Health Indicators (RAG Traffic Light Cards)
   ========================================================================== */
.rag-cards-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

@media (max-width: 900px) {
  .rag-cards-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.rag-card {
  background: var(--sn-surface-alt);
  border: 1px solid var(--sn-border-subtle);
  border-radius: var(--sn-radius-lg);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.2s ease;
}

.rag-card.state-green {
  border-color: var(--rag-green-border);
  background: var(--rag-green-bg);
  box-shadow: 0 0 0 1px var(--rag-green-border);
}

.rag-card.state-yellow {
  border-color: var(--rag-yellow-border);
  background: var(--rag-yellow-bg);
  box-shadow: 0 0 0 1px var(--rag-yellow-border);
}

.rag-card.state-red {
  border-color: var(--rag-red-border);
  background: var(--rag-red-bg);
  box-shadow: 0 0 0 1px var(--rag-red-border);
}

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

.rag-card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--sn-text-main);
}

.rag-current-pill {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--sn-radius-pill);
  text-transform: capitalize;
}

.pill-green {
  background: #d1fae5;
  color: var(--rag-green-text);
  border: 1px solid #6ee7b7;
}

.pill-yellow {
  background: #fef3c7;
  color: var(--rag-yellow-text);
  border: 1px solid #fcd34d;
}

.pill-red {
  background: #fee2e2;
  color: var(--rag-red-text);
  border: 1px solid #fca5a5;
}

/* 3-Way R-Y-G Button Selector */
.rag-button-group {
  display: flex;
  background: var(--sn-surface-card);
  border: 1px solid var(--sn-border-subtle);
  border-radius: var(--sn-radius-md);
  padding: 2px;
  gap: 2px;
}

.rag-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 5px 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--sn-text-subtle);
  border-radius: var(--sn-radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.rag-btn:hover {
  background: var(--sn-surface-alt);
  color: var(--sn-text-main);
}

.rag-btn.btn-green.active {
  background: #10b981;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.3);
}

.rag-btn.btn-yellow.active {
  background: #f59e0b;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(245, 158, 11, 0.3);
}

.rag-btn.btn-red.active {
  background: #ef4444;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(239, 68, 68, 0.3);
}

/* Conditional Badges */
.conditional-badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--sn-radius-pill);
}

.badge-populated {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fcd34d;
}

.badge-blank {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

/* ==========================================================================
   6. Executive Narratives & Contenteditable View
   ========================================================================== */
.sn-narrative-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #ffffff;
}

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

.narrative-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--sn-text-main);
}

.narrative-label .req {
  color: #dc2626;
  font-weight: 700;
  margin-right: 2px;
}

.narrative-label code {
  font-size: 11px;
  color: var(--sn-text-subtle);
  font-weight: 400;
  background: var(--sn-surface-alt);
  padding: 1px 5px;
  border-radius: 3px;
}

.mode-toggle {
  display: flex;
  background: var(--sn-surface-alt);
  border-radius: var(--sn-radius-md);
  padding: 2px;
  gap: 2px;
}

.toggle-btn {
  border: none;
  background: transparent;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--sn-text-subtle);
  border-radius: var(--sn-radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-btn.active {
  background: var(--sn-surface-card);
  color: var(--sn-text-main);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Rich Editor container */
.sn-rich-editor {
  border: 1px solid var(--sn-border-medium);
  border-radius: var(--sn-radius-md);
  padding: 12px 14px;
  min-height: 80px;
  max-height: 260px;
  overflow-y: auto;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--sn-text-main);
  background: var(--sn-surface-card);
  outline: none;
  transition: border-color 0.2s;
}

.sn-rich-editor:focus {
  border-color: var(--sn-brand-green);
  box-shadow: 0 0 0 2px rgba(0, 163, 104, 0.15);
}

.sn-rich-editor:empty::before {
  content: attr(placeholder);
  color: var(--sn-text-subtle);
  font-style: italic;
}

.sn-rich-editor p {
  margin-bottom: 8px;
}

.sn-rich-editor ul {
  padding-left: 20px;
  margin-bottom: 8px;
}

.sn-rich-editor li {
  margin-bottom: 4px;
}

.sn-rich-editor .ai-missing-flag {
  background: var(--rag-yellow-bg);
  border: 1px solid var(--rag-yellow-border);
  border-left: 4px solid #f59e0b;
  border-radius: var(--sn-radius-sm);
  padding: 8px 12px;
  color: var(--rag-yellow-text);
  font-size: 12.5px;
  margin: 6px 0;
}

.sn-code-editor {
  font-family: var(--sn-font-mono) !important;
  font-size: 12px;
  line-height: 1.45;
  background: var(--sn-surface-alt);
  color: var(--sn-text-main);
}

/* ==========================================================================
   7. Form Footer Action Bar
   ========================================================================== */
.sn-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  border-top: 1px solid var(--sn-border-subtle);
  flex-wrap: wrap;
  gap: 12px;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Buttons */
.sn-btn {
  border: 1px solid transparent;
  border-radius: var(--sn-radius-md);
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
  font-family: inherit;
}

.sn-btn-primary {
  background-color: var(--sn-brand-green);
  color: #ffffff;
}

.sn-btn-primary:hover {
  background-color: var(--sn-brand-green-hover);
}

.sn-btn-secondary {
  background-color: var(--sn-surface-alt);
  border-color: var(--sn-border-medium);
  color: var(--sn-text-main);
}

.sn-btn-secondary:hover {
  background-color: var(--bg-hover);
}

.sn-btn-outline {
  background-color: transparent;
  border-color: var(--sn-border-medium);
  color: var(--sn-text-main);
}

.sn-btn-outline:hover {
  background-color: var(--sn-surface-alt);
  border-color: var(--sn-border-dark);
}

.sn-btn-header-primary {
  background-color: var(--sn-brand-green);
  color: #ffffff;
}

.sn-btn-header-primary:hover {
  background-color: var(--sn-brand-green-hover);
}

.sn-btn-ghost {
  background: var(--sn-surface-alt);
  border-color: var(--sn-border-subtle);
  color: var(--sn-text-main);
}

.sn-btn-ghost:hover {
  background: var(--bg-hover);
}

.sn-btn-danger-ghost {
  background: transparent;
  border-color: #fca5a5;
  color: #dc2626;
}

.sn-btn-danger-ghost:hover {
  background: #fef2f2;
}

.sn-btn-text-danger {
  background: none;
  border: none;
  color: #dc2626;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px;
}

.sn-btn-text-danger:hover {
  text-decoration: underline;
}

.sn-link-btn {
  background: none;
  border: none;
  color: #0284c7;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

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

.sn-icon-btn {
  background: none;
  border: none;
  font-size: 14px;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
}

.sn-icon-btn:hover {
  color: #0f172a;
}

.sn-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--sn-radius-pill);
}

.sn-chip-accent {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

/* ==========================================================================
   8. Admin AI Configuration Modal
   ========================================================================== */
.sn-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.sn-modal-dialog {
  background: var(--sn-surface-card);
  border: 1px solid var(--sn-border-medium);
  border-radius: var(--sn-radius-lg);
  box-shadow: var(--sn-shadow-lg);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalPop 0.25s ease;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.sn-modal-header {
  padding: 16px 20px;
  background: var(--sn-surface-alt);
  border-bottom: 1px solid var(--sn-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-sys-name {
  font-family: var(--sn-font-mono);
  font-size: 10.5px;
  color: var(--sn-text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sn-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--sn-text-main);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--sn-text-subtle);
  cursor: pointer;
  padding: 4px;
}

.modal-close-btn:hover {
  color: var(--sn-text-main);
}

.sn-modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sn-modal-body form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sn-modal-footer {
  padding: 14px 20px;
  background: var(--sn-surface-alt);
  border-top: 1px solid var(--sn-border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.input-with-action {
  position: relative;
  display: flex;
}

.sn-btn-peek {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.sn-slider {
  width: 100%;
  cursor: pointer;
  accent-color: var(--sn-brand-green);
}

.range-val {
  font-family: var(--sn-font-mono);
  font-weight: 700;
  color: var(--sn-brand-green);
  font-size: 12px;
}

.config-status-msg {
  padding: 10px 12px;
  border-radius: var(--sn-radius-md);
  font-size: 12px;
}

.config-status-msg.msg-success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.config-status-msg.msg-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* ==========================================================================
   9. Saved Reports & Telemetry Drawer
   ========================================================================== */
.sn-drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  justify-content: flex-end;
}

.sn-drawer {
  background: var(--sn-surface-card);
  width: 100%;
  max-width: 680px;
  height: 100%;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.3s ease;
}

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

.sn-drawer-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--sn-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--sn-surface-alt);
}

.drawer-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--sn-text-main);
}

.drawer-close-btn {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--sn-text-subtle);
  cursor: pointer;
}

.sn-drawer-tabs {
  display: flex;
  border-bottom: 1px solid var(--sn-border-subtle);
  background: var(--sn-surface-card);
  padding: 0 16px;
}

.drawer-tab {
  padding: 12px 16px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--sn-text-subtle);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.drawer-tab.active {
  color: var(--sn-brand-green);
  border-bottom-color: var(--sn-brand-green);
}

.sn-drawer-body {
  padding: 16px 20px;
  flex: 1;
  overflow-y: auto;
}

.pane-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.pane-note {
  font-size: 11.5px;
  color: var(--sn-text-subtle);
}

/* Saved Reports Cards */
.saved-reports-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.saved-report-item {
  border: 1px solid var(--sn-border-subtle);
  border-radius: var(--sn-radius-md);
  padding: 14px;
  background: var(--sn-surface-card);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.2s;
}

.saved-report-item:hover {
  border-color: var(--sn-border-dark);
  box-shadow: var(--sn-shadow-sm);
}

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

.saved-item-proj {
  font-size: 13px;
  font-weight: 700;
  color: var(--sn-text-main);
}

.saved-item-date {
  font-size: 11px;
  color: var(--sn-text-subtle);
}

.saved-item-rag-summary {
  display: flex;
  gap: 6px;
}

.rag-mini-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--sn-radius-sm);
  text-transform: uppercase;
}

.saved-item-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* Telemetry Table */
.telemetry-table-wrap {
  border: 1px solid var(--sn-border-subtle);
  border-radius: var(--sn-radius-md);
  overflow-x: auto;
}

.sn-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  text-align: left;
}

.sn-table th {
  background: var(--sn-surface-alt);
  color: var(--sn-text-muted);
  font-weight: 600;
  padding: 9px 12px;
  border-bottom: 1px solid var(--sn-border-medium);
  white-space: nowrap;
}

.sn-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--sn-border-subtle);
  color: var(--sn-text-main);
  white-space: nowrap;
}

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

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--sn-text-subtle);
  font-size: 13px;
}

.empty-cell {
  text-align: center;
  color: var(--sn-text-subtle);
  padding: 24px !important;
}

/* ==========================================================================
   10. Toast Notification System
   ========================================================================== */
.sn-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 300;
}

.sn-toast {
  background: #1e293b;
  color: #ffffff;
  padding: 12px 18px;
  border-radius: var(--sn-radius-md);
  box-shadow: var(--sn-shadow-lg);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastFadeIn 0.25s ease;
  min-width: 280px;
  max-width: 440px;
}

.sn-toast.toast-success {
  border-left: 4px solid var(--sn-brand-green);
}

.sn-toast.toast-error {
  border-left: 4px solid #ef4444;
}

.sn-toast.toast-info {
  border-left: 4px solid #0284c7;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ==========================================================================
   11. Security PIN Authorization Modal & Anti-Abuse Styling
   ========================================================================== */
.pin-modal-dialog {
  max-width: 480px;
  border-top: 4px solid var(--sn-brand-green);
  animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.pin-security-banner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--rag-green-bg);
  border: 1px solid var(--rag-green-border);
  border-radius: var(--sn-radius-md);
  padding: 14px;
}

.pin-shield-badge {
  font-size: 26px;
  line-height: 1;
  flex-shrink: 0;
}

.pin-banner-heading {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--rag-green-text);
  margin-bottom: 4px;
}

.pin-banner-desc {
  font-size: 12px;
  line-height: 1.5;
  color: var(--rag-green-text);
}

.pin-banner-desc code {
  background: rgba(16, 185, 129, 0.2);
  color: var(--rag-green-text);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--sn-font-mono);
  font-weight: 600;
}

.pin-form-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
}

.pin-field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--sn-text-main);
  display: block;
  margin-bottom: 6px;
}

.pin-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.pin-numeric-input {
  font-size: 24px !important;
  font-family: var(--sn-font-mono) !important;
  letter-spacing: 12px;
  text-align: center;
  padding: 10px 48px 10px 20px !important;
  height: 52px;
  font-weight: 700;
  border: 2px solid var(--sn-border-subtle);
  border-radius: var(--sn-radius-md);
  transition: all 0.2s ease;
}

.pin-numeric-input:focus {
  border-color: var(--sn-brand-green);
  box-shadow: 0 0 0 3px rgba(0, 163, 104, 0.15);
  outline: none;
}

.pin-hint-text {
  font-size: 11.5px;
  color: var(--sn-text-subtle);
  margin-top: 6px;
}

.pin-error-alert {
  margin-top: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 9px 12px;
  border-radius: var(--sn-radius-sm);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  animation: shakePin 0.4s ease;
}

@keyframes shakePin {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.pin-shake {
  animation: shakePin 0.4s ease;
}

/* ==========================================================================
   12. File Protocol Warning Banner
   ========================================================================== */
.sn-file-protocol-banner {
  background: #fef3c7;
  border-bottom: 2px solid #f59e0b;
  color: #78350f;
  padding: 12px 20px;
  position: sticky;
  top: 0;
  z-index: 9999;
}

.sn-file-protocol-banner .banner-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.sn-file-protocol-banner .banner-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.sn-file-protocol-banner .banner-msg {
  font-size: 13px;
  line-height: 1.5;
}

.sn-file-protocol-banner code {
  background: #fde68a;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--sn-font-mono);
  font-weight: 600;
}

.sn-file-protocol-banner .banner-link {
  color: #b45309;
  font-weight: 700;
  text-decoration: underline;
  margin-left: 4px;
}

.sn-file-protocol-banner .banner-link:hover {
  color: #78350f;
}

}
