/* Modern Scientific Dark-Mode Design System for Optical Column CAD */

:root {
  --bg-main: #0a0e17;
  --bg-surface: #111827;
  --bg-surface-elevated: #1e293b;
  --bg-surface-glass: rgba(17, 24, 39, 0.75);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: #38bdf8;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-cyan: #38bdf8;
  --accent-cyan-glow: rgba(56, 189, 248, 0.25);
  --accent-green: #22c55e;
  --accent-green-glow: rgba(34, 197, 94, 0.25);
  --accent-purple: #a855f7;
  --accent-amber: #eab308;
  --accent-red: #ef4444;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Menlo, monospace;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-sans);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Header & Top Bar */
.app-header {
  height: 58px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 20;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px var(--accent-cyan-glow);
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  font-size: 0.65rem;
  padding: 2px 6px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.3);
  text-transform: uppercase;
  font-weight: 600;
  font-family: var(--font-mono);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.control-group-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
}

select, input[type="text"], input[type="number"] {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select:focus, input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--accent-cyan-glow);
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger, .tab-btn {
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.btn-primary {
  background: #0284c7;
  color: #fff;
  border-color: #0369a1;
}

.btn-primary:hover {
  background: #0ea5e9;
  box-shadow: 0 0 12px var(--accent-cyan-glow);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: #334155;
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* Main Layout */
.app-main {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* Left Sidebar: Components & Presets */
.sidebar-left {
  width: 320px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 10;
}

.sidebar-section {
  padding: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.preset-description {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 8px;
  background: rgba(0, 0, 0, 0.2);
  padding: 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.elements-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.element-item {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.element-item:hover {
  border-color: rgba(56, 189, 248, 0.4);
  transform: translateX(2px);
}

.element-item.selected {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.08);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.15);
}

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

.element-tag {
  font-size: 0.65rem;
  font-weight: 600;
  font-family: var(--font-mono);
  padding: 1px 5px;
  border-radius: 4px;
  background: #334155;
  color: #cbd5e1;
}

.element-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.element-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.element-pn-row {
  margin: 3px 0 5px 0;
}

.part-number-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: #a78bfa;
  background: rgba(167, 139, 250, 0.12);
  border: 1px solid rgba(167, 139, 250, 0.3);
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

/* Axis Lock Buttons on Inspector */
.btn-lock-axis {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #1e293b;
  color: #94a3b8;
  border: 1px solid #334155;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-lock-axis:hover {
  background: #334155;
  color: #f8fafc;
  border-color: #64748b;
}

.btn-lock-axis.active-locked {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border-color: #f59e0b;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.25);
}

/* Component Rotation 90° Step Controls */
.rotation-segmented-control {
  display: flex;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 2px;
  gap: 3px;
  margin-bottom: 8px;
}

.btn-rot-step {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #94a3b8;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 5px 0;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.btn-rot-step:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.08);
}

.btn-rot-step.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #38bdf8;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.orientation-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 1px 5px;
  border-radius: 4px;
}

.orientation-badge.rot-90 {
  color: #a78bfa;
  background: rgba(167, 139, 250, 0.15);
  border-color: rgba(167, 139, 250, 0.4);
}

.orientation-badge.rot-180 {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
}

.orientation-badge.rot-270 {
  color: #34d399;
  background: rgba(52, 211, 153, 0.15);
  border-color: rgba(52, 211, 153, 0.4);
}

/* Beamsplitter Coating Specification Card */
.beamsplitter-spec-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 6px;
  padding: 10px;
  margin-top: 10px;
  font-size: 0.74rem;
}

.beamsplitter-spec-card h5 {
  margin: 0 0 8px 0;
  font-size: 0.76rem;
  color: #c084fc;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.coating-surface-item {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  padding: 6px 8px;
  margin-bottom: 6px;
}

.coating-surface-title {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  color: #e2e8f0;
  margin-bottom: 3px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.coating-metric-row {
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
  font-size: 0.70rem;
  font-family: var(--font-mono);
}

.tag-dichroic {
  color: #c084fc;
  background: rgba(168, 85, 247, 0.15);
  padding: 1px 4px;
  border-radius: 3px;
}

.tag-ar {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  padding: 1px 4px;
  border-radius: 3px;
}

/* Drop Zone */
.zmx-drop-zone {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: rgba(255, 255, 255, 0.01);
}

.zmx-drop-zone:hover, .zmx-drop-zone.dragover {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.05);
}

.drop-icon {
  font-size: 1.4rem;
  display: block;
  margin-bottom: 4px;
}

.drop-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.drop-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Center Workbench & Tabs */
.center-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-main);
}

