/* =========================================================================
   CSS VARIABLES AND THEMING
   ========================================================================= */
:root {
  --primary-color: var(--graiph-accent);
  --primary-hover: var(--graiph-accent-hover);
  --accent-primary: var(--graiph-accent);
  --accent-color: var(--graiph-accent);
  --secondary-color: var(--graiph-gray-mid);
  --success-color: var(--graiph-alert-success);
  --success-hover: var(--graiph-accent-hover);
  --danger-color: var(--graiph-alert-error);
  --warning-color: var(--graiph-alert-warning);

  --bg-primary: var(--graiph-bg-surface);
  --bg-secondary: var(--graiph-bg-primary);
  --bg-tertiary: var(--graiph-bg-tertiary);
  --bg-dark: var(--graiph-bg-primary);
  --bg-accent: var(--graiph-bg-elevated);
  --bg-hover: var(--graiph-bg-hover);

  --text-primary: var(--graiph-text-primary);
  --text-secondary: var(--graiph-text-secondary);
  --text-muted: var(--graiph-text-muted);

  --border-color: var(--graiph-border);
  --border-hover: var(--graiph-border-hover);
  --border-focus: var(--graiph-border-focus);

  --shadow-sm: var(--graiph-shadow-sm);
  --shadow-md: var(--graiph-shadow-md);
  --shadow-lg: var(--graiph-shadow-lg);

  --radius-sm: var(--graiph-radius-sm);
  --radius-md: var(--graiph-radius-md);
  --radius-lg: var(--graiph-radius-lg);

  --sidebar-width: 320px;
  --sidebar-collapsed-width: 0px;
  --right-panel-width: 400px;
  --right-panel-collapsed-width: 0px;
  --header-height: 60px;
  --toolbar-height: 50px;
}

/* =========================================================================
   GLOBAL RESET AND BASE STYLES
   ========================================================================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Force form elements to inherit text color (browsers default to black) */
input, select, textarea, button {
  color: inherit;
}

::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

body,
html {
  font-family: var(--graiph-font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  height: 100vh;
  overflow: hidden;
}

/* =========================================================================
   LUCIDE ICON INTEGRATION
   ========================================================================= */
/* Base sizing: inherit font-size from parent, match FA's vertical alignment */
/* Lucide replaces <i data-lucide="x"> with <svg data-lucide="x">, so the SVG
   itself carries the attribute — use svg[data-lucide], not [data-lucide] svg */
svg[data-lucide] {
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  stroke-width: 2;
}

/* Spin animation for loaders */
.lucide-spin svg {
  animation: graiph-spin 1s linear infinite;
}

/* Pure CSS spinner (no icon needed) */
.graiph-spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: middle;
  animation: graiph-spin 1s linear infinite;
}

.graiph-spinner-lg {
  width: 1.5em;
  height: 1.5em;
  border-width: 3px;
}

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

/* =========================================================================
   UTILITY CLASSES
   ========================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
  background: transparent;
}

.btn svg {
  pointer-events: none; /* Clicks pass through icons to the button/link */
}

.notification-close svg,
.batch-close-btn svg,
.sync-close-btn svg {
  pointer-events: none; /* Lucide SVGs must not absorb clicks from close buttons */
}

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

.btn-primary {
  background-color: var(--primary-color);
  color: var(--graiph-accent-ink);
  border: 1px solid var(--primary-color);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-tertiary);
  border-color: var(--border-hover);
}

.btn-success {
  background-color: var(--success-color);
  color: var(--graiph-accent-ink);
  border: 1px solid var(--success-color);
}

.btn-success:hover:not(:disabled) {
  background-color: var(--success-hover);
  box-shadow: var(--shadow-md);
}

.btn-info {
  background-color: var(--graiph-alert-info);
  color: white;
  border: 1px solid var(--graiph-alert-info);
}

.btn-info:hover:not(:disabled) {
  background-color: #1976D2;
  box-shadow: var(--shadow-md);
}

.btn-link {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 4px 0;
  font-size: 12px;
}

.btn-link:hover:not(:disabled) {
  color: var(--graiph-accent-text);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}

.btn-ghost:hover:not(:disabled) {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.btn-danger {
  background-color: var(--graiph-alert-error);
  color: white;
  border: 1px solid var(--graiph-alert-error);
}

.btn-danger:hover:not(:disabled) {
  background-color: #C62828;
  box-shadow: var(--shadow-md);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

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

/* Focus-visible for accessibility lives in /shared/focus.css (TEL-55) — loaded
   last by every interface entry point, not just the five that load this sheet. */

.panel-toggle {
  padding: 8px;
  border-radius: var(--radius-sm);
}

.text-muted {
  color: var(--text-muted);
  font-style: italic;
}

.text-error {
  color: var(--danger-color);
  font-style: italic;
}

/* =========================================================================
   FORM CONTROLS
   ========================================================================= */
.form-group {
  margin-bottom: 16px;
}

.form-group-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.form-group-inline label {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 13px;
  white-space: nowrap;
  min-width: 120px;
}

.form-group-inline .form-slider {
  flex: 1;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-primary);
  font-size: 13px;
}

.form-select,
.form-input,
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  transition: all 0.2s ease;
}

.form-select:focus,
.form-input:focus,
.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(51, 204, 102, 0.15);
}

.form-select option {
  background-color: var(--bg-primary);
  color: var(--text-primary);
}


/* =========================================================================
   CHECKBOXES AND RADIO BUTTONS
   ========================================================================= */
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 0;
  font-size: 13px;
  transition: color 0.2s ease;
  margin-top: 4px;
}

.checkbox-item-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 0 4px 24px;
  font-size: 12px;
  transition: all 0.2s ease;
  opacity: 0.85;
}

.checkbox-item-sub:last-of-type {
  margin-bottom: 4px;
}

.checkbox-item-sub input[type="checkbox"]:disabled ~ * {
  opacity: 0.4;
  cursor: not-allowed;
}

.checkbox-item-sub input[type="checkbox"]:disabled {
  cursor: not-allowed;
}

.checkbox-item-sub:has(input:disabled) {
  opacity: 0.4;
  cursor: not-allowed;
}

.checkbox-item-sub input[type="checkbox"]:disabled + .checkmark {
  background-color: var(--bg-secondary);
  border-color: rgba(255, 255, 255, 0.2);
  opacity: 0.5;
}

.checkbox-item:hover,
.checkbox-item-sub:hover {
  color: var(--graiph-accent-text);
}

.checkbox-item-sub:has(input:disabled):hover {
  color: inherit;
}

.checkbox-item-sub input[type="checkbox"]:disabled:hover + .checkmark {
  background-color: var(--bg-secondary);
  border-color: rgba(255, 255, 255, 0.2);
}

.checkbox-item input[type="checkbox"],
.checkbox-item-sub input[type="checkbox"] {
  display: none;
}

.checkmark {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-radius: 3px;
  position: relative;
  background-color: var(--bg-primary);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.checkbox-item input:checked + .checkmark,
.checkbox-item-sub input:checked + .checkmark {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

.checkbox-item-sub input:checked:disabled + .checkmark {
  background-color: rgba(33, 150, 243, 0.4);
  border-color: rgba(33, 150, 243, 0.4);
}

.checkbox-item input:checked + .checkmark::after,
.checkbox-item-sub input:checked + .checkmark::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -60%) rotate(45deg);
}

/* Checkbox dropdown groups (Tagger, Classes Vector) */
.checkbox-dropdown-group { margin-top: 4px; }
.checkbox-dropdown-header { display: flex; align-items: center; gap: 4px; }

/* Two-column grid wrapper that keeps Depth/Fill aligned across all rows.
   Fixed widths ensure empty slots still reserve space. Column 1 also holds
   the "Edit" toggle (labeler.viz.edit → "Editar"), so it is sized for the
   longest localized label in that slot; both columns clip rather than overrun
   the chevron if a translation is unexpectedly long. */
.viz-toggle-slots {
  display: grid;
  grid-template-columns: 60px 54px;
  gap: 2px;
  flex-shrink: 0;
}
.viz-toggle-slots > .viz-inline-toggle {
  overflow: hidden;
}

/* Inline visualization toggles (Depth/Fill per category) */
.viz-inline-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  white-space: nowrap;
}
.viz-inline-toggle input[type="checkbox"] {
  display: none;
}
.viz-inline-toggle .checkmark {
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--border-color);
  border-radius: 2px;
  position: relative;
  background-color: var(--bg-primary);
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.viz-inline-toggle input:checked + .checkmark {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}
.viz-inline-toggle input:checked + .checkmark::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3px;
  height: 6px;
  border: solid white;
  border-width: 0 1.5px 1.5px 0;
  transform: translate(-50%, -60%) rotate(45deg);
}
.viz-inline-toggle:hover {
  color: var(--text-primary);
}

/* Inline group for standalone checkboxes with Fill toggle */
.checkbox-inline-group {
  display: flex;
  align-items: center;
  gap: 4px;
  grid-column: 1 / -1;
}
.checkbox-inline-group .checkbox-item {
  flex: 1;
  margin: 0;
}

/* Invisible spacer matching .dropdown-chevron width (padding:4px + 14px icon = 22px) */
.dropdown-chevron-spacer {
  width: 22px;
  flex-shrink: 0;
}

.dropdown-chevron {
  background: none; border: none; cursor: pointer;
  padding: 4px; color: var(--text-secondary, #9ca3af);
  display: flex; align-items: center; border-radius: 3px;
  transition: all 0.2s ease;
}
.dropdown-chevron:hover { color: var(--graiph-accent-text); background: rgba(255,255,255,0.05); }
.dropdown-chevron svg { transition: transform 0.2s ease; width: 14px; height: 14px; pointer-events: none; }
.dropdown-chevron.open svg { transform: rotate(180deg); }

.dropdown-panel {
  padding-left: 8px; border-left: 2px solid rgba(255,255,255,0.1);
  margin-left: 8px; margin-top: 2px;
}

/* Classes vector indicators (marker shape + color bar) */
.cv-indicator {
  display: inline-flex; align-items: center; gap: 3px;
  margin-left: 6px; vertical-align: middle;
}
.cv-indicator__marker {
  display: inline-block; width: 8px; height: 8px; flex-shrink: 0;
}
.cv-indicator--original .cv-indicator__marker {
  background: #000; border: 1px solid #fff; border-radius: 50%;
}
.cv-indicator--edited .cv-indicator__marker {
  background: #fff; border: 1px solid #000;
  transform: rotate(45deg); border-radius: 1px;
}
.cv-indicator__bar {
  display: inline-block; width: 16px; height: 4px; border-radius: 1px;
  background: linear-gradient(90deg, #8B4513 0%, #8B4513 35%, #D2B48C 35%, #D2B48C 55%, #ffb366 55%, #ffb366 75%, #00FFFF 75%, #00FFFF 100%);
}

/* Fracture category color indicator (small square next to sub-checkbox label) */
.fracture-cat-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 4px;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Two-column grid layout for dropdown sub-option panels */
.dropdown-panel--two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 8px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}

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

.radio-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 0;
  font-size: 13px;
}

.radio-item input[type="radio"] {
  display: none;
}

.radio-mark {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  position: relative;
  background-color: var(--bg-primary);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.radio-item input:checked + .radio-mark {
  border-color: var(--primary-color);
}

.radio-item input:checked + .radio-mark::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  background-color: var(--primary-color);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

/* =========================================================================
   IMAGE ENHANCEMENT CONTROLS
   ========================================================================= */
.image-enhancement-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.image-enhancement-section h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.image-enhancement-section h4 svg {
  color: var(--graiph-accent-text);
}

.slider-container {
  position: relative;
  margin: 8px 0;
}

.form-slider {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--graiph-border-hover);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: all 0.2s ease;
}

.form-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
  border: 2px solid var(--bg-primary);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.form-slider::-webkit-slider-thumb:hover {
  background: var(--primary-hover);
  transform: scale(1.1);
}

.form-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
  border: 2px solid var(--bg-primary);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.form-slider::-moz-range-thumb:hover {
  background: var(--primary-hover);
  transform: scale(1.1);
}

.form-slider::-moz-range-track {
  height: 4px;
  background: var(--graiph-border-hover);
  border-radius: 2px;
}

.enhancement-controls {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.enhancement-controls .btn {
  flex: 1;
  justify-content: center;
}

/* =========================================================================
   LOGIN OVERLAY
   ========================================================================= */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--graiph-bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(8px);
}

.overlay.hidden {
  display: none !important;
}

.login-container {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-header svg {
  font-size: 48px;
  width: 48px;
  height: 48px;
  color: var(--graiph-accent-text);
  margin-bottom: 16px;
}

.login-header h2 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.login-header p {
  color: var(--text-secondary);
  font-size: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-group {
  position: relative;
}

.input-group svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  z-index: 1;
}

.input-group input {
  width: 100%;
  padding: 12px 12px 12px 40px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 14px;
  background: var(--graiph-bg-elevated);
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.input-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(51, 204, 102, 0.2);
}

.error-message {
  color: var(--danger-color);
  font-size: 12px;
  margin-top: 8px;
  text-align: center;
}

/* =========================================================================
   MAIN APP LAYOUT
   ========================================================================= */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* App header — now handled by shared/header.css (.graiph-header) */

.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* =========================================================================
   SIDEBAR
   ========================================================================= */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  padding: 0;
  overflow-y: auto;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
  min-width: 0;
  border-right: none;
  overflow: hidden;
}

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

.sidebar-section:last-child {
  border-bottom: none;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  background-color: var(--bg-accent);
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.2s ease;
}

.section-header:hover {
  background-color: var(--bg-tertiary);
}

.section-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-header h3 svg {
  color: var(--graiph-accent-text);
  font-size: 14px;
}

.section-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.section-toggle:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.section-toggle svg {
  transition: transform 0.2s ease;
}

.section-header.collapsed .section-toggle svg {
  transform: rotate(90deg);
}

.section-content {
  padding: 20px;
  transition: all 0.3s ease;
  max-height: 1200px;
  overflow-y: auto;
}

.section-content.collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
}

.tray-controls {
  display: flex;
  gap: 8px;
}

.tray-controls .form-select {
  flex: 1;
}

.tray-navigation {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* =========================================================================
   CANVAS AREA
   ========================================================================= */
.canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-secondary);
  min-width: 0;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  height: var(--toolbar-height);
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.toolbar-right {
  justify-content: flex-end;
}

.toolbar-center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.current-image-display {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background-color: transparent;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 400;
}

.current-image-display svg {
  color: var(--graiph-accent-text);
}

.zoom-controls {
  display: flex;
  gap: 4px;
}

/* Delete by Type popover */
.delete-by-type-wrapper {
  position: relative;
  margin-left: 4px;
}

.delete-by-type-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 260px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  overflow: hidden;
}

.dbt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
}

.dbt-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dbt-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
}
.dbt-close-btn svg {
  pointer-events: none;
}

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

/* Click-to-delete toggle row */
.dbt-mode-toggle {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-color);
}

.dbt-toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.dbt-toggle-btn:hover {
  background: var(--bg-hover);
}

.dbt-toggle-btn.active {
  background: rgba(229, 57, 53, 0.15);
  border-color: #E53935;
  color: var(--graiph-alert-error);
}

/* Active state for the toolbar trash button when in delete mode */
#deleteByTypeBtn.delete-mode-active {
  background: #E53935;
  color: #fff;
  border-color: #C62828;
}

/* Active state for the SAM-assist wand toggle. ID-scoped so it beats the
   .btn-secondary base + hover rules and reads unmistakably as "on" (accent
   green fill + glow ring, matching the design-system active/validation color).
   The lucide icon uses currentColor, so the white text color carries it. */
#samAssistBtn {
  transition: background-color 0.12s ease, border-color 0.12s ease,
    color 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

#samAssistBtn.active,
#panModeBtn.active {
  background: var(--primary-color);
  color: var(--graiph-accent-ink);
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(51, 204, 102, 0.3);
}

#panModeBtn.active i {
  color: #fff;
}

#samAssistBtn.active:hover:not(:disabled):not(.sam-ctrl-flip) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: var(--graiph-accent-ink);
}

#samAssistBtn.active i {
  color: #fff;
}

/* Ctrl held: preview the INVERSE mode the next gesture will use, at reduced
   opacity so it reads as a transient, modifier-held state rather than the
   committed toggle. In edit mode → preview the SAM-on (green) look; in SAM
   mode → preview the off look. Added/removed by the Ctrl key listener. */
#samAssistBtn.sam-ctrl-flip {
  opacity: 0.5;
}

#samAssistBtn.sam-ctrl-flip:not(.active) {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: var(--graiph-accent-ink);
  box-shadow: 0 0 0 2px rgba(51, 204, 102, 0.3);
}

#samAssistBtn.sam-ctrl-flip:not(.active) i {
  color: #fff;
}

#samAssistBtn.active.sam-ctrl-flip {
  background: var(--bg-primary);
  border-color: var(--border-color);
  color: var(--text-primary);
  box-shadow: none;
}

#samAssistBtn.active.sam-ctrl-flip i {
  color: var(--text-primary);
}

/* SAM wand states:
   - default (service never asked about — sam2 is not probed on page load): normal
     toolbar look, so an unused wand costs no request.
   - .sam-down (a wand click's health check found the service unavailable):
     muted/greyed via opacity only — no border-color override, so there's no
     bright/white contour.
   - .active (SAM mode on): the green active look defined above.
   A single click toggles the mode. */
#samAssistBtn.sam-down:not(.active) {
  opacity: 0.45;
}

/* Loading: while the tray embedding is being imported/encoded, replace the wand
   icon with a spinner so the wait is visible. */
#samAssistBtn {
  position: relative;
}

#samAssistBtn.sam-loading {
  opacity: 1;
}

#samAssistBtn.sam-loading i {
  visibility: hidden;
}

