/* ============================================
   Pipeline Case Page Styles
   ============================================ */

/* Pipeline Page Layout */
.pipeline-page {
  min-height: 100vh;
  background: #0f0f0f;
  color: #e0e0e0;
  padding-bottom: 60px;
}

/* Header */
.pipeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: #1a1a1a;
  border-bottom: 1px solid #333;
}

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

.back-btn {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 4px;
  transition: all 0.2s;
}

.back-btn:hover {
  background: #333;
  color: #fff;
}

.case-title {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  font-family: monospace;
}

/* Status Badges */
.status-badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
}

.status-badge.status-created { background: #333; color: #888; }
.status-badge.status-pending { background: #333; color: #888; }
.status-badge.status-processing { background: #2d4a77; color: #6bb5ff; }
.status-badge.status-complete { background: #1e4620; color: #4caf50; }
.status-badge.status-landmarks_detected { background: #2d4a77; color: #6bb5ff; }
.status-badge.status-landmarks_approved { background: #3d5a27; color: #8bc34a; }
.status-badge.status-analysis_complete { background: #3d5a27; color: #8bc34a; }
.status-badge.status-brace_generated { background: #1e4620; color: #4caf50; }

/* Pipeline Steps Indicator */
.pipeline-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #1a1a1a;
  border-bottom: 1px solid #333;
}

.pipeline-step {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.pipeline-step-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.3s;
}

.pipeline-step--pending .pipeline-step-number {
  background: #333;
  color: #666;
}

.pipeline-step--active .pipeline-step-number {
  background: #2196f3;
  color: #fff;
  box-shadow: 0 0 12px rgba(33, 150, 243, 0.4);
}

.pipeline-step--complete .pipeline-step-number {
  background: #4caf50;
  color: #fff;
}

.pipeline-step-label {
  font-size: 13px;
  color: #888;
}

.pipeline-step--active .pipeline-step-label {
  color: #2196f3;
  font-weight: 500;
}

.pipeline-step--complete .pipeline-step-label {
  color: #4caf50;
}

.pipeline-step-connector {
  width: 60px;
  height: 2px;
  background: #333;
  margin: 0 12px;
}

.pipeline-step--complete + .pipeline-step .pipeline-step-connector,
.pipeline-step--complete .pipeline-step-connector {
  background: #4caf50;
}

/* Error Banner */
.error-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: #5c2323;
  border-bottom: 1px solid #7a2a2a;
  color: #ff8a8a;
}

.error-banner button {
  background: none;
  border: none;
  color: #ff8a8a;
  cursor: pointer;
  font-size: 18px;
}

/* Upload Section */
.upload-section {
  padding: 60px 24px;
  display: flex;
  justify-content: center;
}

.upload-box {
  background: #1a1a1a;
  border: 2px dashed #444;
  border-radius: 12px;
  padding: 48px;
  text-align: center;
  max-width: 500px;
}

.upload-box h2 {
  margin-bottom: 12px;
  color: #fff;
}

.upload-box p {
  color: #888;
  margin-bottom: 24px;
}

.upload-box input[type="file"] {
  padding: 12px;
  background: #333;
  border-radius: 8px;
  color: #fff;
}

/* Pipeline Stages Container */
.pipeline-stages {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Generic Stage Styles */
.pipeline-stage {
  background: #1a1a1a;
  border-radius: 12px;
  border: 1px solid #333;
  overflow: hidden;
}

.stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #222;
  border-bottom: 1px solid #333;
}

.stage-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

.stage-content {
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
}

.stage-empty, .stage-loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px;
  color: #888;
}

.stage-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
  background: #222;
  border-top: 1px solid #333;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn.primary {
  background: #2196f3;
  color: #fff;
}

.btn.primary:hover {
  background: #1976d2;
}

.btn.primary:disabled {
  background: #333;
  color: #666;
  cursor: not-allowed;
}

.btn.secondary {
  background: #333;
  color: #e0e0e0;
}

.btn.secondary:hover {
  background: #444;
}

.btn-large {
  padding: 14px 32px;
  font-size: 16px;
}

/* Spinner */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #333;
  border-top-color: #2196f3;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

.spinner.large {
  width: 48px;
  height: 48px;
}

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

/* ============================================
   Stage 1: Landmark Detection
   ============================================ */

.landmark-stage .stage-content {
  grid-template-columns: 1fr 280px;
}

.landmark-main {
  position: relative;
}

.landmark-empty,
.landmark-loading,
.landmark-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  background: #111;
  border-radius: 8px;
}

.landmark-error {
  color: #f44336;
  gap: 16px;
}

.landmark-error p {
  margin: 0;
  text-align: center;
}

.landmark-canvas-container {
  position: relative;
}

.landmark-canvas,
.landmark-visualization {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.landmark-canvas {
  cursor: crosshair;
}

.edit-instructions {
  padding: 12px;
  background: #222;
  border-radius: 8px;
  margin-top: 12px;
  font-size: 13px;
  color: #888;
}

.edit-legend {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}

.legend-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-detected::before { background: #ff0000; }
.legend-manual::before { background: #00ff00; }
.legend-undetected::before { background: #ffff00; }

/* Landmark Sidebar */
.landmark-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.vertebrae-summary,
.undetected-panel,
.initial-analysis {
  background: #222;
  border-radius: 8px;
  padding: 16px;
}

.vertebrae-summary h3,
.undetected-panel h3,
.initial-analysis h3 {
  font-size: 14px;
  color: #fff;
  margin-bottom: 12px;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 24px;
  font-weight: 600;
  color: #2196f3;
}

.stat-label {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
}

.panel-hint {
  font-size: 12px;
  color: #666;
  margin-bottom: 12px;
}

.vertebrae-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.vertebra-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: #1a1a1a;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.vertebra-item:hover {
  background: #333;
}

.vertebra-item.selected {
  background: #2d4a77;
}

.vertebra-level {
  font-weight: 500;
  color: #fff;
}

.vertebra-status {
  font-size: 12px;
  color: #888;
}

/* All vertebrae panel */
.all-vertebrae-panel {
  background: #222;
  border-radius: 8px;
  padding: 16px;
}

.all-vertebrae-panel h3 {
  font-size: 14px;
  color: #fff;
  margin-bottom: 12px;
}

.vertebrae-scroll-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 250px;
  overflow-y: auto;
}

.vertebra-item-compact {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: #1a1a1a;
  border-radius: 4px;
  font-size: 13px;
}

.vertebra-item-compact.manual {
  border-left: 2px solid #00ff00;
}

.vertebra-item-compact.missing {
  opacity: 0.5;
}

.tag {
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
}

.tag-detected {
  background: #1e4620;
  color: #4caf50;
}

.tag-manual {
  background: #0a3a0a;
  color: #00ff00;
}

.tag-placed {
  background: #5c4020;
  color: #ff9800;
}

.tag-missing {
  background: #333;
  color: #888;
}

.manual-summary {
  margin-top: 12px;
  padding: 8px 12px;
  background: #0a3a0a;
  border-radius: 6px;
  color: #00ff00;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.manual-edits-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: #0a3a0a;
  color: #00ff00;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.landmark-canvas-container {
  position: relative;
}

.xray-preview {
  max-width: 100%;
  max-height: 300px;
  margin-bottom: 16px;
  border-radius: 8px;
}

.loading-hint {
  font-size: 12px;
  color: #666;
  margin-top: 8px;
}

/* Initial Analysis Preview */
.cobb-preview {
  margin-bottom: 12px;
}

.cobb-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
}

.cobb-row span:first-child {
  color: #888;
}

.cobb-row span:last-child {
  color: #fff;
  font-weight: 500;
}

.rigo-preview {
  display: flex;
  gap: 8px;
}

.rigo-badge,
.curve-badge {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.rigo-badge {
  background: #2d4a77;
  color: #6bb5ff;
}

.curve-badge {
  background: #3d5a27;
  color: #8bc34a;
}

/* ============================================
   Interactive Landmark Stage (Always editable)
   ============================================ */

.landmark-interactive {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 16px;
  padding: 16px;
}

.landmark-canvas-area {
  background: #111;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 500px;
  padding: 16px;
}

.landmark-canvas-interactive {
  max-width: 100%;
  max-height: calc(100vh - 300px);
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.canvas-hint {
  margin-top: 12px;
  padding: 8px 16px;
  background: #1a1a1a;
  border-radius: 6px;
  font-size: 12px;
  color: #888;
}

.canvas-hint strong {
  color: #2196f3;
}

/* Vertebrae Panel (inline) */
.vertebrae-panel-inline {
  background: #1a1a1a;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: calc(100vh - 250px);
}

.panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid #333;
}

.panel-header h3 {
  font-size: 14px;
  color: #fff;
  margin: 0 0 8px 0;
}

.panel-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-pill {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.stat-pill.detected {
  background: #1e4620;
  color: #4caf50;
}

.stat-pill.manual {
  background: #0a3a0a;
  color: #00ff00;
}

.vertebrae-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.vert-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 3px;
}

.vert-row:hover {
  background: #2a2a2a;
}

.vert-row.selected {
  background: #2d4a77;
  box-shadow: inset 0 0 0 1px #2196f3;
}

.vert-row.manual {
  border-left: 2px solid #00ff00;
}

.vert-row.missing {
  opacity: 0.5;
}

.vert-level {
  font-weight: 600;
  font-size: 13px;
  color: #fff;
  width: 28px;
}

.vert-info {
  flex: 1;
  font-size: 11px;
}

.info-conf {
  color: #4caf50;
}

.info-manual {
  color: #00ff00;
  font-weight: 500;
}

.info-placed {
  color: #ff9800;
}

.info-missing {
  color: #666;
  font-style: italic;
}

.has-corners {
  color: #22aa22;
  margin-left: 4px;
  font-size: 10px;
}

.vert-reset {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.15s;
}

.vert-row:hover .vert-reset {
  opacity: 1;
}

.vert-reset:hover {
  background: #333;
  color: #fff;
}

.panel-legend {
  padding: 10px 16px;
  border-top: 1px solid #333;
  display: flex;
  gap: 12px;
  font-size: 10px;
  color: #666;
}

.panel-legend .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

.panel-legend .dot.red { background: #ff3333; }
.panel-legend .dot.green { background: #00ff00; }
.panel-legend .dot.gray { background: #888; }

/* Quick Analysis */
.quick-analysis {
  padding: 12px 16px;
  border-top: 1px solid #333;
  background: #151515;
}

.qa-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 3px 0;
}

.qa-row span:first-child {
  color: #888;
}

.qa-row span:last-child {
  color: #fff;
  font-weight: 500;
}

.qa-rigo {
  margin-top: 8px;
}

.rigo-tag {
  background: #2d4a77;
  color: #6bb5ff;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

/* Changes indicator */
.changes-indicator {
  color: #ff9800;
  font-size: 13px;
  margin-right: auto;
}

/* ============================================
   Stage 2: Spine Analysis
   ============================================ */

.analysis-stage .stage-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.analysis-panel {
  background: #222;
  border-radius: 8px;
  padding: 20px;
}

.analysis-panel h3 {
  font-size: 14px;
  color: #fff;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid #333;
}

/* Cobb Angles Grid */
.cobb-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.cobb-card {
  background: #1a1a1a;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  border-left: 4px solid #444;
}

.cobb-card.severity-normal { border-color: #4caf50; }
.cobb-card.severity-mild { border-color: #8bc34a; }
.cobb-card.severity-moderate { border-color: #ff9800; }
.cobb-card.severity-severe { border-color: #f44336; }

.cobb-region {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
}

.cobb-label {
  font-size: 11px;
  color: #666;
  margin-bottom: 8px;
}

.cobb-value {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
}

.cobb-severity {
  font-size: 12px;
  text-transform: uppercase;
  margin-top: 4px;
}

.severity-normal .cobb-severity { color: #4caf50; }
.severity-mild .cobb-severity { color: #8bc34a; }
.severity-moderate .cobb-severity { color: #ff9800; }
.severity-severe .cobb-severity { color: #f44336; }

/* Classification Grid */
.classification-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.classification-card {
  background: #1a1a1a;
  border-radius: 8px;
  padding: 16px;
}

.classification-type {
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.classification-badge {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.rigo-card .classification-badge { color: #6bb5ff; }
.curve-card .classification-badge { color: #8bc34a; }

.classification-desc {
  font-size: 12px;
  color: #888;
  line-height: 1.4;
}

/* Treatment Panel */
.treatment-panel {
  grid-column: 1 / -1;
}

.treatment-panel.treatment-routine { border-left: 4px solid #4caf50; }
.treatment-panel.treatment-standard { border-left: 4px solid #8bc34a; }
.treatment-panel.treatment-priority { border-left: 4px solid #ff9800; }
.treatment-panel.treatment-high { border-left: 4px solid #f44336; }
.treatment-panel.treatment-urgent { border-left: 4px solid #d32f2f; }

.treatment-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.max-cobb {
  font-size: 14px;
  color: #888;
}

.max-cobb strong {
  color: #fff;
}

.urgency-badge {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.urgency-routine { background: #1e4620; color: #4caf50; }
.urgency-standard { background: #3d5a27; color: #8bc34a; }
.urgency-priority { background: #5c4020; color: #ff9800; }
.urgency-high { background: #5c2323; color: #f44336; }
.urgency-urgent { background: #5c2323; color: #ff5252; }

.treatment-recommendation {
  font-size: 14px;
  color: #e0e0e0;
  line-height: 1.5;
}

/* Metadata Grid */
.metadata-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.metadata-item {
  text-align: center;
}

.metadata-label {
  display: block;
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.metadata-value {
  font-size: 16px;
  font-weight: 500;
  color: #fff;
}

/* ============================================
   Stage 3: Brace Generation
   ============================================ */

.brace-stage .stage-content {
  grid-template-columns: 1fr 320px;
}

.brace-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brace-viewer {
  background: #111;
  border-radius: 8px;
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brace-viz-image {
  max-width: 100%;
  max-height: 500px;
  border-radius: 8px;
}

.brace-viewer-placeholder {
  text-align: center;
  color: #666;
}

.brace-viewer-placeholder .hint {
  font-size: 12px;
  margin-top: 8px;
}

.brace-empty,
.brace-loading {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
}

.loading-hint {
  font-size: 13px;
  color: #666;
  margin-top: 8px;
}

/* Output Tabs */
.output-tabs {
  display: flex;
  gap: 8px;
}

.output-tab {
  padding: 8px 16px;
  background: #222;
  border: 1px solid #333;
  border-radius: 6px;
  color: #888;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.output-tab:hover {
  background: #333;
}

.output-tab.active {
  background: #2d4a77;
  border-color: #2196f3;
  color: #fff;
}

.output-tab:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Brace Sidebar */
.brace-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brace-panel {
  background: #222;
  border-radius: 8px;
  padding: 16px;
}

.brace-panel h3 {
  font-size: 14px;
  color: #fff;
  margin-bottom: 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-label {
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
}

.summary-value {
  font-size: 14px;
  color: #fff;
}

.summary-value.badge {
  background: #2d4a77;
  color: #6bb5ff;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
  width: fit-content;
}

/* Downloads List */
.downloads-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.download-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #1a1a1a;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.2s;
}

.download-item:hover {
  background: #333;
}

.download-icon {
  font-size: 24px;
}

.download-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.download-name {
  font-size: 13px;
  color: #fff;
  font-weight: 500;
}

.download-desc {
  font-size: 11px;
  color: #666;
}

.download-action {
  color: #2196f3;
  font-size: 18px;
}

/* Cobb Mini Grid */
.cobb-mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.cobb-mini {
  text-align: center;
  padding: 8px;
  background: #1a1a1a;
  border-radius: 6px;
}

.cobb-mini .cobb-label {
  font-size: 12px;
  color: #888;
}

.cobb-mini .cobb-value {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

/* Marker Editor Overlay */
.marker-editor-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.marker-editor-modal {
  background: #1a1a1a;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #333;
}

.modal-header h3 {
  font-size: 16px;
  color: #fff;
}

.close-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 24px;
  cursor: pointer;
}

.modal-content {
  padding: 20px;
  color: #e0e0e0;
  line-height: 1.6;
}

.modal-content ul {
  margin: 12px 0;
  padding-left: 20px;
}

.modal-content .hint {
  color: #888;
  font-size: 13px;
  margin-top: 16px;
}

.modal-actions {
  padding: 16px 20px;
  border-top: 1px solid #333;
  display: flex;
  justify-content: flex-end;
}

/* ============================================
   Landmark Editor
   ============================================ */

.landmark-editor {
  position: fixed;
  inset: 0;
  background: #0a0a0a;
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: #1a1a1a;
  border-bottom: 1px solid #333;
}

.toolbar-info {
  display: flex;
  gap: 20px;
  color: #888;
  font-size: 13px;
}

.toolbar-actions {
  display: flex;
  gap: 12px;
}

.editor-content {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  overflow: hidden;
}

.vertebrae-panel {
  background: #1a1a1a;
  border-right: 1px solid #333;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.vertebrae-panel h3 {
  padding: 16px;
  margin: 0;
  font-size: 14px;
  color: #fff;
  border-bottom: 1px solid #333;
}

.vertebrae-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.vertebra-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 4px;
}

.vertebra-row:hover {
  background: #2a2a2a;
}

.vertebra-row.selected {
  background: #2d4a77;
  box-shadow: 0 0 0 2px #2196f3;
}

.vertebra-row.manual {
  border-left: 3px solid #00ff00;
}

.vertebra-row.unplaced {
  opacity: 0.6;
}

.vertebra-level {
  font-weight: 600;
  color: #fff;
  width: 32px;
}

.vertebra-status {
  flex: 1;
  font-size: 12px;
}

.status-detected {
  color: #4caf50;
}

.status-manual {
  color: #00ff00;
  font-weight: 500;
}

.status-placed {
  color: #ff9800;
}

.status-undetected {
  color: #666;
  font-style: italic;
}

.reset-btn {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 4px;
}

.reset-btn:hover {
  background: #333;
  color: #fff;
}

.legend {
  padding: 12px 16px;
  border-top: 1px solid #333;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #888;
}

.legend-item .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-item .dot.detected {
  background: #ff0000;
}

.legend-item .dot.manual {
  background: #00ff00;
}

.legend-item .dot.undetected {
  background: #888;
}

.canvas-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #111;
  overflow: auto;
  padding: 20px;
}

.editor-canvas {
  max-width: 100%;
  max-height: 100%;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.canvas-instructions {
  margin-top: 12px;
  padding: 8px 16px;
  background: #222;
  border-radius: 6px;
  font-size: 13px;
  color: #888;
}

.canvas-instructions strong {
  color: #2196f3;
}

/* Brace Pressure Zones Section */
.pressure-zones-section {
  background: #1a1a1a;
  border-radius: 8px;
  padding: 20px;
  margin-top: 20px;
}

.pressure-zones-section h3 {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 8px;
}

.zones-desc {
  font-size: 13px;
  color: #888;
  margin-bottom: 16px;
}

.pressure-zones-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}

.zone-card {
  background: #222;
  border-radius: 8px;
  padding: 14px 16px;
  border-left: 4px solid transparent;
  transition: all 0.2s;
}

.zone-card:hover {
  background: #282828;
  transform: translateY(-1px);
}

.zone-card.zone-pressure {
  border-left-color: #22c55e;
  background: rgba(34, 197, 94, 0.08);
}

.zone-card.zone-relief {
  border-left-color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
}

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

.zone-name {
  font-weight: 500;
  color: #fff;
  font-size: 14px;
}

.zone-value {
  font-weight: 600;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 4px;
}

.zone-value.pressure {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
}

.zone-value.relief {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}

.zone-reason {
  font-size: 12px;
  color: #888;
  line-height: 1.4;
}

.patch-grid-info {
  margin-top: 16px;
  font-size: 12px;
  color: #666;
  text-align: right;
}

/* Downloads Section - Bottom of Stage 4 */
.downloads-section {
  margin-top: 24px;
  padding: 20px;
  background: #1a1a1a;
  border-radius: 12px;
}

.downloads-section h3 {
  font-size: 16px;
  color: #fff;
  margin-bottom: 16px;
}

.downloads-list.horizontal {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.downloads-list.horizontal .download-item {
  flex: 1;
  min-width: 200px;
  max-width: 300px;
}

/* Brace 3D Viewer */
.brace-viewer.brace-viewer-3d {
  position: relative;
  min-height: 450px;
  background: linear-gradient(180deg, #1e1e2e 0%, #16213e 100%);
  border-radius: 12px;
  overflow: hidden;
}

.brace-model-viewer-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 12px;
  overflow: hidden;
}

.brace-model-viewer-canvas {
  width: 100%;
  height: 100%;
}

.brace-model-viewer-canvas canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.brace-model-viewer-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #1e1e2e 0%, #16213e 100%);
  color: #888;
  border-radius: 12px;
}

.brace-model-viewer-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(30, 30, 46, 0.9);
  color: #888;
  border-radius: 12px;
  pointer-events: none;
}

.brace-model-viewer-overlay.error {
  color: #f44336;
}

.brace-model-viewer-overlay.placeholder {
  background: linear-gradient(180deg, #1e1e2e 0%, #16213e 100%);
  pointer-events: auto;
}

.brace-model-viewer-overlay .placeholder-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.brace-model-viewer-overlay p {
  margin-top: 8px;
  font-size: 14px;
}

/* ========================================
   DUAL BRACE VIEWERS - Side by Side
   ======================================== */

/* Summary row - right under header */
.brace-summary-row {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  padding: 0 4px;
}

.brace-summary-row .brace-panel {
  flex: 1;
  margin: 0;
  padding: 16px 20px;
}

.brace-summary-row .summary-panel {
  flex: 1.5;
}

.brace-summary-row .cobb-panel {
  flex: 1;
}

.summary-grid.horizontal,
.cobb-mini-grid.horizontal {
  display: flex;
  gap: 24px;
  align-items: center;
}

.cobb-mini-grid.horizontal .cobb-mini {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Dual viewers container */
.dual-brace-viewers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.brace-viewer-container {
  background: #1a1a1a;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.viewer-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, #2a2a3a 0%, #1e1e2e 100%);
  border-bottom: 1px solid #333;
}

.viewer-header h3 {
  margin: 0 0 4px 0;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
}

.viewer-subtitle {
  font-size: 13px;
  color: #888;
}

.brace-viewer-container .brace-viewer {
  flex: 1;
  min-height: 350px;
}

.viewer-stats {
  display: flex;
  gap: 16px;
  padding: 12px 20px;
  background: #151515;
  font-size: 12px;
  color: #666;
}

.viewer-stats span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.viewer-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 350px;
  background: linear-gradient(180deg, #1e1e2e 0%, #16213e 100%);
  color: #666;
  text-align: center;
}

.viewer-placeholder .placeholder-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.viewer-placeholder p {
  margin: 4px 0;
}

.viewer-placeholder .hint {
  font-size: 12px;
  color: #555;
}

/* Download columns */
.downloads-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.download-column h4 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.download-column .downloads-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.download-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #1a1a1a;
  border-radius: 8px;
  color: #555;
  font-size: 13px;
}

/* Responsive: stack on smaller screens */
@media (max-width: 1200px) {
  .dual-brace-viewers {
    grid-template-columns: 1fr;
  }
  
  .downloads-columns {
    grid-template-columns: 1fr;
  }
  
  .brace-summary-row {
    flex-direction: column;
  }
}

/* ==============================================
   BRACE INLINE EDITOR STYLES
   ============================================== */

/* Editor Toggle Row */
.editor-toggle-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
  padding: 0 4px;
  margin-bottom: 12px;
}

/* Save Status */
.save-status {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  background: #2a2a3a;
  color: #888;
  animation: fadeIn 0.2s ease-out;
}

.save-status.success {
  background: #1e4620;
  color: #4caf50;
}

.save-status.error {
  background: #5c2323;
  color: #f44336;
}

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

.btn-toggle-editor {
  padding: 8px 16px;
  background: #2a2a3a;
  border: 1px solid #444;
  border-radius: 6px;
  color: #888;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-toggle-editor:hover {
  background: #3a3a4a;
  color: #fff;
}

.btn-toggle-editor.active {
  background: #2d4a77;
  border-color: #2196f3;
  color: #fff;
}

/* Modified Indicator */
.modified-indicator {
  display: inline-block;
  padding: 2px 8px;
  background: #5c4020;
  color: #ff9800;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  margin-left: 8px;
}

/* Viewer with Editor Layout */
.dual-brace-viewers.with-editors {
  grid-template-columns: 1fr 1fr;
}

.brace-viewer-with-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #1a1a1a;
  border-radius: 12px;
  overflow: hidden;
}

.brace-viewer-with-editor .brace-viewer-container {
  border-radius: 0;
  background: transparent;
}

/* Inline Editor Panel */
.brace-inline-editor {
  background: #1f1f2a;
  border-top: 1px solid #333;
  padding: 16px;
}

.viewer-inline-editor {
  margin: 0;
}

.brace-inline-editor .editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.brace-inline-editor .editor-header h4 {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin: 0;
}

.brace-inline-editor .modified-badge {
  padding: 2px 8px;
  background: #5c4020;
  color: #ff9800;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
}

/* Slider Styles */
.brace-inline-editor .editor-sliders {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.brace-inline-editor .editor-sliders.advanced {
  padding-top: 12px;
  border-top: 1px solid #333;
  margin-top: 4px;
}

.brace-inline-editor .slider-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brace-inline-editor .slider-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.brace-inline-editor .slider-label span:first-child {
  color: #888;
}

.brace-inline-editor .slider-value {
  color: #fff;
  font-weight: 500;
  font-family: monospace;
  min-width: 50px;
  text-align: right;
}

.brace-inline-editor .slider-input {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: #333;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.brace-inline-editor .slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: #2196f3;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s;
}

.brace-inline-editor .slider-input::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.brace-inline-editor .slider-input::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #2196f3;
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

/* Mode Toggle */
.brace-inline-editor .editor-mode-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.brace-inline-editor .toggle-label {
  font-size: 12px;
  color: #888;
}

.brace-inline-editor .toggle-buttons {
  display: flex;
  gap: 4px;
}

.brace-inline-editor .toggle-btn {
  padding: 4px 10px;
  background: #2a2a3a;
  border: 1px solid #444;
  border-radius: 4px;
  color: #888;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.brace-inline-editor .toggle-btn:hover {
  background: #3a3a4a;
  color: #fff;
}

.brace-inline-editor .toggle-btn.active {
  background: #2d4a77;
  border-color: #2196f3;
  color: #fff;
}

/* Checkbox */
.brace-inline-editor .editor-checkbox {
  margin-bottom: 12px;
}

.brace-inline-editor .editor-checkbox label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #888;
  cursor: pointer;
}

.brace-inline-editor .editor-checkbox input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.brace-inline-editor .editor-checkbox span {
  user-select: none;
}

/* Advanced Toggle */
.brace-inline-editor .advanced-toggle {
  display: block;
  width: 100%;
  padding: 8px;
  background: transparent;
  border: none;
  color: #666;
  font-size: 11px;
  cursor: pointer;
  text-align: left;
  transition: color 0.15s;
}

.brace-inline-editor .advanced-toggle:hover {
  color: #2196f3;
}

/* Action Buttons */
.brace-inline-editor .editor-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #333;
}

.brace-inline-editor .btn-editor {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.brace-inline-editor .btn-editor.reset {
  background: #333;
  color: #888;
}

.brace-inline-editor .btn-editor.reset:hover {
  background: #444;
  color: #fff;
}

.brace-inline-editor .btn-editor.save {
  background: #2196f3;
  color: #fff;
}

.brace-inline-editor .btn-editor.save:hover {
  background: #1976d2;
}

.brace-inline-editor .btn-editor.save:disabled {
  background: #333;
  color: #666;
  cursor: not-allowed;
}

/* BraceTransformViewer Styles */
.brace-transform-viewer-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 12px;
  overflow: hidden;
}

.brace-transform-viewer-canvas {
  width: 100%;
  height: 100%;
}

.brace-transform-viewer-canvas canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.brace-transform-viewer-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #1e1e2e 0%, #16213e 100%);
  color: #888;
  border-radius: 12px;
}

.brace-transform-viewer-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(30, 30, 46, 0.9);
  color: #888;
  border-radius: 12px;
  pointer-events: none;
}

.brace-transform-viewer-overlay.error {
  color: #f44336;
}

.brace-transform-viewer-overlay.placeholder {
  background: linear-gradient(180deg, #1e1e2e 0%, #16213e 100%);
  pointer-events: auto;
}

.brace-transform-viewer-overlay .placeholder-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.brace-transform-viewer-overlay p {
  margin-top: 8px;
  font-size: 14px;
}

/* Dimensions overlay for measurement grid */
.brace-dimensions-overlay {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(136, 255, 136, 0.3);
  border-radius: 8px;
  padding: 12px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  z-index: 10;
  min-width: 120px;
}

.brace-dimensions-overlay .dimensions-title {
  color: #88ff88;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(136, 255, 136, 0.2);
}

.brace-dimensions-overlay .dimension-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 4px 0;
}

.brace-dimensions-overlay .dim-label {
  color: #999;
  font-size: 11px;
}

.brace-dimensions-overlay .dim-value {
  color: #fff;
  font-weight: 600;
  font-size: 13px;
}

/* Responsive for editors */
@media (max-width: 1400px) {
  .dual-brace-viewers.with-editors {
    grid-template-columns: 1fr;
  }
  
  .brace-viewer-with-editor {
    flex-direction: column;
  }
  
  .brace-inline-editor {
    max-height: none;
  }
}

/* ==============================================
   BODY SCAN UPLOAD STAGE (Stage 3)
   ============================================== */

.body-scan-stage .stage-content {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
}

.body-scan-content {
  display: contents;
}

.body-scan-main {
  background: #1a1a1a;
  border-radius: 12px;
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Upload Dropzone */
.upload-dropzone {
  width: 100%;
  height: 100%;
  min-height: 400px;
  border: 2px dashed #444;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.upload-dropzone:hover {
  border-color: #2196f3;
  background: rgba(33, 150, 243, 0.05);
}

.upload-dropzone.drag-active {
  border-color: #4caf50;
  background: rgba(76, 175, 80, 0.1);
}

.dropzone-content {
  text-align: center;
  padding: 40px;
}

.dropzone-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.7;
}

.dropzone-content h3 {
  font-size: 20px;
  color: #fff;
  margin-bottom: 8px;
}

.dropzone-content p {
  color: #888;
  margin-bottom: 4px;
}

.dropzone-content .file-types {
  font-size: 12px;
  color: #666;
  margin-top: 12px;
}

.upload-progress {
  color: #2196f3 !important;
  font-weight: 500;
  margin-top: 16px !important;
}

.upload-error {
  color: #f44336 !important;
  font-weight: 500;
  margin-top: 16px !important;
}

/* Body Scan Preview with 3D Viewer */
.body-scan-preview {
  width: 100%;
  height: 100%;
  min-height: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border-radius: 12px;
}

/* When 3D preview is active, fill the entire space */
.body-scan-preview.body-scan-preview-3d {
  padding: 0;
}

/* 3D Body Scan Viewer - fills parent container */
.body-scan-viewer-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
  border-radius: 12px;
  overflow: hidden;
}

.body-scan-viewer-canvas {
  width: 100%;
  height: 100%;
}

.body-scan-viewer-canvas canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.body-scan-viewer-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
  color: #888;
  border-radius: 12px;
}

.body-scan-viewer-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(26, 26, 46, 0.9);
  color: #888;
  border-radius: 12px;
  pointer-events: none;
}

.body-scan-viewer-overlay.error {
  color: #f44336;
}

.body-scan-viewer-overlay.placeholder {
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
}

.body-scan-viewer-overlay p {
  margin-top: 12px;
  font-size: 14px;
}

/* Preview info overlay */
.preview-info-overlay {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.6);
  padding: 8px 16px;
  border-radius: 8px;
  backdrop-filter: blur(4px);
}

.preview-info-overlay .filename {
  color: #fff;
  font-family: monospace;
  font-size: 13px;
}

.preview-info-overlay .vertex-count {
  color: #888;
  font-size: 11px;
}

/* Legacy placeholder styles (fallback) */
.preview-placeholder {
  text-align: center;
}

.preview-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: white;
  margin: 0 auto 20px;
}

.preview-placeholder h3 {
  font-size: 20px;
  color: #fff;
  margin-bottom: 8px;
}

.preview-placeholder .filename {
  color: #888;
  font-family: monospace;
  font-size: 14px;
}

.preview-placeholder .vertex-count {
  color: #666;
  font-size: 12px;
  margin-top: 8px;
}

.btn-remove {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: rgba(244, 67, 54, 0.2);
  color: #f44336;
  border: 1px solid rgba(244, 67, 54, 0.3);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.btn-remove:hover {
  background: rgba(244, 67, 54, 0.3);
}

/* Body Scan Sidebar */
.body-scan-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.info-panel {
  background: #1a1a1a;
  border-radius: 8px;
  padding: 20px;
}

.info-panel h3 {
  font-size: 16px;
  color: #fff;
  margin-bottom: 12px;
}

.info-panel p {
  color: #888;
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 12px;
}

.benefits-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px 0;
}

.benefits-list li {
  padding: 8px 0 8px 24px;
  color: #aaa;
  font-size: 13px;
  position: relative;
}

.benefits-list li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: #4caf50;
}

.optional-note {
  background: rgba(33, 150, 243, 0.1);
  border-left: 3px solid #2196f3;
  padding: 12px;
  border-radius: 0 6px 6px 0;
  font-size: 13px !important;
}

.optional-note strong {
  color: #2196f3;
}

/* Measurements Panel */
.measurements-panel {
  background: #1a1a1a;
  border-radius: 8px;
  padding: 20px;
}

.measurements-panel h3 {
  font-size: 16px;
  color: #fff;
  margin-bottom: 16px;
}

.measurements-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.measurement-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #222;
  border-radius: 6px;
}

.measurement-item .label {
  color: #888;
  font-size: 13px;
}

.measurement-item .value {
  color: #fff;
  font-weight: 500;
  font-family: monospace;
}

.measurement-item.highlight {
  background: rgba(33, 150, 243, 0.15);
  border: 1px solid rgba(33, 150, 243, 0.3);
}

.measurement-item.highlight .label {
  color: #2196f3;
}

.measurement-item.highlight .value {
  color: #64b5f6;
}

/* Body Scan Loading */
.body-scan-loading {
  text-align: center;
  padding: 60px 40px;
}

.body-scan-loading .spinner {
  margin: 0 auto 20px;
}

.body-scan-loading p {
  color: #888;
}

/* ==============================================
   THREE.JS BRACE VIEWER
   ============================================== */

.brace-viewer-container {
  position: relative;
  background: #1a1a1a;
  border-radius: 8px;
  overflow: hidden;
}

.brace-viewer-canvas {
  display: block;
}

.brace-viewer-canvas canvas {
  display: block;
  border-radius: 8px;
}

.brace-viewer-loading,
.brace-viewer-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(26, 26, 26, 0.9);
  color: #888;
}

.brace-viewer-overlay.error {
  color: #f44336;
}

.brace-viewer-overlay.placeholder {
  background: #1a1a1a;
}

.brace-viewer-overlay p {
  margin-top: 12px;
  font-size: 14px;
}

/* Brace Editor Stage */
.brace-editor-stage .stage-content {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
}

.brace-editor-main {
  background: #1a1a1a;
  border-radius: 12px;
  overflow: hidden;
}

.brace-editor-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Deformation Controls */
.deformation-controls {
  background: #1a1a1a;
  border-radius: 8px;
  padding: 20px;
}

.deformation-controls h3 {
  font-size: 16px;
  color: #fff;
  margin-bottom: 16px;
}

.control-group {
  margin-bottom: 16px;
}

.control-group label {
  display: block;
  font-size: 13px;
  color: #888;
  margin-bottom: 6px;
}

.control-slider {
  display: flex;
  align-items: center;
  gap: 12px;
}

.control-slider input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  background: #333;
  border-radius: 2px;
  outline: none;
}

.control-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: #2196f3;
  border-radius: 50%;
  cursor: pointer;
}

.control-slider .value {
  min-width: 50px;
  text-align: right;
  font-family: monospace;
  font-size: 13px;
  color: #fff;
}

/* Markers Panel */
.markers-panel {
  background: #1a1a1a;
  border-radius: 8px;
  padding: 20px;
}

.markers-panel h3 {
  font-size: 16px;
  color: #fff;
  margin-bottom: 12px;
}

.markers-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.marker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #222;
  border-radius: 6px;
  font-size: 13px;
}

.marker-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.marker-name {
  flex: 1;
  color: #aaa;
  font-family: monospace;
}

.marker-position {
  color: #666;
  font-size: 11px;
}

/* Export Panel */
.export-panel {
  background: #1a1a1a;
  border-radius: 8px;
  padding: 20px;
}

.export-panel h3 {
  font-size: 16px;
  color: #fff;
  margin-bottom: 12px;
}

.export-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.export-buttons .btn {
  width: 100%;
  justify-content: center;
}

/* Control Actions */
.control-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #333;
}

.control-actions .btn.small {
  padding: 8px 16px;
  font-size: 13px;
}

/* Tips List */
.tips-list {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}

.tips-list li {
  padding: 6px 0;
  font-size: 12px;
  color: #888;
}

.tips-list li strong {
  color: #aaa;
}

/* Viewer Controls */
.viewer-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: #222;
  border-top: 1px solid #333;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #888;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Editor Empty State */
.editor-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  text-align: center;
}

.editor-empty p {
  color: #888;
  font-size: 14px;
}

/* ============================================
   Stage 5: Brace Fitting Inspection
   ============================================ */

.fitting-stage {
  background: #1a1a1a;
  border-radius: 12px;
  padding: 24px;
  margin: 20px;
}

.fitting-content {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  margin-top: 20px;
}

/* 3-column layout for Stage 5 */
.fitting-layout-3col {
  display: grid;
  grid-template-columns: 260px 1fr 280px;
  gap: 16px;
  margin-top: 20px;
  min-height: 600px;
}

.fitting-panel {
  background: #222;
  border-radius: 8px;
  padding: 16px;
  overflow-y: auto;
  max-height: 700px;
}

.fitting-panel h3 {
  font-size: 14px;
  color: #fff;
  margin: 0 0 16px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid #333;
}

.fitting-panel .panel-section {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #333;
}

.fitting-panel .panel-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.fitting-panel h4 {
  font-size: 12px;
  color: #888;
  margin: 0 0 8px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Checkbox rows */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
  color: #ccc;
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #4a90d9;
}

.color-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Compact sliders for transforms */
.slider-compact {
  display: grid;
  grid-template-columns: 20px 1fr 45px;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 11px;
  color: #888;
}

.slider-compact input[type="range"] {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: #333;
  outline: none;
  cursor: pointer;
  accent-color: #4a90d9;
}

.slider-compact span:last-child {
  text-align: right;
  font-family: monospace;
  color: #aaa;
}

/* Full width slider */
.fitting-panel > .panel-section > input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #333;
  outline: none;
  cursor: pointer;
  accent-color: #4a90d9;
}

/* Reset button */
.btn-reset-all {
  width: 100%;
  padding: 10px;
  margin: 12px 0;
  background: #333;
  border: 1px solid #444;
  border-radius: 4px;
  color: #aaa;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-reset-all:hover {
  background: #444;
  color: #fff;
  border-color: #555;
}

/* Tips in panel */
.fitting-panel .tips ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.fitting-panel .tips li {
  padding: 4px 0;
  font-size: 11px;
  color: #777;
  padding-left: 12px;
  position: relative;
}

.fitting-panel .tips li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #555;
}

/* Fitting Controls Panel */
.fitting-controls {
  background: #222;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.fitting-controls .controls-section {
  padding-bottom: 16px;
  border-bottom: 1px solid #333;
}

.fitting-controls .controls-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.fitting-controls h4 {
  font-size: 13px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.fitting-controls .control-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
  color: #ccc;
  cursor: pointer;
}

.fitting-controls .control-item.checkbox {
  padding: 6px 0;
}

.fitting-controls .control-item.slider {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.fitting-controls .control-item.slider span {
  display: flex;
  justify-content: space-between;
}

.fitting-controls .control-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #4a90d9;
}

.fitting-controls .control-item input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #333;
  outline: none;
  cursor: pointer;
  accent-color: #4a90d9;
}

.fitting-controls .color-indicator {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Legend */
.fitting-controls .legend .legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  font-size: 12px;
  color: #aaa;
}

.fitting-controls .legend .legend-color {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Tips */
.fitting-controls .tips ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.fitting-controls .tips li {
  padding: 4px 0;
  font-size: 12px;
  color: #777;
  padding-left: 12px;
  position: relative;
}

.fitting-controls .tips li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #555;
}

/* Transform Controls */
.fitting-controls .transform-group {
  display: grid;
  grid-template-columns: 60px 1fr 40px;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.fitting-controls .transform-label {
  font-size: 12px;
  color: #888;
}

.fitting-controls .transform-value {
  font-size: 12px;
  color: #aaa;
  text-align: right;
  font-family: monospace;
}

.fitting-controls .transform-group input[type="range"] {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: #333;
  outline: none;
  cursor: pointer;
  accent-color: #4a90d9;
}

.fitting-controls .btn-reset {
  width: 100%;
  padding: 8px 12px;
  margin-top: 12px;
  background: #333;
  border: 1px solid #444;
  border-radius: 4px;
  color: #aaa;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.fitting-controls .btn-reset:hover {
  background: #444;
  color: #fff;
  border-color: #555;
}

/* Brace Selector Buttons */
.brace-selector {
  display: flex;
  gap: 8px;
}

.brace-select-btn {
  flex: 1;
  padding: 8px 12px;
  background: #333;
  border: 1px solid #444;
  border-radius: 4px;
  color: #888;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.brace-select-btn:hover:not(:disabled) {
  background: #444;
  color: #ccc;
}

.brace-select-btn.active {
  background: #2d4a77;
  border-color: #4a90d9;
  color: #6bb5ff;
}

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

/* Control hint text */
.control-hint {
  font-size: 11px;
  color: #666;
  margin-top: 4px;
  font-style: italic;
}

/* Fitting Inline Editor */
.fitting-inline-editor {
  background: #252535;
  border-radius: 6px;
  padding: 12px;
  margin-top: 8px;
}

.fitting-inline-editor .editor-header {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #333;
}

.fitting-inline-editor .editor-header h4 {
  font-size: 13px;
  color: #aaa;
  margin: 0;
}

.fitting-inline-editor .editor-sliders {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fitting-inline-editor .slider-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fitting-inline-editor .slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #888;
}

.fitting-inline-editor .slider-value {
  color: #aaa;
  font-family: monospace;
}

.fitting-inline-editor .slider-input {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: #333;
  outline: none;
  cursor: pointer;
  accent-color: #4a90d9;
}

.fitting-inline-editor .editor-mode-toggle {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #333;
}

.fitting-inline-editor .toggle-label {
  font-size: 11px;
  color: #888;
  margin-bottom: 6px;
  display: block;
}

.fitting-inline-editor .toggle-buttons {
  display: flex;
  gap: 4px;
}

.fitting-inline-editor .toggle-btn {
  flex: 1;
  padding: 4px 8px;
  background: #333;
  border: 1px solid #444;
  border-radius: 3px;
  color: #888;
  font-size: 10px;
  cursor: pointer;
}

.fitting-inline-editor .toggle-btn.active {
  background: #2d4a77;
  border-color: #4a90d9;
  color: #6bb5ff;
}

.fitting-inline-editor .editor-checkbox {
  margin-top: 10px;
  font-size: 12px;
  color: #888;
}

.fitting-inline-editor .editor-checkbox label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.fitting-inline-editor .advanced-toggle {
  width: 100%;
  padding: 6px;
  margin-top: 10px;
  background: transparent;
  border: none;
  color: #666;
  font-size: 11px;
  cursor: pointer;
  text-align: left;
}

.fitting-inline-editor .advanced-toggle:hover {
  color: #888;
}

.fitting-inline-editor .editor-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #333;
}

.fitting-inline-editor .btn-editor {
  flex: 1;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.fitting-inline-editor .btn-editor.reset {
  background: #333;
  border: 1px solid #444;
  color: #888;
}

.fitting-inline-editor .btn-editor.reset:hover {
  background: #444;
  color: #ccc;
}

.fitting-inline-editor .btn-editor.save {
  background: #2d5a27;
  border: 1px solid #3d7a37;
  color: #8bc34a;
}

.fitting-inline-editor .btn-editor.save:hover {
  background: #3d7a37;
  color: #a5d66a;
}

/* Fitting Viewer */
.fitting-viewer-container {
  position: relative;
  background: #1a1a2e;
  border-radius: 8px;
  overflow: hidden;
  min-height: 500px;
}

.fitting-viewer-canvas {
  width: 100%;
  height: 500px;
}

.fitting-viewer-loading,
.fitting-viewer-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(26, 26, 46, 0.9);
  color: #888;
}

.fitting-viewer-overlay.error {
  color: #ff6b6b;
}

/* Fitting Empty State */
.fitting-empty {
  text-align: center;
  padding: 60px 40px;
  color: #888;
}

.fitting-empty p {
  margin: 8px 0;
}

.fitting-empty .hint {
  font-size: 13px;
  color: #666;
}

/* Pressure Info Section */
.fitting-pressure-info {
  margin-top: 24px;
  padding: 20px;
  background: #222;
  border-radius: 8px;
}

.fitting-pressure-info h4 {
  font-size: 14px;
  color: #fff;
  margin-bottom: 8px;
}

.fitting-pressure-info > p {
  font-size: 13px;
  color: #888;
  margin-bottom: 16px;
}

.pressure-zones-mini {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.zone-mini {
  display: flex;
  flex-direction: column;
  padding: 10px 16px;
  background: #2a2a3a;
  border-radius: 6px;
  min-width: 100px;
}

.zone-mini.pressure {
  border-left: 3px solid #ff6b6b;
}

.zone-mini.relief {
  border-left: 3px solid #4caf50;
}

.zone-mini .zone-name {
  font-size: 12px;
  color: #888;
  margin-bottom: 4px;
}

.zone-mini .zone-value {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

/* Stage Continue Section */
.stage-continue-section {
  display: flex;
  justify-content: center;
  padding: 24px;
  margin-top: 20px;
  border-top: 1px solid #333;
}

.stage-continue-section .btn-large {
  padding: 14px 32px;
  font-size: 16px;
}

/* Pipeline step available state */
.pipeline-step--available .pipeline-step-number {
  background: #2d4a77;
  color: #6bb5ff;
}

.pipeline-step--available .pipeline-step-label {
  color: #6bb5ff;
}

.pipeline-step.clickable:hover .pipeline-step-number {
  transform: scale(1.1);
  transition: transform 0.2s;
}

.pipeline-step.clickable:hover .pipeline-step-label {
  color: #fff;
}

/* Responsive */
@media (max-width: 900px) {
  .stage-content {
    grid-template-columns: 1fr;
  }
  
  .landmark-stage .stage-content,
  .analysis-stage .stage-content,
  .body-scan-stage .stage-content,
  .brace-stage .stage-content,
  .brace-editor-stage .stage-content {
    grid-template-columns: 1fr;
  }
  
  .fitting-content {
    grid-template-columns: 1fr;
  }
  
  .fitting-controls {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .fitting-controls .controls-section {
    flex: 1;
    min-width: 150px;
    border-bottom: none;
    border-right: 1px solid #333;
    padding-right: 16px;
  }
  
  .fitting-controls .controls-section:last-child {
    border-right: none;
  }
  
  .cobb-grid,
  .classification-grid {
    grid-template-columns: 1fr;
  }
  
  .editor-content {
    grid-template-columns: 1fr;
  }
  
  .vertebrae-panel {
    max-height: 200px;
  }
}
