/*
 * SPARC Theme — Bootstrap 5.3 overrides restoring the original SPARC visual identity.
 * Loaded AFTER bootstrap.min.css and application.css so these rules win by source order.
 *
 * Structure:
 *   1. Design token overrides (light + dark)
 *   2. Bootstrap component overrides (card, btn, table, form, container)
 *   3. Badge aliases with SPARC palette
 *   4. Reusable component classes (dashboard headers, control cards, heatmaps, etc.)
 */

/* ═══════════════════════════════════════════════════════════════════
   1. DESIGN TOKEN OVERRIDES
   ═══════════════════════════════════════════════════════════════════ */

:root,
[data-bs-theme="light"] {
  /* Backgrounds */
  --bs-body-bg: #f5f5f5;
  --bs-secondary-bg: #f8f9fa;
  --bs-tertiary-bg: #ffffff;

  /* Text */
  --bs-body-font-size: 1.05rem;
  --bs-body-color: #333333;
  --bs-secondary-color: #666666;
  --bs-tertiary-color: #6a6a6a;

  /* Borders — WCAG 2.1 AA: 3:1 against body bg (#f5f5f5) for UI components */
  --bs-border-color: #828b97;

  /* Primary palette (RGB triplets for Bootstrap's rgba() helpers)
     darkened so white-on-button passes WCAG 2.1 AA 4.5:1 */
  --bs-primary-rgb: 31, 111, 165;
  --bs-success-rgb: 29, 131, 72;
  --bs-danger-rgb: 192, 57, 43;
  --bs-secondary-rgb: 93, 106, 108;
  --bs-warning-rgb: 243, 156, 18;

  /* Links — synced to AA-passing primary on #f5f5f5 */
  --bs-link-color-rgb: 31, 111, 165;
  --bs-link-hover-color-rgb: 24, 90, 133;

  /* SPARC custom tokens */
  --sparc-primary: #1f6fa5;
  --sparc-primary-hover: #185a85;
  --sparc-success: #19743f;  /* WCAG AA: 5.31:1 on #f5f5f5 (was #1d8348 = 4.39, failed AA as outline-button text); white-on-fill still passes 5.78:1 */
  --sparc-success-hover: #155e34;
  --sparc-danger: #c0392b;
  --sparc-danger-hover: #922a20;
  --sparc-secondary: #5d6a6c;
  --sparc-secondary-hover: #4a5556;
  --sparc-warning: #f39c12;       /* paired with black label per WCAG */
  --sparc-warning-fg: #8a6300;    /* dark amber as TEXT: 4.98:1 on #f5f5f5 (--sparc-warning #f39c12 as text was 2.01:1) */
  --sparc-info: #0c6e80;          /* WCAG AA: 5.42:1 on #f5f5f5 (Bootstrap .text-info #0dcaf0 was 1.95:1) */
  --sparc-purple: #8e44ad;        /* already passes white-text AA */
  --sparc-purple-hover: #7d3c98;
  --sparc-orange: #b6580a;
  --sparc-surface: #ffffff;
  --sparc-surface-alt: #f8f9fa;
  --sparc-border: #828b97;
  --sparc-border-soft: #c4c8cf;
  --sparc-text-muted: #666666;
  --sparc-text-faint: #6a6a6a;
  --sparc-focus: #1f6fa5;
}

[data-bs-theme="dark"] {
  /* Backgrounds */
  --bs-body-bg: #0f1419;
  --bs-secondary-bg: #1e2632;
  --bs-tertiary-bg: #252d3a;

  /* Text */
  --bs-body-font-size: 1.05rem;
  --bs-body-color: #e2e8f0;
  --bs-secondary-color: #a6b4c6;    /* WCAG AA: 5.1:1 on #343a40 cards (#94a3b8 was 4.48, just under) */
  --bs-tertiary-color: #a6b4c6;     /* #599 R5: muted text passes AA on dark surfaces */

  /* Borders — WCAG 2.1 AA: 3:1 against #0f1419 body and #252d3a cards */
  --bs-border-color: #717a8a;

  /* Primary palette — pale brand colors paired with black labels
     (see .btn-* dark-mode override block; pale + black gives 5–15:1 AA) */
  --bs-primary-rgb: 93, 173, 226;
  --bs-success-rgb: 46, 204, 113;
  --bs-danger-rgb: 239, 83, 80;
  --bs-secondary-rgb: 176, 190, 197;
  --bs-warning-rgb: 246, 224, 94;

  /* Links — pale brand already AAA against body bg with white text */
  --bs-link-color-rgb: 93, 173, 226;
  --bs-link-hover-color-rgb: 52, 152, 219;

  /* SPARC custom tokens */
  --sparc-primary: #5dade2;
  --sparc-primary-hover: #3498db;
  --sparc-success: #2ecc71;
  --sparc-success-hover: #27ae60;
  --sparc-danger: #ef5350;
  --sparc-danger-hover: #e53935;
  --sparc-secondary: #b0bec5;
  --sparc-secondary-hover: #90a4ae;
  --sparc-warning: #f6e05e;
  --sparc-warning-fg: #f6e05e;    /* light amber as text: passes AA on dark surfaces */
  --sparc-info: #5bc8da;          /* light cyan: passes AA on dark surfaces */
  --sparc-purple: #bb6bd9;
  --sparc-purple-hover: #a855c7;
  --sparc-orange: #f6ad55;
  --sparc-surface: #1e2632;
  --sparc-surface-alt: #252d3a;
  --sparc-border: #717a8a;
  --sparc-border-soft: #4a5568;
  --sparc-text-muted: #94a3b8;
  --sparc-text-faint: #94a3b8;
  --sparc-focus: #5dade2;
}


/* ═══════════════════════════════════════════════════════════════════
   2. BOOTSTRAP COMPONENT OVERRIDES
   ═══════════════════════════════════════════════════════════════════ */

/* Cards — restore SPARC padding, shadow, radius.
   IMPORTANT: use background-color (not shorthand) so gradient headers survive. */
.card {
  --bs-card-bg: var(--sparc-surface);
  --bs-card-border-color: var(--bs-border-color);
  --bs-card-border-radius: 8px;
  padding: 2rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  border: 1px solid var(--bs-border-color);
  background-color: var(--sparc-surface);
}

/* Theme-aware card — uses SPARC palette for both light and dark modes */
.sparc-card {
  background-color: var(--sparc-surface) !important;
  border-color: var(--sparc-border) !important;
  color: var(--bs-body-color) !important;
}

.sparc-card .card-header {
  background-color: var(--sparc-surface-alt) !important;
  border-bottom-color: var(--sparc-border) !important;
  color: var(--bs-body-color) !important;
}

.sparc-card .table {
  color: var(--bs-body-color) !important;
  --bs-table-bg: transparent;
}

.sparc-card .table th,
.sparc-card .table td {
  border-color: var(--sparc-border) !important;
}

.card .card-body {
  padding: 0;  /* card itself has 2rem, avoid double-padding */
  font-size: 1.05rem;
}

/* Gradient overlays on cards — must override card background */
.card.sparc-gradient-header,
.sparc-gradient-header {
  background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%) !important;
  color: white;
  border-color: transparent;
}