#samAssistBtn.sam-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: samSpin 0.7s linear infinite;
}

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

.dbt-body {
  max-height: 300px;
  overflow-y: auto;
}

.dbt-type-list {
  padding: 4px 0;
}

.dbt-type-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 13px;
  color: var(--text-primary);
}

.dbt-type-item:hover {
  background: var(--bg-hover);
}

.dbt-type-item.dbt-selected {
  background: rgba(229, 57, 53, 0.1);
}

.dbt-type-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.dbt-type-label {
  flex: 1;
}

.dbt-type-count {
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.dbt-delete-all-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-top: 1px solid var(--border-color);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  color: #e53935;
  transition: background 0.15s;
}

.dbt-delete-all-btn:hover,
.dbt-delete-all-btn.dbt-selected {
  background: rgba(229, 57, 53, 0.1);
}

.dbt-delete-all-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.dbt-delete-all-btn .dbt-type-label {
  text-align: left;
}

.dbt-confirm {
  padding: 10px 12px;
  border-top: 1px solid var(--border-color);
  background: rgba(229, 57, 53, 0.05);
}

.dbt-confirm-text {
  margin: 0 0 8px 0;
  font-size: 12px;
  color: var(--text-primary);
  line-height: 1.4;
}

.dbt-confirm-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas {
  max-width: 100%;
  max-height: 100%;
  cursor: crosshair;
  user-select: none;
  display: block;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

/* =========================================================================
   LOADING STATES
   ========================================================================= */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--graiph-overlay, rgba(20, 20, 24, 0.9));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 10;
}

.loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

.loading-overlay p {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

.list-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--graiph-overlay, rgba(20, 20, 24, 0.9));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: var(--radius-md);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-color);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.inline-spinner {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

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

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state svg {
  font-size: 48px;
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* =========================================================================
   RIGHT PANEL
   ========================================================================= */
.right-panel {
  width: var(--right-panel-width);
  background-color: var(--bg-primary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.right-panel.collapsed {
  width: var(--right-panel-collapsed-width);
  min-width: 0;
  border-left: none;
  overflow: hidden;
}

.panel-tabs-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.panel-tabs {
  display: flex;
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-behavior: smooth;
}

.panel-tabs::-webkit-scrollbar {
  display: none;
}

.tab-item {
  flex: 0 0 auto;
  min-width: 90px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tab-item:hover {
  background-color: var(--bg-tertiary);
}

.tab-item input[type="radio"] {
  display: none;
}

.tab-item input:checked + * {
  color: var(--graiph-accent-text);
}

.tab-item:has(input:checked) {
  color: var(--graiph-accent-text);
  border-bottom-color: var(--primary-color);
  background-color: var(--bg-primary);
}

.tab-scroll-btn {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 0;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 46px;
  width: 32px;
  flex-shrink: 0;
  transition: all 0.2s ease;
  z-index: 2;
}

.tab-scroll-btn:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.tab-scroll-btn:active {
  background-color: var(--bg-tertiary);
}

.tab-scroll-left {
  border-right: none;
  border-radius: 0;
}

.tab-scroll-right {
  border-left: none;
  border-radius: 0;
}

.tab-scroll-btn svg {
  font-size: 12px;
  width: 12px;
  height: 12px;
}

.panel-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* =========================================================================
   NOTIFICATIONS
   ========================================================================= */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  min-width: 300px;
  animation: slideIn 0.3s ease;
}

.notification-info {
  background-color: var(--primary-color);
  color: var(--graiph-accent-ink);
}

.notification-success {
  background-color: var(--success-color);
  color: var(--graiph-accent-ink);
}

.notification-warning {
  background-color: var(--warning-color);
  color: white;
}

.notification-error {
  background-color: var(--danger-color);
  color: white;
}

.notification-close {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 4px;
  margin-left: auto;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
/* =========================================================================
   METADATA MODE
   ========================================================================= */

.metadata-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.metadata-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.metadata-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 16px;
}

.stat-item {
  text-align: center;
  padding: 8px;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.field-group {
  margin-bottom: 20px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.field-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background-color: var(--bg-accent);
  cursor: pointer;
  transition: all 0.2s ease;
}

.field-group-header:hover {
  background-color: var(--bg-tertiary);
}

.field-group-header h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.field-group-header h4 svg {
  color: var(--graiph-accent-text);
  font-size: 14px;
}

.toggle-icon {
  color: var(--text-secondary);
  transition: transform 0.2s ease;
  font-size: 12px;
}

.field-group-header.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

.field-group-content {
  padding: 16px;
  background-color: var(--bg-primary);
  border-top: 1px solid var(--border-color);
}

/* Metadata Main Section Container */
.metadata-main-section > .field-group-content {
  padding: 8px;
}

/* Metadata Subsections */
.metadata-subsection {
  margin-bottom: 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.metadata-subsection:last-child {
  margin-bottom: 0;
}

.metadata-subsection > .field-group-header {
  background-color: var(--bg-secondary);
  padding: 10px 14px;
}

.metadata-subsection > .field-group-header h4 {
  font-size: 12px;
  font-weight: 500;
}

.metadata-subsection > .field-group-content {
  padding: 12px;
  background-color: var(--bg-primary);
}

/* Hidden Fields List */
.hidden-fields-list {
  padding: 8px;
  background-color: var(--bg-accent);
  border-radius: var(--radius-sm);
}

.hidden-fields-note {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  margin-bottom: 8px;
}

.hidden-field-names {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.hidden-field-tag {
  display: inline-block;
  padding: 3px 8px;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

/* Subsection Header Styling */
.subsection-header {
  background-color: var(--bg-secondary);
}

.subsection-header h4 {
  font-size: 12px;
  color: var(--text-secondary);
}

.subsection-header h4 svg {
  font-size: 11px;
  color: var(--secondary-color);
}

/* =========================================================================
   GEOLOGICAL LABELS - UNIFIED ROW LAYOUT
   ========================================================================= */

.labels-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}

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

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 500;
  color: white;
}

.status-indicator svg {
  font-size: 8px;
}

.ai-model-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-secondary);
}

.status-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-select {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.status-select option {
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

/* Column headers */
.labels-header-row {
  display: grid;
  grid-template-columns: 1.5fr 80px 1fr;
  gap: 8px;
  padding: 8px 12px;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.labels-header-field {
  text-align: left;
}

.labels-header-ai,
.labels-header-user {
  text-align: center;
}

.labels-header-ai svg,
.labels-header-user svg {
  margin-right: 4px;
}

/* Unified field rows */
.labels-unified-fields {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}

.labels-field-row {
  display: grid;
  grid-template-columns: 1.5fr 80px 1fr;
  gap: 8px;
  padding: 8px 10px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  align-items: center;
  min-height: 38px;
}

.labels-field-row:hover {
  background-color: var(--bg-accent);
}

.labels-field-row.has-difference {
  background-color: rgba(255, 193, 7, 0.1);
  border-left: 3px solid var(--warning-color);
}

.labels-field-row.has-disagreement {
  background-color: rgba(255, 87, 34, 0.08);
  border-left: 3px solid #FF5722;
}

/* Other annotators' read-only values */
.labels-other-value { font-size: 11px; color: var(--text-secondary); }
.labels-other-value .no-value { color: var(--text-muted); }
.labels-other-value.value-differs { color: #FF9800; font-weight: 500; }

/* Annotations toggle */
.annotations-toggle-bar { padding: 4px 0; margin-bottom: 4px; }
.annotation-count-badge {
  background: var(--accent-primary, #33CC66);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  margin-left: 6px;
}

/* Consensus builder section */
.consensus-section { margin-top: 8px; }
.consensus-resolved-badge {
  background: #33CC66;
  color: #000;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 6px;
}

.consensus-field-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border-color);
}

.consensus-field-name {
  flex: 0 0 110px;
  font-size: 11px;
  color: var(--text-secondary);
}

.consensus-options {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
}

.consensus-option {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 10px;
  cursor: pointer;
  background: transparent;
}

.consensus-option:hover { background: rgba(255, 255, 255, 0.05); }
.consensus-option.selected {
  border-color: var(--accent-primary, #33CC66);
  background: rgba(51, 204, 102, 0.1);
}

.consensus-option input[type="radio"] {
  width: 12px;
  height: 12px;
  margin: 0;
}

.consensus-source-label {
  font-weight: 600;
  color: var(--text-secondary);
}

.consensus-source-value {
  color: var(--text-primary);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.labels-field-name {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.field-label-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-word;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
}

.field-info-icon {
  font-size: 10px;
  color: var(--text-muted);
  cursor: help;
  flex-shrink: 0;
  opacity: 0.6;
  position: relative;
}

.field-info-icon:hover {
  opacity: 1;
  color: var(--graiph-accent-text);
}

/* Tooltip container */
.field-name-with-tooltip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

/* Custom tooltip */
.field-tooltip {
  position: relative;
  display: inline-flex;
}

.field-tooltip .tooltip-text {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  z-index: 1000;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 200px;
  max-width: 280px;
  padding: 8px 10px;
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 11px;
  line-height: 1.4;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  white-space: pre-line;
  text-align: left;
  transition: opacity 0.2s, visibility 0.2s;
}

.field-tooltip .tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: var(--border-color) transparent transparent transparent;
}

.field-tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* Position tooltip to the right if near left edge */
.field-tooltip.tooltip-right .tooltip-text {
  left: 0;
  transform: translateX(0);
}

.field-tooltip.tooltip-right .tooltip-text::after {
  left: 15px;
}

.labels-ai-value {
  text-align: center;
  font-size: 11px;
  color: var(--text-secondary);
  word-break: break-word;
  line-height: 1.3;
}

.labels-ai-value .no-value {
  color: var(--text-muted);
}

.labels-ai-value .option-value {
  font-size: 11px;
}

.labels-ai-value .complex-value {
  font-size: 10px;
  color: var(--text-muted);
  cursor: help;
}

.labels-user-value {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Base style for all small form inputs */
.form-input-sm {
  padding: 5px 6px;
  font-size: 11px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

.form-input-sm option {
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

.labels-user-value .form-input-sm {
  width: 100%;
}

.labels-user-value select.form-input-sm {
  padding-right: 20px;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 4px center;
  background-repeat: no-repeat;
  background-size: 16px 12px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.labels-user-value .form-input-sm:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(51, 204, 102, 0.1);
}

/* Color display */
.color-value {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.color-code {
  font-size: 10px;
}

.color-swatch {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.color-swatch-tiny {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid var(--border-color);
  display: inline-block;
  vertical-align: middle;
  margin-right: 4px;
}

/* Color selector with preview */
.color-selector-with-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.color-preview-swatch {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.color-select-input {
  flex: 1;
  min-width: 0;
}

/* Nested object sections (micro_defects, etc.) */
.nested-object-section {
  margin-top: 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.nested-object-header {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.nested-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.nested-title svg {
  margin-right: 6px;
  color: var(--secondary-color);
}

.nested-object-content {
  padding: 8px;
  background-color: var(--bg-primary);
}

.nested-toggle-row {
  background-color: var(--bg-accent);
  border-color: var(--primary-color);
}

.nested-field-row {
  margin-left: 12px;
  border-left: 2px solid var(--border-color);
}

.nested-conditional-fields {
  margin-top: 4px;
}

/* Toggle switch for booleans */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  transition: 0.3s;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: var(--graiph-text-primary);
  border-radius: 50%;
  transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--success-color);
  border-color: var(--success-color);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(16px);
}

/* Color selector inline */
.color-selector-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.color-selector-inline .form-input-sm {
  flex: 1;
  min-width: 0;
}

/* Array fields section */
.labels-array-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.array-field-container {
  margin-bottom: 16px;
}

.array-field-container:last-child {
  margin-bottom: 0;
}

.array-field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border: 1px solid var(--border-color);
  border-bottom: none;
}

.array-field-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.array-field-title svg {
  margin-right: 6px;
  color: var(--secondary-color);
}

.array-add-btn {
  padding: 4px 10px;
  font-size: 11px;
}

.array-field-content {
  padding: 12px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.array-section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.array-section-label svg {
  font-size: 10px;
}

.array-ai-items {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border-color);
}

.array-item-display {
  display: inline-block;
  margin: 2px 4px 2px 0;
}

.array-item-display.ai-item {
  opacity: 0.8;
}

.array-item-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-size: 11px;
  color: var(--text-secondary);
}

.array-item-type {
  font-weight: 600;
  color: var(--text-primary);
}

.array-item-content {
  color: var(--text-secondary);
}

.array-item-color {
  font-weight: 500;
}

.array-user-items {
  min-height: 40px;
}

.array-empty-message {
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
  padding: 8px;
  text-align: center;
}

.array-item-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  margin-bottom: 8px;
  background-color: var(--bg-accent);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.array-item-editor:last-child {
  margin-bottom: 0;
}

.array-item-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.array-item-index {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.array-delete-btn {
  padding: 4px 6px;
  color: var(--danger-color);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.array-delete-btn:hover {
  background-color: rgba(229, 57, 53, 0.1);
}

.array-item-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.array-field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.array-field-group.color-field-group {
  width: 100%;
}

.array-field-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
}

.array-item-fields .form-input-sm {
  width: 100%;
}

.array-field-row {
  display: flex;
  gap: 8px;
}

.array-field-row .array-field-group {
  flex: 1;
  min-width: 0;
}

/* Notes section */
.labels-notes-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.labels-notes-section .field-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.labels-notes-section .form-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 12px;
  resize: vertical;
  min-height: 60px;
}

/* Action buttons */
.labels-action-buttons {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  justify-content: flex-end;
}

.labels-action-buttons .btn {
  padding: 6px 12px;
  font-size: 12px;
}

/* Helper classes */
.text-success {
  color: var(--graiph-accent-text);
}

.btn-xs {
  padding: 4px 8px;
  font-size: 10px;
}

.btn-icon {
  padding: 4px 6px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.btn-icon:hover {
  background-color: var(--bg-tertiary);
}

/* Expand down behavior - keep scroll position stable */
.metadata-fields {
  display: flex;
  flex-direction: column;
}

.field-group {
  flex-shrink: 0;
}

/* Right panel scroll behavior */
#metadataContent {
  display: flex;
  flex-direction: column;
}

.field-group-content h5 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 12px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--bg-tertiary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.field-group-content h5 svg {
  color: var(--graiph-accent-text);
  font-size: 12px;
}

.field-group-content h6 {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 16px 0 8px 0;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--bg-tertiary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.field-group-content h6 svg {
  color: var(--graiph-accent-text);
  font-size: 11px;
}

.field-sub-group {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 12px;
  margin-top: 16px;
}

.field-sub-group h5 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.field-sub-group h6 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
  margin-top: 16px;
}

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

.field-item.readonly {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--bg-tertiary);
}

.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
  display: block;
}

.field-value {
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-word;
}

.depth-input {
  font-family: "Monaco", "Menlo", monospace;
}

kbd {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  font-size: 11px;
  padding: 2px 4px;
  margin-right: 6px;
  font-family: monospace;
}

.truncatedText {
  display: inline-block;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: all 0.2s ease;
}

.truncatedText:hover {
  background-color: var(--bg-secondary);
  padding: 2px 4px;
  border-radius: 4px;
}

.truncatedText.expanded {
  white-space: normal;
  max-width: none;
  overflow: visible;
  text-overflow: initial;
}

.info-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.4;
}

.info-card svg {
  color: var(--graiph-accent-text);
  margin-top: 2px;
  flex-shrink: 0;
}

.info-card strong {
  color: var(--text-primary);
}

.info-card small {
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.help-text {
  margin-top: 16px;
  padding: 12px;
  background-color: var(--graiph-accent-muted);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--primary-color);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.help-text svg {
  color: var(--graiph-accent-text);
  margin-top: 2px;
  flex-shrink: 0;
}

/* =========================================================================
   METADATA MODE ACTION BUTTON CONTAINERS
   ========================================================================= */

/* Background container for action buttons */
.metadata-actions-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.2s ease;
}

.metadata-actions-container:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Actions buttons styling */
.metadata-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.metadata-actions .btn {
  margin: 0;
  transition: all 0.2s ease;
}

.metadata-actions .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Fracture category section styling */
.fracture-category-section {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.fracture-category-section .field-item {
  margin-bottom: 12px;
}

.fracture-category-section .field-item:last-child {
  margin-bottom: 0;
}

/* Coordinate details styling */
.coordinate-details {
  background: var(--bg-accent);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 8px;
}

.coordinate-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 8px 0;
  font-family: "Monaco", "Menlo", monospace;
  font-size: 12px;
}

.coordinate-point {
  padding: 4px 8px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

/* Enhanced visual hierarchy for metadata mode */
.metadata-actions-container,
.field-sub-group,
.metadata-actions-container:focus-within,
.field-sub-group:focus-within,
.fracture-category-section:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(51, 204, 102, 0.1);
}

/* =========================================================================
   REEL MODE CONFIGURATIONS
   ========================================================================= */

/* Reel header styling */
.reel-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 20px;
}

.reel-header h3 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Labels section */
.reel-labels {
  margin-bottom: 20px;
}

.reel-labels h4 {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 12px;
  color: var(--text-primary);
}

/* Two-column checkbox grid */
.reel-checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
}

/* Button container with background box */
.reel-button-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
}

/* Navigation section styling */
.reel-navigation {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
}

/* Navigation header with segment info and auto zoom */
.navigation-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  gap: 16px;
}

.segment-info {
  flex: 1;
}

.segment-info label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: block;
}

.segment-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.segment-controls input {
  width: 60px;
  padding: 4px 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  text-align: center;
  font-size: 13px;
}

/* Auto zoom wrapper + intensity controls */
.auto-zoom-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.auto-zoom-control {
  flex-shrink: 0;
  font-size: 13px;
  margin: 0;
  padding: 4px 0;
}

.zoom-intensity-value {
  font-size: 11px;
  color: var(--text-muted, #888);
  margin-left: 4px;
}

.zoom-intensity-row {
  padding: 0 2px;
}

.zoom-intensity-row.hidden {
  display: none;
}

.zoom-intensity-slider {
  width: 100px;
  height: 4px;
  cursor: pointer;
  accent-color: var(--accent-primary, #33CC66);
}

/* Navigation buttons container */
.navigation-buttons-container {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.navigation-buttons {
  display: flex;
  gap: 8px;
}

.navigation-buttons .btn {
  flex: 1;
  justify-content: center;
}

/* Segment actions with background */
.segment-actions {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  min-height: 60px;
}

/* Enhanced reel actions styling */
.reel-actions {
  padding: 0;
}

.reel-actions h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Button styling improvements */
.reel-actions .btn {
  margin-bottom: 8px;
}

.reel-actions .btn:last-child {
  margin-bottom: 0;
}

/* Split actions container */
.split-actions {
  display: flex;
  gap: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.split-actions button {
  flex: 1;
}

/* Enhanced quick fields */
.quick-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.quick-field label {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  margin: 0;
}

.quick-field input,
.quick-field select {
  flex: 1;
  padding: 4px 8px;
  min-width: 0;
}

/* Enhanced quick flags */
.quick-flags {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin: 12px 0;
  padding: 12px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .reel-checkbox-grid {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .navigation-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .auto-zoom-wrapper {
    align-self: flex-start;
  }

  .segment-controls {
    justify-content: center;
  }
}

/* Enhanced visual hierarchy */
.reel-button-container,
.reel-navigation,
.segment-actions {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.2s ease;
}

.reel-button-container:hover,
.reel-navigation:hover,
.segment-actions:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* =========================================================================
   MODELS MODE CONFIGURATIONS
   ========================================================================= */
/* Collapsible section styles for Models tab */
.collapsible-section {
  margin-bottom: 16px;
}

.section-toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.section-toggle-btn:hover {
  background: var(--bg-primary);
  border-color: var(--primary-color);
}

.section-toggle-btn svg[data-lucide="chevron-right"],
.section-toggle-btn svg[data-lucide="chevron-down"] {
  width: 14px;
  height: 14px;
  pointer-events: none;
  transition: transform 0.3s ease;
  color: var(--text-secondary);
}

.section-toggle-btn:not(.collapsed) svg[data-lucide="chevron-right"] {
  transform: rotate(90deg);
}

.section-toggle-btn span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.collapsible-content {
  overflow: hidden;
  max-height: 2000px;
  transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
  margin-top: 16px;
  opacity: 1;
}

.collapsible-content.collapsed {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
}

.collapsible-content .models-header {
  margin-bottom: 20px;
}

.collapsible-content .models-header p {
  margin-top: 0;
}

.models-header {
  margin-bottom: 24px;
}

.models-header h3 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.models-description {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}

.models-config {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
}

.models-config h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.models-actions {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
}

.models-actions h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.models-actions .btn-full {
  margin-bottom: 8px;
}

.action-hint {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  margin-bottom: 12px;
}

.action-hint svg {
  margin-right: 4px;
}

.models-info {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
}

.models-info h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.models-info p {
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.models-info ul {
  margin: 0;
  padding-left: 20px;
  list-style-type: disc;
}

.models-info li {
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

/* Segmentation Models Section Styles */
.segmentation-warning {
  background: rgba(33, 150, 243, 0.1);
  border: 1px solid var(--primary-color);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--text-primary);
}

.segmentation-warning svg {
  color: var(--graiph-accent-text);
  margin-top: 2px;
  flex-shrink: 0;
}

.segmentation-warning strong {
  display: block;
  margin-bottom: 4px;
}

.segmentation-models {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 20px;
}

.model-section {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: all 0.2s ease;
}

.model-section:hover {
  background: rgba(255, 255, 255, 0.05);
}

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

.model-header h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.model-header h4 svg {
  font-size: 14px;
  opacity: 0.8;
}

.model-checkbox {
  margin: 0;
  font-size: 12px;
}

.model-description {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.4;
  margin: 8px 0 12px 0;
}

.granulometry-options {
  margin: 12px 0;
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.granulometry-options .checkbox-item {
  margin: 0;
  font-size: 13px;
}

.granulometry-options .field-hint {
  display: block;
  margin-top: 6px;
  margin-left: 28px;
  font-size: 11px;
}

/* =========================================================================
   UTILS SECTION STYLES
   ========================================================================= */

/* Utils Header */
.utils-header {
  margin-bottom: 20px;
}

.utils-header h3 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.utils-description {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 16px 0;
  line-height: 1.5;
}

/* Utils Operations Container */
.utils-operations {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 20px;
}

/* Individual Util Section */
.util-section {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: all 0.2s ease;
}

.util-section:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

/* Util Header */
.util-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--bg-secondary);
}

.util-header h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.util-header h4 svg {
  font-size: 14px;
  color: var(--graiph-accent-text);
  opacity: 0.9;
}

/* Util Description */
.util-description {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  margin: 12px 0 16px 0;
}

/* Util Config */
.util-config {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.util-config .field-item {
  margin-bottom: 16px;
}

.util-config .field-item:last-child {
  margin-bottom: 0;
}

/* Field Hint (General Style) */
.field-hint {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

.checkbox-item + .field-hint {
  margin-left: 0;
  margin-top: 4px;
}

/* Util Buttons */
.util-section .btn-full {
  margin-top: 4px;
}

/* Utils Checkbox Grid Spacing */
.util-config .checkbox-grid {
  margin-top: 8px;
  gap: 8px;
}

.util-config .checkbox-grid .checkbox-item {
  padding: 8px 12px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.util-config .checkbox-grid .checkbox-item:hover {
  background: var(--bg-tertiary);
}

/* Input fields in util-config */
.util-config .form-input {
  width: 100%;
}

/* Spacing adjustments for better layout */
.util-config .field-label {
  font-weight: 600;
  margin-bottom: 8px;
}

.api-status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
}

.api-status-indicator svg {
  font-size: 8px;
}

.api-status-indicator.available {
  background: rgba(51, 204, 102, 0.1);
  border: 1px solid rgba(51, 204, 102, 0.3);
  color: #4caf50;
}

.api-status-indicator.available svg {
  color: #4caf50;
}

.api-status-indicator.unavailable {
  background: rgba(229, 57, 53, 0.1);
  border: 1px solid rgba(229, 57, 53, 0.3);
  color: #f44336;
}

.api-status-indicator.unavailable svg {
  color: #f44336;
}

.api-status-indicator.checking {
  background: rgba(245, 166, 35, 0.1);
  border: 1px solid rgba(245, 166, 35, 0.3);
  color: var(--warning-color);
}

.api-status-indicator.checking svg {
  color: var(--warning-color);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* Pipeline Section Styles */
.pipeline-divider {
  height: 1px;
  background: var(--border-color);
  margin: 32px 0;
}

.pipeline-header {
  margin-bottom: 20px;
}

.pipeline-header h3 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.pipeline-description {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}

.pipeline-warning {
  background: rgba(245, 166, 35, 0.15);
  border: 1px solid var(--graiph-alert-warning);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--graiph-alert-warning);
}

.pipeline-warning svg {
  margin-top: 2px;
  flex-shrink: 0;
}

.pipeline-warning strong {
  display: block;
  margin-bottom: 4px;
}

.pipeline-config {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
}

.pipeline-config h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.pipeline-options {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
}

.pipeline-options h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.pipeline-steps-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}

.pipeline-advanced {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
}

.pipeline-advanced-section {
  margin-top: 8px;
  padding: 12px;
  background: var(--bg-accent);
  border-radius: 6px;
}

.advanced-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  padding: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s ease;
}

.advanced-toggle:hover {
  color: var(--graiph-accent-text);
}

.advanced-toggle svg {
  transition: transform 0.3s ease;
}

.advanced-options-content {
  margin-top: 16px;
  overflow: hidden;
  max-height: 1000px;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}

.advanced-options-content.collapsed {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
}

.advanced-params-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}

.param-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.param-item label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.param-item input {
  padding: 6px 8px;
  font-size: 13px;
}

.pipeline-actions {
  margin-top: 20px;
}

.btn-lg {
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 600;
}

.btn-lg svg {
  font-size: 16px;
}

/* Responsive adjustments for pipeline */
@media (max-width: 768px) {
  .pipeline-steps-grid,
  .advanced-params-grid {
    grid-template-columns: 1fr;
  }
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* =========================================================================
   SHARED MODAL BASE STYLES
   ========================================================================= */

/* Base overlay styles (shared by all modals) */
.base-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease-out;
}

/* Base modal container styles */
.base-modal {
  background: var(--bg-primary);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.3s ease-out;
}

/* Base modal header with gradient */
.base-modal-header-gradient {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--graiph-border);
  background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 100%);
  border-radius: 12px 12px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.base-modal-header-gradient h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Base close button for gradient headers */
.base-modal-close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.base-modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Base modal body */
.base-modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
}

/* Base modal footer */
.base-modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--graiph-border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: var(--graiph-bg-secondary);
  border-radius: 0 0 12px 12px;
}

/* Base progress bar styles */
.base-progress-bar-container {
  height: 8px;
  background: var(--graiph-bg-elevated);
  border-radius: 4px;
  overflow: hidden;
}

.base-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--graiph-accent) 0%, var(--graiph-accent-hover) 100%);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.base-progress-bar.success {
  background: var(--success-color);
}

.base-progress-bar.error {
  background: var(--danger-color);
}

.saved-results-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.saved-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  transition: all 0.2s;
}

.saved-result-item:hover {
  background: var(--bg-hover);
  transform: translateX(2px);
}

.result-info {
  flex: 1;
}

.result-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.result-meta {
  font-size: 12px;
  color: var(--text-secondary);
}

.saved-result-item .load-btn {
  white-space: nowrap;
}

.tray-selection-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tray-selection-controls .btn {
  flex: 1;
}

.tray-selection-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tray-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.2s ease;
  font-size: 13px;
}

.tray-item:hover {
  background-color: var(--bg-tertiary);
}

.tray-item input[type="checkbox"] {
  display: none;
}

.tray-item .checkmark {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-radius: 3px;
  position: relative;
  background-color: var(--bg-primary);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.tray-item input:checked + .checkmark {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

.tray-item input:checked + .checkmark::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -60%) rotate(45deg);
}

.tray-name {
  font-weight: 500;
  color: var(--text-primary);
}

.tray-depth {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

.image-cell {
  width: 120px;
  padding: 4px;
}

.segment-image {
  width: 100%;
  max-width: 120px;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-primary);
}

.class-intactrock {
  color: var(--danger-color);
  font-weight: 600;
}

.class-grinding {
  color: #9333ea;
  font-weight: 600;
}

.class-depthblock {
  color: var(--graiph-alert-info);
  font-weight: 600;
}

.class-falsedepthblock {
  color: #eab308;
  font-weight: 600;
}

.scrollable-trays-container {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  margin-bottom: 24px;
}

.scrollable-tray-list {
  padding: 8px;
}

/* FIXED: Tray checkbox centering - corrected alignment */
.tray-checkbox-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  margin: 0;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background-color 0.2s ease;
  font-size: 13px;
}

