/* ==========================================================================
   Radiology Code Semantic Cleaner - Unified Design System
   Healthcare-focused, accessible, and professional styling
   Based on HNZ Priority Decision Support design system
   ========================================================================== */

/* ==========================================================================
   Validation Interface Enhancements
   ========================================================================== */

/* Validation Toolbar - Sticky navigation and controls */
.validation-toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-white);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.validation-counters {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  margin-bottom: var(--space-3);
  font-size: var(--font-size-sm);
}

.counter-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--color-gray-5);
  border: 1px solid var(--color-gray-200);
}

.counter-item .count {
  font-weight: var(--font-weight-bold);
  min-width: 2ch;
}

.counter-item.approved { border-color: var(--color-success); background: var(--color-success-light); }
.counter-item.rejected { border-color: var(--color-danger); background: var(--color-danger-light); }
.counter-item.skipped { border-color: var(--color-warning); background: var(--color-warning-light); }
.counter-item.unapproved { border-color: var(--color-warning); background: var(--color-warning-light); }
.counter-item.pending { border-color: var(--color-info); background: var(--color-info-light); }

.validation-filters {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.filter-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-sm);
  background: var(--color-white);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: var(--font-size-sm);
  user-select: none;
}

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

.filter-toggle.active {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: var(--color-white);
}

.validation-sort {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.sort-select {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-sm);
  background: var(--color-white);
  font-size: var(--font-size-sm);
  cursor: pointer;
}

.validation-search {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-3);
}

.search-input {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
}

.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-light);
}

/* Validation Group Headers with enhanced state */
.validation-group-header {
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.validation-group-header:hover {
  box-shadow: 0 4px 12px rgba(0, 90, 156, 0.15);
}

.validation-group-header.expanded {
  background-color: var(--color-primary-light);
  box-shadow: 0 4px 8px rgba(0, 90, 156, 0.2);
}

.expand-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
  color: var(--color-gray-600);
}

.expand-icon.rotated {
  transform: rotate(90deg);
}

/* Mapping item states */
.mapping-item {
  transition: all 0.2s ease;
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
}

.mapping-item.compact {
  padding: var(--space-2) var(--space-3);
}

.mapping-item.is-approved {
  border-color: var(--color-success);
  background: var(--color-success-light);
}

.mapping-item.is-rejected {
  border-color: var(--color-danger);
  background: var(--color-danger-light);
}

.mapping-item.is-skipped {
  border-color: var(--color-warning);
  background: var(--color-warning-light);
}

.mapping-item.focused {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
  box-shadow: 0 0 0 2px var(--color-primary-light);
}

/* Flag badges with consistent styling */
.flag-badge {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  background: var(--color-gray-100);
  color: var(--color-gray-700);
  border: 1px solid var(--color-gray-200);
}

.flag-badge.flag-low-confidence {
  background: var(--color-warning-light);
  color: var(--color-warning-dark);
  border-color: var(--color-warning);
}

.flag-badge.flag-ambiguous {
  background: var(--color-info-light);
  color: var(--color-info-dark);
  border-color: var(--color-info);
}

.flag-badge.flag-singleton {
  background: var(--color-secondary-light);
  color: var(--color-secondary-dark);
  border-color: var(--color-secondary);
}

.flag-badge.flag-secondary {
  background: var(--color-accent-light);
  color: var(--color-accent-dark);
  border-color: var(--color-accent);
}

/* Confidence Section Headers */
.confidence-section-header td {
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
}

.confidence-section-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-left: 4px solid;
  margin: 12px 0 4px 0;
  border-radius: 0 6px 6px 0;
  font-family: var(--font-family-primary, sans-serif);
}

.confidence-section-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--hnz-secondary-100, #13294b);
  letter-spacing: 0.3px;
}

.confidence-section-count {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.mobile-confidence-section-header {
  margin: 12px 0 4px 0;
}

.mobile-confidence-section-header .confidence-section-bar {
  border-radius: 6px;
}

/* Confidence indicators */
.confidence-pill {
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
}

.confidence-pill.confidence-high {
  background: var(--color-success);
  color: var(--color-white);
}

.confidence-pill.confidence-medium {
  background: var(--color-warning);
  color: var(--color-white);
}

.confidence-pill.confidence-low {
  background: var(--color-danger);
  color: var(--color-white);
}

.confidence-bar {
  width: 100%;
  height: 4px;
  background: var(--color-gray-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  transition: width 0.3s ease;
}

.confidence-fill.confidence-high {
  background: var(--color-success);
}

.confidence-fill.confidence-medium {
  background: var(--color-warning);
}

.confidence-fill.confidence-low {
  background: var(--color-danger);
}

/* SNOMED inline display in headers */
.snomed-inline {
  font-size: var(--font-size-xs);
  color: var(--color-gray-600);
  background-color: var(--color-gray-100);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  margin-left: var(--space-2);
  font-weight: normal;
}

/* Inline metadata layout */
.mapping-meta-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-gray-700);
  margin-bottom: var(--space-3);
}

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

.meta-separator {
  color: var(--color-gray-400);
  font-weight: bold;
}

.confidence-inline {
  font-weight: var(--font-weight-medium);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
}

.confidence-inline.confidence-high {
  background-color: var(--color-success);
  color: white;
}

.confidence-inline.confidence-medium {
  background-color: var(--color-warning);
  color: white;
}

.confidence-inline.confidence-low {
  background-color: var(--color-danger);
  color: white;
}

/* Smaller validation buttons */
.button-sm {
  min-height: 24px;
  min-width: 24px;
}

.validation-header.expanded {
  background-color: var(--color-primary-light);
}

/* ==========================================================================
   Homepage Action Cards & Hero Section
   ========================================================================== */

.action-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  border-color: var(--hnz-primary-100) !important;
}

.action-card.selected {
  border-color: var(--hnz-primary-100) !important;
  background: rgba(255,255,255,1) !important;
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0, 85, 140, 0.18);
}

/* ==========================================================================
   Unified Configuration Panel
   ========================================================================== */

.config-panel {
  border: 2px solid var(--color-primary);
  border-radius: 14px;
  background: var(--color-primary-light);
  padding: 28px;
  opacity: 1 !important;
  animation: configSlideIn 0.35s ease-out;
}

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

/* --- AI Pipeline Info Bar --- */
.pipeline-info-bar {
  background: linear-gradient(135deg, #00558c 0%, #043c60 100%);
  border-radius: 10px;
  padding: 18px 22px;
  margin-bottom: 24px;
  color: white;
}

.pipeline-info-header {
  font-family: var(--font-family-primary);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.75;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pipeline-info-models {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.pipeline-model-chip {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 12px 16px;
  flex: 1;
  min-width: 200px;
}

.pipeline-model-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.65;
  margin-bottom: 4px;
}

.pipeline-model-name {
  display: block;
  font-family: var(--font-family-primary);
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.pipeline-model-desc {
  display: block;
  font-size: 0.82rem;
  opacity: 0.7;
  line-height: 1.3;
}

.pipeline-model-divider {
  color: rgba(255, 255, 255, 0.35);
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* --- Config Section Title --- */
.config-section-title {
  font-family: var(--font-family-primary);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-gray-800);
  margin: 0 0 20px 0;
}

/* --- Config Card --- */
.config-card {
  background: white;
  border: 1px solid var(--color-gray-200);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}

.config-label {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-gray-800);
  margin-bottom: 10px;
}

.config-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.config-label-row .config-label {
  margin-bottom: 0;
}

.config-description {
  font-size: 0.9rem;
  color: var(--color-gray-500);
  margin: 8px 0 0;
  line-height: 1.4;
}

/* --- Session Size --- */
.session-size-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.session-size-input {
  width: 100px;
  padding: 10px 12px;
  border: 2px solid var(--color-gray-300);
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  color: var(--color-gray-800);
  transition: border-color 0.2s;
  font-family: var(--font-family-body);
}

.session-size-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0, 85, 140, 0.12);
}

.session-size-hint {
  font-size: 0.95rem;
  color: var(--color-gray-600);
}

/* --- Process All Toggle (custom switch) --- */
.process-all-toggle {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  transition: background 0.15s;
  user-select: none;
}

.process-all-toggle:hover {
  background: var(--color-gray-5);
}