.card.sparc-dashboard-header,
.sparc-dashboard-header {
  background: linear-gradient(135deg, #1a252f 0%, #2c3e50 100%) !important;
  color: white;
  border-color: transparent;
}

.card.sparc-processing-banner,
.sparc-processing-banner {
  background: linear-gradient(135deg, #1a252f 0%, #2c3e50 100%) !important;
  color: white;
  border-color: transparent;
}

/* Buttons — restore SPARC sizing and palette */
.btn {
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: 1rem;
  transition: all 0.3s;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-primary {
  --bs-btn-bg: var(--sparc-primary);
  --bs-btn-border-color: var(--sparc-primary);
  --bs-btn-hover-bg: var(--sparc-primary-hover);
  --bs-btn-hover-border-color: var(--sparc-primary-hover);
}

.btn-success {
  --bs-btn-bg: var(--sparc-success);
  --bs-btn-border-color: var(--sparc-success);
  --bs-btn-hover-bg: var(--sparc-success-hover);
  --bs-btn-hover-border-color: var(--sparc-success-hover);
}

.btn-danger {
  --bs-btn-bg: var(--sparc-danger);
  --bs-btn-border-color: var(--sparc-danger);
  --bs-btn-hover-bg: var(--sparc-danger-hover);
  --bs-btn-hover-border-color: var(--sparc-danger-hover);
}

.btn-secondary {
  --bs-btn-bg: var(--sparc-secondary);
  --bs-btn-border-color: var(--sparc-secondary);
  --bs-btn-hover-bg: var(--sparc-secondary-hover);
  --bs-btn-hover-border-color: var(--sparc-secondary-hover);
}

/* Outline buttons — Bootstrap bakes literal default hex into --bs-btn-color
   (e.g. #0d6efd primary, #6c757d secondary), so the --bs-*-rgb token overrides
   above never reach them and the small variants fail WCAG 2.1 AA 4.5:1 on the
   #f5f5f5 body. Re-point resting text/border at the darkened --sparc-* tokens
   (each verified >=4.95:1 on #f5f5f5); hover keeps Bootstrap's white-on-fill.
   WCAG 2.1 AA (SC 1.4.3) — see #599 a11y sweep / docs/dev/a11y_audit.md */
.btn-outline-primary {
  --bs-btn-color: var(--sparc-primary);
  --bs-btn-border-color: var(--sparc-primary);
  --bs-btn-hover-bg: var(--sparc-primary);
  --bs-btn-hover-border-color: var(--sparc-primary);
}

.btn-outline-secondary {
  --bs-btn-color: var(--sparc-secondary);
  --bs-btn-border-color: var(--sparc-secondary);
  --bs-btn-hover-bg: var(--sparc-secondary);
  --bs-btn-hover-border-color: var(--sparc-secondary);
}

.btn-outline-success {
  --bs-btn-color: var(--sparc-success);
  --bs-btn-border-color: var(--sparc-success);
  --bs-btn-hover-bg: var(--sparc-success);
  --bs-btn-hover-border-color: var(--sparc-success);
}

.btn-outline-danger {
  --bs-btn-color: var(--sparc-danger);
  --bs-btn-border-color: var(--sparc-danger);
  --bs-btn-hover-bg: var(--sparc-danger);
  --bs-btn-hover-border-color: var(--sparc-danger);
}

/* #599 Round 3: info + warning outlines were missed in Round 1. Bootstrap's
   #0dcaf0 / #ffc107 as outline text are 1.79:1 / 1.63:1 on light. Route text
   through AA tokens; warning hover fills amber and switches to black. */
.btn-outline-info {
  --bs-btn-color: var(--sparc-info);
  --bs-btn-border-color: var(--sparc-info);
  --bs-btn-hover-bg: var(--sparc-info);
  --bs-btn-hover-border-color: var(--sparc-info);
}

.btn-outline-warning {
  --bs-btn-color: var(--sparc-warning-fg);
  --bs-btn-border-color: var(--sparc-warning-fg);
  --bs-btn-hover-bg: var(--sparc-warning);
  --bs-btn-hover-border-color: var(--sparc-warning);
  --bs-btn-hover-color: #000;
}

/* Dark theme: --sparc-danger (#ef5350) as outline TEXT is only 3.98:1 on the
   #252d3a card. Use a lighter red for the resting text/border (5.59:1) — the
   solid .btn-danger fill is untouched (it pairs #ef5350 with black). */
[data-bs-theme="dark"] .btn-outline-danger {
  --bs-btn-color: #f48a87;
  --bs-btn-border-color: #f48a87;
}

/* Inline <code> — Bootstrap's default #d63384 pink is 4.12:1 on #f5f5f5
   (fails AA). Darken to #ab296a (5.39:1 light) while keeping the magenta
   identity; pale #e685b5 on dark surfaces. WCAG 2.1 AA — see #599 sweep. */
code {
  color: #ab296a;
}

[data-bs-theme="dark"] code {
  color: #e685b5;
}

/* WCAG 2.1 AA: warning yellow needs black label in both themes (white = 2.2:1, black = 9.6:1) */
.btn-warning,
.btn-warning:hover,
.btn-warning:focus,
.btn-warning:active {
  --bs-btn-color: #000;
  --bs-btn-hover-color: #000;
  --bs-btn-active-color: #000;
}

/* Dark-mode buttons: pale brand colors paired with black labels (5–15:1 AA) */
[data-bs-theme="dark"] .btn-primary,
[data-bs-theme="dark"] .btn-success,
[data-bs-theme="dark"] .btn-danger,
[data-bs-theme="dark"] .btn-secondary,
[data-bs-theme="dark"] .btn-info {
  --bs-btn-color: #000;
  --bs-btn-hover-color: #000;
  --bs-btn-active-color: #000;
}

/* Universal :focus-visible — WCAG 2.4.7 (visible focus indicator) */
*:focus-visible {
  outline: 2px solid var(--sparc-focus);
  outline-offset: 2px;
}

/* Forced-colors mode (Windows High Contrast etc.) — let system colors win */
@media (forced-colors: active) {
  .btn,
  .form-control,
  .form-select {
    border: 1px solid CanvasText;
  }
  *:focus-visible {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }
}

/* Tables — restore original padding and header bg */
.table th {
  background-color: var(--bs-secondary-bg);
  font-weight: 600;
}

.table th,
.table td {
  padding: 0.75rem;
  font-size: 1.05rem;
  border-bottom-color: var(--sparc-border);
  color: var(--bs-body-color);
}

/* Forms — restore original SPARC padding and radius */
.form-control,
.form-select {
  padding: 0.75rem;
  border-radius: 4px;
  background-color: var(--sparc-surface) !important;
  border-color: var(--sparc-border) !important;
  color: var(--bs-body-color) !important;
}

.form-control:focus,
.form-select:focus {
  background-color: var(--sparc-surface-alt) !important;
  border-color: var(--sparc-accent, #3b82f6) !important;
  color: var(--bs-body-color) !important;
  box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
}

.form-control::placeholder {
  color: rgba(var(--bs-body-color-rgb, 108, 117, 125), 0.5);
}

.form-text {
  color: rgba(var(--bs-body-color-rgb, 108, 117, 125), 0.65) !important;
}

.form-label {
  color: var(--bs-body-color);
}

/* Container — original max-width */
.container {
  max-width: 1200px;
}

/* Navbar — ensure dark navbar links stay white despite global overrides */
.navbar-dark .nav-link,
.navbar-dark .navbar-nav .nav-link {
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.05rem;
}
.navbar-dark .nav-link:hover,
.navbar-dark .nav-link:focus,
.navbar-dark .navbar-nav .nav-link:hover,
.navbar-dark .navbar-nav .nav-link:focus {
  color: rgba(255, 255, 255, 1);
}
.navbar-dark .navbar-brand {
  color: #fff;
}

/* ── Navbar button-styled items ────────────────────────────────── */

.sparc-nav-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 6px;
  padding: 0.35rem 0.75rem !important;
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8) !important;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  white-space: nowrap;
}

.sparc-nav-btn:hover,
.sparc-nav-btn:focus {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff !important;
}

.sparc-nav-btn.show {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff !important;
}

/* OSCAL layer accent borders on active/hover */
.sparc-nav-controls:hover,
.sparc-nav-controls.show {
  border-bottom-color: #6ba3d6;
}
.sparc-nav-implementation:hover,
.sparc-nav-implementation.show {
  border-bottom-color: #6abf69;
}
.sparc-nav-assessment:hover,
.sparc-nav-assessment.show {
  border-bottom-color: #e8a838;
}
.sparc-nav-boundaries:hover,
.sparc-nav-boundaries.show {
  border-bottom-color: #bb6bd9;
}

/* Vertical separator between nav sections */
.sparc-nav-separator {
  display: inline-block;
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.15);
  vertical-align: middle;
  margin: 0 0.25rem;
}

/* Theme toggle button (compact) */
.sparc-nav-theme-btn {
  padding: 0.3rem 0.6rem !important;
  font-size: 0.85rem;
  border-radius: 6px;
}

/* User menu toggle */
.sparc-nav-user {
  padding: 0.25rem 0.5rem !important;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.85) !important;
  transition: background 0.2s;
}