.tray-checkbox-item:hover {
  background-color: var(--bg-accent);
}

.tray-checkbox-item input[type="checkbox"] {
  display: none;
}

/* FIXED: Centered checkmark for tray selection */
.tray-checkbox-item .checkmark {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-radius: 3px;
  position: relative;
  background: var(--bg-primary);
  flex-shrink: 0;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tray-checkbox-item input[type="checkbox"]:checked + .checkmark {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

/* FIXED: Properly centered checkmark */
.tray-checkbox-item input[type="checkbox"]:checked + .checkmark::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -60%) rotate(45deg);
}

.tray-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.form-section {
  margin-bottom: 20px;
}

.form-section h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.plotly .legend {
  font-size: 14px !important;
  max-height: 250px !important;
  overflow-y: auto !important;
  overflow-x: auto !important;
  background: var(--graiph-bg-surface) !important;
  border: 1px solid var(--graiph-border) !important;
  border-radius: 4px !important;
  padding: 4px !important;
}

.plotly .legend .traces .legendtext {
  font-size: 14px !important;
}

.plotly .legend .traces .legendpoints .scatterpts .point {
  stroke-width: 4px !important;
}

.selected-segments-container {
  margin-top: 16px;
}

.selected-segments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 8px 0;
}

.segment-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.segment-card:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* NEW: Clicked point styling */
.segment-card.clicked-point {
  border-color: var(--success-color);
  background: linear-gradient(
    135deg,
    rgba(51, 204, 102, 0.05),
    rgba(51, 204, 102, 0.1)
  );
  box-shadow: 0 4px 12px rgba(51, 204, 102, 0.2);
}

.segment-card.clicked-point:hover {
  border-color: var(--success-hover);
  box-shadow: 0 6px 16px rgba(51, 204, 102, 0.3);
}

/* NEW: Loading state for segment cards */
.segment-card.loading {
  opacity: 0.8;
  pointer-events: none;
}