.process-all-toggle input[type="checkbox"] {
  display: none;
}

.toggle-track {
  width: 44px;
  height: 24px;
  background: var(--color-gray-300);
  border-radius: 12px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
  margin-top: 1px;
}

.toggle-thumb {
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.process-all-toggle input:checked + .toggle-track {
  background: var(--color-primary);
}

.process-all-toggle input:checked + .toggle-track .toggle-thumb {
  transform: translateX(20px);
}

.toggle-label-text {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-gray-800);
}

.toggle-label-sub {
  display: block;
  font-size: 0.85rem;
  color: var(--color-gray-500);
  margin-top: 2px;
  line-height: 1.4;
}

/* --- Select All / Deselect All toggle --- */
.chip-toggle-all {
  background: none;
  border: 1px solid var(--color-gray-300);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-gray-600);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-family-body);
}

.chip-toggle-all:hover {
  background: var(--color-gray-5);
  border-color: var(--color-gray-500);
  color: var(--color-gray-800);
}

/* --- Chip Grid --- */
.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* --- Toggle Chip --- */
.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
  border: 2px solid var(--color-gray-200);
  background: white;
  color: var(--color-gray-600);
}

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

.toggle-chip.selected {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
  font-weight: 600;
}

.toggle-chip.selected:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  color: white;
}

.toggle-chip .chip-check {
  font-size: 0.75em;
  opacity: 0;
  transition: opacity 0.15s;
}

.toggle-chip.selected .chip-check {
  opacity: 1;
}

.toggle-chip input[type="checkbox"] {
  display: none;
}

/* --- Launch Section --- */
.config-launch {
  text-align: center;
  margin-top: 24px;
}

.config-launch-btn {
  padding: 16px 40px !important;
  font-size: 1.15rem !important;
  font-weight: 700 !important;
  border-radius: 10px !important;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}

.config-launch-btn small {
  display: block;
  font-size: 0.72em;
  font-weight: 400;
  margin-top: 4px;
  opacity: 0.85;
}

.config-launch-hint {
  font-size: 0.88rem;
  color: var(--color-gray-500);
  margin: 10px 0 0;
}

/* --- Button states (carried over) --- */
.button.large {
  transition: all 0.2s ease;
}

.button.large:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 90, 156, 0.3);
}

.button.large:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Legacy compat: keep workflow-step.active for JS that still toggles it --- */
.workflow-step {
  transition: all 0.3s ease;
}

.workflow-step.active {
  opacity: 1 !important;
}

.step.active {
  background: var(--color-primary) !important;
  color: white !important;
}

.step {
  transition: all 0.3s ease;
}

/* ==========================================================================
   Responsive - Action Cards & Config Panel
   ========================================================================== */

@media (max-width: 768px) {
  .action-paths {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
    padding: 0 8px;
  }

  .action-card {
    max-width: 100% !important;
    padding: 16px !important;
    margin: 0 !important;
  }

  .action-card .action-icon {
    font-size: 2em !important;
  }

  .action-card h3 {
    font-size: 1.1em !important;
  }

  .action-card p {
    font-size: 0.95em !important;
    line-height: 1.4;
  }

  .action-card .button {
    padding: 10px 16px !important;
    font-size: 0.95em !important;
    border-radius: 8px;
    min-height: 44px;
  }

  .action-card {
    min-height: 100px;
    touch-action: manipulation;
  }

  .action-card:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }

  /* AI Mapping Summary responsive */
  #aiMappingSummary div[style*="grid-template-columns: repeat(4"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  #aiMappingSummary div[style*="grid-template-columns: repeat(3"] {
    grid-template-columns: 1fr !important;
  }
  #aiMappingSummary div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  .config-panel {
    padding: 18px;
    border-radius: 10px;
  }

  .pipeline-info-models {
    flex-direction: column;
    gap: 10px;
  }

  .pipeline-model-chip {
    min-width: unset;
  }

  .pipeline-model-divider {
    transform: rotate(90deg);
    align-self: center;
  }

  .chip-grid {
    gap: 8px;
  }

  .toggle-chip {
    font-size: 0.85rem;
    padding: 7px 13px;
  }

  .session-size-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  /* Fix demo button grid overflow on mobile */
  #demoOptions > div {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
  }

  #demoOptions .button.large {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding: 12px 16px !important;
  }
}

/* ==========================================================================
   1. Design System: CSS Custom Properties (Variables)
   ========================================================================== */