.viewport-tabs-bar {
  height: 42px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.tabs-group {
  display: flex;
  gap: 4px;
}

.tab-btn {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 14px;
  font-size: 0.8rem;
  font-weight: 500;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.05);
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tab-content {
  flex: 1;
  display: none;
  position: relative;
  overflow: hidden;
}

.tab-content.active {
  display: flex;
}

#optical-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

#view-3d-container {
  width: 100%;
  height: 100%;
}

/* Diagnostics & Plots View */
.diagnostics-container {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
  gap: 16px;
  padding: 16px;
  overflow-y: auto;
}

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

.plot-title {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.plot-canvas-wrapper {
  flex: 1;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.plot-canvas-wrapper canvas {
  width: 100%;
  height: 100%;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Prescription & BOM Views */
.scrollable-view-content {
  width: 100%;
  height: 100%;
  padding: 20px;
  overflow-y: auto;
}

.code-viewer {
  background: #070a10;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #38bdf8;
  white-space: pre;
  overflow-x: auto;
  line-height: 1.5;
}

/* Right Sidebar: Inspector & Metrics */
.sidebar-right {
  width: 340px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 10;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metric-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px 10px;
}

.metric-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.metric-value {
  font-size: 0.95rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.metric-value.highlight {
  color: var(--accent-cyan);
}

.metric-value.green {
  color: var(--accent-green);
}

/* Inspector Controls */
.inspector-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.component-desc {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.35;
}

.component-power-badge {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 12px;
}

.field-group {
  margin-bottom: 12px;
}

.field-group label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input-with-stepper {
  display: flex;
  align-items: center;
  gap: 4px;
}

.input-with-stepper input {
  flex: 1;
  text-align: center;
  font-family: var(--font-mono);
}

.btn-step {
  width: 32px;
  height: 32px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
}

.btn-step:hover {
  background: #334155;
  color: var(--accent-cyan);
}

.field-group-actions {
  display: flex;
  gap: 8px;
  margin: 12px 0 16px;
}

.field-group-actions button {
  flex: 1;
}

/* Surfaces & BOM Tables */
.surfaces-table-container h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.surfaces-table, .bom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
  font-family: var(--font-mono);
}

.surfaces-table th, .bom-table th {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-weight: 600;
}

.surfaces-table td, .bom-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
}

.glass-pill, .type-pill, .tube-pill {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
}

.glass-pill {
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-cyan);
}

.type-pill {
  background: rgba(168, 85, 247, 0.15);
  color: var(--accent-purple);
}

.tube-pill {
  background: rgba(34, 197, 94, 0.15);
  color: var(--accent-green);
}

.part-number {
  color: #f8fafc;
  font-weight: 600;
}

.empty-state {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  text-align: center;
  padding: 20px 10px;
}

/* Footer Status Bar */
.app-statusbar {
  height: 28px;
  background: #070a10;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.status-left, .status-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-indicator {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);
}

/* ==========================================================
   Interactive On-Canvas HUD Overlay & Hints
   ========================================================== */
.canvas-hud {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(56, 189, 248, 0.35);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 15px rgba(56, 189, 248, 0.15);
  border-radius: 28px;
  padding: 6px 14px;
  z-index: 20;
  transition: all 0.2s ease;
  pointer-events: auto;
}

.canvas-hud:hover {
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.6), 0 0 20px rgba(56, 189, 248, 0.25);
}