.segment-card.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.segment-label {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.segment-label.intactrock {
  background-color: var(--danger-color);
}

.segment-label.grinding {
  background-color: #9333ea;
}

.segment-tray {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.segment-content {
  margin-bottom: 8px;
}

.segment-alias {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 13px;
  margin-bottom: 4px;
}

.segment-details {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.segment-image:hover {
  transform: scale(1.02);
}

.segment-image-placeholder {
  width: 100%;
  height: 60px;
  background: var(--bg-tertiary);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 8px;
}

.plotly .gtitle {
  font-size: 16px !important;
  font-weight: 600 !important;
}

.plotly-graph-div {
  overflow: hidden !important;
}

.plotly .colorbar {
  font-size: 10px !important;
}

.plotly .colorbar .cbarnumber {
  font-size: 9px !important;
}

/* =========================================================================
   SCROLLBAR STYLING
   ========================================================================= */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* =========================================================================
   RESPONSIVE DESIGN
   ========================================================================= */
@media (max-width: 1400px) {
  :root {
    --sidebar-width: 280px;
    --right-panel-width: 350px;
  }
}

@media (max-width: 1200px) {
  :root {
    --sidebar-width: 260px;
    --right-panel-width: 320px;
  }

  .sidebar .section-content {
    padding: 16px;
  }

  .panel-content {
    padding: 16px;
  }

  .image-cell {
    width: 100px;
  }
}

@media (max-width: 768px) {
  /* Keep the canvas full-area; the side panels become slide-in overlays rather
     than stacked blocks, so the image always fills the viewport (stacking them
     in a column squeezed the canvas to ~0 height — the image vanished). The
     header's panel toggles slide them in/out via the existing .collapsed class;
     JS defaults both to collapsed on phones (see initPanelToggles). */
  .main-content {
    flex-direction: row;
    position: relative;
  }

  .canvas-area { min-width: 0; }
  .canvas-container { flex: 1; min-width: 0; }

  .sidebar,
  .right-panel {
    position: absolute;
    top: 0;
    bottom: 0;
    height: auto;
    z-index: 60;
    width: min(86vw, 320px);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar {
    left: 0;
    border-right: 1px solid var(--border-color);
    transform: translateX(-100%);
  }
  .right-panel {
    right: 0;
    border-left: 1px solid var(--border-color);
    transform: translateX(100%);
  }
  /* Open state slides the panel in over the canvas. */
  .sidebar:not(.collapsed) { transform: translateX(0); }
  .right-panel:not(.collapsed) { transform: translateX(0); }
  /* Collapsed panels keep full width so they sit fully off-canvas (override the
     desktop collapsed-width rule, which would leave a sliver peeking in). */
  .sidebar.collapsed,
  .right-panel.collapsed { width: min(86vw, 320px); }

  .canvas-toolbar {
    flex-direction: column;
    height: auto;
    padding: 8px;
    gap: 8px;
  }

  .toolbar-left,
  .toolbar-center,
  .toolbar-right {
    width: 100%;
    justify-content: center;
  }

  .tab-item {
    min-width: 80px;
    font-size: 11px;
    padding: 10px 12px;
  }

  .tab-scroll-btn {
    width: 28px;
    height: 42px;
  }

  /* Report responsive */
  .image-cell {
    width: 80px;
  }

  .tray-selection-controls {
    flex-direction: column;
  }

  /* 3D Mode responsive */

  .scrollable-trays-container {
    max-height: 150px;
  }
}

/* =========================================================================
   User Section Styles - Add this to styles.css
   ========================================================================= */

/* User section at bottom of left sidebar */
.user-section {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  background: var(--sidebar-bg);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  background: var(--background-secondary);
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--primary-color);
  color: var(--graiph-accent-ink);
  border-radius: 50%;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.user-details {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
  flex: 1;
}

.user-email {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-status {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.btn-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid #dc3545;
  background: #dc3545;
  color: white;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-logout:hover {
  background: #c82333;
  border-color: #c82333;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(229, 57, 53, 0.2);
}

.btn-logout:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(229, 57, 53, 0.2);
}

.btn-logout:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-logout:disabled:hover {
  background: #dc3545;
  border-color: #dc3545;
  transform: none;
  box-shadow: none;
}

.btn-logout svg {
  font-size: 0.875rem;
}

/* Ensure left sidebar has proper flex layout for user section positioning */
.sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Make sure the sidebar sections area can grow to push user section to bottom */
.sidebar > .sidebar-section:not(.user-section) {
  flex-shrink: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .user-section {
    padding: 0.75rem;
  }

  .user-info {
    padding: 0.375rem;
    margin-bottom: 0.5rem;
  }

  .user-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
  }

  .user-email {
    font-size: 0.8125rem;
  }

  .user-status {
    font-size: 0.6875rem;
  }

  .btn-logout {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
  }
}

/* Dark mode adjustments if you have dark mode support */
@media (prefers-color-scheme: dark) {
  .user-section {
    border-top-color: rgba(255, 255, 255, 0.1);
  }

  .user-info {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
  }

  .user-avatar {
    background: var(--primary-color);
  }
}

/* 3D Mode CSS v3*/

/* Custom Axis Container */
.custom-axis-container {
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 12px;
}

.custom-axis-container .form-group {
  margin-bottom: 12px;
}

.custom-axis-container .form-group:last-child {
  margin-bottom: 0;
}

.custom-axis-container label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
  display: block;
}

.custom-axis-container select {
  width: 100%;
  padding: 6px 8px;
  font-size: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
}

.filter-container {
  margin-bottom: 16px;
}

.filter-section {
  background: var(--bg-accent);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.filter-section h5 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.numerical-filters-section {
  background: var(--bg-accent);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

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

.filter-section-header h5 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.numerical-filter-item {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 12px;
  position: relative;
}

.numerical-filter-item:last-child {
  margin-bottom: 0;
}

.filter-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  position: relative;
}

.filter-delete-btn {
  position: absolute;
  top: 4px;
  right: 0px;
  width: 24px;
  height: 24px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 10px;
  background: rgb(255, 255, 255) !important;
  color: rgb(0, 0, 0) !important;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.filter-delete-btn:hover {
  background: var(--danger-color) !important;
  transform: scale(1.1);
}

.filter-controls {
  transition: opacity 0.2s ease;
}

.filter-controls .form-group {
  margin-bottom: 12px;
}

.filter-controls .form-group:last-child {
  margin-bottom: 0;
}

.filter-controls label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
  display: block;
}

.filter-controls select,
.filter-controls input[type="number"] {
  width: 100%;
  padding: 6px 8px;
  font-size: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
}

.filter-controls small {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 4px;
  display: block;
}

.categorical-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin: 0;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background-color 0.2s ease;
  font-size: 13px;
}

.filter-checkbox-item:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.filter-checkbox-item input[type="checkbox"] {
  display: none;
}

.filter-checkbox-item .checkmark {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-color);
  border-radius: 3px;
  position: relative;
  background: var(--bg-primary);
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.filter-checkbox-item input[type="checkbox"]:checked + .checkmark {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.filter-checkbox-item input[type="checkbox"]:checked + .checkmark::after {
  content: "✓";
  position: absolute;
  top: -2px;
  left: 1px;
  color: white;
  font-size: 10px;
  font-weight: bold;
}

.shape-indicator {
  width: 18px;
  height: 18px;
  display: inline-block;
  flex-shrink: 0;
  position: relative;
  box-sizing: border-box;
}

.shape-indicator[data-shape="circle"] {
  border: 4px solid #000000;
  border-radius: 50%;
  background: transparent !important;
}

.shape-indicator[data-shape="square"] {
  border: 4px solid #000000;
  border-radius: 2px;
  background: transparent !important;
}

.shape-indicator[data-shape="diamond"] {
  border: 4px solid #000000;
  transform: rotate(45deg);
  border-radius: 2px;
  background: transparent !important;
}

.color-indicator {
  width: 18px;
  height: 18px;
  display: inline-block;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid #000000;
}

.selected-segments {
  margin-top: 20px;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

.empty-state p {
  margin: 0;
  font-size: 14px;
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-color);
}

@media (max-width: 768px) {
  .categorical-filters {
    gap: 6px;
  }

  .filter-checkbox-item {
    padding: 4px 6px;
    font-size: 12px;
  }

  .shape-indicator,
  .color-indicator {
    width: 18px;
    height: 18px;
  }

  .color-indicator {
    border-width: 2px;
  }

  .shape-indicator[data-shape="circle"],
  .shape-indicator[data-shape="square"],
  .shape-indicator[data-shape="diamond"] {
    border-width: 3px;
  }

  .custom-axis-container {
    padding: 8px;
  }

  .custom-axis-container .form-group {
    margin-bottom: 8px;
  }

  .filter-section,
  .numerical-filters-section {
    padding: 12px;
  }

  .filter-section-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .numerical-filter-item {
    padding: 8px;
    padding-top: 16px;
  }

  .filter-header {
    margin-bottom: 8px;
  }

  .filter-delete-btn {
    top: 4px;
    right: 4px;
  }
}

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

.filter-checkbox-item input[type="checkbox"]:focus + .checkmark {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.filter-checkbox-item:focus-within {
  background-color: rgba(0, 0, 0, 0.1);
}

.numerical-filters-section:empty {
  display: none;
}

/* Back to 3D button styles */
.back-to-3d-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--primary-hover)
  );
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
}

.back-to-3d-btn:before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.5s ease;
}

.back-to-3d-btn:hover {
  background: linear-gradient(
    135deg,
    var(--primary-hover),
    var(--primary-color)
  );
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

.back-to-3d-btn:hover:before {
  left: 100%;
}

.back-to-3d-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.back-to-3d-btn svg {
  font-size: 12px;
  transition: transform 0.2s ease;
}

.back-to-3d-btn:hover svg {
  transform: translateX(-2px);
}

/* Enhanced segment card styling */

.segment-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, transparent, rgba(51, 204, 102, 0.05));
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.segment-card:hover::before {
  opacity: 1;
}

.segment-card.clicked-point::before {
  background: linear-gradient(
    135deg,
    rgba(255, 107, 53, 0.1),
    rgba(255, 107, 53, 0.05)
  );
  opacity: 1;
}

/* Enhanced segment image styling for better interaction feedback */

.segment-image:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.segment-card.clicked-point .segment-image {
  border: 2px solid var(--success-color);
  box-shadow: 0 0 0 3px rgba(51, 204, 102, 0.2);
}

/* Loading overlay for segment navigation */
.segment-navigation-loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}

.segment-navigation-loading .spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Enhanced toolbar styling to accommodate back button */
.toolbar-left {
  gap: 12px;
}

.toolbar-left .back-to-3d-btn {
  margin-right: 8px;
  border-right: 1px solid rgba(255, 255, 255, 0.2);
  padding-right: 16px;
}

/* Animation for button appearance */
@keyframes slideInFromLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.back-to-3d-btn {
  animation: slideInFromLeft 0.3s ease-out;
}

/* Notification styling for segment navigation */
.notification.segment-navigation {
  background: linear-gradient(135deg, var(--info-color), var(--info-hover));
  border: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.notification.segment-navigation svg {
  color: white;
  font-size: 16px;
}

.segment-label.depthblock {
  background-color: var(--info-color);
}

.segment-label.falsedepthblock {
  background-color: var(--warning-color);
}

.segment-label.fracture {
  background-color: #06b6d4;
}

.segment-label.emptygutter {
  background-color: var(--success-color);
}

.segment-label.smallrock {
  background-color: var(--secondary-color);
}

.segment-label.exposedrock {
  background-color: var(--warning-color);
}

.segment-image-placeholder:hover {
  background: var(--bg-secondary);
  border-color: var(--primary-color);
}

/* Canvas zoom animation enhancement */
.canvas-container {
  transition: transform 0.3s ease-out;
}

.canvas-container.zooming {
  transform: scale(0.98);
}

/* Enhanced segment details */
.segment-details small {
  display: block;
  margin-bottom: 2px;
}

/* Enhanced segment grid scrollbar */
.selected-segments-grid::-webkit-scrollbar {
  width: 6px;
}

.selected-segments-grid::-webkit-scrollbar-track {
  background: var(--bg-accent);
  border-radius: var(--radius-sm);
}

.selected-segments-grid::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-sm);
}

.selected-segments-grid::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Enhanced segment card hover effects */

.segment-card:hover .segment-image {
  transform: scale(1.02);
}

.segment-card:hover .segment-label {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Navigation success states */
.navigation-success {
  background: linear-gradient(
    135deg,
    var(--success-color),
    var(--success-hover)
  );
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  margin: 8px 0;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.navigation-success svg {
  font-size: 14px;
}

/* Responsive design for mobile devices */
@media (max-width: 768px) {
  .back-to-3d-btn {
    padding: 6px 12px;
    font-size: 12px;
  }

  .back-to-3d-btn span {
    display: none;
  }

  .toolbar-left .back-to-3d-btn {
    margin-right: 4px;
    padding-right: 12px;
  }
}

/* Focus states for accessibility */
.back-to-3d-btn:focus,
.segment-card:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .back-to-3d-btn {
    border: 2px solid var(--text-primary);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .back-to-3d-btn,
  .segment-card,
  .segment-image,
  .canvas-container {
    transition: none;
  }

  .back-to-3d-btn {
    animation: none;
  }
}

/* Dark mode enhancements */
@media (prefers-color-scheme: dark) {
  .back-to-3d-btn {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  }

  .segment-navigation-loading {
    background: rgba(0, 0, 0, 0.8);
  }
}

/* =========================================================================
   Polygon Operations CSS Styles
   ========================================================================= */

/* Operation Dialog Styles */
.operation-dialog {
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  margin: 10px 0;
  overflow: hidden;
  animation: slideIn 0.2s ease-out;
}

.operation-header {
  background: var(--bg-accent);
  padding: 12px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.operation-header h4 {
  margin: 0;
  color: var(--text-primary);
  font-size: 16px;
}

.cancel-operation-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.cancel-operation-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.operation-content {
  padding: 15px;
}

.operation-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.operation-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.operation-form label {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 14px;
}

.operation-form .form-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color 0.2s ease;
}

.operation-form .form-input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(51, 204, 102, 0.2);
}

.operation-form small {
  color: var(--text-secondary);
  font-size: 12px;
  margin-top: 2px;
}

.operation-actions {
  padding: 15px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.execute-operation-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Selection Status Styles */
.selection-status {
  text-align: center;
  margin-bottom: 15px;
}

.selection-status p {
  margin: 5px 0;
  color: var(--text-primary);
}

.selection-status .instruction {
  color: var(--graiph-accent-text);
  font-weight: 500;
  font-style: italic;
}

.selected-polygon-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.polygon-preview {
  background: var(--bg-accent);
  padding: 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  font-size: 14px;
  transition: all 0.2s ease;
}

.polygon-preview:not([style*="display: none"]) {
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Polygon Operations Section Styles */
.polygon-operations-section {
  padding: 0;
}

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

.operation-buttons .btn {
  justify-content: flex-start;
  text-align: left;
  transition: all 0.2s ease;
}

.operation-buttons .btn:hover {
  transform: translateX(2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.operation-buttons .btn svg {
  margin-right: 8px;
  width: 16px;
  text-align: center;
}

.operation-help {
  display: block;
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--bg-accent);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 12px;
  border-left: 3px solid var(--accent-color);
}

.operation-help svg {
  margin-right: 6px;
}

/* Reel Mode Polygon Operations Styles */
.reel-polygon-operations {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--border-color);
}

.reel-polygon-operations h6 {
  margin: 0 0 10px 0;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
}

.operation-buttons-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.operation-buttons-grid .btn {
  padding: 8px 6px;
  font-size: 12px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.operation-buttons-grid .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.operation-buttons-grid .btn svg {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

/* Fracture Category Section Styles */

.fracture-category-section .field-item {
  margin-bottom: 0;
}

/* Enhanced Button Styles for Operations */
.btn[data-polygon-operation] {
  position: relative;
  overflow: hidden;
}

.btn[data-polygon-operation]:before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  transition: left 0.5s ease;
}

.btn[data-polygon-operation]:hover:before {
  left: 100%;
}

/* Success/Error State Indicators */
.operation-status-indicator {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success-color);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.operation-status-indicator.error {
  background: var(--error-color);
}

.operation-status-indicator.show {
  opacity: 1;
}

/* Loading States */
.btn.loading {
  pointer-events: none;
  position: relative;
}

.btn.loading:after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Responsive Design */
@media (max-width: 768px) {
  .operation-dialog {
    margin: 5px;
  }

  .operation-actions {
    flex-direction: column;
  }

  .operation-actions .btn {
    width: 100%;
  }
}

/* Dark Mode Adjustments */
@media (prefers-color-scheme: dark) {
  .operation-dialog {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  }

  .polygon-preview {
    background: rgba(255, 255, 255, 0.05);
  }

  .operation-help {
    background: rgba(255, 255, 255, 0.05);
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .operation-dialog {
    border-width: 3px;
  }

  .operation-buttons .btn {
    border-width: 2px;
  }

  .operation-help {
    border-left-width: 4px;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .operation-dialog,
  .polygon-preview,
  .btn[data-polygon-operation],
  .btn[data-polygon-operation]:before {
    animation: none !important;
    transition: none !important;
  }

  .operation-buttons .btn:hover {
    transform: none;
  }

  .operation-buttons-grid .btn:hover {
    transform: none;
  }
}
/* ========================================================================= 
   2D Mode Complete Styles
   ========================================================================= */

/* Main Containers */
.crops-container {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 20px;
  background: var(--graiph-bg-secondary);
}

/* Grouped Segments Container */
.grouped-segments-container-2d {
  padding: 20px;
}

/* Group Section */
.segment-group-section {
  background: var(--bg-primary);
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  margin-bottom: 30px;
  overflow: hidden;
}

.group-section-header {
  background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
  color: white;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.group-title {
  margin: 0;
  font-size: 1.2em;
  font-weight: 600;
}

.group-count {
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 12px;
  border-radius: 15px;
  font-size: 0.9em;
}

/* Batch Navigation */
.group-batch-navigation {
  background: var(--graiph-bg-secondary);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  border-bottom: 1px solid var(--graiph-border);
}

.batch-nav-btn {
  background: var(--bg-primary);
  border: 1px solid var(--graiph-border);
  padding: 5px 12px;
  border-radius: 4px;
  transition: all 0.2s;
}

.batch-nav-btn:hover:not(:disabled) {
  background: var(--graiph-accent);
  color: var(--graiph-accent-ink);
  border-color: var(--graiph-accent);
}

.batch-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.batch-info {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Segments Grid */
.segments-grid-2d-grouped {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  padding: 15px;
  background: var(--graiph-bg-secondary);
}

.segment-info-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  color: white;
  padding: 4px;
  font-size: 9px;
  font-weight: 500;
  text-align: center;
  line-height: 1.2;
}

/* Segment Details Container */
.segment-details-container {
  margin-top: 15px;
  background: var(--bg-primary);
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.segment-details-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--graiph-border);
}

.segment-details-header h4 {
  margin: 0;
  font-size: 16px;
  color: var(--text-primary);
}

.segment-full-image {
  position: relative;
  cursor: pointer;
  margin-bottom: 15px;
  border-radius: 6px;
  overflow: hidden;
}

.segment-full-image img {
  width: 100%;
  height: auto;
  display: block;
}

.segment-full-image .image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s;
}

.segment-full-image:hover .image-overlay {
  opacity: 1;
}

.segment-metadata {
  display: grid;
  gap: 8px;
}

.metadata-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--graiph-bg-secondary);
  border-radius: 4px;
  font-size: 13px;
}

.metadata-item label {
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 10px;
}

.metadata-item span {
  color: var(--text-primary);
  text-align: right;
  flex: 1;
}

/* Categorical Filters */
.categorical-filters-grid {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.categorical-filter-group {
  background: var(--graiph-bg-secondary);
  border-radius: 6px;
  padding: 10px;
}

.filter-group-label {
  display: block;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-values {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-value-item {
  display: flex;
  align-items: center;
  background: var(--bg-primary);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.filter-value-item:hover {
  background: var(--graiph-bg-elevated);
}

.filter-value-item input[type="checkbox"] {
  margin-right: 5px;
}

/* Numerical Filters */
.numerical-filters {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filter-item {
  background: var(--graiph-bg-secondary);
  border: 1px solid var(--graiph-border);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 10px;
}

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

.filter-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-controls select,
.filter-controls input {
  flex: 1;
  min-width: 80px;
  max-width: 150px;
  padding: 4px 8px;
  border: 1px solid var(--graiph-border);
  border-radius: 4px;
  font-size: 13px;
}

.loading-2d {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  z-index: 10;
}

.loading-2d-progress {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 10;
  padding: 24px;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
}

.loading-2d-progress .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.loading-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--graiph-accent-hover));
  border-radius: 4px;
  transition: width 0.3s ease;
}

.loading-progress-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0;
}

.loading-tray-name {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  font-style: italic;
}

.loading-segments-count {
  font-size: 13px;
  color: var(--graiph-accent-text);
  font-weight: 500;
  margin: 0;
}

/* Inline loading progress (non-blocking) */
.loading-inline-progress {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.loading-inline-content {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.loading-inline-content svg {
  color: var(--graiph-accent-text);
}

.loading-inline-content .loading-segments-count {
  margin-left: auto;
  color: var(--graiph-accent-text);
  font-weight: 500;
}

.loading-inline-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}

.loading-inline-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--graiph-accent-hover));
  border-radius: 2px;
  transition: width 0.2s ease;
}

/* =========================================================================
   Scrollable Lists
   ========================================================================= */

.scrollable-tray-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--graiph-border);
  border-radius: 6px;
  padding: 8px;
}

.tray-checkbox-item:last-child {
  border-bottom: none;
}

.tray-name {
  font-weight: 500;
  color: var(--text-primary);
}

.tray-depth {
  font-size: 12px;
  color: var(--text-muted);
}

/* Empty State */

/* Loading State */
.loading {
  text-align: center;
  color: var(--text-muted);
}

/* Button Groups */
.button-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-block {
  width: 100%;
}

/* Text Utilities */

.mb-2 {
  margin-bottom: 8px;
}

/* Responsive Breakpoints */
@media (max-width: 1200px) {
  .segments-grid-2d-grouped {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  }
}