:root {
  /* =================================================================
     HNZ Rad Tools Design System Tokens
     Aligned with hnz-design-system.md specification
     ================================================================= */

  /* ## HNZ Primary Blues (interactive elements, headings, links) */
  --hnz-primary-110: #043c60;       /* Hover/active states, dark emphasis */
  --hnz-primary-100: #00558c;       /* Primary buttons, links, headings, focus rings */
  --hnz-primary-75: #4080a9;        /* Lighter interactive states */
  --hnz-primary-50: #80aac5;        /* Borders on selected items */
  --hnz-primary-25: #bfd4e2;        /* Light borders, selected chip backgrounds */
  --hnz-primary-5: #f2f7f9;         /* Very light backgrounds, hover fills */

  /* ## HNZ Secondary Navy (structural elements, text, sidebar) */
  --hnz-secondary-110: #041836;     /* Dark hover states */
  --hnz-secondary-100: #13294b;     /* Sidebar/topbar bg, dark headings, primary buttons */
  --hnz-secondary-75: #4e5e78;      /* Body text colour */
  --hnz-secondary-50: #8994a5;      /* Muted/helper text */
  --hnz-secondary-25: #c4c9d2;      /* Disabled text, light borders */
  --hnz-secondary-5: #f3f4f6;       /* Segmented control bg, card backgrounds */

  /* ## HNZ Accent Teal (highlights, active states, accents) */
  --hnz-accent-110: #0c818f;        /* Active edit mode button */
  --hnz-accent-105: #30a1ac;        /* Icon tint */
  --hnz-accent-100: #2dccd3;        /* Active nav indicator, accent highlights */
  --hnz-accent-75: #61d9de;         /* Editing mode badge text */
  --hnz-accent-50: #96e5e9;         /* Light accent fills */
  --hnz-accent-25: #caf2f4;         /* Very light accent backgrounds */
  --hnz-accent-5: #ecfafb;          /* Teal tinted surfaces */

  /* ## HNZ Surfaces */
  --hnz-sky: #f1ffff;               /* Teal-tinted surface */
  --hnz-cream: #fdfff6;             /* Warm-tinted surface */

  /* ## Mapped aliases (existing code references these) */
  --color-primary: #00558c;         /* = --hnz-primary-100 */
  --color-primary-light: #f2f7f9;   /* = --hnz-primary-5 */
  --color-primary-dark: #043c60;    /* = --hnz-primary-110 */
  --color-primary-hover: #043c60;   /* = --hnz-primary-110 */
  --color-secondary: #2dccd3;       /* = --hnz-accent-100 (teal) */
  --color-secondary-light: #ecfafb; /* = --hnz-accent-5 */
  --color-secondary-hover: #0c818f; /* = --hnz-accent-110 */
  --color-secondary-dark: #0c818f;  /* = --hnz-accent-110 */
  --color-accent: #2dccd3;          /* Teal accent */
  --color-accent-light: #caf2f4;    /* = --hnz-accent-25 */
  --color-accent-dark: #0c818f;     /* = --hnz-accent-110 */

  /* ## Neutral Color Scale (aligned to HNZ secondary navy tints) */
  --color-white: #FFFFFF;
  --color-gray-5: #f3f4f6;          /* = --hnz-secondary-5 */
  --color-gray-50: #F9FAFB;         /* Page background per HNZ spec */
  --color-gray-100: #f3f4f6;        /* = --hnz-secondary-5, section backgrounds */
  --color-gray-200: #E0E6ED;        /* Card/divider borders */
  --color-gray-300: #c4c9d2;        /* = --hnz-secondary-25, input borders */
  --color-gray-400: #c4c9d2;        /* Placeholder, disabled text */
  --color-gray-500: #8994a5;        /* = --hnz-secondary-50, muted text */
  --color-gray-600: #4e5e78;        /* = --hnz-secondary-75, body text */
  --color-gray-700: #4e5e78;        /* = --hnz-secondary-75, body text */
  --color-gray-800: #13294b;        /* = --hnz-secondary-100, headings */
  --color-gray-900: #13294b;        /* = --hnz-secondary-100, primary text */

  /* ## Semantic Colors (per HNZ design system) */
  --color-success: #166534;         /* Success text */
  --color-success-light: #dcfce7;   /* Success background */
  --color-success-dark: #166534;    /* Darker green */
  --color-success-hover: #15803d;   /* Success hover */
  --color-success-border: #BBF7D0;  /* Success border */
  --color-warning: #92400e;         /* Warning text */
  --color-warning-light: #fef3c7;   /* Warning background */
  --color-warning-dark: #92400e;    /* Darker amber */
  --color-warning-hover: #78350f;   /* Warning hover */
  --color-warning-border: #FDE68A;  /* Warning border */
  --color-danger: #991b1b;          /* Danger text */
  --color-danger-light: #fecaca;    /* Danger background */
  --color-danger-dark: #991b1b;     /* Darker red */
  --color-danger-hover: #7f1d1d;    /* Danger hover */
  --color-danger-border: #FECACA;   /* Danger border */
  --color-info: #00558c;            /* = --hnz-primary-100 */
  --color-info-light: #f2f7f9;      /* = --hnz-primary-5 */
  --color-info-dark: #043c60;       /* = --hnz-primary-110 */

  /* ## HNZ Text Colours */
  --text-primary: #00558c;          /* Headings, important labels */
  --text-secondary: #13294b;        /* Subheadings, strong labels */
  --text-body: #4e5e78;             /* Body text (default) */
  --text-muted: #8994a5;            /* Helper text, captions */
  --text-disabled: #c4c9d2;         /* Disabled elements */

  /* ## Typography Scale (14px base per HNZ spec) */
  --font-family-primary: 'Poppins', sans-serif;
  --font-family-body: 'Open Sans', 'Public-Sans', sans-serif;
  --font-family-fallback: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-family-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;

  /* Font Sizes (14px base) */
  --font-size-xs: 0.6875rem;        /* 11px - small indicators, captions */
  --font-size-sm: 0.8125rem;        /* 13px - labels, sidebar links, table cells */
  --font-size-base: 0.875rem;       /* 14px - body text, form inputs */
  --font-size-lg: 1rem;             /* 16px - large body text */
  --font-size-xl: 1.125rem;         /* 18px - subheadings */
  --font-size-2xl: 1.25rem;         /* 20px - section headings, page titles */
  --font-size-3xl: 1.5rem;          /* 24px - large page titles */
  --font-size-4xl: 1.5rem;          /* 24px - alias for largest */

  /* Line Heights */
  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.625;

  /* Font Weights */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* ## Spacing Scale */
  --space-0: 0;
  --space-1: 0.25rem;               /* 4px */
  --space-2: 0.5rem;                /* 8px */
  --space-3: 0.75rem;               /* 12px */
  --space-4: 1rem;                  /* 16px */
  --space-5: 1.25rem;               /* 20px */
  --space-6: 1.5rem;                /* 24px */
  --space-8: 2rem;                  /* 32px */
  --space-10: 2.5rem;               /* 40px */
  --space-12: 3rem;                 /* 48px */
  --space-16: 4rem;                 /* 64px */

  /* ## Border Radius (per HNZ spec) */
  --radius-sm: 4px;                 /* Small elements */
  --radius-base: 8px;               /* Cards, dropdowns */
  --radius-md: 10px;                /* Advanced cards, segmented controls */
  --radius-lg: 12px;                /* Modals, pill badges */
  --radius-xl: 12px;                /* Alias for modals */
  --radius-full: 9999px;            /* Fully rounded */

  /* ## Shadows (per HNZ spec - minimal) */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-base: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* ## Focus States (teal focus ring per HNZ spec) */
  --focus-ring: 0 0 0 4px rgba(0, 122, 134, 0.1);
  --focus-ring-primary: 0 0 0 4px rgba(0, 122, 134, 0.1);

  /* ## Transitions */
  --transition-base: all 0.2s ease;
  --transition-fast: all 0.15s ease;
  --transition-slow: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* ## Z-Index Scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
}

/* ==========================================================================
   2. Enhanced Header Styles
   ========================================================================== */

/* App Header (HNZ Topbar: 64px, sticky, dark navy) */
.app-header {
  margin-bottom: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--hnz-secondary-100);
}

.brand-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--hnz-secondary-100);
  padding: 0 1rem;
  height: 64px;
  color: var(--color-white);
  max-width: 1400px;
  margin: 0 auto;
  border-radius: 0;
}

.brand-content {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.app-logo {
  height: 32px;
  width: auto;
  margin-right: 0;
}

.header-divider {
  width: 1px;
  height: 28px;
  background: rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.brand-title {
  font-family: var(--font-family-primary);
  font-size: 1.4rem;
  font-weight: var(--font-weight-semibold);
  color: var(--color-white);
  margin: 0;
  line-height: var(--line-height-tight);
}

.brand-subtitle {
  font-size: var(--font-size-sm);
  color: rgba(255, 255, 255, 0.65);
  margin: 0;
  line-height: var(--line-height-normal);
  font-family: var(--font-family-body);
}

/* Hamburger Menu */
.hamburger-menu {
  position: relative;
}

.hamburger-button {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  width: 24px;
  height: 24px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 10;
}

.hamburger-button:focus {
  outline: none;
}

.hamburger-line {
  width: 24px;
  height: 2px;
  background: white;
  border-radius: 10px;
  transition: all 0.3s linear;
  position: relative;
  transform-origin: 1px;
}

.hamburger-dropdown {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  min-width: 240px;
  z-index: var(--z-dropdown);
  overflow: hidden;
}

.dropdown-section {
  padding: var(--space-2) 0;
}

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

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-family-body);
  font-size: var(--font-size-sm);
  color: var(--color-gray-700) !important;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: var(--transition-base);
  text-decoration: none;
}

.dropdown-item:hover {
  background-color: var(--color-gray-50);
  color: var(--color-gray-900) !important;
}

.dropdown-item:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
  background-color: var(--color-primary-light);
}

.dropdown-icon {
  font-size: var(--font-size-lg);
  color: var(--color-gray-500);
  width: 20px;
  text-align: center;
}

/* HNZ Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(75, 85, 99, 0.6);
  z-index: var(--z-modal-backdrop);
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-overlay.hidden {
  display: none;
}

.modal-container {
  background: var(--color-white);
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  z-index: var(--z-modal);
}

.modal-content {
  background-color: var(--color-white);
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  position: relative;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 2rem;
}

.modal-header {
  padding: 0 0 var(--space-4);
  border-bottom: 1px solid #E9ECEF;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.modal-header h2 {
  margin: 0;
  font-family: var(--font-family-primary);
  font-size: 1.1rem;
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
}

.modal-close, .close-modal {
  background: none;
  border: none;
  font-size: var(--font-size-2xl);
  color: #9CA3AF;
  cursor: pointer;
  padding: var(--space-2);
  line-height: 1;
}

.modal-close:hover, .close-modal:hover {
  color: #374151;
}

.modal-body {
  padding: var(--space-6) 0;
  overflow-y: auto;
  min-height: 0;
  flex: 1 1 auto;
}

.modal-footer {
  padding: 0;
  margin-top: 2rem;
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  flex-shrink: 0;
}

.help-modal {
  max-width: 900px;
  width: 90%;
  max-height: 80vh;
}

.help-content {
  max-height: 60vh;
  overflow-y: auto;
  padding: var(--space-4);
}

.help-text {
  font-family: var(--font-family-body);
  line-height: var(--line-height-relaxed);
  color: var(--color-gray-700);
}

.help-text h1 {
  font-family: var(--font-family-primary);
  font-size: var(--font-size-2xl);
  color: var(--color-gray-900);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 2px solid var(--color-primary);
}

.help-text h2 {
  font-family: var(--font-family-primary);
  font-size: var(--font-size-xl);
  color: var(--color-gray-800);
  margin-top: var(--space-8);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-gray-200);
}

.help-text h3 {
  font-family: var(--font-family-primary);
  font-size: var(--font-size-lg);
  color: var(--color-gray-800);
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
}

.help-text h4 {
  font-family: var(--font-family-primary);
  font-size: var(--font-size-base);
  color: var(--color-gray-700);
  margin-top: var(--space-4);
  margin-bottom: var(--space-2);
  font-weight: var(--font-weight-semibold);
}

/* Architecture Modal Specific Styling */
.architecture-modal .modal-container {
  max-width: 90vw;
  max-height: 90vh;
  width: 1200px;
}