.hud-pill-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #e2e8f0;
}

.hud-badge {
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.5px;
  background: rgba(56, 189, 248, 0.18);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.hud-badge.flipped {
  background: rgba(245, 158, 11, 0.22);
  color: #fbbf24;
  border-color: #f59e0b;
  animation: pulse-border 2s infinite ease-in-out;
}

@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 4px rgba(245, 158, 11, 0.4); }
  50% { box-shadow: 0 0 12px rgba(245, 158, 11, 0.8); }
}

.hud-divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.15);
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-label {
  font-size: 0.76rem;
  color: #94a3b8;
  font-weight: 500;
}

.hud-btn {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f1f5f9;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 3px;
}

.hud-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--accent-cyan);
  color: #ffffff;
  transform: translateY(-1px);
}

.hud-btn-accent {
  background: rgba(234, 179, 8, 0.15);
  border-color: rgba(234, 179, 8, 0.5);
  color: #facc15;
}

.hud-btn-accent:hover {
  background: rgba(234, 179, 8, 0.3);
  border-color: #facc15;
  color: #ffffff;
}

.hud-btn-flip {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.5);
  color: var(--accent-cyan);
  font-weight: 600;
}

.hud-btn-flip:hover {
  background: rgba(56, 189, 248, 0.35);
  border-color: var(--accent-cyan);
  color: #ffffff;
}

.hud-val {
  font-size: 0.76rem;
  font-family: var(--font-mono);
  color: #38bdf8;
  font-weight: 600;
  min-width: 60px;
}

.canvas-hint-bar {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.72rem;
  color: #94a3b8;
  z-index: 15;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.canvas-hint-bar strong {
  color: #e2e8f0;
}

/* ==========================================================
   Component Hover Tooltip Card (De-cluttered 2D View)
   ========================================================== */
.component-hover-tooltip {
  position: absolute;
  z-index: 50;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(56, 189, 248, 0.45);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.75), 0 0 20px rgba(56, 189, 248, 0.25);
  border-radius: 8px;
  padding: 12px 14px;
  width: 300px;
  max-width: 90vw;
  color: #e2e8f0;
  font-family: var(--font-sans);
  font-size: 0.76rem;
  line-height: 1.4;
  transition: opacity 0.12s ease;
}

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

.hover-pn-tag {
  background: rgba(167, 139, 250, 0.2);
  border: 1px solid rgba(167, 139, 250, 0.4);
  color: #c084fc;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 4px;
}

.hover-type-badge {
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #38bdf8;
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 4px;
}

.hover-tooltip-title {
  font-weight: 700;
  color: #f8fafc;
  font-size: 0.84rem;
  margin-bottom: 2px;
}

.hover-tooltip-desc {
  color: #94a3b8;
  font-size: 0.71rem;
  margin-bottom: 8px;
  line-height: 1.35;
}

.hover-tooltip-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 8px;
  background: rgba(30, 41, 59, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 7px 9px;
  margin-bottom: 8px;
}

.hover-stat {
  display: flex;
  flex-direction: column;
}

.hover-stat .stat-label {
  font-size: 0.63rem;
  color: #64748b;
  text-transform: uppercase;
  font-weight: 600;
}

.hover-stat .stat-val {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  color: #f1f5f9;
  font-weight: 500;
}

.hover-stat .stat-val.cyan {
  color: #38bdf8;
}

.hover-stat .stat-val.amber {
  color: #fbbf24;
}

.hover-details-box {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 5px;
  padding: 7px 9px;
  font-size: 0.71rem;
  line-height: 1.4;
}

.hover-details-box .section-heading {
  color: #38bdf8;
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  margin-bottom: 3px;
  display: flex;
  justify-content: space-between;
}

.hover-details-row {
  display: flex;
  justify-content: space-between;
  color: #cbd5e1;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  margin-top: 2px;
}