@media (max-width: 768px) {
  .segments-grid-2d-grouped {
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 6px;
  }

  .group-batch-navigation {
    flex-wrap: wrap;
    gap: 10px;
  }

  .batch-info {
    width: 100%;
    text-align: center;
    order: -1;
  }

  .filter-controls {
    flex-direction: column;
  }

  .filter-controls select,
  .filter-controls input {
    max-width: 100%;
  }

  .segment-group-section {
    margin-bottom: 20px;
  }

  .group-section-header {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .segments-grid-2d-grouped {
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 4px;
    padding: 10px;
  }

  .crops-container {
    padding: 10px;
  }

  .grouped-segments-container-2d {
    padding: 10px;
  }
}

/* =========================================================================
   COMBOBOX STYLES (Moved from HTML)
   ========================================================================= */
.combobox-container {
  position: relative;
  width: 100%;
}

.combobox-input {
  width: 100%;
  padding: 8px 36px 8px 12px; /* Simplified padding */
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  cursor: text;
  box-sizing: border-box;
}

.combobox-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(51, 204, 102, 0.15);
}

.combobox-input::placeholder {
  color: var(--text-muted, #6b7280);
  font-weight: 400;
}

.combobox-arrow {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted, #6b7280);
  pointer-events: none;
  transition: transform 0.2s ease;
}

.combobox-container.open .combobox-arrow {
  transform: translateY(-50%) rotate(180deg);
}

.combobox-dropdown {
  position: absolute;
  top: calc(100% - 2px);
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 0 0 var(--radius-md, 8px) var(--radius-md, 8px);
  max-height: calc(10 * 2.5rem);
  overflow-y: auto;
  z-index: 99999; /* Very high z-index */
  display: none;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.combobox-container.open .combobox-dropdown {
  display: block;
}

.combobox-option {
  padding: 0.5rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--graiph-bg-tertiary);
  transition: background-color 0.15s ease;
  font-size: 0.875rem;
  line-height: 1.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.combobox-option:hover {
  background-color: var(--graiph-bg-tertiary);
}

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

.combobox-option.selected {
  background-color: var(--primary-color);
  color: var(--graiph-accent-ink);
}

.combobox-no-results {
  padding: 0.75rem 1rem;
  color: var(--text-muted, #6b7280);
  font-style: italic;
  text-align: center;
  font-size: 0.875rem;
}

.combobox-container.loading .combobox-arrow {
  display: none;
}

/* CRITICAL FIX: Ensure dropdown is above other elements */
.combobox-container:focus-within {
  z-index: 10000;
}

/* Sidebar sections need relative positioning for dropdowns */
.sidebar-section {
  position: relative;
}

/* Add to the combobox styles section */
.combobox-option.highlighted {
  background-color: var(--bg-tertiary);
}

.combobox-option.selected {
  background-color: var(--primary-color);
  color: var(--graiph-accent-ink);
}

.combobox-option.highlighted.selected {
  background-color: var(--primary-hover);
  color: var(--graiph-accent-ink);
}
/* =========================================================================
   CLASSIFICATION STYLES
   ========================================================================= */
.classification-section {
  margin-top: 16px;
}

.classification-disabled {
  padding: 12px;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
}

.classification-controls {
  padding: 12px;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-top: 12px;
}

.classification-controls h5 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 12px 0;
}

.classification-buttons {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.classification-result {
  margin-top: 12px;
  padding: 12px;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--primary-color);
}

.prediction-display {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.prediction-label {
  font-weight: 600;
  color: var(--graiph-accent-text);
  text-transform: capitalize;
}

.prediction-confidence {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 2px 6px;
  background-color: var(--bg-accent);
  border-radius: var(--radius-sm);
}

.confidence-breakdown {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.confidence-bar-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.confidence-bar-row.top-prediction .confidence-class-label,
.confidence-bar-row.top-prediction .confidence-bar-value {
  color: var(--graiph-accent-text);
  font-weight: 600;
}

.confidence-class-label {
  font-size: 11px;
  color: var(--text-secondary);
  width: 80px;
  text-transform: capitalize;
  flex-shrink: 0;
}

.confidence-bar-track {
  flex: 1;
  height: 6px;
  background-color: var(--bg-accent);
  border-radius: 3px;
  overflow: hidden;
}

.confidence-bar-fill {
  height: 100%;
  background-color: var(--primary-color);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.confidence-bar-row:not(.top-prediction) .confidence-bar-fill {
  background-color: var(--text-tertiary, #666);
}

.confidence-bar-value {
  font-size: 11px;
  color: var(--text-secondary);
  width: 40px;
  text-align: right;
  flex-shrink: 0;
}

.fracture-metadata-section {
  margin-top: 16px;
}

/* =========================================================================
   Classification Batch Buttons Styles
   ========================================================================= */

.batch-classification-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.classification-batch-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

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

.batch-classification-section .operation-help {
  display: block;
  margin-top: 8px;
  padding: 8px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
}

.batch-classification-section .operation-help svg {
  margin-right: 6px;
  color: var(--graiph-accent-text);
}

.classification-controls-section {
  padding-bottom: 12px;
}

.classification-buttons .btn {
  flex: 1;
}

/* Button states for batch operations */
.btn-warning {
  background-color: var(--warning-color);
  color: white;
  border: 1px solid var(--warning-color);
}

.btn-warning:hover:not(:disabled) {
  background-color: #b45309;
  box-shadow: var(--shadow-md);
}

.btn-warning:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Spinner animation (legacy support + lucide) */

/* Lucide replaces elements so data-lucide is on the SVG itself */
.lucide-spin svg,
svg[data-lucide="loader-circle"] {
  animation: graiph-spin 1s linear infinite;
}

/* =========================================================================
   Statistics Overlay
   ========================================================================= */
.statistics-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  z-index: 5;
  overflow: hidden;
}

.statistics-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  animation: fadeIn 0.3s ease;
}

.statistics-header {
  flex-shrink: 0;
  text-align: center;
  padding: 1.5rem 2rem;
  background: var(--bg-primary);
  border-bottom: 2px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
}

.statistics-header h2 {
  color: var(--text-primary);
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.statistics-header h2 svg {
  color: var(--graiph-accent-text);
}

.statistics-header .text-muted {
  font-size: 1rem;
  color: var(--text-muted);
}

.statistics-body {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  align-content: start;
}

.stat-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card.compact {
  padding: 1rem;
  background: var(--bg-secondary);
}

.stat-card.compact .stat-card-header {
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
}

.stat-card.compact .stat-card-header svg {
  font-size: 1.25rem;
}

.stat-card.compact .stat-card-header h3 {
  font-size: 1rem;
}

.stat-card.full-width {
  grid-column: 1 / -1;
}

.stat-card.full-width .stat-card-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

/* The Drillhole Information card is a single-column form, not a stat tile grid.
   Override the auto-fit grid so fields, the sync block and the action buttons
   stack vertically (otherwise .form-actions lands in its own grid cell and the
   Sync button stretches to fill the row height). */
.stat-card.full-width.drillhole-form-card .stat-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 720px;
}

.stat-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.stat-card-header svg {
  font-size: 1.5rem;
  color: var(--graiph-accent-text);
}

.stat-card-header h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.stat-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Pill-styled stat rows inside stat-cards (scoped to avoid conflicting with line ~1205) */
.stat-card .stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 0.875rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

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

.stat-value {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.stat-value.ready {
  color: var(--graiph-accent-text);
}

.stat-value.pending {
  color: var(--warning-color);
}

.stat-percentage {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.stat-progress {
  width: 100%;
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.stat-progress-bar {
  height: 100%;
  background: linear-gradient(
    90deg,
    var(--primary-color),
    var(--success-color)
  );
  transition: width 0.5s ease;
}

.stat-empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

.stat-empty svg {
  font-size: 3rem;
  width: 3rem;
  height: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Flag Trend Chart Styles */
.flag-trend-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.flag-trend-type-toggle,
.flag-trend-range {
  display: flex;
  gap: 0;
  border: 1px solid var(--border-color, #333);
  border-radius: 6px;
  overflow: hidden;
}

.flag-trend-type-btn,
.flag-trend-range-btn {
  background: transparent;
  color: var(--text-secondary, #999);
  border: none;
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  font-family: "Nunito Sans", sans-serif;
  cursor: pointer;
  transition: all 0.15s;
  border-right: 1px solid var(--border-color, #333);
}

.flag-trend-type-btn:last-child,
.flag-trend-range-btn:last-child {
  border-right: none;
}

.flag-trend-type-btn.active,
.flag-trend-range-btn.active {
  background: rgba(51, 204, 102, 0.12);
  color: var(--graiph-accent-text);
}

.flag-trend-type-btn:hover:not(.active),
.flag-trend-range-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.04);
  color: #ccc;
}

.flag-trend-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.flag-pill {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border-color, #333);
  font-size: 0.75rem;
  color: var(--text-secondary, #999);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.flag-pill:hover {
  border-color: #555;
  color: #ccc;
}

.flag-pill.active {
  border-color: rgba(51, 204, 102, 0.4);
  color: #ddd;
  background: rgba(51, 204, 102, 0.06);
}

.flag-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
  transition: background-color 0.15s;
}

.flag-pill.active .flag-pill-dot {
  background: #33CC66;
}

.flag-trend-trigger-filter select {
  background: transparent;
  color: var(--text-secondary, #999);
  border: 1px solid var(--border-color, #333);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  font-size: 0.78rem;
  font-family: "Nunito Sans", sans-serif;
  cursor: pointer;
  appearance: auto;
}

.flag-trend-trigger-filter select:focus {
  outline: none;
  border-color: #33CC66;
}

.flag-trend-filter-note {
  text-align: center;
  color: var(--alert-info, #2196F3);
  font-size: 0.75rem;
  padding: 0.4rem 0.75rem;
  margin-bottom: 0.5rem;
  border: 1px solid rgba(33, 150, 243, 0.2);
  border-radius: 4px;
  background: rgba(33, 150, 243, 0.06);
}

.flag-trend-loading {
  text-align: center;
  color: var(--text-muted, #666);
  padding: 1rem;
  font-size: 0.85rem;
  display: none;
}

/* Activity Log Styles */
.activity-log-card {
  grid-column: 1 / -1;
  max-height: 400px;
  overflow-y: auto;
}

.activity-log-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.activity-log-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  transition: background-color 0.2s;
}

.activity-log-item:hover {
  background: var(--bg-hover);
}

.activity-log-icon {
  font-size: 1.25rem;
  color: var(--graiph-accent-text);
  width: 2rem;
  text-align: center;
}

.activity-log-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.activity-log-action {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.activity-log-details {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.activity-log-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Text Filter Container */
.text-filter-container {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.text-filter-container .filter-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.text-filter-container .filter-text-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.text-filter-container .filter-text-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(51, 204, 102, 0.1);
}

.text-filter-container .filter-text-input::placeholder {
  color: var(--text-muted);
}

.text-filter-container .filter-help {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Ready Filters Grid */
.ready-filters-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}

.ready-filters-grid .checkbox-item {
  padding: 4px 0;
  font-size: 12px;
  gap: 6px;
}

.ready-filters-grid .checkmark {
  width: 14px;
  height: 14px;
}

.ready-filters-grid .label-text {
  font-size: 12px;
}

.ready-flags-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  padding: 0.75rem 0;
}

.section-header.collapsed .section-toggle svg {
  transform: rotate(90deg);
}

.section-header:not(.collapsed) .section-toggle svg {
  transform: rotate(0deg);
}

/* Responsive Design */
@media (max-width: 768px) {
  .statistics-body {
    grid-template-columns: 1fr;
  }

  .statistics-content {
    padding: 1rem;
  }

  .statistics-header h2 {
    font-size: 1.5rem;
  }
}

/* =========================================================================
   ADMIN CREATION FORMS
   ========================================================================= */
.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.form-actions .btn {
  flex: 0 1 auto;
  white-space: nowrap;
  min-width: fit-content;
}

/* Ensure buttons in statistics overlay don't break */
.stat-card .form-actions .btn {
  padding: 10px 16px;
  font-size: 0.9rem;
}

.stat-card .form-actions .btn svg {
  margin-right: 6px;
}

.tray-preview {
  margin-top: 16px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.tray-preview img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

input[type="file"].form-control {
  padding: 8px;
  border: 2px dashed var(--border-color);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

input[type="file"].form-control:hover {
  border-color: var(--primary-color);
  background: var(--bg-accent);
}

.stat-card textarea.form-control {
  resize: vertical;
  min-height: 80px;
  font-family: var(--font-stack);
}

.statistics-body .form-group {
  margin-bottom: 20px;
}

.statistics-body .form-group:last-child {
  margin-bottom: 0;
}

#statsSubtitle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#statsSubtitle button {
  vertical-align: middle;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ===================================================================
   Polygon Operations UI Styles
   =================================================================== */

#operationUIContainer {
  margin-top: 1rem;
}

.operation-ui-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.operation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--color-primary);
  color: white;
}

.operation-header h6 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.btn-close-operation {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.btn-close-operation:hover {
  opacity: 1;
}

.operation-content {
  padding: 1rem;
}

.polygon-info-box {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.polygon-info-box strong {
  color: var(--color-primary);
}

.polygon-info-box small {
  display: block;
  color: var(--color-text-secondary);
  margin-top: 0.25rem;
}

.control-group {
  margin-bottom: 1rem;
}

.control-group:last-child {
  margin-bottom: 0;
}

.control-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--color-text);
}

.control-group small {
  display: block;
  margin-top: 0.25rem;
  color: var(--color-text-secondary);
  font-size: 0.8rem;
}

.control-group .form-control {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.9rem;
  background: var(--bg-primary);
}

.control-group .form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(51, 204, 102, 0.1);
}

.selection-status {
  margin-bottom: 1rem;
}

.polygon-selection {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  border-radius: 4px;
  border: 2px solid transparent;
  background: var(--color-bg);
}

.polygon-selection.first-selection {
  border-color: rgba(0, 100, 200, 0.6);
  background: rgba(0, 100, 200, 0.08);
}

.polygon-selection.second-selection {
  border-color: rgba(255, 120, 0, 0.6);
  background: rgba(255, 120, 0, 0.08);
}

.polygon-selection.pending {
  border-color: var(--color-border);
  background: var(--color-surface);
  opacity: 0.6;
}

.selection-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.first-selection .selection-badge {
  background: rgba(0, 100, 200, 1);
  color: white;
}

.second-selection .selection-badge {
  background: rgba(255, 120, 0, 1);
  color: white;
}

.pending .selection-badge {
  background: var(--color-border);
  color: var(--color-text-secondary);
}

.selection-label {
  flex: 1;
  font-weight: 500;
  color: var(--color-text);
}

.selection-vertices {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.info-box {
  background: rgba(51, 204, 102, 0.05);
  border: 1px solid rgba(51, 204, 102, 0.2);
  border-radius: 4px;
  padding: 0.75rem;
  font-size: 0.9rem;
  color: var(--color-text);
}

.info-box svg {
  color: var(--color-primary);
  margin-right: 0.5rem;
}

.operation-actions {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
}

.operation-actions .btn {
  flex: 1;
}

.btn.active-operation {
  background: var(--primary-color);
  color: var(--graiph-accent-ink);
  box-shadow: 0 0 0 2px rgba(51, 204, 102, 0.3);
  border-color: var(--primary-color);
}

.btn.active-operation:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

/* Button states for API availability */
.btn.api-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: #6c757d !important;
  border-color: #6c757d !important;
}

.btn.api-disabled:hover {
  background-color: #6c757d !important;
  border-color: #6c757d !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .operation-ui-panel {
    margin-bottom: 0.75rem;
  }

  .operation-header {
    padding: 0.5rem 0.75rem;
  }

  .operation-content {
    padding: 0.75rem;
  }

  .operation-actions {
    flex-direction: column;
    padding: 0.75rem;
  }

  .operation-actions .btn {
    width: 100%;
  }
}

/* =========================================================================
   Custom Confirm Modal Styles
   ========================================================================= */

.custom-confirm-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease-in-out;
}

.custom-confirm-modal {
  background: var(--bg-primary);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.3s ease-out;
}

.custom-confirm-modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--graiph-border);
  background: var(--graiph-bg-secondary);
}

.custom-confirm-modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.custom-confirm-modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
  color: var(--text-secondary);
  line-height: 1.6;
}

.custom-confirm-modal-body p {
  margin: 0.5rem 0;
}

.custom-confirm-modal-body ul {
  margin: 0.75rem 0;
}

.custom-confirm-modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--graiph-border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: var(--graiph-bg-secondary);
}

.custom-confirm-btn {
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.custom-confirm-btn-cancel {
  background: var(--graiph-bg-elevated);
  color: var(--text-secondary);
}

.custom-confirm-btn-cancel:hover {
  background: var(--graiph-border-hover);
}

.custom-confirm-btn-confirm {
  background: var(--primary-color);
  color: var(--graiph-accent-ink);
}

.custom-confirm-btn-confirm:hover {
  background: var(--primary-hover);
}

@media (max-width: 600px) {
  .custom-confirm-modal {
    max-width: 95%;
    width: 95%;
  }

  .custom-confirm-modal-header,
  .custom-confirm-modal-body,
  .custom-confirm-modal-footer {
    padding: 1rem;
  }

  .custom-confirm-modal-footer {
    flex-direction: column;
  }

  .custom-confirm-btn {
    width: 100%;
  }
}

/* ====================================
   Nueva sección: Estilos para interfaz mejorada
   ==================================== */

/* Class Labels Grid - Layout de dos columnas con radio buttons */
.class-labels-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  height: 150px; /* Fixed height for scrollable grid */
  overflow-y: auto;
  padding-right: 4px;
  align-content: start; /* Align items to top when fewer than 6 */
}

.class-labels-grid::-webkit-scrollbar {
  width: 4px;
}

.class-labels-grid::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 2px;
}

.class-labels-grid::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.class-labels-grid::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.class-label-item {
  display: flex;
  align-items: center;
  padding: 6px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg-primary);
}

.class-label-item:hover {
  background: var(--bg-hover);
  border-color: var(--primary-color);
}

.class-label-item input[type="radio"] {
  display: none;
}

.class-label-item input[type="radio"]:checked + .class-color-box {
  border: 2px solid var(--primary-color);
  box-shadow: 0 0 0 2px rgba(51, 204, 102, 0.2);
}

.class-label-item input[type="radio"]:checked ~ .class-name {
  font-weight: 600;
  color: var(--graiph-accent-text);
}

.class-label-item .selected-mark {
  display: none;
}

.class-label-item
  input[type="radio"]:checked
  + .class-color-box
  .selected-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  inset: 0;
  font-size: 12px;
  color: white;
  font-weight: bold;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

.class-color-box {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  margin-right: 8px;
  border: 1px solid var(--border-color);
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.class-name {
  font-size: 0.875rem;
  flex: 1;
}

/* Visualization Grid - Layout de dos columnas */
.visualization-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  max-height: 40vh;
  overflow-y: auto;
}

.checkbox-item-indent {
  padding-left: 20px;
  font-size: 0.85rem;
}

/* Metadata Header Compact */
.metadata-header-compact {
  background: var(--bg-accent);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}

.metadata-header-compact .header-title {
  margin-bottom: 8px;
}

.metadata-header-compact .header-title h3 {
  font-size: 1.1rem;
  margin: 0;
  color: var(--text-primary);
}

.metadata-header-compact .header-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.stat-compact {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.stat-compact svg {
  font-size: 0.75rem;
}

/* Ready Flags Grid - Dos columnas */
.ready-flags-grid-two-columns {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

/* Polygon Operations - Dos columnas */
.operation-buttons-two-columns {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.btn-compact {
  padding: 8px 12px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.btn-compact svg {
  margin-right: 4px;
}

/* Depth Fields Grid - 3 columnas compactas */
.depth-fields-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
  width: 100%;
}

/* Block Properties Grid - 2 columnas para checkboxes */
.block-properties-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 8px;
  margin-bottom: 12px;
}

/* Checkboxes más compactos dentro del grid de block properties */
.block-properties-grid .checkbox-item {
  padding: 4px 0;
  font-size: 12px;
  gap: 6px;
}

.block-properties-grid .checkmark {
  width: 14px;
  height: 14px;
}

.block-properties-grid .label-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field-item-compact {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0; /* Permite que el contenido se contraiga */
}

.field-label-compact {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.form-input-compact {
  padding: 5px 6px;
  font-size: 0.8rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-primary);
  width: 100%;
  min-width: 0;
}

.form-input-compact:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(51, 204, 102, 0.1);
}

/* Models Mode - Estilos compactos */
.models-config-compact {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-accent);
  border-radius: 6px;
  margin-bottom: 12px;
}

.field-label-inline {
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
}

.form-input-inline {
  width: 80px;
  padding: 6px 8px;
  font-size: 0.875rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

.models-actions-compact {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.models-actions-inline {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.model-row-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-accent);
  border-radius: 6px;
}

.model-row-title {
  flex: 1;
  font-weight: 500;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Model Section Compact */
.segmentation-models-compact,
.utils-operations-compact {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.model-section-compact {
  padding: 12px;
  background: var(--bg-accent);
  border-radius: 6px;
}

.model-header-compact {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 500;
}

.model-header-compact svg {
  margin-right: 6px;
}

.checkbox-item-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  cursor: pointer;
}

.checkbox-item-inline input[type="checkbox"] {
  display: none;
}

.checkbox-item-inline .checkmark {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-radius: 3px;
  position: relative;
  background-color: var(--bg-primary);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.checkbox-item-inline input[type="checkbox"]:checked + .checkmark {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

.checkbox-item-inline input[type="checkbox"]:checked + .checkmark::after {
  display: block;
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -60%) rotate(45deg);
}

.checkbox-group-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 4px;
}

/* API Status Compact */
.api-status-indicator-compact {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-accent);
  border-radius: 6px;
  font-size: 0.8rem;
  margin-bottom: 12px;
}

.api-status-indicator-compact svg {
  font-size: 0.7rem;
}

/* Pipeline Styles Compact */
.pipeline-config-compact {
  padding: 12px;
  background: var(--bg-accent);
  border-radius: 6px;
  margin-bottom: 12px;
}

.pipeline-steps-compact {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 12px;
  background: var(--bg-accent);
  border-radius: 6px;
  margin-bottom: 12px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .class-labels-grid,
  .visualization-grid,
  .ready-flags-grid-two-columns,
  .operation-buttons-two-columns,
  .pipeline-steps-compact {
    grid-template-columns: 1fr;
  }

  /* Mantener 3 columnas para depth fields incluso en pantallas pequeñas */
  /* .depth-fields-grid se mantiene con 3 columnas */
}

/* Utils Section Compact */
.utils-operations-compact {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.util-section-compact {
  padding: 12px;
  background: var(--bg-accent);
  border-radius: 6px;
}

.util-header-compact {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

.util-header-compact .util-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  width: 14px;
  height: 14px;
  pointer-events: none;
}

.util-header-compact.expanded .util-chevron {
  transform: rotate(90deg);
}

.util-config-compact.collapsed {
  display: none;
}

.util-header-compact svg {
  margin-right: 6px;
}

.util-config-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  padding: 8px;
  background: var(--bg-primary);
  border-radius: 4px;
}

/* =========================================================================
   TAGGER PIPELINE STYLES
   ========================================================================= */

.pipeline-description {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding: 8px;
  background: var(--bg-accent);
  border-radius: 4px;
  border-left: 3px solid var(--primary-color);
}

.pipeline-options-section {
  margin-bottom: 12px;
  padding: 12px;
  background: var(--bg-accent);
  border-radius: 6px;
}

.field-label-block {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.pipeline-steps-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--bg-accent);
  border-radius: 6px;
}

.pipeline-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-primary);
  border-radius: 4px;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.pipeline-step-icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.pipeline-step-name {
  flex: 1;
  font-weight: 500;
}

.pipeline-step-detail {
  font-size: 0.75rem;
  color: var(--text-muted);
  max-width: 150px;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Pipeline step states */
.pipeline-step[data-status="pending"] {
  opacity: 0.6;
}

.pipeline-step[data-status="pending"] .pipeline-step-icon svg {
  color: var(--text-muted);
}

.pipeline-step[data-status="running"] {
  background: rgba(var(--primary-rgb, 59, 130, 246), 0.1);
  border-left: 3px solid var(--primary-color);
}

.pipeline-step[data-status="running"] .pipeline-step-icon svg {
  color: var(--graiph-accent-text);
}

.pipeline-step[data-status="success"] {
  background: rgba(16, 185, 129, 0.1);
  border-left: 3px solid var(--success-color);
}

.pipeline-step[data-status="success"] .pipeline-step-icon svg {
  color: var(--graiph-accent-text);
}

.pipeline-step[data-status="failed"] {
  background: rgba(239, 68, 68, 0.1);
  border-left: 3px solid var(--danger-color);
}

.pipeline-step[data-status="failed"] .pipeline-step-icon svg {
  color: var(--danger-color);
}

.pipeline-step[data-status="skipped"] {
  background: rgba(156, 163, 175, 0.1);
  border-left: 3px solid var(--text-muted);
  opacity: 0.7;
}

.pipeline-step[data-status="skipped"] .pipeline-step-icon svg {
  color: var(--text-muted);
}

/* =========================================================================
   PIPELINE STEP CARDS (Models Mode — new step-based UI)
   ========================================================================= */

/* Pipeline Mode Selector (New vs Legacy toggle) */
.pipeline-mode-selector {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
}

.pipeline-mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  border: none;
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.pipeline-mode-btn:hover {
  background: var(--bg-accent);
  color: var(--text-primary);
}

.pipeline-mode-btn.active {
  background: var(--primary-color);
  color: var(--graiph-accent-ink);
}

.pipeline-mode-btn svg {
  width: 14px;
  height: 14px;
}

/* ── Pipeline Step Cards (compact layout) ── */

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

.pipeline-step-card {
  padding: 8px 10px;
  background: var(--bg-accent);
  border-radius: 6px;
  border-left: 3px solid transparent;
  transition: border-color 0.2s ease;
}

.pipeline-step-card.step-ready {
  border-left-color: #33CC66;
}

.pipeline-step-card.step-running {
  border-left-color: #F5A623;
}

.pipeline-step-card.step-pending {
  border-left-color: #F5A623;
}

.pipeline-step-card.step-error {
  border-left-color: #E53935;
}

.pipeline-step-card.step-skipped {
  border-left-color: #F5A623;
}

.pipeline-step-header {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  user-select: none;
}

.pipeline-step-header .checkbox-item-inline {
  flex-shrink: 0;
  margin: 0;
}

.pipeline-step-title {
  flex: 1;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pipeline-step-title svg {
  width: 14px;
  height: 14px;
  margin-right: 4px;
  vertical-align: -2px;
}

.pipeline-step-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.pipeline-step-header.expanded .pipeline-step-chevron {
  transform: rotate(90deg);
}

.pipeline-step-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pipeline-force-label {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  font-size: 0.72rem;
  opacity: 0.6;
  cursor: pointer;
  white-space: nowrap;
  margin: 0;
  min-width: 68px;
}
.pipeline-force-label:hover { opacity: 1; }
.pipeline-force-label input[type="checkbox"] {
  width: 13px;
  height: 13px;
  cursor: pointer;
  accent-color: var(--graiph-accent);
  margin: 0;
}
.pipeline-force-label .checkmark { display: none; }

.pipeline-step-run {
  padding: 3px 10px !important;
  font-size: 0.78rem !important;
  line-height: 1.2;
  white-space: nowrap;
}

.pipeline-step-run svg {
  width: 12px;
  height: 12px;
}

/* Status indicator dot */
.pipeline-step-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #666;            /* default: idle/gray */
  transition: background 0.2s ease;
}

.pipeline-step-status.ready {
  background: #33CC66;         /* green — configured and ready */
}

.pipeline-step-status.running {
  background: #F5A623;         /* amber — in progress */
}

.pipeline-step-status.pending {
  background: #F5A623;         /* amber — completed but unsaved */
}

.pipeline-step-status.error {
  background: #E53935;         /* red — failed */
}

.pipeline-step-status.skipped {
  background: #F5A623;         /* amber/warning — skipped due to prior failure */
}

/* Collapsible step config */
.pipeline-step-config {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  padding: 8px;
  background: var(--bg-primary);
  border-radius: 4px;
}

.pipeline-step-config.collapsed {
  display: none;
}

.pipeline-step-desc {
  font-size: 0.75rem;
  color: var(--gray-light, #CCCCCC);
  margin: 0;
  width: 100%;
}

/* Dependency hint (shown when prerequisite step not completed) */
.pipeline-dep-hint {
  font-size: 0.75rem;
  color: var(--graiph-alert-warning);
  padding: 4px 8px;
  margin-top: 4px;
  border-left: 2px solid #F5A623;
  background: rgba(245, 166, 35, 0.08);
  border-radius: 0 4px 4px 0;
}

/* Pipeline step streaming progress */
.pipeline-step-progress {
  margin-top: 6px;
  padding: 4px 8px;
}

.pipeline-progress-bar {
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 4px;
}

.pipeline-progress-fill {
  height: 100%;
  background: #33CC66;
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
}

.pipeline-progress-text {
  font-size: 0.72rem;
  color: var(--gray-light, #CCCCCC);
  opacity: 0.85;
}

/* Pipeline mode content visibility */
.pipeline-mode-content {
  /* controlled via JS display toggle */
}

/* =========================================================================
   READY TAGS SYSTEM STYLES
   ========================================================================= */

/* Ready Tags Container */
.ready-tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
  min-height: 60px;
  align-items: flex-start;
  align-content: flex-start;
}

.ready-tags-container:empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* No Tags Message */
.no-tags-message {
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
  text-align: center;
  width: 100%;
  padding: 8px;
}

/* Ready Tag Chip */
.ready-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background-color: var(--primary-color);
  color: var(--graiph-accent-ink);
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.ready-tag-chip:hover {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow-sm);
}

.ready-tag-chip .tag-label {
  line-height: 1;
}

.ready-tag-chip .tag-remove-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  background-color: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ready-tag-chip .tag-remove-btn:hover {
  background-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.ready-tag-chip .tag-remove-btn svg {
  font-size: 10px;
}

/* Ready Tags Controls */
.ready-tags-controls {
  margin-top: 12px;
  padding: 12px;
  background-color: var(--bg-accent);
}

/* Available Tags Container */
.available-tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  margin-bottom: 8px;
  max-height: 120px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

/* Available Tag Chip */
.available-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.available-tag-chip:hover {
  background-color: var(--primary-color);
  color: var(--graiph-accent-ink);
  border-color: var(--primary-color);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.available-tag-chip:active {
  transform: translateY(0);
}

.available-tag-chip svg {
  font-size: 10px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.available-tag-chip:hover svg {
  opacity: 1;
}

.ready-tags-controls label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
  border-radius: var(--radius-md);
}

.ready-tags-controls .form-select,
.ready-tags-controls .form-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.ready-tags-controls .form-select:focus,
.ready-tags-controls .form-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(51, 204, 102, 0.15);
}

.ready-tags-controls .form-select-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.ready-tags-controls .form-input-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.ready-tags-controls .btn-full {
  width: 100%;
  justify-content: center;
}

.ready-tags-controls .btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* Ready Filters Grid - Dynamic Tags */
.ready-filters-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 4px 0;
}

/* Spacing utility */
.mt-2 {
  margin-top: 8px;
}

/* Quality Control Section Adjustments */
#qualityControl .section-content {
  padding: 16px;
}

/* Metadata Mode Ready Tags */
#readyFlagsContent .ready-tags-container {
  margin-bottom: 12px;
}

#readyFlagsContent .ready-tags-controls {
  margin-top: 0;
}