.architecture-content {
  max-height: 70vh;
  overflow-y: auto;
  padding: var(--space-4);
}

.architecture-text {
  font-family: var(--font-family-body);
  line-height: var(--line-height-relaxed);
  color: var(--color-gray-700);
}

.architecture-text h1 {
  font-family: var(--font-family-primary);
  font-size: var(--font-size-3xl);
  color: var(--color-primary);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-3);
  border-bottom: 3px solid var(--color-primary);
}

.architecture-text h2 {
  font-family: var(--font-family-primary);
  font-size: var(--font-size-2xl);
  color: var(--color-gray-900);
  margin-top: var(--space-10);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 2px solid var(--color-secondary);
}

.architecture-text h3 {
  font-family: var(--font-family-primary);
  font-size: var(--font-size-xl);
  color: var(--color-gray-800);
  margin-top: var(--space-8);
  margin-bottom: var(--space-3);
  padding-left: var(--space-2);
  border-left: 4px solid var(--color-accent);
}

.architecture-text h4 {
  font-family: var(--font-family-primary);
  font-size: var(--font-size-lg);
  color: var(--color-gray-700);
  margin-top: var(--space-6);
  margin-bottom: var(--space-2);
  font-weight: var(--font-weight-semibold);
}

.architecture-text p {
  margin-bottom: var(--space-4);
  text-align: justify;
}

.architecture-text ul, .architecture-text ol {
  margin-bottom: var(--space-4);
  padding-left: var(--space-6);
}

.architecture-text li {
  margin-bottom: var(--space-2);
}

.architecture-text code {
  background-color: var(--color-gray-100);
  color: var(--color-primary-dark);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-family: var(--font-family-mono);
  font-size: 0.9em;
}

.architecture-text pre {
  background-color: var(--color-gray-100);
  color: var(--color-gray-800);
  padding: var(--space-4);
  border-radius: var(--radius-base);
  overflow-x: auto;
  margin-bottom: var(--space-4);
  font-family: var(--font-family-mono);
  border-left: 4px solid var(--color-primary);
}

.architecture-text strong {
  color: var(--color-gray-900);
  font-weight: var(--font-weight-semibold);
}

.architecture-text em {
  color: var(--color-secondary);
  font-style: italic;
}

/* Candidate Selection Modal */
.candidate-modal-container {
  max-width: 680px;
  width: 95vw;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}