/* ==========================================================================
   3D Component CAD & Specification Inspector Modal
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(4, 7, 15, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modalFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.component-inspector-modal {
  width: 95vw;
  max-width: 1200px;
  height: 85vh;
  max-height: 820px;
  background: var(--bg-surface);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7), 0 0 30px rgba(56, 189, 248, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  height: 64px;
  padding: 0 24px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.modal-icon {
  font-size: 1.6rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 10px;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.modal-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}

.badge-pn {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 4px;
}

.badge-type {
  font-family: var(--font-mono);
  font-size: 0.70rem;
  font-weight: 600;
  padding: 2px 6px;
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 4px;
}

.badge-accent {
  font-size: 0.70rem;
  font-weight: 500;
  color: #94a3b8;
}

.btn-modal-close {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  font-size: 1.1rem;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-modal-close:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #ffffff;
}

/* Modal Body Split (3D Viewport on Left, Specifications on Right) */
.modal-body-split {
  flex: 1;
  display: flex;
  overflow: hidden;
}
.modal-3d-viewport-wrapper {
  flex: 1;
  position: relative;
  background: #f6f8fa;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.component-3d-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* CAD Screen-Space 2D Overlay (Constant typography size, draggable, non-overlapping) */
.cad-screen-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
  overflow: hidden;
}

.cad-overlay-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.cad-annotations-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.cad-badge {
  position: absolute;
  pointer-events: auto;
  user-select: none;
  cursor: grab;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid #cbd5e1;
  border-left-width: 3.5px;
  border-radius: 6px;
  padding: 4px 8px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  min-width: 110px;
  max-width: 200px;
  transform: translate(-50%, -50%);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.cad-badge:hover {
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.18);
  border-color: #94a3b8;
}

.cad-badge.dragging {
  cursor: grabbing;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.25);
  border-color: #0284c7;
  z-index: 50;
}

.cad-badge-tag {
  display: inline-block;
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(2, 132, 199, 0.12);
  color: #0284c7;
  margin-bottom: 2px;
}

.cad-badge-text {
  font-size: 10.5px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.25;
}

.cad-badge-subtext {
  font-size: 9px;
  font-weight: 400;
  color: #64748b;
  margin-top: 2px;
  line-height: 1.2;
}

/* 2D Dimension Value Pills */
.cad-dim-pill {
  position: absolute;
  pointer-events: auto;
  user-select: none;
  cursor: grab;
  background: #ffffff;
  border: 1px solid #0284c7;
  color: #0284c7;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.15);
  transform: translate(-50%, -50%);
  white-space: nowrap;
  transition: transform 0.05s ease;
}

.cad-dim-pill:hover {
  background: #f0f9ff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
}

.cad-dim-pill.dragging {
  cursor: grabbing;
  border-color: #0369a1;
  background: #e0f2fe;
  z-index: 50;
}

/* Viewport HUD Toolbar */
.viewport-hud-toolbar {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}

.hud-btn-group {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  padding: 5px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  pointer-events: auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.hud-action-btn,
.hud-toggle-btn {
  background: rgba(241, 245, 249, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: #334155;
  padding: 4px 10px;
  font-size: 0.73rem;
  font-weight: 500;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.hud-action-btn:hover,
.hud-toggle-btn:hover {
  background: rgba(2, 132, 199, 0.12);
  color: #0284c7;
  border-color: rgba(2, 132, 199, 0.35);
}

.hud-action-btn.active,
.hud-toggle-btn.active {
  background: rgba(2, 132, 199, 0.18);
  color: #0284c7;
  border-color: #0284c7;
  font-weight: 600;
  box-shadow: 0 0 10px rgba(2, 132, 199, 0.2);
}

.viewport-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.70rem;
  color: #475569;
  pointer-events: none;
  font-family: var(--font-mono);
}

/* Modal Specs Sidebar */
.modal-specs-sidebar {
  width: 380px;
  background: var(--bg-surface-elevated);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
}

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

.specs-section-header h3 {
  font-size: 0.88rem;
  font-weight: 700;
  color: #f8fafc;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.specs-tag {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 6px;
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 4px;
}

.specs-content-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.spec-category-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 10px 12px;
}

.spec-category-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #38bdf8;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.spec-grid-table {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.spec-item {
  display: flex;
  flex-direction: column;
}