/* Animation for tag chips */
@keyframes tagSlideIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ready-tag-chip {
  animation: tagSlideIn 0.2s ease;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .ready-tags-container {
    min-height: 50px;
  }

  .ready-tag-chip {
    font-size: 11px;
    padding: 5px 8px;
  }
}

.combobox-option .filter-match-check {
  margin-right: 8px;
  color: var(--graiph-accent-text);
  font-size: 14px;
}

/* Ajustar el layout de la opción del combobox para acomodar el checkmark */
.combobox-option {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Cuando la opción está seleccionada, cambiar el color del checkmark */
.combobox-option.selected .filter-match-check {
  color: #ffffff;
}

/* Contenedor de tags disponibles expandido */
.available-tags-container.expanded {
  max-height: none !important;
  overflow-y: auto;
}

/* =========================================================================
   Image Resolution Controls
   ========================================================================= */

/* Soft blur for low-res preview (applied via JS with updateImageFilters) */
#mainCanvas.image-preview-blur {
  /* Blur is applied via JS filter property to combine with brightness/contrast */
}

/* Image resolution controls layout */
.image-resolution-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.image-resolution-controls .checkbox-item {
  margin: 0;
}

/* Resolution indicator */
.resolution-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.resolution-indicator svg {
  font-size: 10px;
}

.resolution-indicator.loading {
  background: rgba(33, 150, 243, 0.15);
  color: var(--graiph-alert-info);
}

.resolution-indicator.loading svg {
  animation: spin 1s linear infinite;
}

.resolution-indicator.small {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning-color);
}

.resolution-indicator.medium {
  background: rgba(16, 185, 129, 0.15);
  color: var(--graiph-accent-text);
}

.resolution-indicator.high {
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
}

.resolution-indicator.error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger-color);
}

/* =========================================================================
   AI LABELS SECTION STYLES
   ========================================================================= */

.ai-labels-section {
  border: 2px solid rgba(100, 149, 237, 0.3);
  border-radius: 8px;
  background: linear-gradient(
    135deg,
    rgba(100, 149, 237, 0.05),
    rgba(138, 43, 226, 0.05)
  );
}

.ai-prediction-container,
.user-correction-container {
  background: var(--bg-secondary);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 12px;
}

.ai-header,
.user-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.ai-header h5,
.user-header h5 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-meta-info {
  display: flex;
  gap: 8px;
  align-items: center;
}