.candidate-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 2px solid var(--hnz-primary-25, #bfd4e2);
  background: var(--hnz-primary-5, #f2f7f9);
}

.candidate-modal-title {
  font-family: var(--font-family-primary, sans-serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--hnz-secondary-100, #13294b);
  display: flex;
  align-items: center;
  gap: 10px;
}

.candidate-modal-title i {
  color: var(--hnz-primary-100, #00558c);
}

.candidate-modal-body {
  padding: 20px 24px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.candidate-context-card {
  background: var(--hnz-secondary-5, #f3f4f6);
  border: 1px solid var(--hnz-secondary-25, #c4c9d2);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.candidate-context-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 4px 0;
}

.candidate-context-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--hnz-secondary-50, #8994a5);
  min-width: 100px;
  flex-shrink: 0;
}

.candidate-context-value {
  font-size: 14px;
  color: var(--hnz-secondary-75, #4e5e78);
  font-weight: 500;
}

.candidate-context-current {
  display: flex;
  align-items: center;
}

.candidate-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--hnz-secondary-50, #8994a5);
}

.candidate-list-hint {
  font-size: 12px;
  font-style: italic;
}

.candidate-cards-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.candidate-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border: 1px solid var(--hnz-primary-25, #bfd4e2);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: all 0.15s ease;
}

.candidate-card:hover:not(.candidate-card-current) {
  border-color: var(--hnz-primary-100, #00558c);
  background: var(--hnz-primary-5, #f2f7f9);
  box-shadow: 0 2px 8px rgba(0, 85, 140, 0.1);
}

.candidate-card-current {
  background: var(--hnz-secondary-5, #f3f4f6);
  border-color: var(--hnz-secondary-25, #c4c9d2);
  opacity: 0.7;
  cursor: default;
}

.candidate-card-recommended {
  border-color: #ea580c;
  background: #fff7ed;
  order: -1;
}

.candidate-card-recommended:hover:not(.candidate-card-current) {
  border-color: #c2410c;
  background: #ffedd5;
}

.candidate-recommended-badge {
  font-size: 11px;
  font-weight: 600;
  background: #ea580c;
  color: #fff;
  padding: 1px 8px;
  border-radius: 10px;
  margin-left: 8px;
}

.candidate-card-body {
  flex: 1;
  min-width: 0;
}

.candidate-card-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--hnz-secondary-100, #13294b);
  margin-bottom: 4px;
}

.candidate-card-current .candidate-card-name {
  text-decoration: line-through;
  color: var(--hnz-secondary-50, #8994a5);
}

.candidate-current-badge {
  font-size: 11px;
  font-weight: 500;
  text-decoration: none;
  background: var(--hnz-secondary-25, #c4c9d2);
  color: var(--hnz-secondary-75, #4e5e78);
  padding: 1px 8px;
  border-radius: 10px;
  margin-left: 8px;
}

.candidate-card-snomed {
  font-size: 13px;
  color: var(--hnz-secondary-50, #8994a5);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.candidate-card-id {
  color: var(--hnz-secondary-25, #c4c9d2);
  font-size: 12px;
}

.candidate-card-confidence {
  display: flex;
  align-items: center;
  gap: 8px;
}

.candidate-card-conf-text {
  font-size: 13px;
  font-weight: 600;
  background: none !important;
}

.candidate-card-conf-text.confidence-high { color: #166534; background: none !important; }
.candidate-card-conf-text.confidence-medium { color: #92400e; background: none !important; }
.candidate-card-conf-text.confidence-low { color: #991b1b; background: none !important; }

.candidate-select-btn {
  flex-shrink: 0;
  margin-left: 16px;
}

.candidate-empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--hnz-secondary-50, #8994a5);
  font-size: 14px;
}

.candidate-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-top: 1px solid var(--hnz-secondary-25, #c4c9d2);
  background: var(--hnz-secondary-5, #f3f4f6);
  border-radius: 0 0 12px 12px;
  flex-shrink: 0;
}

.candidate-no-suitable-btn {
  display: flex;
  align-items: center;
  gap: 6px;
}

.help-text p {
  margin-bottom: var(--space-4);
  color: var(--color-gray-700);
}

.help-text ul, .help-text ol {
  margin-bottom: var(--space-4);
  padding-left: var(--space-6);
}

.help-text li {
  margin-bottom: var(--space-2);
  color: var(--color-gray-700);
}

.help-text code {
  background: var(--color-gray-100);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-family: var(--font-family-mono);
  font-size: var(--font-size-sm);
  color: var(--color-gray-800);
}

.help-text pre {
  background: var(--color-gray-100);
  padding: var(--space-4);
  border-radius: var(--radius-base);
  overflow-x: auto;
  margin-bottom: var(--space-4);
  font-family: var(--font-family-mono);
  font-size: var(--font-size-sm);
  color: var(--color-gray-800);
}

.help-text blockquote {
  border-left: 4px solid var(--color-primary);
  padding-left: var(--space-4);
  margin: var(--space-4) 0;
  color: var(--color-gray-600);
  font-style: italic;
}

.help-text table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-4);
}

.help-text th, .help-text td {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-gray-200);
  text-align: left;
}

.help-text th {
  background: var(--color-gray-100);
  font-weight: var(--font-weight-semibold);
  color: var(--color-gray-800);
}

/* Responsive Design */
@media (max-width: 768px) {
  .brand-bar {
    padding: 0 0.75rem;
    height: 56px;
  }

  .brand-content {
    gap: var(--space-2);
    flex: 1;
    min-width: 0;
  }

  .app-logo {
    height: 26px;
    width: auto;
    flex-shrink: 0;
  }

  .brand-text {
    min-width: 0;
    overflow: hidden;
  }

  .brand-title {
    font-size: 1rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .brand-subtitle {
    font-size: var(--font-size-xs);
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .header-divider {
    height: 20px;
    display: none;
  }
}

/* Extra small mobile screens */
@media (max-width: 480px) {
  .brand-bar {
    padding: 0 0.6rem;
    height: 52px;
  }

  .brand-content {
    gap: var(--space-1);
  }

  .app-logo {
    height: 22px;
    width: auto;
  }
  
  /* Action cards optimized for small screens */
  .action-paths {
    padding: 0 12px !important;
    gap: 12px !important;
  }
  
  .action-card {
    padding: 14px !important;
    border-radius: 8px !important;
  }
  
  .action-card .action-icon {
    font-size: 1.8em !important;
  }
  
  .action-card h3 {
    font-size: 1em !important;
  }
  
  .action-card p {
    font-size: 0.85em !important;
    margin-bottom: 10px !important;
  }
  
  .action-card .button {
    padding: 8px 12px !important;
    font-size: 0.85em !important;
  }
  
  .brand-title {
    font-size: var(--font-size-base);
    line-height: 1.2;
  }
  
  .brand-subtitle {
    font-size: var(--font-size-xs);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

/* Portrait orientation adjustments */
@media (max-width: 390px) {
  .brand-bar {
    padding: 0 0.5rem;
    height: 48px;
  }

  .brand-content {
    gap: var(--space-1);
  }

  .app-logo {
    height: 20px;
    width: auto;
  }
  
  .brand-title {
    font-size: var(--font-size-sm);
    line-height: 1.1;
  }
  
  .brand-subtitle {
    font-size: 11px;
    line-height: 1.2;
  }
  
  /* Hamburger menu adjustments for very small screens */
  .hamburger-button {
    width: 20px;
    height: 20px;
  }
  
  .hamburger-line {
    width: 20px;
  }
  
  .help-modal {
    width: 95%;
    max-height: 90vh;
  }
  
  .help-content {
    padding: var(--space-2);
  }
}

/* ==========================================================================
   3. Base Styles & Reset
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-family-body);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  color: var(--text-body);
  background: #F9FAFB;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography Reset — HNZ spec */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-family: var(--font-family-primary);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  color: var(--text-primary);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }
h5 { font-size: var(--font-size-base); }
h6 { font-size: var(--font-size-sm); }

p {
  margin: 0 0 var(--space-4) 0;
  line-height: var(--line-height-relaxed);
}

a {
  color: var(--hnz-primary-100);
  text-decoration: none;
  transition: var(--transition-base);
}

a:hover {
  color: var(--hnz-primary-110);
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   3. Layout Components
   ========================================================================== */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-8) var(--space-8);
}

/* ==========================================================================
   4. Application-Specific Layout
   ========================================================================== */

/* Header Styling */
.header {
  text-align: center;
  color: var(--color-white);
  margin-bottom: var(--space-12);
}

.header h1 {
  font-size: var(--font-size-4xl);
  margin-bottom: var(--space-4);
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
  color: var(--color-white);
}

.header p {
  font-size: var(--font-size-xl);
  opacity: 0.9;
  margin-bottom: 0;
}

/* Main Card */
.main-card {
  background: var(--color-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: var(--space-8);
  margin-top: var(--space-8);
  margin-bottom: var(--space-8);
}

/* ==========================================================================
   5. Card Components
   ========================================================================== */

/* HNZ Standard Card */
.card {
  background-color: var(--color-white);
  border: 1px solid #E0E6ED;
  border-radius: 10px;
  overflow: hidden;
  transition: var(--transition-base);
}

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

.card-header {
  padding: 0.7em 1em;
  border-bottom: 1px solid #E0E4E8;
  background-color: #F3F5F7;
  font-family: var(--font-family-primary);
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-base);
  color: var(--hnz-secondary-100);
}

.card-body {
  padding: 1em;
}

.card-footer {
  padding: 1em;
  border-top: 1px solid #E0E4E8;
  background-color: #F3F5F7;
}

/* ==========================================================================
   6. Button Components
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-family-primary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-base);
  padding: 0.6em 1.5em;
  min-width: 140px;
}

.btn:disabled,
.btn.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* Loading disabled state for buttons and action cards */
.loading-disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  position: relative;
}

.loading-disabled::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: inherit;
  backdrop-filter: blur(1px);
  z-index: 1;
}

.action-card.loading-disabled {
  background-color: var(--color-gray-50) !important;
  border-color: var(--color-gray-200) !important;
  box-shadow: none !important;
}

.action-card.loading-disabled .card-title {
  color: var(--color-gray-400) !important;
}

.action-card.loading-disabled .card-description {
  color: var(--color-gray-400) !important;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring-primary);
}

/* Button Variants — HNZ Design System */
.btn-primary {
  color: var(--color-white);
  background-color: var(--hnz-secondary-100);
  border-color: var(--hnz-secondary-100);
}

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

.btn-secondary {
  color: #4B5563;
  background-color: #F3F4F6;
  border-color: #D1D5DB;
}

.btn-secondary:hover:not(:disabled) {
  background-color: #E5E7EB;
  border-color: #D1D5DB;
  color: #4B5563;
}

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

.btn-success:hover:not(:disabled) {
  background-color: #15803d;
  border-color: #15803d;
  color: var(--color-white);
}

/* Legacy button classes — HNZ Design System */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-family-primary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-base);
  padding: 0.6em 1.5em;
  color: var(--color-white);
  background-color: var(--hnz-secondary-100);
  border-color: var(--hnz-secondary-100);
}

.button:hover:not(:disabled) {
  background-color: #0f2533;
  border-color: #0f2533;
}

.button:disabled,
.button.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}

.button.primary {
  background-color: var(--hnz-secondary-100);
  border-color: var(--hnz-secondary-100);
}

.button.primary:hover:not(:disabled) {
  background-color: #0f2533;
  border-color: #0f2533;
}

.button.secondary {
  color: #4B5563;
  background-color: #F3F4F6;
  border-color: #D1D5DB;
}

.button.secondary:hover:not(:disabled) {
  background-color: #E5E7EB;
  border-color: #D1D5DB;
}

.button.success {
  color: var(--color-white);
  background-color: #166534;
  border-color: #166534;
}

.button.success:hover:not(:disabled) {
  background-color: #15803d;
  border-color: #15803d;
}

/* Button variant styles for mapping actions — HNZ semantic colors */
.button-success {
  color: var(--color-white);
  background-color: #166534;
  border-color: #166534;
}

.button-success:hover:not(:disabled) {
  background-color: #15803d;
  border-color: #15803d;
}

.button-danger {
  color: var(--color-white);
  background-color: #DC2626;
  border-color: #DC2626;
}

.button-danger:hover:not(:disabled) {
  background-color: #B91C1C;
  border-color: #B91C1C;
}

.button-warning {
  color: var(--color-white);
  background-color: #D97706;
  border-color: #D97706;
}

.button-warning:hover:not(:disabled) {
  background-color: #B45309;
  border-color: #B45309;
}

.button-secondary {
  color: #4B5563;
  background-color: #F3F4F6;
  border-color: #D1D5DB;
}

.button-secondary:hover:not(:disabled) {
  background-color: #E5E7EB;
  border-color: #D1D5DB;
}

/* New Upload / Start Over Button */
.button.new-upload {
  background: #DC2626;
  border-color: #DC2626;
  color: white;
  font-weight: 600;
}

.button.new-upload:hover:not(:disabled) {
  background: #B91C1C;
  border-color: #B91C1C;
}

.button.new-upload:active {
  background: #991b1b;
  border-color: #991b1b;
}

/* Pagination and Table Controls */
.table-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
  padding: var(--space-3);
  background: var(--color-gray-50);
  border-radius: var(--radius-base);
  border: 1px solid var(--color-gray-200);
}

.table-info {
  font-size: var(--font-size-sm);
  color: var(--color-gray-600);
  font-weight: 500;
}

.pagination-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  margin-top: var(--space-4);
  background: var(--color-gray-50);
  border-radius: var(--radius-base);
  border: 1px solid var(--color-gray-200);
}

.page-info {
  font-size: var(--font-size-sm);
  color: var(--color-gray-700);
  font-weight: 500;
  min-width: 120px;
  text-align: center;
}

.page-size-selector {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-sm);
  background: white;
  font-size: var(--font-size-sm);
  color: var(--color-gray-700);
}

.page-size-selector:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: -1px;
  border-color: var(--color-primary);
}

/* ==========================================================================
   7. Form Components
   ========================================================================== */

/* HNZ Form Controls */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  font-family: var(--font-family-primary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.form-control {
  display: block;
  width: 100%;
  padding: 1rem 1.25rem;
  font-family: var(--font-family-body);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  color: var(--text-body);
  background-color: #f8fafc;
  border: 1.5px solid #d4dbe4;
  border-radius: 10px;
  transition: var(--transition-base);
  appearance: none;
}

.form-control::placeholder {
  color: #9ca3af;
  font-style: italic;
  opacity: 0.7;
}

.form-control:focus {
  outline: none;
  border-color: #007A86;
  box-shadow: 0 0 0 4px rgba(0, 122, 134, 0.1);
}

.form-control:disabled {
  background-color: var(--hnz-secondary-5);
  border-color: var(--hnz-secondary-25);
  color: var(--text-disabled);
  cursor: not-allowed;
}

/* ==========================================================================
   8. Upload Section
   ========================================================================== */

.upload-section {
  text-align: center;
  padding: var(--space-12);
  border: 2px dashed var(--color-gray-300);
  border-radius: var(--radius-base);
  transition: var(--transition-base);
  cursor: pointer;
}

.upload-section:hover,
.upload-section.dragover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.upload-icon {
  font-size: var(--font-size-4xl);
  margin-bottom: var(--space-4);
  color: var(--color-primary);
}

/* ==========================================================================
   9. Statistics Grid
   ========================================================================== */

.stats-grid {
  display: grid;
  /* smaller minimum width so more cards fit per row */
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  /* tighter gap for denser layout */
  gap: var(--space-4);
  margin: var(--space-8) 0;
}

.stat-card {
  background: var(--color-gray-50);
  /* reduce internal padding */
  padding: var(--space-4);
  border-radius: var(--radius-base);
  text-align: center;
  border: 1px solid var(--color-gray-200);
  transition: var(--transition-base);
}

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

.stat-value {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--hnz-primary-100);
  margin-bottom: var(--space-2);
  font-family: var(--font-family-primary);
}

.stat-label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--font-family-primary);
  font-weight: var(--font-weight-bold);
}

/* ==========================================================================
   9a. Mapping Summary Card
   ========================================================================== */

.mapping-summary-card {
  background: var(--color-white);
  border: 1px solid var(--color-gray-200);
  border-radius: 10px;
  margin: var(--space-6) 0;
  overflow: hidden;
}

.summary-stats-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  gap: var(--space-4);
  border-bottom: 1px solid var(--color-gray-200);
}

.summary-stat {
  flex: 1;
  text-align: center;
  min-width: 0;
}

.summary-stat-value {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--hnz-primary-100);
  font-family: var(--font-family-primary);
  line-height: var(--line-height-tight);
  margin-bottom: var(--space-1);
}

.summary-stat-label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--font-family-primary);
  font-weight: var(--font-weight-bold);
}