.sparc-nav-user:hover,
.sparc-nav-user.show {
  background: rgba(255, 255, 255, 0.1);
  color: #fff !important;
}


/* ── OSCAL-layer dropdown menus ───────────────────────────────── */

.sparc-dropdown-menu {
  background: var(--sparc-surface);
  border: 1px solid var(--sparc-border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  padding: 0.35rem 0;
  min-width: 220px;
  margin-top: 0.35rem !important;
}

.sparc-dropdown-menu .dropdown-item {
  padding: 0.6rem 1rem;
  font-size: 1.05rem;
  border-radius: 4px;
  margin: 0.1rem 0.35rem;
  color: var(--bs-body-color);
  transition: background 0.15s;
}

.sparc-dropdown-menu .dropdown-item:hover,
.sparc-dropdown-menu .dropdown-item:focus {
  background: var(--sparc-surface-alt);
}

/* Dropdown header with OSCAL layer accent */
.sparc-dropdown-header {
  padding: 0.5rem 1rem 0.3rem;
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sparc-text-faint);
  pointer-events: none;
}

.sparc-dropdown-header-controls {
  color: #6ba3d6;
}

.sparc-dropdown-header-implementation {
  color: #6abf69;
}

.sparc-dropdown-header-assessment {
  color: #d4943c;
}

.sparc-dropdown-header-boundaries {
  color: #bb6bd9;
}

/* Dropdown item icons */
.sparc-dropdown-icon {
  display: inline-block;
  width: 1.4em;
  text-align: center;
  margin-right: 0.15rem;
  font-size: 0.9em;
}


/* ── User avatar ──────────────────────────────────────────────── */

.sparc-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sparc-primary), var(--sparc-purple));
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  overflow: hidden;
  line-height: 1;
}

.sparc-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Medium size (dropdown header, profile page) */
.sparc-avatar-md {
  width: 36px;
  height: 36px;
  font-size: 0.8rem;
}

/* Large size (profile edit page) */
.sparc-avatar-lg {
  width: 64px;
  height: 64px;
  font-size: 1.3rem;
}

/* ── Data Quality Card (#237) ─────────────────────────────── */