.label-confidence-badge {
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.label-confidence-badge.confidence-high {
  background: rgba(40, 167, 69, 0.15);
  color: #28a745;
}

.label-confidence-badge.confidence-medium {
  background: rgba(255, 193, 7, 0.15);
  color: #ffc107;
}

.label-confidence-badge.confidence-low {
  background: rgba(229, 57, 53, 0.15);
  color: #dc3545;
}

.model-info {
  font-size: 11px;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ai-prediction-fields,
.user-correction-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.no-data-message {
  padding: 12px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.label-status-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.label-status-selector label {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
}

.quick-verify-section {
  padding: 12px;
  background: rgba(40, 167, 69, 0.08);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.quick-verify-section .help-text {
  font-size: 11px;
  color: var(--text-secondary);
  margin: 0;
}

.label-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.label-actions .btn {
  flex: 1;
}

/* =========================================================================
   ARRAY FIELDS (depth_blocks_above, anthropogenic_features, etc.)
   ========================================================================= */

.array-field-container {
  background: var(--bg-secondary);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 12px;
}

.array-field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.array-field-header h6 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.array-add-button {
  padding: 4px 10px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.array-field-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.array-item {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  overflow: hidden;
}

.array-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.array-item-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.array-item-title {
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.array-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.array-item-actions .toggle-icon {
  font-size: 10px;
  color: var(--text-secondary);
  transition: transform 0.2s;
}

.array-delete-button {
  background: transparent;
  border: none;
  color: #dc3545;
  cursor: pointer;
  padding: 4px;
  border-radius: 3px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.array-delete-button:hover {
  background: rgba(229, 57, 53, 0.15);
}
.array-delete-button svg {
  pointer-events: none;
}

.array-item-content {
  padding: 12px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.array-item-content.collapsed {
  display: none;
}

/* =========================================================================
   MUNSELL COLOR SELECTOR
   ========================================================================= */

.munsell-color-selector {
  display: flex;
  gap: 8px;
  align-items: center;
}

.munsell-select {
  flex: 1;
}

.munsell-color-preview,
.color-preview-small,
.color-preview-inline {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.color-preview-small {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  display: inline-block;
  vertical-align: middle;
}

.color-preview-inline {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  display: inline-block;
  vertical-align: middle;
  margin-left: 6px;
}

/* =========================================================================
   LABEL COMPARISON VIEW
   ========================================================================= */

.label-comparison-section {
  margin-top: 12px;
}

.label-comparison-view {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.label-comparison-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.comparison-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.comparison-row.different {
  background: rgba(255, 193, 7, 0.08);
}

.comparison-label {
  font-weight: 600;
  color: var(--text-primary);
}

.comparison-ai {
  color: rgba(100, 149, 237, 0.9);
  font-style: italic;
}

.comparison-user {
  color: rgba(40, 167, 69, 0.9);
  font-weight: 500;
}

/* =========================================================================
   FIELD LABEL STYLES FOR LABELS SECTION
   ========================================================================= */

[data-label-field] {
  transition: border-color 0.2s, box-shadow 0.2s;
}

[data-label-field]:focus {
  border-color: rgba(100, 149, 237, 0.5);
  box-shadow: 0 0 0 2px rgba(100, 149, 237, 0.15);
}

[data-label-field].modified {
  border-left: 3px solid #17a2b8;
}

/* =========================================================================
   REEL MODE QUICK LABELS
   ========================================================================= */

.reel-quick-edit {
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: 6px;
}

.reel-ai-overview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  background: rgba(100, 149, 237, 0.08);
  border-radius: 4px;
  margin-bottom: 12px;
}

.reel-essential-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.reel-quick-actions {
  display: flex;
  gap: 6px;
}

.reel-quick-actions .btn {
  flex: 1;
  font-size: 12px;
  padding: 6px 10px;
}

/* =========================================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================================= */

@media (max-width: 768px) {
  .comparison-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .comparison-label {
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-color);
  }

  .label-actions {
    flex-direction: column;
  }

  .munsell-color-selector {
    flex-direction: column;
    align-items: stretch;
  }
}

/* =========================================================================
   LOADING STATES
   ========================================================================= */

.labels-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: var(--text-secondary);
}

.labels-loading svg {
  margin-right: 8px;
  animation: spin 1s linear infinite;
}

/* Manual entry info message */
.manual-entry-info {
  padding: 12px;
  background: rgba(111, 66, 193, 0.08);
  border-radius: 6px;
  margin-bottom: 12px;
}

.info-message {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.info-message svg {
  color: #6f42c1;
}

/* =========================================================================
   REEL MODE LABELS SUMMARY
   ========================================================================= */

.reel-labels-summary {
  background: var(--bg-secondary);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 16px;
  border: 1px solid var(--border-color);
}

.reel-labels-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.reel-labels-header h6 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.reel-label-status {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.reel-label-status.status-pending {
  background: rgba(255, 193, 7, 0.15);
  color: #ffc107;
}

.reel-label-status.status-verified {
  background: rgba(40, 167, 69, 0.15);
  color: #28a745;
}

.reel-label-status.status-corrected {
  background: rgba(23, 162, 184, 0.15);
  color: #17a2b8;
}

.reel-labels-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.reel-field-compact {
  display: flex;
  font-size: 11px;
  padding: 4px 6px;
  background: var(--bg-tertiary);
  border-radius: 4px;
}

.reel-field-label {
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 100px;
  flex-shrink: 0;
}

.reel-field-value {
  color: var(--text-primary);
  word-break: break-word;
}

.reel-no-labels {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  padding: 8px;
  margin: 8px 0;
  background: var(--bg-tertiary);
  border-radius: 4px;
}

.reel-quick-verify,
.reel-add-labels {
  margin-top: 8px;
  font-size: 12px;
  padding: 6px 12px;
}

/* =========================================================================
   REEL MODE - GEOLOGICAL LABELS FULL SECTION
   ========================================================================= */

.reel-geological-labels {
  background: var(--bg-secondary);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 16px;
  border: 1px solid var(--border-color);
}

.reel-geological-labels.collapsed .reel-section-header .toggle-icon {
  transform: rotate(-90deg);
}

.reel-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
  user-select: none;
}

.reel-section-header:hover {
  background: rgba(255, 255, 255, 0.02);
}

.reel-section-header h6 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.reel-section-header .toggle-icon {
  font-size: 10px;
  transition: transform 0.2s;
}

.reel-section-content {
  padding-top: 10px;
}

.reel-ai-display {
  background: var(--bg-tertiary);
  border-radius: 4px;
  padding: 8px;
  margin-bottom: 8px;
}

.reel-ai-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 11px;
  font-weight: 600;
}

.reel-confidence {
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(40, 167, 69, 0.15);
  color: #28a745;
  font-size: 10px;
}

.reel-compact-field {
  display: flex;
  font-size: 11px;
  padding: 3px 0;
}

.reel-compact-field .reel-field-label {
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 120px;
  flex-shrink: 0;
}

.reel-compact-field .reel-field-value {
  color: var(--text-primary);
  word-break: break-word;
}

.reel-verify-labels-btn {
  font-size: 12px;
  padding: 6px 12px;
}

.reel-edit-hint {
  font-style: italic;
}

.reel-edit-hint svg {
  color: #17a2b8;
}

/* Color list options with miniature preview */
.form-input option[data-hex] {
  padding-left: 30px;
}

/* =========================================================================
   Batch Process Modal Styles
   ========================================================================= */

.batch-process-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  animation: fadeIn 0.2s ease-in-out;
}

.batch-process-modal {
  background: var(--bg-primary);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  /* Wide enough for the per-tray flag matrix (12 step columns + Dataset) with
     readable tray aliases. */
  max-width: 1360px;
  width: 95%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.3s ease-out;
}

.batch-process-modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--graiph-border);
  background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 100%);
  border-radius: 12px 12px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.batch-process-modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
  gap: 10px;
}

.batch-close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.batch-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Batch Process Tabs */
.batch-tabs {
  display: flex;
  border-bottom: 1px solid var(--graiph-border);
  background: var(--graiph-bg-secondary);
}

.batch-tab {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  position: relative;
}

.batch-tab:hover {
  background: var(--graiph-bg-tertiary);
  color: var(--text-secondary);
}

.batch-tab.active {
  color: var(--text-primary);
  background: var(--bg-primary);
  border-bottom: 2px solid var(--graiph-accent);
}

.batch-tab-badge {
  background: var(--danger-color);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 4px;
}

.batch-tab.active .batch-tab-badge {
  background: #1e3a5f;
}

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

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

.batch-process-modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
  max-height: calc(90vh - 220px);
}

.batch-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--graiph-border);
}

.batch-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.batch-section h4 {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.batch-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.batch-section-header h4 {
  margin: 0;
}

.batch-select-actions {
  display: flex;
  gap: 8px;
}

.batch-drillholes-list {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--graiph-border);
  border-radius: 8px;
  background: var(--graiph-bg-secondary);
}

.batch-drillhole-item {
  border-bottom: 1px solid var(--graiph-border);
}

.batch-drillhole-item:last-child {
  border-bottom: none;
}

.batch-drillhole-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg-primary);
  transition: background 0.2s;
}

.batch-drillhole-header:hover {
  background: var(--graiph-bg-tertiary);
}

.batch-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.95rem;
}

.batch-checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--graiph-accent);
}

.batch-drillhole-name {
  font-weight: 500;
  color: var(--text-primary);
}

.batch-expand-btn {
  background: var(--graiph-bg-elevated);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: var(--text-muted);
}

.batch-expand-btn:hover {
  background: var(--graiph-border-hover);
  color: var(--text-secondary);
}

.batch-trays-container {
  background: var(--graiph-bg-tertiary);
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  border-top: 1px solid var(--graiph-border);
}

.batch-trays-loading {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0.5rem;
}

.batch-trays-header {
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--graiph-border);
}

.batch-select-all-trays {
  font-weight: 500;
  color: var(--text-primary);
}

.batch-trays-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 150px;
  overflow-y: auto;
}

.batch-tray-item {
  font-size: 0.9rem;
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.batch-tray-item:hover {
  background: var(--graiph-bg-elevated);
}

.batch-tray-depth {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: 8px;
}

.batch-no-trays,
.batch-error {
  color: var(--text-muted);
  font-style: italic;
  padding: 0.5rem;
}

/* Batch tray flag columns (T6.1) */
/* Tray table = aligned CSS-grid matrix: checkbox | tray | 12 flag cols | dataset.
   Header and rows share the SAME template so flag dots line up under their
   abbreviated headers (full names live in each header's tooltip).
   The flag-column count comes from --btc-flag-cols, set inline on the list
   container from BATCH_STEP_FLAGS.length (labeler main.js) so the grid can
   never fall out of sync with the data again — one column short makes the
   Dataset cell wrap onto a second grid line. */
.batch-tray-table-header,
.batch-tray-row {
  display: grid;
  grid-template-columns: 26px minmax(220px, 1.6fr) repeat(var(--btc-flag-cols, 12), minmax(26px, 1fr)) 64px;
  align-items: center;
  font-size: 0.85rem;
}

.batch-tray-table-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-secondary, #11121a);
  padding: 6px 10px;
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 2px;
}

.batch-tray-row {
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}

.batch-tray-row:hover {
  background: rgba(255, 255, 255, 0.05);
}

.batch-tray-row.batch-tray-alldone {
  opacity: 0.55;
}

.batch-tray-row.batch-tray-no-prereq .btc-alias {
  color: #888;
  font-style: italic;
}

.btc-cb {
  display: flex;
  align-items: center;
  justify-content: center;
}