/* Pipeline breakdown section */
.summary-pipeline-section {
  padding: var(--space-3) var(--space-6) var(--space-4);
  background: var(--hnz-accent-5);
}

.summary-section-label {
  font-family: var(--font-family-primary);
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-3);
}

.summary-pipeline-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.pipeline-stat {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.pipeline-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: var(--font-size-sm);
  flex-shrink: 0;
}

.pipeline-icon-approved {
  background: var(--hnz-accent-25);
  color: var(--hnz-accent-110);
}

.pipeline-icon-reranker {
  background: var(--color-info-light);
  color: var(--hnz-primary-100);
}

.pipeline-icon-secondary {
  background: #f3e5f5;
  color: #7b1fa2;
}

.pipeline-icon-processed {
  background: var(--color-gray-100);
  color: var(--color-gray-600);
}

.pipeline-icon-improved {
  background: var(--color-success-light);
  color: var(--color-success);
}

.pipeline-icon-flagged {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.pipeline-icon-review {
  background: var(--hnz-primary-5);
  color: var(--hnz-primary-100);
}

.pipeline-stat-detail {
  display: flex;
  flex-direction: column;
  line-height: var(--line-height-tight);
}

.pipeline-stat-value {
  font-family: var(--font-family-primary);
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-base);
  color: var(--text-secondary);
}

.pipeline-stat-label {
  font-family: var(--font-family-body);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.pipeline-divider {
  width: 1px;
  height: 28px;
  background: var(--color-gray-300);
  flex-shrink: 0;
}

/* AI-Approved Banner */
.ai-approved-banner {
  background: var(--hnz-accent-5);
  border: 1px solid var(--hnz-accent-25);
  border-radius: 10px;
  padding: var(--space-3) var(--space-5);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: var(--line-height-normal);
  font-family: var(--font-family-body);
}

.ai-approved-banner i {
  color: var(--hnz-accent-110);
  font-size: var(--font-size-lg);
  flex-shrink: 0;
}

/* AI badge colour variants (replaces inline gradients) */
.secondary-pipeline-tag.ai-approved-reranker {
  background: var(--hnz-primary-100);
}

.secondary-pipeline-tag.ai-improved-secondary {
  background: var(--hnz-accent-110);
}

/* Sort select */
.table-sort-select {
  padding: 0.5rem 1rem;
  border: 1.5px solid var(--color-gray-300);
  border-radius: 6px;
  font-family: var(--font-family-body);
  font-size: var(--font-size-sm);
  color: var(--text-body);
  background: var(--color-white);
}

.table-sort-select:focus {
  border-color: var(--hnz-accent-110);
  box-shadow: 0 0 0 4px rgba(0, 122, 134, 0.1);
  outline: none;
}

/* Responsive: pipeline section */
@media (max-width: 768px) {
  .summary-stats-row {
    flex-wrap: wrap;
    padding: var(--space-3) var(--space-4);
  }

  .summary-stat {
    flex: 0 0 calc(50% - var(--space-2));
    margin-bottom: var(--space-2);
  }

  .summary-pipeline-row {
    gap: var(--space-3);
  }

  .pipeline-divider {
    display: none;
  }

  .summary-pipeline-section {
    padding: var(--space-3) var(--space-4);
  }
}

/* ==========================================================================
   9.5. Source Legend
   ========================================================================== */

.source-legend {
  margin: var(--space-2) 0;
  padding: var(--space-3);
  background: var(--color-gray-50);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-base);
}

.source-legend-grid {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--space-4);
  align-items: center;
  overflow-x: auto;
  padding-bottom: var(--space-2);
  scrollbar-width: thin;
}

.source-legend-grid::-webkit-scrollbar {
  height: 4px;
}

.source-legend-grid::-webkit-scrollbar-thumb {
  background: var(--color-gray-300);
  border-radius: var(--radius-sm);
}

.source-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-gray-700);
  white-space: nowrap;
  flex-shrink: 0;
}

.source-legend-color {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   10. Results Section & Tables
   ========================================================================== */

.results-section {
  margin-top: var(--space-8);
  display: none;
}

/* HNZ Data Table */
.results-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-4);
  font-size: var(--font-size-sm);
  font-family: var(--font-family-body);
}

.results-table th {
  background: #F9FAFB;
  color: var(--text-secondary);
  padding: 0.75rem 1rem;
  text-align: left;
  position: sticky;
  top: 0;
  font-weight: var(--font-weight-semibold);
  font-family: var(--font-family-body);
  z-index: var(--z-sticky);
  border-bottom: 1px solid #E5EAF0;
}

.results-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #E5EAF0;
}

.results-table tr:hover {
  background: #F8FAFC;
}

.table-container {
  max-height: 600px;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
}

/* Mobile card-based table layout */
.results-table-mobile {
  display: none; /* Hidden by default, shown on mobile */
}