.spec-item .label {
  font-size: 0.67rem;
  color: #94a3b8;
  font-weight: 500;
}

.spec-item .value {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: #f1f5f9;
  font-weight: 600;
  margin-top: 2px;
}

.spec-item .value.accent {
  color: #facc15;
}

.spec-coating-card {
  background: rgba(15, 23, 42, 0.7);
  border-radius: 6px;
  padding: 8px 10px;
  margin-top: 6px;
}

.spec-coating-card.s1 {
  border-left: 3px solid #c084fc;
  border-top: 1px solid rgba(192, 132, 252, 0.3);
  border-right: 1px solid rgba(192, 132, 252, 0.2);
  border-bottom: 1px solid rgba(192, 132, 252, 0.2);
}

.spec-coating-card.s2 {
  border-left: 3px solid #34d399;
  border-top: 1px solid rgba(52, 211, 153, 0.3);
  border-right: 1px solid rgba(52, 211, 153, 0.2);
  border-bottom: 1px solid rgba(52, 211, 153, 0.2);
}

.specs-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.95);
}

/* Assembly List & Inspector 3D CAD Inspect Button */
.btn-inspect-cad-sm {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #38bdf8;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.btn-inspect-cad-sm:hover {
  background: rgba(56, 189, 248, 0.25);
  border-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.3);
}

.btn-inspect-cad-lg {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(168, 85, 247, 0.2));
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
  width: 100%;
}

.btn-inspect-cad-lg:hover {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.35), rgba(168, 85, 247, 0.35));
  border-color: #38bdf8;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.35);
}





/* ==========================================================================
   Supabase Multi-User Auth & AES-256 Lock Screen Styles
   ========================================================================== */

.auth-lock-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999999;
  background: radial-gradient(circle at 50% 30%, rgba(15, 23, 42, 0.96) 0%, rgba(3, 7, 18, 0.99) 100%);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  opacity: 1;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.auth-lock-overlay.auth-fade-out {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.02);
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8), 0 0 40px rgba(56, 189, 248, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  overflow: hidden;
}

.auth-card-glow {
  position: absolute;
  top: -50px;
  left: 50%;
  transform: translateX(-50%);
  width: 250px;
  height: 100px;
  background: radial-gradient(ellipse at center, rgba(56, 189, 248, 0.35), transparent 70%);
  pointer-events: none;
}

.auth-icon-badge {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(14, 165, 233, 0.05));
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.25);
}

.auth-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #f8fafc;
  margin: 0 0 6px 0;
  letter-spacing: -0.01em;
}

.auth-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.auth-desc {
  font-size: 0.84rem;
  color: #94a3b8;
  line-height: 1.5;
  margin: 0 0 24px 0;
}

.auth-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.auth-input-icon {
  position: absolute;
  left: 14px;
  color: #64748b;
  pointer-events: none;
}

.auth-input {
  width: 100%;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 12px 42px 12px 40px;
  font-size: 0.95rem;
  color: #f8fafc;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.auth-input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25);
}

.auth-pwd-toggle {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.auth-pwd-toggle:hover {
  opacity: 1;
}

.auth-error-banner {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.8rem;
  line-height: 1.4;
  text-align: left;
}

.auth-submit-btn {
  width: 100%;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 13px 18px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(2, 132, 199, 0.35);
}

.auth-submit-btn:hover {
  background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.45);
}

.auth-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: auth-spin 0.7s linear infinite;
}

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

.auth-input-shake {
  animation: auth-shake 0.4s ease-in-out;
}

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

.auth-footer-note {
  margin-top: 24px;
  font-size: 0.72rem;
  color: #64748b;
  letter-spacing: 0.02em;
}