.data-quality-card--warnings {
  border-left: 4px solid var(--bs-warning, #ffc107);
}

.data-quality-card--clean {
  border-left: 4px solid var(--bs-success, #198754);
}

.data-quality-card summary::-webkit-details-marker {
  display: none;
}

.data-quality-card .data-quality-arrow {
  font-size: 0.75rem;
  color: var(--bs-secondary);
  transition: transform 0.15s;
}

/* ── Avatar Crop Modal (#234) ──────────────────────────────── */

.avatar-crop-container {
  max-height: 400px;
  overflow: hidden;
  background: var(--bs-dark-bg-subtle, #1a1a2e);
  border-radius: 0.5rem;
}

.avatar-crop-container img {
  display: block;
  max-width: 100%;
}

.avatar-crop-preview {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--sparc-primary);
  background: var(--bs-dark-bg-subtle, #1a1a2e);
}

/* Cropper.js circular crop guide overlay */
.cropper-view-box,
.cropper-face {
  border-radius: 50%;
}

/* Navbar logo — responsive sizing */
.sparc-navbar-logo {
  height: 44px;
  width: auto;
}
@media (min-width: 992px) {
  .sparc-navbar-logo {
    height: 52px;
  }
}

/* Login page logo — larger for prominent branding */
.sparc-login-logo {
  height: 160px;
  width: auto;
  display: block;
  margin: 0 auto 0.5rem;
}
@media (min-width: 576px) {
  .sparc-login-logo {
    height: 200px;
  }
}


/* ═══════════════════════════════════════════════════════════════════
   3. BADGE ALIASES WITH SPARC PALETTE
   ═══════════════════════════════════════════════════════════════════ */

.badge-ok {
  background-color: #d4edda !important;
  color: #155724 !important;
}

.badge-warn {
  background-color: #fff3cd !important;
  color: #856404 !important;
}

.badge-fail {
  background-color: #f8d7da !important;
  color: #721c24 !important;
}

.badge-info {
  background-color: #d6eaf8 !important;
  color: #1a5276 !important;
}

[data-bs-theme="dark"] .badge-ok {
  background-color: #1a3a2a !important;
  color: #68d391 !important;
}

[data-bs-theme="dark"] .badge-warn {
  background-color: #3a3520 !important;
  color: #f6e05e !important;
}

[data-bs-theme="dark"] .badge-fail {
  background-color: #3a1a1a !important;
  color: #fc8181 !important;
}

[data-bs-theme="dark"] .badge-info {
  background-color: #1a2a3a !important;
  color: #5dade2 !important;
}

/* #599 R5: Bootstrap text-bg / bg-secondary badges put white text on the
   SPARC dark palette, whose fills are PALE (#b0bec5 secondary 1.9:1, #2ecc71
   success 2.1:1). Pair them with black in dark theme — same move as the dark
   btn overrides. Scoped to .badge so .bg-secondary panels are untouched. */
[data-bs-theme="dark"] .badge.text-bg-secondary,
[data-bs-theme="dark"] .badge.bg-secondary,
[data-bs-theme="dark"] .badge.text-bg-success,
[data-bs-theme="dark"] .badge.text-bg-info,
[data-bs-theme="dark"] .badge.text-bg-primary,
[data-bs-theme="dark"] .badge.text-bg-danger {
  color: #000 !important;
}

/* ═══════════════════════════════════════════════════════════════════
   3b. STATUS PILL — semantic variants (WORM, #599 Round 2)
   Single source of truth for status/severity/priority badge color.
   Markup declares meaning (sparc-status--<variant>); CSS owns the AA
   contrast. Every fg/bg pair verified WCAG 2.1 AA >= 4.5:1, light + dark.
   Helpers (*_variant) map domain values → these keys; never hex.
   ═══════════════════════════════════════════════════════════════════ */
.sparc-status {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 0.25rem;
  font-weight: 600;
  font-size: 0.78rem;
  border: 1px solid;
  white-space: nowrap;
}

/* Light theme — Bootstrap subtle palette (matches .badge-*; ~7:1) */
.sparc-status--success { color: #0f5132 !important; background: #d1e7dd !important; border-color: #badbcc !important; }
.sparc-status--warning { color: #664d03 !important; background: #fff3cd !important; border-color: #ffecb5 !important; }
.sparc-status--danger  { color: #842029 !important; background: #f8d7da !important; border-color: #f5c2c7 !important; }
.sparc-status--info    { color: #055160 !important; background: #cff4fc !important; border-color: #b6effb !important; }
.sparc-status--neutral { color: #41464b !important; background: #e2e3e5 !important; border-color: #d3d6d8 !important; }
.sparc-status--purple  { color: #5b2c6f !important; background: #ebdef0 !important; border-color: #d7bde2 !important; }
.sparc-status--orange  { color: #7a3d00 !important; background: #ffe8d4 !important; border-color: #ffd6b0 !important; }

/* Dark theme — mirrors .badge-* dark overrides (light text on dark fill) */
[data-bs-theme="dark"] .sparc-status--success { color: #68d391 !important; background: #1a3a2a !important; border-color: #2c5440 !important; }
[data-bs-theme="dark"] .sparc-status--warning { color: #f6e05e !important; background: #3a3520 !important; border-color: #574f2e !important; }
[data-bs-theme="dark"] .sparc-status--danger  { color: #fc8181 !important; background: #3a1a1a !important; border-color: #5a2a2a !important; }
[data-bs-theme="dark"] .sparc-status--info    { color: #5dade2 !important; background: #1a2a3a !important; border-color: #2c4257 !important; }
[data-bs-theme="dark"] .sparc-status--neutral { color: #ced4da !important; background: #2a2d31 !important; border-color: #41464b !important; }
[data-bs-theme="dark"] .sparc-status--purple  { color: #cba3e3 !important; background: #2e2440 !important; border-color: #463a5e !important; }
[data-bs-theme="dark"] .sparc-status--orange  { color: #f6ad55 !important; background: #3a2a14 !important; border-color: #574326 !important; }

/* Decorative fills — solid hues for non-text elements (heatmap stacked bars,
   legend swatches). No contrast requirement; keeps the saturated palette. */
.sparc-fill--success { background: #27ae60; }
.sparc-fill--warning { background: #f39c12; }
.sparc-fill--danger  { background: #e74c3c; }
.sparc-fill--info    { background: #3498db; }
.sparc-fill--neutral { background: #95a5a6; }
.sparc-fill--purple  { background: #9b59b6; }
.sparc-fill--orange  { background: #ff9900; }

/* Family compliance-percentage text — AA on light/dark card surfaces
   (replaces inline #27ae60/#e67e22/#e74c3c which failed at 2.8–3.9:1). */
.sparc-pct-good { color: #19743f; }
.sparc-pct-mid  { color: #8a5000; }
.sparc-pct-low  { color: #c0392b; }
[data-bs-theme="dark"] .sparc-pct-good { color: #68d391; }
[data-bs-theme="dark"] .sparc-pct-mid  { color: #f6ad55; }
[data-bs-theme="dark"] .sparc-pct-low  { color: #fc8181; }

/* Section / OSCAL-layer heading colors (WORM, #599 Round 3). Replaces inline
   <h_ style="color:#hex"> (controls=blue, implementation=green, assessment=
   amber, enterprise=purple) that rendered at 2.8–3.6:1. AA on light + dark. */
.sparc-heading-controls       { color: #1a5276; }
.sparc-heading-implementation { color: #19743f; }
.sparc-heading-assessment     { color: #8a5000; }
.sparc-heading-enterprise     { color: #6c3483; }
.sparc-heading-danger         { color: #c0392b; }
[data-bs-theme="dark"] .sparc-heading-controls       { color: #5dade2; }
[data-bs-theme="dark"] .sparc-heading-implementation { color: #68d391; }
[data-bs-theme="dark"] .sparc-heading-assessment     { color: #f6ad55; }
[data-bs-theme="dark"] .sparc-heading-enterprise     { color: #cba3e3; }
[data-bs-theme="dark"] .sparc-heading-danger         { color: #fc8181; }

/* Required-field asterisk — AA red (was inline #e74c3c ~3.9:1 as small text) */
.sparc-required { color: #c0392b; }
[data-bs-theme="dark"] .sparc-required { color: #fc8181; }

/* Custom button variants */
.btn-sparc-purple {
  background-color: var(--sparc-purple);
  border-color: var(--sparc-purple);
  color: white;
}
/* #599 R5: in dark theme --sparc-purple is a pale #bb6bd9; white text is only
   3.37:1. Pair with black like the dark .btn-* overrides (matches .btn-success
   adapting to black-on-pale-fill in dark). */
[data-bs-theme="dark"] .btn-sparc-purple,
[data-bs-theme="dark"] .btn-sparc-purple:hover {
  color: #000;
}
.btn-sparc-purple:hover {
  background-color: var(--sparc-purple-hover);
  border-color: var(--sparc-purple-hover);
  color: white;
}

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

/* Link accent colors */
a.link-accent { color: var(--sparc-primary); }
a.link-purple { color: var(--sparc-purple); }
/* #599 R5: --sparc-purple (#bb6bd9) is only 3.4:1 on dark surfaces */
[data-bs-theme="dark"] a.link-purple { color: #cba3e3; }


/* ═══════════════════════════════════════════════════════════════════
   4. REUSABLE COMPONENT CLASSES
   ═══════════════════════════════════════════════════════════════════ */

/* ── Dashboard header buttons (dark gradient backgrounds) ──────── */

.sparc-btn-ghost {
  background: rgba(255, 255, 255, 0.12);
  color: white;
  text-decoration: none;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  white-space: nowrap;
  display: inline-block;
}
.sparc-btn-ghost:hover { background: rgba(255, 255, 255, 0.2); color: white; text-decoration: none; }

.sparc-btn-ghost-muted {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  white-space: nowrap;
  display: inline-block;
}
.sparc-btn-ghost-muted:hover { background: rgba(255, 255, 255, 0.15); color: white; text-decoration: none; }

/* Light theme: the white-on-white-tint ghost button is invisible (1.06:1) on
   light pages like /admin/data_migrations. Use dark text/border on a faint dark
   tint so it passes WCAG AA there; the dark-theme rule above is unchanged.
   WCAG 2.1 AA — see #599 a11y sweep. */
[data-bs-theme="light"] .sparc-btn-ghost-muted {
  background: rgba(0, 0, 0, 0.04);
  color: #333333;
  border-color: rgba(0, 0, 0, 0.18);
}
[data-bs-theme="light"] .sparc-btn-ghost-muted:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #000;
}

.sparc-btn-oscal {
  background: rgba(46, 204, 113, 0.2);
  color: #2ecc71;
  text-decoration: none;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  border: 1px solid rgba(46, 204, 113, 0.4);
  white-space: nowrap;
  font-weight: 600;
  display: inline-block;
}
.sparc-btn-oscal:hover { background: rgba(46, 204, 113, 0.3); color: #2ecc71; text-decoration: none; }

.sparc-btn-enrich {
  background: rgba(243, 156, 18, 0.2);
  color: #f39c12;
  text-decoration: none;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  border: 1px solid rgba(243, 156, 18, 0.4);
  white-space: nowrap;
  font-weight: 600;
  display: inline-block;
}
.sparc-btn-enrich:hover { background: rgba(243, 156, 18, 0.3); color: #f39c12; text-decoration: none; }


/* ── Dashboard header text elements ────────────────────────────── */

.sparc-header-subtitle {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 0.3rem;
}

.sparc-header-title {
  color: white;
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0;
}

.sparc-header-meta {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 0.3rem;
}

.sparc-version-badge {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.12rem 0.45rem;
  border-radius: 4px;
}

.sparc-creation-badge {
  background: rgba(255, 255, 255, 0.12);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.68rem;
  font-weight: 600;
}

.sparc-enriched-badge {
  background: rgba(46, 204, 113, 0.2);
  color: #2ecc71;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.68rem;
  font-weight: 600;
}


/* ── Dashboard header editing controls ─────────────────────────── */

.sparc-btn-header-edit {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  font-size: 0.7rem;
  cursor: pointer;
}

.sparc-input-dark {
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.sparc-input-dark-lg {
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0.3rem 0.6rem;
  min-width: 200px;
}

.sparc-input-dark-sm {
  font-size: 0.85rem;
  padding: 0.3rem 0.6rem;
  width: 100px;
}

.sparc-btn-save {
  background: #27ae60;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.sparc-btn-save:hover { background: #229954; }

.sparc-btn-cancel-dark {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  cursor: pointer;
}


/* ── Score displays (SSP + SAR show) ───────────────────────────── */

.sparc-score {
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.sparc-score-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 0.2rem;
}

.sparc-score-detail {
  font-size: 0.58rem;
  color: rgba(255, 255, 255, 0.3);
  margin-top: 0.1rem;
}

.sparc-divider-v {
  width: 1px;
  height: 52px;
  background: rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}


/* ── Summary chips (status counts in dashboard headers) ────────── */

.sparc-summary-chip {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  min-width: 80px;
  text-decoration: none;
  display: inline-block;
}
.sparc-summary-chip:hover { background: rgba(0, 0, 0, 0.35); text-decoration: none; }
.sparc-summary-chip.active { background: rgba(255, 255, 255, 0.15); }

.sparc-chip-count {
  font-size: 1.5rem;
  font-weight: 800;
  color: white;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.sparc-chip-label {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
  margin-top: 0.15rem;
}


/* ── Progress bars (dark backgrounds) ──────────────────────────── */

.sparc-progress-bar {
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  background: rgba(255, 255, 255, 0.08);
}


/* ── Control cards ─────────────────────────────────────────────── */

.control-card {
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 8px;
  padding: 1.1rem 1.25rem;
  margin-bottom: 0.65rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.sparc-ctrl-id {
  font-family: monospace;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--bs-body-color);
}

.sparc-ctrl-title {
  font-size: 0.85rem;
  color: var(--bs-body-color);
  font-weight: 500;
}

.sparc-ctrl-family {
  font-size: 0.68rem;
  color: var(--bs-tertiary-color);
  font-family: monospace;
}

.sparc-btn-edit {
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  flex-shrink: 0;
  background: var(--sparc-primary);  /* WCAG AA: was #3498db (white = 3.15:1) */
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}
.sparc-btn-edit:hover { background: var(--sparc-primary-hover); }
/* Dark theme: --sparc-primary is a pale blue (#5dade2); pair it with black text
   like Bootstrap's dark .btn-primary (white would be 2.45:1). */
[data-bs-theme="dark"] .sparc-btn-edit { color: #000; }


/* ── Status pill / outline tag ─────────────────────────────────── */

.sparc-status-pill {
  padding: 0.15rem 0.55rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
  color: white;
  display: inline-block;
}

.sparc-tag-outline {
  padding: 0.12rem 0.5rem;
  border-radius: 4px;
  font-size: 0.67rem;
  font-weight: 600;
  white-space: nowrap;
  display: inline-block;
}


/* ── Asset / Environment tags on control cards ─────────────────── */

.sparc-asset-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  background: rgba(44, 62, 80, 0.1);
  border: 1px solid rgba(44, 62, 80, 0.25);
  color: #495057;  /* WCAG AA: --bs-secondary-color (#666) was 4.46:1 on the tint */
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}

.sparc-env-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  background: rgba(39, 174, 96, 0.08);
  border: 1px solid rgba(39, 174, 96, 0.2);
  color: #495057;  /* WCAG AA: see .sparc-asset-tag */
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}

[data-bs-theme="dark"] .sparc-asset-tag,
[data-bs-theme="dark"] .sparc-env-tag { color: #ced4da; }

.sparc-tag-separator {
  color: var(--bs-tertiary-color);
  font-size: 0.65rem;
}


/* ── Field tables (inside control card details) ────────────────── */

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

.sparc-field-table tr {
  border-top: 1px solid var(--bs-border-color);
}

.sparc-field-label {
  width: 26%;
  padding: 0.4rem 0.5rem 0.4rem 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bs-tertiary-color);
  vertical-align: top;
  white-space: nowrap;
  /* Rendered as <th scope="row"> for key/value tables (Web:S5256). Reset the
     UA defaults so the semantic change is invisible: <th> would otherwise
     come out bold and centered. No-op on the <td> uses of this class. */
  font-weight: 400;
  text-align: left;
}

.sparc-field-label-padded {
  width: 26%;
  padding: 0.38rem 0.5rem 0.38rem 0.75rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bs-tertiary-color);
  vertical-align: top;
  white-space: nowrap;
}

.sparc-field-value {
  padding: 0.4rem 0 0.4rem 0.5rem;
  font-size: 0.84rem;
  color: var(--bs-body-color);
  vertical-align: top;
}

.sparc-field-value-padded {
  padding: 0.38rem 0.75rem 0.38rem 0.5rem;
  font-size: 0.83rem;
  vertical-align: top;
  white-space: pre-wrap;
}

.sparc-editable-indicator {
  color: #27ae60;
  font-size: 0.65rem;
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
}

.sparc-editable-indicator:hover {
  color: #2ecc71;
}

.sparc-field-editable:hover {
  background: var(--bs-tertiary-bg);
}


/* ── Heatmap grid ──────────────────────────────────────────────── */

.sparc-heatmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 0.7rem;
}

.sparc-heatmap-card {
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 8px;
  padding: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.sparc-heatmap-card:hover {
  border-color: var(--bs-secondary-color);
}
.sparc-heatmap-card.active {
  border-color: #3498db;
  box-shadow: 0 0 0 1px #3498db;
}

.sparc-family-link {
  font-family: monospace;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--bs-body-color);
  text-decoration: none;
  cursor: pointer;
}
.sparc-family-link:hover { color: var(--sparc-primary); }

.sparc-heatmap-bar {
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
  display: flex;
  background: var(--bs-border-color);
  margin-bottom: 0.55rem;
}

.sparc-heatmap-badge {
  /* color owned by the .sparc-status--<variant> companion class (AA) */
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.4;
  text-decoration: none;
  display: inline-block;
}
.sparc-heatmap-badge:hover { opacity: 0.85; text-decoration: none; }
.sparc-heatmap-badge:focus-visible {
  outline: 2px solid var(--sparc-primary);
  outline-offset: 2px;
}
.sparc-family-link:focus-visible {
  outline: 2px solid var(--sparc-primary);
  outline-offset: 2px;
  border-radius: 2px;
}

.sparc-legend-label {
  font-size: 0.72rem;
  color: var(--bs-tertiary-color);
}

.sparc-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  color: var(--bs-secondary-color);
}

.sparc-legend-dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 2px;
  flex-shrink: 0;
}


/* ── Section summary header ────────────────────────────────────── */

.sparc-section-summary {
  cursor: pointer;
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  color: var(--bs-body-color);
  list-style: none;
  user-select: none;
}

.sparc-section-hint {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--bs-tertiary-color);
  margin-left: 0.25rem;
}

.sparc-section-arrow {
  font-size: 0.75rem;
}


/* ── Card details (collapsible sections inside control cards) ──── */

.sparc-card-arrow {
  font-size: 0.55rem;
}

.sparc-card-detail-toggle {
  cursor: pointer;
  font-size: 0.7rem;
  color: var(--bs-tertiary-color);
  padding: 0.2rem 0;
  list-style: none;
  user-select: none;
}

.sparc-card-detail-separator {
  border-top: 1px solid var(--bs-border-color);
  flex: 1;
  margin-left: 0.2rem;
}


/* ── Assessment context panel ──────────────────────────────────── */

.sparc-ctx-panel {
  border: 1px solid var(--bs-border-color);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bs-secondary-bg);
}

.sparc-ctx-header {
  cursor: pointer;
  padding: 0.35rem 0.75rem;
  font-size: 0.63rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--bs-tertiary-color);
  list-style: none;
  user-select: none;
}

.sparc-ctx-arrow {
  font-size: 0.6rem;
}


/* ── Edit form sections ────────────────────────────────────────── */

.sparc-edit-ctx-panel {
  background: var(--bs-secondary-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.sparc-edit-ctx-header {
  padding: 0.35rem 0.75rem;
  border-bottom: 1px solid var(--bs-border-color);
  font-size: 0.63rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--bs-tertiary-color);
}

.sparc-edit-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bs-secondary-color);
}

.sparc-edit-editable-hint {
  color: #27ae60;
  font-size: 0.7rem;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.sparc-edit-readonly-hint {
  color: var(--bs-tertiary-color);
  font-size: 0.7rem;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.sparc-readonly-value {
  background: var(--bs-secondary-bg);
  padding: 0.6rem 0.75rem;
  border-radius: 4px;
  font-size: 0.875rem;
  color: var(--bs-secondary-color);
  margin: 0;
}


/* ── Filter banner ─────────────────────────────────────────────── */

.sparc-filter-banner {
  background: #1a252f;
  color: white;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.sparc-filter-text {
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.9);
}

.sparc-btn-clear-filter {
  background: rgba(255, 255, 255, 0.12);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 5px;
  padding: 0.25rem 0.7rem;
  cursor: pointer;
  font-size: 0.8rem;
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
  display: inline-block;
}
.sparc-btn-clear-filter:hover { background: rgba(255, 255, 255, 0.2); color: white; text-decoration: none; }


/* ── Pill filter tabs (SAR sections, environments) ─────────────── */

.sparc-pill-filter {
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  border: 1px solid var(--bs-border-color);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  color: var(--bs-body-color);
  background: var(--bs-body-bg);
  font-weight: 400;
}
.sparc-pill-filter:hover { text-decoration: none; }
.sparc-pill-filter.active {
  background: #2c3e50;
  color: white;
  font-weight: 600;
}


/* ── Processing state ──────────────────────────────────────────── */

.sparc-spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #f39c12;
  border-radius: 50%;
  animation: sparc-spin 1s linear infinite;
}

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

.sparc-processing-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.sparc-processing-title {
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
}

.sparc-processing-title-error { color: #e74c3c; }
.sparc-processing-title-pending { color: #f39c12; }

.sparc-processing-text {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
}

.sparc-processing-text-muted {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.88rem;
}


/* ── Home page section cards ──────────────────────────────────── */

.sparc-section-card {
  border-width: 1px;
  border-left-width: 3px;
  border-style: solid;
  padding: 0;
  transition: box-shadow 0.2s, transform 0.15s;
}

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

[data-bs-theme="dark"] .sparc-section-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}


/* ── Home page tiles ───────────────────────────────────────────── */

.sparc-hero-tile {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 0.5rem;
  padding: 0.65rem;
  text-align: center;
}

/* #770 bug 4 — clickable artifact-summary tiles. Inherit color so the tile
   content isn't recolored as a link, and lift slightly on hover to signal
   the whole tile navigates. */
.sparc-hero-tile-link {
  color: inherit;
}

.sparc-hero-tile-link:hover .sparc-hero-tile {
  background: rgba(255, 255, 255, 0.25);
}

.sparc-hero-tile-count {
  font-size: 2rem;
  font-weight: 700;
}

.sparc-hero-tile-label {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.75);
  margin-top: 0.15rem;
}

@media (max-width: 575.98px) {
  .sparc-hero-tile-count { font-size: 1.6rem; }
  .sparc-hero-tile-label { font-size: 0.75rem; }
}

/* WCAG 2.1 AA: route through --sparc-success (tracks theme; AA in both) */
.sparc-check-icon {
  color: var(--sparc-success);
  flex-shrink: 0;
}

/* Bootstrap .text-info (#0dcaf0) is only ~1.95:1 on light surfaces — route
   through --sparc-info so it passes WCAG AA in both themes (e.g. the "running"
   counter on /admin/data_migrations). !important matches Bootstrap's utility. */
.text-info {
  color: var(--sparc-info) !important;
}

/* Same treatment for the other low-contrast Bootstrap text utilities:
   .text-warning (#f39c12 ~1.8:1) and .text-success (dips below AA on light
   tints). Route through AA tokens (both have dark-theme values). #599 R3. */
.text-warning {
  color: var(--sparc-warning-fg) !important;
}
.text-success {
  color: var(--sparc-success) !important;
}

/* Consent-banner notice (#602): admin-supplied banner HTML styles its NOTICE
   heading with Bootstrap .text-warning, which renders --sparc-warning (#f39c12)
   as TEXT at only 2.01:1 on the modal's light surface. Scope a WCAG-AA dark
   amber here so the banner-body amber passes without touching the token's
   intended amber-fill-on-black use elsewhere. !important matches Bootstrap. */
#consentBannerBody .text-warning {
  color: var(--sparc-warning-fg) !important;
}

/* OSCAL overview SVG layer labels — themed via tokens so the text passes AA
   in both modes; rect tints stay decorative (opacity, no contrast requirement) */
.oscal-svg-text-controls       { fill: var(--sparc-primary); }
.oscal-svg-text-implementation { fill: var(--sparc-success); }
.oscal-svg-text-assessment     { fill: var(--sparc-orange); }


/* ── Source badges (index tables) ──────────────────────────────── */

.sparc-source-badge {
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  display: inline-block;
}

.sparc-source-excel {
  background: rgba(149, 165, 166, 0.13);
  color: #495057;  /* WCAG AA: was #95a5a6 (~2:1) as text on the light tint */
  border: 1px solid rgba(149, 165, 166, 0.33);
}

.sparc-source-wizard {
  background: rgba(52, 152, 219, 0.13);
  color: #1a5276;  /* WCAG AA: was #3498db (~3:1) */
  border: 1px solid rgba(52, 152, 219, 0.33);
}

.sparc-source-oscal {
  background: rgba(46, 204, 113, 0.13);
  color: #155724;  /* WCAG AA: was #2ecc71 (~2.3:1) */
  border: 1px solid rgba(46, 204, 113, 0.33);
}

[data-bs-theme="dark"] .sparc-source-excel  { color: #ced4da; }
[data-bs-theme="dark"] .sparc-source-wizard { color: #5dade2; }
[data-bs-theme="dark"] .sparc-source-oscal  { color: #68d391; }

/* Index table "Enriched" / "Basic" indicators */
.sparc-oscal-enriched {
  background: rgba(46, 204, 113, 0.15);
  color: #155724;  /* WCAG AA: was #27ae60 (~2.8:1) */
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}
[data-bs-theme="dark"] .sparc-oscal-enriched { color: #68d391; }

.sparc-oscal-basic {
  color: var(--bs-tertiary-color);
  font-size: 0.78rem;
}

/* Index table "Enrich" action link */
.sparc-btn-enrich-sm {
  background: rgba(243, 156, 18, 0.15);
  color: #8a5000;  /* WCAG AA: was #e67e22 (~3:1) as text on the amber tint */
  border: 1px solid rgba(243, 156, 18, 0.3);
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  font-size: 0.8rem;
  text-decoration: none;
  font-weight: 500;
  display: inline-block;
}
.sparc-btn-enrich-sm:hover { background: rgba(243, 156, 18, 0.25); color: #6f4000; text-decoration: none; }
[data-bs-theme="dark"] .sparc-btn-enrich-sm,
[data-bs-theme="dark"] .sparc-btn-enrich-sm:hover { color: #f6ad55; }


/* ── Enrich page sections ──────────────────────────────────────── */

.sparc-enrich-section {
  border: 1px solid var(--bs-border-color);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  background: var(--sparc-surface);
}

.sparc-enrich-section-header {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--bs-body-color);
}

.sparc-enrich-field-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bs-secondary-color);
  margin-bottom: 0.35rem;
}


/* ── Statement block (blue-bordered info blocks) ───────────────── */

.sparc-statement-block {
  background: rgba(41, 128, 185, 0.07);
  border: 1px solid rgba(41, 128, 185, 0.2);
  border-left: 3px solid #2980b9;
  border-radius: 6px;
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.75rem;
}

.sparc-statement-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--bs-secondary-color);
}


/* ── Pagination ────────────────────────────────────────────────── */

.sparc-pagination-info {
  font-size: 0.8rem;
  color: var(--bs-tertiary-color);
  margin-top: 0.5rem;
}


/* ── Misc utilities ────────────────────────────────────────────── */

.sparc-monospace {
  font-family: monospace;
}

.sparc-text-success-bold {
  color: #19743f;  /* WCAG AA: was #2ecc71 (~2.8:1) */
  font-weight: 600;
}

.sparc-text-warning-bold {
  color: #8a5000;  /* WCAG AA: was #f39c12 (~1.9:1) */
  font-weight: 600;
}

[data-bs-theme="dark"] .sparc-text-success-bold { color: #68d391; }
[data-bs-theme="dark"] .sparc-text-warning-bold { color: #f6ad55; }

/* ── Family Selector (profile create / manage controls) ────────── */
.sparc-family-group {
  border: 1px solid var(--bs-border-color);
  border-radius: 0.375rem;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}
.sparc-family-group summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.sparc-family-group summary::-webkit-details-marker { display: none; }
.sparc-family-indicator {
  font-size: 0.82rem;
  color: var(--bs-secondary-color);
  margin-left: auto;
}

/* ── Sub-parts / Implementation Statements (profile show) ──────── */
.sparc-sub-parts-section {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--bs-border-color);
}
.sparc-sub-part-item {
  padding: 0.25rem 0 0.25rem 0.75rem;
  border-left: 2px solid var(--bs-border-color);
  margin-bottom: 0.25rem;
  font-size: 0.84rem;
  line-height: 1.4;
}
.sparc-sub-part-id {
  font-family: monospace;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--bs-tertiary-color);
  margin-right: 0.4rem;
}
.sparc-sub-part-title {
  color: var(--bs-body-color);
}

/* ═══════════════════════════════════════════════════════════════════
   5. DRAG-AND-DROP FILE UPLOAD COMPONENT
   ═══════════════════════════════════════════════════════════════════ */

.sparc-dropzone {
  border: 2px dashed var(--bs-border-color);
  border-radius: 8px;
  padding: 2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.25s ease, background-color 0.25s ease;
  background-color: var(--bs-tertiary-bg);
  position: relative;
}
.sparc-dropzone:hover {
  border-color: var(--sparc-primary);
  background-color: rgba(var(--bs-primary-rgb), 0.04);
}

/* Active drag-over state */
.sparc-dropzone--dragover {
  border-color: var(--sparc-primary);
  background-color: rgba(var(--bs-primary-rgb), 0.08);
  box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb), 0.12);
}

/* File successfully selected */
.sparc-dropzone--has-file {
  border-color: var(--sparc-success);
  background-color: rgba(var(--bs-success-rgb), 0.05);
}

/* Validation error */
.sparc-dropzone--error {
  border-color: var(--sparc-danger);
  background-color: rgba(var(--bs-danger-rgb), 0.05);
}

.sparc-dropzone__icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.5rem;
  color: var(--bs-tertiary-color);
  transition: color 0.25s ease;
}
.sparc-dropzone:hover .sparc-dropzone__icon,
.sparc-dropzone--dragover .sparc-dropzone__icon {
  color: var(--sparc-primary);
}
.sparc-dropzone--has-file .sparc-dropzone__icon {
  color: var(--sparc-success);
}

.sparc-dropzone__prompt {
  font-size: 0.9rem;
  color: var(--bs-secondary-color);
  margin-bottom: 0.25rem;
}
.sparc-dropzone__prompt strong {
  color: var(--sparc-primary);
  font-weight: 600;
}

.sparc-dropzone__hint {
  font-size: 0.78rem;
  color: var(--bs-tertiary-color);
  margin-top: 0.25rem;
}

.sparc-dropzone__filename {
  display: none;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--sparc-success);
  margin-top: 0.5rem;
  word-break: break-all;
}
.sparc-dropzone--has-file .sparc-dropzone__filename {
  display: block;
}
.sparc-dropzone--has-file .sparc-dropzone__prompt {
  display: none;
}
.sparc-dropzone--has-file .sparc-dropzone__hint {
  display: none;
}

.sparc-dropzone__error {
  display: none;
  font-size: 0.82rem;
  color: var(--sparc-danger);
  font-weight: 500;
  margin-top: 0.5rem;
}
.sparc-dropzone--error .sparc-dropzone__error {
  display: block;
}

.sparc-dropzone__filesize {
  font-size: 0.78rem;
  color: var(--bs-tertiary-color);
  margin-top: 0.15rem;
}

/* ── Multi-file list ──────────────────────────────────────────── */

.sparc-dropzone__file-list {
  width: 100%;
  text-align: left;
  padding: 0 0.5rem;
}

.sparc-dropzone__file-summary {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--bs-success-text-emphasis);
  margin-bottom: 0.5rem;
  text-align: center;
}

.sparc-dropzone__file-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.82rem;
  background: var(--bs-tertiary-bg);
  margin-bottom: 0.25rem;
}

.sparc-dropzone__file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--bs-body-color);
}

.sparc-dropzone__file-size {
  font-size: 0.75rem;
  color: var(--bs-tertiary-color);
  white-space: nowrap;
}

.sparc-dropzone__remove-btn {
  background: none;
  border: none;
  color: var(--bs-danger);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.25rem;
  cursor: pointer;
  opacity: 0.6;
}

.sparc-dropzone__remove-btn:hover {
  opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════════
   6. STIG PARSER COMPONENT STYLES
   ═══════════════════════════════════════════════════════════════════ */

.sparc-stig-stats {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.sparc-stig-stat {
  background: var(--bs-secondary-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 6px;
  padding: 0.6rem 1rem;
  min-width: 90px;
  text-align: center;
}
.sparc-stig-stat__value {
  font-size: 1.4rem;
  font-weight: 700;
  font-family: monospace;
  line-height: 1;
}
.sparc-stig-stat__label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bs-tertiary-color);
  margin-top: 0.2rem;
}

.sparc-stig-severity {
  display: inline-block;
  font-family: monospace;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  white-space: nowrap;
}
.sparc-stig-severity--high {
  background: rgba(var(--bs-danger-rgb), 0.12);
  color: var(--sparc-danger);
  border: 1px solid rgba(var(--bs-danger-rgb), 0.3);
}
.sparc-stig-severity--medium {
  background: rgba(var(--bs-warning-rgb), 0.12);
  color: var(--sparc-warning);
  border: 1px solid rgba(var(--bs-warning-rgb), 0.3);
}
.sparc-stig-severity--low {
  background: rgba(var(--bs-primary-rgb), 0.12);
  color: var(--sparc-primary);
  border: 1px solid rgba(var(--bs-primary-rgb), 0.3);
}

.sparc-stig-cci {
  display: inline-block;
  background: rgba(var(--bs-primary-rgb), 0.08);
  border: 1px solid rgba(var(--bs-primary-rgb), 0.25);
  border-radius: 3px;
  padding: 0.05rem 0.4rem;
  margin: 0.1rem 0.15rem;
  font-family: monospace;
  font-size: 0.72rem;
  color: var(--sparc-primary);
}

.sparc-stig-nist {
  display: inline-block;
  background: rgba(var(--bs-success-rgb), 0.08);
  border: 1px solid rgba(var(--bs-success-rgb), 0.25);
  border-radius: 3px;
  padding: 0.05rem 0.4rem;
  margin: 0.1rem 0.15rem;
  font-family: monospace;
  font-size: 0.72rem;
  color: var(--sparc-success);
}

.sparc-stig-table tr {
  cursor: pointer;
  transition: background-color 0.1s ease;
}
.sparc-stig-table tr:hover {
  background-color: rgba(var(--bs-primary-rgb), 0.04);
}
.sparc-stig-detail {
  background-color: var(--bs-secondary-bg);
  border-top: 1px solid var(--bs-border-color);
}
.sparc-stig-detail td {
  padding: 1rem 1.25rem !important;
}
.sparc-stig-detail__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--bs-tertiary-color);
  margin-bottom: 0.2rem;
}

.sparc-stig-filter-btn {
  font-family: monospace;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.35rem 0.85rem;
}
.sparc-stig-filter-btn.active {
  background-color: rgba(var(--bs-primary-rgb), 0.15);
  border-color: var(--sparc-primary);
  color: var(--sparc-primary);
}

/* ── Easter egg video overlay ─────────────────────────────────── */

.sparc-video-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.sparc-video-overlay.d-none {
  display: none !important;
}

.sparc-video-player {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 8px;
  cursor: default;
}

/* ─── Sidebar Navigation ────────────────────────────────────────────── */
.sparc-sidebar {
  width: 220px;
  min-width: 220px;
  min-height: calc(100vh - 56px);
  background: var(--sparc-bg);
  border-right: 1px solid var(--sparc-border);
  color: var(--sparc-text);
  font-size: 1.05rem;
  overflow-y: auto;
  flex-shrink: 0;
}

.sparc-sidebar-header {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--sparc-border);
}

.sparc-sidebar-body {
  padding: 0;
}

.sparc-main-content {
  min-width: 0;
}

@media (max-width: 991.98px) {
  .sparc-sidebar {
    display: none;
  }
}

.sparc-sidebar-section {
  padding: 0.25rem 0;
}

.sparc-sidebar-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.5rem 1rem;
  border: none;
  background: transparent;
  color: var(--sparc-text);
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.sparc-sidebar-toggle:hover {
  background: var(--sparc-hover-bg, rgba(255,255,255,0.08));
}

[data-bs-theme="light"] .sparc-sidebar-toggle:hover {
  background: rgba(0,0,0,0.05);
}

.sparc-sidebar-toggle::before {
  content: "\25B6";
  font-size: 0.55rem;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.sparc-sidebar-toggle[aria-expanded="true"]::before {
  transform: rotate(90deg);
}

.sparc-sidebar-indent-1 {
  padding-left: 1.5rem;
  font-weight: 500;
  font-size: 0.95rem;
}

.sparc-sidebar-indent-2 {
  padding-left: 2.25rem;
  font-weight: 400;
  font-size: 0.9rem;
}

.sparc-sidebar-icon {
  font-size: 0.9rem;
  flex-shrink: 0;
}

.sparc-sidebar-leaves {
  list-style: none;
  margin: 0;
  padding: 0.15rem 0 0.35rem 0;
}

.sparc-sidebar-leaf {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 1rem 0.3rem 3.25rem;
  color: var(--sparc-text);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.15s;
}

.sparc-sidebar-leaf:hover {
  background: var(--sparc-hover-bg, rgba(255,255,255,0.08));
  color: var(--sparc-primary);
  text-decoration: none;
}

[data-bs-theme="light"] .sparc-sidebar-leaf:hover {
  background: rgba(0,0,0,0.05);
}

.sparc-sidebar-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Environment / rules header bar (#682) ─────────────────────────────────
   Operator-configurable notice shown on every screen (SPARC_HEADER_TEXT).
   Brand-default appearance: #ffffff on #1f6fa5 = 5.42:1 (WCAG AA). Operator
   colors override these via the `environment-header` Stimulus controller
   (CSSOM, not subject to CSP style-src). Keep defaults in sync with
   SparcConfig::HEADER_DEFAULT_* . */
.sparc-env-header {
  color: #ffffff;
  background-color: #1f6fa5;
  text-align: center;
  padding: 0.35rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.3;
  word-break: break-word;
}

/* ── Help Center / User Guides (#784) ──────────────────────────────────────
   In-app rendering of the wiki User Guides. Cards on the index; typographic
   polish for the rendered Markdown body (headings, lists, tables, images,
   Mermaid) so guides match SPARC styling and stay readable in light + dark. */
.sparc-guide-card {
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.sparc-guide-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.12);
}

.sparc-guide-content {
  line-height: 1.65;
}
.sparc-guide-content h1 { font-size: 1.9rem; font-weight: 700; margin-bottom: 1rem; }
.sparc-guide-content h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--bs-border-color);
}
.sparc-guide-content h3 { font-size: 1.15rem; font-weight: 600; margin-top: 1.5rem; margin-bottom: 0.5rem; }
.sparc-guide-content p,
.sparc-guide-content ul,
.sparc-guide-content ol { margin-bottom: 1rem; }
.sparc-guide-content li { margin-bottom: 0.25rem; }
.sparc-guide-content code {
  background: var(--bs-secondary-bg);
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
  font-size: 0.875em;
}
.sparc-guide-content pre {
  background: var(--bs-secondary-bg);
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
}
.sparc-guide-content pre code { background: none; padding: 0; }
.sparc-guide-content blockquote {
  border-left: 4px solid var(--bs-primary);
  padding: 0.25rem 0 0.25rem 1rem;
  margin: 0 0 1rem 0;
  color: var(--bs-secondary-color);
}
.sparc-guide-img {
  display: block;
  max-width: 100%;
  margin: 1rem auto;
}
.sparc-guide-content .mermaid {
  text-align: center;
  margin: 1.5rem 0;
}
.sparc-guide-content .table-responsive { margin-bottom: 1rem; }