.result-card {
  background: var(--color-white);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-base);
  margin-bottom: var(--space-3);
  padding: var(--space-4);
  box-shadow: var(--shadow-base);
}

.result-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-3);
  gap: var(--space-2);
}

.result-card-title {
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-base);
  color: var(--color-primary);
  flex-grow: 1;
}

/* Updated 2025-01-27: Mobile confidence badges */
.result-card-confidence {
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  min-width: 48px;
  text-align: center;
}

.result-card-confidence.confidence-high {
  background: var(--color-success) !important;
  color: var(--color-white) !important;
}

.result-card-confidence.confidence-medium {
  background: var(--color-warning) !important;
  color: var(--color-white) !important;
}

.result-card-confidence.confidence-low {
  background: var(--color-danger) !important;
  color: var(--color-white) !important;
}

.result-card-body {
  display: grid;
  gap: var(--space-2);
}

.result-card-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--color-gray-100);
  gap: var(--space-2);
}

.result-card-row:last-child {
  border-bottom: none;
}

.result-card-label {
  font-size: var(--font-size-sm);
  color: var(--color-gray-600);
  font-weight: var(--font-weight-medium);
  flex-shrink: 0;
  min-width: 80px;
}

.result-card-value {
  font-size: var(--font-size-sm);
  color: var(--color-gray-800);
  text-align: right;
  word-break: break-word;
}

/* Add extra padding under the mapping title */
#fullView h3 {
  margin-bottom: var(--space-6);
}

/* ==========================================================================
   11. Tags & Badges
   ========================================================================== */

.tag {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  background: var(--color-info-light);
  color: var(--color-info);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  margin: var(--space-1);
  font-weight: var(--font-weight-medium);
}

.tag.anatomy {
  background: var(--color-success-light);
  color: var(--color-success);
}

.tag.laterality {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.tag.contrast {
  background: #e0f2fe;
  color: #1565c0;
}

.tag.technique {
  background: #f3e5f5;
  color: #7b1fa2;
}

.tag.gender {
  background: #e1f5fe;
  color: #0277bd;
}

.tag.age {
  background: #fce4ec;
  color: #c2185b;
}

.tag.clinical {
  background: #fff8e1;
  color: #ff8f00;
}

.tag.equivalent {
  background: #f1f8e9;
  color: #689f38;
}

/* Secondary Pipeline Tag (alias) */
.secondary-pipeline-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 3px 8px;
  background: var(--hnz-accent-110);
  color: white;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  vertical-align: middle;
}

/* ==========================================================================
   12. Confidence Bars
   ========================================================================== */

.confidence-bar {
  display: inline-block;
  width: 50px;
  height: 10px;
  background: var(--color-gray-200);
  border-radius: var(--radius-sm);
  position: relative;
}

.confidence-fill {
  height: 100%;
  background: var(--color-success);
  border-radius: var(--radius-sm);
}

.confidence-low {
  background: var(--color-danger) !important;
}

.confidence-medium {
  background: var(--color-warning) !important;
}

.confidence-high {
  background: var(--color-success) !important;
}

/* ==========================================================================
   13. [DEPRECATED] Consolidated Results - styles left for compatibility
   Note: Consolidated Results view removed in issue #137 but styles kept
   to avoid breaking other components. These can be safely removed in future.
   ========================================================================== */

.consolidated-group {
  background: var(--color-white);
  border-radius: var(--radius-base);
  box-shadow: var(--shadow-base);
  margin-bottom: var(--space-4);
  border: none;
  transition: box-shadow var(--transition-fast);
}

.consolidated-group:hover {
  box-shadow: var(--shadow-md);
}

.consolidated-header {
  background: var(--color-gray-5);
  color: var(--color-gray-800);
  padding: var(--space-3) var(--space-4);
  display: block;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
  position: relative;
}

/* Quick Validation Buttons for Results Table */
.quick-validation-cell {
  display: flex;
  gap: 6px;
  align-items: center;
}

.validation-status {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 4px;
}

.status-approved {
  background-color: #dcfce7;
  color: #166534;
  border: 1px solid #BBF7D0;
}

.status-rejected {
  background-color: #fecaca;
  color: #991b1b;
  border: 1px solid #FECACA;
}

.quick-validation-cell .button {
  padding: 4px 8px;
  font-size: 12px;
  min-width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.quick-validation-cell .button-success {
  background: #166534;
  border-color: #166534;
  color: white;
}

.quick-validation-cell .button-success:hover {
  background: #15803d;
  border-color: #15803d;
}

.quick-validation-cell .button-danger {
  background: #DC2626;
  border-color: #DC2626;
  color: white;
}

.quick-validation-cell .button-danger:hover {
  background: #B91C1C;
  border-color: #B91C1C;
}

.quick-validation-cell .button-warning {
  background: #D97706;
  border-color: #D97706;
  color: white;
}

.quick-validation-cell .button-warning:hover {
  background: #B45309;
  border-color: #B45309;
}

/* Flag button styles */
.quick-validation-cell .button-info {
  background: var(--hnz-primary-100);
  border-color: var(--hnz-primary-100);
  color: white;
  font-size: 0.85em;
}

.quick-validation-cell .button-info:hover {
  background: var(--hnz-primary-110);
  border-color: var(--hnz-primary-110);
}

/* Secondary Pipeline Tag — HNZ accent teal */
.secondary-pipeline-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--hnz-accent-110);
  color: white;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  margin-left: 8px;
  vertical-align: middle;
}

.secondary-pipeline-tag i {
  font-size: 0.9em;
}

/* Review reason hint — explains why an item needs human review */
.review-reason-hint {
  display: block;
  margin-top: 4px;
  font-size: 0.7rem;
  color: var(--hnz-neutral-500, #64748B);
  line-height: 1.3;
}

.review-reason-hint i {
  margin-right: 3px;
  color: var(--hnz-neutral-400, #94A3B8);
}

.review-reason-hint-mobile {
  background: #F1F5F9;
  padding: 4px 8px;
  border-radius: 4px;
  border-left: 2px solid var(--hnz-neutral-400, #94A3B8);
  margin-top: 5px;
  font-size: 0.8rem;
  color: var(--hnz-neutral-600, #475569);
}

/* Flag indicator styles */
.flag-indicator {
  display: inline-block;
  margin-left: 5px;
}

.flag-indicator i {
  color: #D97706;
  animation: flag-pulse 2s infinite;
}

@keyframes flag-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Flagged row highlighting */
.results-table tr.flagged-row {
  box-shadow: inset 4px 0 0 #D97706 !important;
}

/* Quick validation row highlighting — HNZ semantic */
.results-table tr.validated-approved {
  background-color: #dcfce7 !important;
  border-left: 3px solid #166534 !important;
}

.results-table tr.validated-rejected {
  background-color: #fecaca !important;
  border-left: 3px solid #DC2626 !important;
}

/* Responsive handling for mobile */
@media (max-width: 768px) {
  .quick-validation-cell {
    flex-direction: column;
    gap: 4px;
    min-width: 100px;
  }
  
  .validation-status {
    font-size: 10px;
    padding: 1px 4px;
  }
  
  .quick-validation-cell .button {
    padding: 3px 6px;
    font-size: 10px;
    min-width: 24px;
    height: 24px;
  }
}

/* ==========================================================================
   Candidate Selection Modal Styles (Added 2025-01-27)
   ========================================================================== */

.candidate-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-gray-200);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.candidate-option:hover {
  background-color: var(--color-gray-50);
}

.candidate-option:last-child {
  border-bottom: none;
}

.candidate-option.rejected {
  background-color: var(--color-danger-light);
  opacity: 0.7;
}

.candidate-option.rejected .candidate-name {
  text-decoration: line-through;
  color: var(--color-danger);
}

.candidate-details {
  flex: 1;
}

.candidate-name {
  font-weight: var(--font-weight-medium);
  color: var(--color-gray-900);
  font-size: var(--font-size-base);
}

.candidate-meta {
  font-size: var(--font-size-sm);
  color: var(--color-gray-600);
  margin-top: 2px;
}

.candidate-actions {
  text-align: right;
  margin-left: var(--space-4);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
}

.current-mapping-info {
  background: var(--color-gray-50);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  border: 1px solid var(--color-gray-200);
}

.current-mapping-info div {
  margin-bottom: var(--space-2);
}

.current-mapping-info div:last-child {
  margin-bottom: 0;
}

#candidateList {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-md);
}

/* Utility Classes */
.hidden {
  display: none !important;
}


/* Modal Base Styles — HNZ overlay */
.modal {
  display: none;
  position: fixed;
  z-index: var(--z-modal);
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(75, 85, 99, 0.6);
  justify-content: center;
  align-items: center;
}


/* Toggle Button Active States */
.model-toggle.active,
.reranker-toggle.active {
  background-color: var(--color-primary) !important;
  color: var(--color-white) !important;
  border-color: var(--color-primary) !important;
}


/* ================================================================
   Flagged Review — Instructions Banner & Inline Legend
   ================================================================ */

.flagged-review-banner {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px solid #f59e0b;
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 16px;
  font-family: var(--font-family-primary, 'Poppins', sans-serif);
}

.flagged-review-banner-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.flagged-review-banner-header i {
  font-size: 20px;
  color: #d97706;
}

.flagged-review-banner-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #92400e;
}

.flagged-review-banner-dismiss {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: #b45309;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.flagged-review-banner-dismiss:hover {
  opacity: 1;
}

.flagged-review-banner-body {
  font-size: 13px;
  line-height: 1.65;
  color: #78350f;
}

.flagged-review-banner-body p {
  margin: 0 0 8px;
}

.flagged-review-banner-body p:last-child {
  margin-bottom: 0;
}

.flagged-review-banner-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.flagged-review-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(255,255,255,0.7);
  border-radius: 8px;
  padding: 10px 12px;
}