.btc-alias {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* One flag column cell (header abbreviation + per-row dot), centered */
.btc-flag,
.btc-flag-h {
  text-align: center;
}

.btc-flag-h {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--gray-light, #aab);
  cursor: help;
}

.batch-flag-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.batch-flag-dot.flag-done {
  background: var(--accent-primary, #33CC66);
}

.batch-flag-dot.flag-missing {
  background: var(--gray-light, #CCCCCC);
  opacity: 0.35;
}

.btc-dataset {
  text-align: center;
}

.batch-dataset-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  vertical-align: middle;
}

.batch-dataset-dot.batch-dataset-in {
  background: var(--accent-primary, #33CC66);
  box-shadow: 0 0 0 2px rgba(51, 204, 102, 0.2);
}

.batch-dataset-dot.batch-dataset-none {
  background: transparent;
  border: 1px solid var(--gray-light, #CCCCCC);
  opacity: 0.35;
}

/* createFractures inline source selector */
.batch-source-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  opacity: 0.85;
  flex-shrink: 0;
}

.batch-source-select {
  max-width: 140px;
  padding: 4px 8px;
  font-size: 0.78rem;
  color: var(--text-color, #fff);
  background: var(--bg-secondary, #1a1b26);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.18));
  border-radius: 4px;
  cursor: pointer;
}

.batch-source-select:hover {
  border-color: var(--accent-primary, #33CC66);
}

.batch-source-select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.batch-selection-summary {
  font-size: 0.8rem;
  color: var(--gray-light, #CCCCCC);
  padding: 4px 8px;
  margin-bottom: 4px;
  border-left: 2px solid var(--accent-primary, #33CC66);
  background: rgba(51, 204, 102, 0.06);
}

.batch-error {
  color: var(--danger-color);
}

.batch-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.batch-option-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.batch-option-group label:not(.batch-checkbox-label) {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

.batch-input-small {
  max-width: 120px;
  padding: 6px 10px;
  font-size: 0.9rem;
}

.batch-pipeline-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.batch-option-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
}

.batch-step-row {
  justify-content: space-between;
  align-items: center;
}

.batch-force-label {
  font-size: 0.78rem;
  opacity: 0.7;
  min-width: 80px;
  flex-shrink: 0;
}

.batch-force-label:hover {
  opacity: 1;
}

/* Legacy — kept for backward compat */
.batch-overwrite-label {
  font-size: 0.78rem;
  opacity: 0.7;
}

.batch-overwrite-label:hover {
  opacity: 1;
}

.batch-progress-section {
  background: rgba(51, 204, 102, 0.05);
  border-radius: 8px;
  padding: 1rem !important;
  border: 1px solid rgba(51, 204, 102, 0.2);
}

.batch-progress-info {
  margin-bottom: 1rem;
}

.batch-progress-info p {
  margin: 0.25rem 0;
  font-size: 0.95rem;
}

.batch-progress-bar-container {
  height: 12px;
  background: var(--graiph-bg-elevated);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.batch-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--graiph-accent), var(--graiph-accent-hover));
  border-radius: 6px;
  transition: width 0.5s ease;
}

.batch-progress-bar.batch-progress-indeterminate {
  width: 100% !important;
  background: linear-gradient(
    90deg,
    var(--graiph-bg-elevated) 0%,
    var(--graiph-bg-elevated) 40%,
    var(--graiph-accent) 50%,
    var(--graiph-bg-elevated) 60%,
    var(--graiph-bg-elevated) 100%
  );
  background-size: 200% 100%;
  animation: batch-progress-pulse 1.5s ease-in-out infinite;
}

@keyframes batch-progress-pulse {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.batch-progress-bar.batch-progress-error {
  background: var(--danger-color);
}

.batch-progress-bar.batch-progress-success {
  background: var(--success-color);
}

.batch-progress-status {
  font-size: 0.9rem;
}

.batch-elapsed-time {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--graiph-bg-tertiary);
  border-radius: 6px;
}

.batch-elapsed-time svg {
  color: var(--graiph-accent-text);
}

.batch-elapsed-time .elapsed-value {
  font-weight: 600;
  color: var(--text-primary);
  font-family: monospace;
}

.batch-processing-steps {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--graiph-bg-secondary);
  border-radius: 6px;
  border: 1px solid var(--graiph-border);
}

.batch-step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0.25rem 0;
}

.batch-step svg {
  width: 16px;
  text-align: center;
}

.batch-step.batch-step-active {
  color: var(--graiph-accent-text);
  font-weight: 500;
}

.batch-step.batch-step-active svg {
  animation: spin 1s linear infinite;
}

.batch-step.batch-step-completed {
  color: var(--graiph-accent-text);
}

.batch-step.batch-step-pending {
  color: var(--text-muted);
}

.batch-estimated-time {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  font-style: italic;
}

.batch-status-success {
  color: var(--graiph-accent-text);
  font-weight: 600;
}

.batch-status-warning {
  color: var(--warning-color);
  font-weight: 600;
}

.batch-status-error {
  color: var(--danger-color);
  font-weight: 600;
}

.batch-results-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.batch-result-item {
  background: var(--bg-primary);
  padding: 0.75rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--graiph-border);
  min-width: 100px;
  text-align: center;
}

.batch-result-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.batch-result-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.batch-result-success .batch-result-value {
  color: var(--graiph-accent-text);
}

.batch-result-error .batch-result-value {
  color: var(--danger-color);
}

.batch-drillhole-results {
  margin-top: 1rem;
}

.batch-drillhole-results h5 {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.batch-drillhole-result {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: var(--bg-primary);
  border-radius: 4px;
  margin-bottom: 4px;
  border-left: 3px solid var(--success-color);
}

.batch-drillhole-partial {
  border-left-color: var(--warning-color);
}

.batch-dh-id {
  font-weight: 500;
  color: var(--text-primary);
}

.batch-dh-stats {
  color: var(--text-muted);
}

.batch-dh-failed {
  color: var(--danger-color);
  margin-left: 8px;
}

.batch-failed-trays {
  margin-top: 1rem;
  background: rgba(229, 57, 53, 0.1);
  border: 1px solid rgba(229, 57, 53, 0.3);
  border-radius: 6px;
  padding: 0.75rem;
}

.batch-failed-trays h5 {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
  color: var(--danger-color);
}

.batch-failed-tray {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(229, 57, 53, 0.3);
  font-size: 0.85rem;
}

.batch-failed-tray:last-child {
  border-bottom: none;
}

.batch-failed-error {
  color: var(--danger-color);
  max-width: 350px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-more-failed {
  margin: 0.5rem 0 0 0;
  font-size: 0.85rem;
  color: var(--danger-color);
  font-style: italic;
}

.batch-process-modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--graiph-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--graiph-bg-secondary);
  border-radius: 0 0 12px 12px;
}

.batch-selection-count {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.batch-selection-count span {
  font-weight: 600;
  color: var(--graiph-accent-text);
}

.batch-footer-actions {
  display: flex;
  gap: 0.75rem;
}

.no-data {
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
}

/* Data Source Toggle */
.batch-source-toggle {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.batch-radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 0.75rem 1rem;
  border: 2px solid var(--graiph-border);
  border-radius: 8px;
  transition: all 0.2s;
  background: var(--bg-primary);
}

.batch-radio-label:hover {
  border-color: var(--graiph-accent);
  background: rgba(51, 204, 102, 0.05);
}

.batch-radio-label input[type="radio"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--graiph-accent);
}

.batch-radio-label input[type="radio"]:checked + span {
  color: var(--graiph-accent-text);
  font-weight: 500;
}

.batch-radio-label span {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}

.batch-radio-label span svg {
  color: var(--text-muted);
}

.batch-radio-label input[type="radio"]:checked + span svg {
  color: var(--graiph-accent-text);
}

/* Graiph Import Section */
.batch-graiph-import {
  background: var(--graiph-bg-secondary);
  border-radius: 8px;
  padding: 1rem;
}

.batch-import-hint {
  margin: 0 0 1rem 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.batch-import-hint svg {
  color: var(--graiph-accent-text);
  margin-top: 2px;
}

.batch-graiph-textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--graiph-border);
  border-radius: 6px;
  font-family: "Monaco", "Consolas", monospace;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 120px;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.batch-graiph-textarea:focus {
  outline: none;
  border-color: var(--graiph-accent);
  box-shadow: 0 0 0 3px rgba(51, 204, 102, 0.15);
}

.batch-graiph-textarea::placeholder {
  color: var(--text-muted);
}

.batch-graiph-options {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--graiph-border);
}

.batch-graiph-parsed {
  margin-top: 1rem;
}

.batch-parse-success {
  margin: 0;
  padding: 0.75rem;
  background: rgba(51, 204, 102, 0.1);
  border: 1px solid rgba(51, 204, 102, 0.3);
  border-radius: 6px;
  color: var(--graiph-accent-text);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.batch-parse-success svg {
  color: var(--graiph-accent-text);
}

.batch-parsed-ids {
  font-family: "Monaco", "Consolas", monospace;
  font-size: 0.85rem;
  color: var(--graiph-accent-text);
}

.batch-parse-warning {
  margin: 0;
  padding: 0.75rem;
  background: rgba(245, 166, 35, 0.12);
  border: 1px solid rgba(245, 166, 35, 0.3);
  border-radius: 6px;
  color: var(--graiph-alert-warning);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.batch-parse-warning svg {
  color: var(--warning-color);
}

@media (max-width: 768px) {
  .batch-process-modal {
    max-width: 100%;
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .batch-process-modal-header {
    border-radius: 0;
  }

  .batch-process-modal-footer {
    border-radius: 0;
    flex-direction: column;
    gap: 1rem;
  }

  .batch-options-grid {
    grid-template-columns: 1fr;
  }

  .batch-option-row {
    flex-direction: column;
    gap: 0.5rem;
  }

  .batch-results-grid {
    flex-direction: column;
  }

  .batch-result-item {
    min-width: auto;
  }

  .batch-source-toggle {
    flex-direction: column;
    gap: 0.75rem;
  }

  .batch-graiph-options {
    flex-direction: column;
  }
}

/* =========================================================================
   Sync from Graiph Modal Styles
   (Extends base-modal styles)
   ========================================================================= */

.sync-modal-overlay {
  /* Extends .base-modal-overlay */
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease-out;
}

.sync-modal {
  /* Extends .base-modal */
  background: var(--bg-primary);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  max-width: 500px;
  width: 95%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.3s ease-out;
}

.sync-modal-header {
  /* Extends .base-modal-header-gradient */
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--graiph-border);
  background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 100%);
  border-radius: 12px 12px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sync-modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync-close-btn {
  /* Extends .base-modal-close-btn */
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.sync-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.sync-modal-body {
  /* Extends .base-modal-body */
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.sync-modal-footer {
  /* Extends .base-modal-footer */
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--graiph-border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: var(--graiph-bg-secondary);
  border-radius: 0 0 12px 12px;
}

.sync-progress-info {
  margin-bottom: 1rem;
}

.sync-progress-info p {
  margin: 0;
  font-size: 0.9rem;
}

.sync-progress-bar-container {
  /* Extends .base-progress-bar-container */
  height: 8px;
  background: var(--graiph-bg-elevated);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.sync-progress-bar {
  /* Extends .base-progress-bar */
  height: 100%;
  background: linear-gradient(90deg, var(--graiph-accent) 0%, var(--graiph-accent-hover) 100%);
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.sync-progress-bar.sync-progress-indeterminate {
  width: 100%;
  animation: sync-progress-pulse 1.5s ease-in-out infinite;
}

@keyframes sync-progress-pulse {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}

.sync-progress-bar.sync-progress-success {
  background: var(--success-color);
}

.sync-progress-bar.sync-progress-error {
  background: var(--danger-color);
}

.sync-progress-details {
  margin-top: 0.5rem;
}

.sync-result-summary {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sync-result-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

.sync-result-item.sync-result-success {
  background: rgba(51, 204, 102, 0.1);
  color: var(--graiph-accent-text);
}

.sync-result-item.sync-result-info {
  background: rgba(33, 150, 243, 0.1);
  color: var(--graiph-alert-info);
}

.sync-result-item.sync-result-error {
  background: rgba(229, 57, 53, 0.1);
  color: var(--graiph-alert-error);
}

.sync-error-msg {
  color: var(--graiph-alert-error);
  font-size: 0.9rem;
  padding: 0.75rem;
  background: rgba(229, 57, 53, 0.1);
  border-radius: 6px;
  margin: 0;
}

/* =========================================================================
   Batch Trays Real-Time Table
   ========================================================================= */

.batch-progress-header-info {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.batch-info-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.batch-info-label {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.batch-info-value {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.85rem;
}

.batch-trays-table-container {
  margin-top: 1rem;
  border: 1px solid var(--graiph-border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-primary);
}

.batch-trays-table-header {
  padding: 0.75rem 1rem;
  background: var(--graiph-bg-tertiary);
  border-bottom: 1px solid var(--graiph-border);
}

.batch-trays-table-header h4 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.batch-trays-table-header h4 svg {
  color: var(--text-muted);
}

.batch-trays-table-wrapper {
  max-height: 350px;
  overflow-y: auto;
}

.batch-trays-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.batch-trays-table thead {
  position: sticky;
  top: 0;
  background: var(--graiph-bg-secondary);
  z-index: 1;
}

.batch-trays-table th {
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--graiph-border);
  white-space: nowrap;
}

.batch-trays-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--graiph-bg-tertiary);
  vertical-align: middle;
}

.batch-trays-table .col-drillhole {
  width: 12%;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.batch-trays-table .col-tray {
  width: 16%;
  font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
  font-size: 0.8rem;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-trays-table .col-state {
  width: 11%;
}

.batch-trays-table .col-step {
  width: 14%;
  color: var(--text-muted);
}

.batch-trays-table .col-time {
  width: 8%;
  text-align: center;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.batch-trays-table .col-counts {
  width: 19%;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.batch-trays-table .col-error {
  width: 20%;
}

/* Error cells by category */
.batch-error-cell {
  font-size: 0.78rem;
  color: var(--text-muted);
  max-width: 300px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  line-height: 1.3;
}
.batch-error-cell.error-timeout { color: var(--alert-warning, #F5A623); }
.batch-error-cell.error-auth_expired,
.batch-error-cell.error-auth_forbidden { color: var(--alert-error, #E53935); }
.batch-error-cell.error-service_unavailable { color: var(--alert-error, #E53935); }
.batch-error-cell.error-missing_data { color: var(--alert-info, #2196F3); }
.batch-error-cell.error-network { color: var(--alert-warning, #F5A623); }
.batch-error-cell.error-unknown { color: var(--text-muted); }

/* Tray row states */
.tray-row {
  transition: background-color 0.2s ease;
}

.tray-row.tray-queued {
  background: transparent;
  color: var(--text-muted);
}

.tray-row.tray-active,
.tray-row.tray-started {
  background: transparent;
}

.tray-row.tray-completed {
  background: rgba(51, 204, 102, 0.08);
}

.tray-row.tray-failed {
  background: rgba(229, 57, 53, 0.1);
}

.tray-row.tray-skipped {
  background: rgba(245, 166, 35, 0.08);
}

/* Wide first-column preview (readable tray header, ROI-zoom surface) + lightbox */
.tray-preview {
  position: relative;
  height: 140px;
  overflow: hidden;
  border: 1px solid var(--graiph-border);
  border-radius: 6px;
  background: var(--graiph-bg-tertiary);
}

.tray-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  cursor: zoom-in;
}

.tray-preview-hint {
  margin: 4px 0 0;
  font-size: 0.75rem;
  color: var(--alert-warning, #F5A623);
}

.roi-armed {
  outline: 1px solid var(--graiph-accent, #33CC66);
  color: var(--graiph-accent-text, #33CC66);
}

.tray-lightbox {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 30, 0.88);
  cursor: zoom-out;
}

.tray-lightbox img {
  max-width: 96vw;
  max-height: 96vh;
  object-fit: contain;
}

/* State badges */
.batch-state-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.batch-state-badge.state-queued {
  background: var(--graiph-bg-tertiary);
  color: var(--text-muted);
}

.batch-state-badge.state-active {
  background: rgba(33, 150, 243, 0.15);
  color: var(--graiph-alert-info);
}

.batch-state-badge.state-success {
  background: rgba(51, 204, 102, 0.15);
  color: var(--graiph-accent-text);
}

.batch-state-badge.state-error {
  background: rgba(229, 57, 53, 0.15);
  color: var(--graiph-alert-error);
}

.batch-state-badge.state-skipped {
  background: rgba(245, 166, 35, 0.12);
  color: var(--graiph-alert-warning);
}

/* Collapsible activity log */
.batch-activity-log.collapsed .batch-activity-entries {
  display: none;
}

.batch-activity-log .batch-activity-header {
  cursor: pointer;
  padding: 0.75rem 1rem;
  background: var(--graiph-bg-tertiary);
  border-radius: 6px;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
  margin-top: 1rem;
}

.batch-activity-log .batch-activity-header:hover {
  background: var(--graiph-bg-elevated);
}

.batch-activity-log .batch-activity-header svg {
  font-size: 0.7rem;
  transition: transform 0.2s ease;
}

.batch-activity-log .batch-activity-entries {
  max-height: 150px;
  overflow-y: auto;
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: var(--graiph-bg-secondary);
  border-radius: 0 0 6px 6px;
  border: 1px solid var(--graiph-border);
  border-top: none;
}

.batch-activity-entry {
  padding: 2px 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.batch-activity-error { color: var(--alert-error, #E53935); }
.batch-activity-warning { color: var(--alert-warning, #F5A623); }
.batch-activity-success { color: var(--accent-primary, #33CC66); }

/* Progress bar warning state */
.batch-progress-bar.batch-progress-warning {
  background: var(--warning-color) !important;
}

/* =========================================================================
   Company Progress Modal Styles
   ========================================================================= */

.progress-modal {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  z-index: 100;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.progress-modal-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 20px;
  overflow: hidden;
}

.progress-modal-header {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.progress-modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-modal-header > .btn {
  position: absolute;
  right: 0;
}

.progress-modal-header h2 svg {
  color: var(--graiph-accent-text);
}

.progress-modal-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.progress-summary-item {
  text-align: center;
  padding: 8px;
  background: var(--bg-primary);
  border-radius: 6px;
}

.progress-summary-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--graiph-accent-text);
  display: block;
}

.progress-summary-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.progress-modal-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Progress Modal Tabs */
.progress-tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 12px;
  flex-shrink: 0;
}

.progress-tab-btn {
  padding: 8px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary, #CCC);
  cursor: pointer;
  font-size: 13px;
  font-family: 'Nunito Sans', sans-serif;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}

.progress-tab-btn:hover {
  color: #FFF;
}

.progress-tab-btn.active {
  color: var(--accent-primary, #33CC66);
  border-bottom-color: var(--accent-primary, #33CC66);
}

.progress-tab-panel {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Progress Table */
.progress-table-container {
  flex: 1;
  overflow: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-primary);
}

.progress-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.progress-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.progress-table th {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 600;
  padding: 10px 12px;
  text-align: center;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.progress-table th.sticky-col {
  position: sticky;
  left: 0;
  z-index: 11;
  text-align: left;
  min-width: 180px;
  background: var(--bg-secondary);
}

.progress-table th.flag-col {
  min-width: 60px;
  font-size: 11px;
  padding: 8px 6px;
}

.progress-table th.tray-flag-header {
  background: linear-gradient(
    180deg,
    rgba(139, 92, 246, 0.15) 0%,
    var(--bg-secondary) 100%
  );
  border-top: 3px solid #8b5cf6;
}

.progress-table th.object-flag-header {
  background: linear-gradient(
    180deg,
    rgba(16, 185, 129, 0.15) 0%,
    var(--bg-secondary) 100%
  );
  border-top: 3px solid var(--success-color);
}

.progress-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  text-align: center;
}

.progress-table td.sticky-col {
  position: sticky;
  left: 0;
  background: var(--bg-primary);
  z-index: 5;
  text-align: left;
  border-right: 1px solid var(--border-color);
}

.progress-table tbody tr:hover td {
  background: var(--bg-hover);
}

.progress-table tbody tr:hover td.sticky-col {
  background: var(--bg-hover);
}

.drillhole-name-cell {
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.drillhole-name-cell svg {
  color: var(--graiph-accent-text);
  font-size: 12px;
  user-select: none;
  pointer-events: none;
}

.drillhole-name-link {
  cursor: pointer;
}

.drillhole-name-link:hover {
  text-decoration: underline;
  color: var(--graiph-accent-text);
}

.tray-count-cell {
  font-weight: 600;
  color: var(--text-primary);
}

.flag-cell {
  font-size: 12px;
  min-width: 50px;
}

.flag-cell.flag-active {
  color: var(--graiph-accent-text);
  font-weight: 600;
}

.flag-cell.flag-zero {
  color: var(--text-muted);
  opacity: 0.5;
}

/* Editable train/val/test split cells */
.progress-table th.split-col {
  font-size: 11px;
  white-space: nowrap;
}

.split-cell {
  min-width: 72px;
}

.split-select {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.75rem;
  padding: 3px 6px;
  cursor: pointer;
  color-scheme: dark;
}

.split-select:hover {
  border-color: var(--accent-color);
}

.split-select:focus {
  outline: none;
  border-color: var(--accent-color);
}

/* Totals row */
.totals-row {
  background: var(--bg-secondary) !important;
}

.totals-row td {
  border-top: 2px solid var(--border-color);
  background: var(--bg-secondary) !important;
}

.totals-row td.sticky-col {
  background: var(--bg-secondary) !important;
}

/* Legend */
.progress-table-legend {
  display: flex;
  gap: 20px;
  padding: 12px 16px;
  margin-top: 12px;
  background: var(--bg-secondary);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-color {
  width: 16px;
  height: 4px;
  border-radius: 2px;
}

.legend-color.tray-flag-legend {
  background: #8b5cf6;
}

.legend-color.object-flag-legend {
  background: var(--success-color);
}

/* No data message */
.no-drillholes-message {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.no-drillholes-message svg {
  font-size: 48px;
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.no-drillholes-message p {
  margin: 0;
  font-size: 14px;
}

/* Loading state */
.progress-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.progress-loading svg {
  font-size: 32px;
  width: 32px;
  height: 32px;
  color: var(--graiph-accent-text);
  margin-bottom: 16px;
  animation: spin 1s linear infinite;
}

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

/* Responsive adjustments */
@media (max-width: 768px) {
  .progress-modal-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .progress-table th.sticky-col,
  .progress-table td.sticky-col {
    min-width: 120px;
  }

  .progress-table th.flag-col {
    min-width: 45px;
    font-size: 10px;
  }
}

/* =========================================================================
   EXPOSED ROCK LINK UI STYLES
   ========================================================================= */

.exposed-rock-link-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.link-display-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.linked-object-display {
  flex: 1;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.linked-object-display.has-link {
  background: rgba(0, 191, 255, 0.1);
  border-color: #00BFFF;
  color: var(--text-primary);
}

.linked-object-display.no-link {
  font-style: italic;
  color: var(--text-muted);
}

.link-selection-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(51, 204, 102, 0.1);
  border: 1px solid var(--primary-color);
  border-radius: var(--radius-md);
  margin-top: 8px;
}

.link-selection-status .status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--graiph-accent-text);
  font-size: 13px;
}

.link-selection-status .status-indicator svg {
  animation: pulse 1.5s ease-in-out infinite;
}

.link-selection-status .status-indicator.selecting {
  color: var(--graiph-accent-text);
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Link button styles */
#selectIntactRockBtn,
#selectFractureBtn {
  min-width: 70px;
}

#clearIntactRockBtn,
#clearFractureBtn {
  padding: 6px 8px;
  min-width: auto;
  color: var(--danger-color);
}

#clearIntactRockBtn:hover,
#clearFractureBtn:hover {
  background: rgba(220, 38, 38, 0.1);
  border-color: var(--danger-color);
}

/* Position select for ExposedRock */
#exposedRockPosition {
  margin-top: 4px;
}

.field-help {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* =============================================================================
   FEEDBACK MODAL STYLES
   ============================================================================= */

.feedback-form-group {
  margin-bottom: 1rem;
}

.feedback-form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.feedback-form-group label span.required {
  color: var(--danger-color);
  margin-left: 2px;
}

.feedback-form-group select,
.feedback-form-group textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--graiph-border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.feedback-form-group select:focus,
.feedback-form-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(51, 204, 102, 0.15);
}

.feedback-form-group textarea {
  min-height: 100px;
  resize: vertical;
}

.feedback-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.feedback-context-info {
  background: var(--graiph-bg-tertiary);
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  font-size: 13px;
}

.feedback-context-info .context-label {
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.feedback-context-info .context-value {
  color: var(--text-primary);
  word-break: break-all;
}

.feedback-severity-options {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.feedback-severity-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--graiph-border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.feedback-severity-option:hover {
  background: var(--graiph-bg-secondary);
}

.feedback-severity-option.selected {
  border-color: var(--primary-color);
  background: rgba(51, 204, 102, 0.08);
}

.feedback-severity-option input[type="radio"] {
  display: none;
}

.severity-low { color: var(--graiph-accent-text); }
.severity-medium { color: var(--warning-color); }
.severity-high { color: var(--danger-color); }
.severity-critical { color: #7c3aed; }

/* Feedback button in header */
#feedbackBtn {
  margin-right: 0.5rem;
}

#feedbackBtn:hover {
  color: var(--graiph-accent-text);
}