.flagged-review-step-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #d97706;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.flagged-review-step-text {
  font-size: 12.5px;
  color: #78350f;
  line-height: 1.5;
}

.flagged-review-step-text strong {
  color: #92400e;
}

/* Inline Action Legend Strip */
.flagged-action-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: center;
  padding: 10px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 12px;
  font-family: var(--font-family-primary, 'Poppins', sans-serif);
  font-size: 12px;
  color: #475569;
}

.flagged-action-legend-title {
  font-weight: 600;
  color: #334155;
  font-size: 12px;
  margin-right: 4px;
}

.flagged-action-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.flagged-action-legend-icon {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
}

.flagged-action-legend-sep {
  width: 1px;
  height: 16px;
  background: #cbd5e1;
  flex-shrink: 0;
}


/* ================================================================
   Flagged Review — Category Section Headers
   ================================================================ */

.flag-category-header {
  background: none;
  border: none;
}

.flag-category-header td {
  padding: 18px 12px 8px !important;
  border-bottom: none !important;
}

.flag-category-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  border-left: 4px solid;
}

.flag-category-bar-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.flag-category-bar-label {
  font-weight: 700;
  font-size: 13.5px;
  color: #1e293b;
}

.flag-category-bar-desc {
  font-size: 12px;
  color: #64748b;
  font-weight: 400;
  margin-left: 4px;
}

.flag-category-bar-count {
  margin-left: auto;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}


/* ================================================================
   Flagged Review — Improved Explanation Rows
   ================================================================ */

.flagged-explanation-row td {
  padding: 0 !important;
  border-bottom: 1px solid #e5e7eb !important;
}

.flagged-explanation-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 16px 12px 28px;
  font-size: 13px;
  line-height: 1.6;
}

.flagged-explanation-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  margin-top: 1px;
  letter-spacing: 0.01em;
}

.flagged-explanation-text {
  color: #374151;
  flex: 1;
  min-width: 0;
}

.flagged-explanation-text em {
  font-style: normal;
  color: #6b7280;
}


/* ================================================================
   Flagged Review — Action Buttons with Labels
   ================================================================ */

.flagged-actions-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.flagged-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.12s, transform 0.1s;
  font-family: var(--font-family-primary, 'Poppins', sans-serif);
}

.flagged-action-btn:hover {
  filter: brightness(0.92);
  transform: translateY(-1px);
}

.flagged-action-btn:active {
  transform: translateY(0);
}

.flagged-action-btn i {
  font-size: 11px;
}

.flagged-action-btn-approve {
  background: #dcfce7;
  color: #166534;
}

.flagged-action-btn-flag {
  background: #fef3c7;
  color: #92400e;
}

.flagged-action-btn-nomapping {
  background: #f1f5f9;
  color: #475569;
}

.flagged-action-btn-undo {
  background: #f1f5f9;
  color: #64748b;
}

.flagged-action-btn-undo:hover {
  background: #e2e8f0;
}

/* Completed states */
.flagged-actions-done {
  display: flex;
  align-items: center;
  gap: 8px;
}

.flagged-actions-done-label {
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
}

@media (max-width: 900px) {
  .flagged-review-banner-steps {
    grid-template-columns: 1fr;
  }
  .flagged-action-legend {
    font-size: 11px;
    padding: 8px 12px;
  }
  .flagged-action-btn {
    padding: 4px 7px;
    font-size: 11px;
  }
}

/* ─── Corroboration Panel ─────────────────────────────────────────────────── */

.corroboration-panel {
  margin-top: 10px;
  min-height: 24px;
}

.corroboration-loading {
  font-size: 11px;
  color: var(--color-gray-400, #9ca3af);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}

.corroboration-empty {
  font-size: 11px;
  color: var(--color-gray-400, #9ca3af);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-top: 1px dashed var(--color-gray-200, #e5e7eb);
  margin-top: 6px;
  font-style: italic;
}

.corroboration-panel-inner {
  border-top: 1px solid var(--color-gray-200, #e5e7eb);
  margin-top: 8px;
  padding-top: 8px;
}

/* Strength tints */
.corroboration-strong  { --corr-accent: #059669; --corr-bg: #f0fdf4; --corr-border: #bbf7d0; }
.corroboration-moderate { --corr-accent: #2563eb; --corr-bg: #eff6ff; --corr-border: #bfdbfe; }
.corroboration-weak    { --corr-accent: #d97706; --corr-bg: #fffbeb; --corr-border: #fde68a; }

.corroboration-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.corroboration-strength-icon {
  font-size: 11px;
  color: var(--corr-accent);
}

.corroboration-strength-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--corr-accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.corroboration-counts {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.corroboration-count {
  font-size: 10.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 10px;
}

.corroboration-count--validated {
  background: #dcfce7;
  color: #166534;
}

.corroboration-count--approved {
  background: #dbeafe;
  color: #1e40af;
}

.corroboration-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.corroboration-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px 3px 7px;
  border-radius: 6px;
  border: 1px solid var(--corr-border);
  background: var(--corr-bg);
  font-size: 11px;
  line-height: 1.3;
  max-width: 260px;
}

.corroboration-pill--validated {
  --corr-border: #bbf7d0;
  --corr-bg: #f0fdf4;
}

.corroboration-pill--approved {
  --corr-border: #bfdbfe;
  --corr-bg: #eff6ff;
}

.pill-source {
  font-weight: 600;
  color: var(--color-gray-700, #374151);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}

.pill-code {
  color: var(--color-gray-500, #6b7280);
  font-family: 'Courier New', monospace;
  font-size: 10.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90px;
}

.pill-validated-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #059669;
  flex-shrink: 0;
}

/* ── Approval Tier Badges ───────────────────────────────────────── */
.approval-tier {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  border: 1px solid transparent;
}

.approval-tier img {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

/* Human — green: authoritative, reviewed by a person */
.approval-tier--human {
  background: #f0fdf4;
  color: #166534;
  border-color: #bbf7d0;
}

.approval-tier--human i {
  color: #16a34a;
}

/* LLM — blue: Scout secondary pipeline (Claude + GPT + Gemini ensemble) */
.approval-tier--llm {
  background: #eff6ff;
  color: #1e40af;
  border-color: #bfdbfe;
}

/* Reranker — amber: fast auto-approval at ≥95% confidence, no LLM review */
.approval-tier--reranker {
  background: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
}

.approval-tier--reranker i {
  color: #d97706;
}

/* Unknown fallback */
.approval-tier--unknown {
  background: #f9fafb;
  color: #6b7280;
  border-color: #e5e7eb;
}
