/* ==================== CORE DESIGN TOKENS ==================== */
:root {
  --background: #090D16;
  --surface: #1E293B;
  --surface-variant: #334155;
  --primary: #0EA5E9;
  --secondary: #CD2C2C;
  --on-surface: #F8FAFC;
  --on-surface-variant: #94A3B8;
  --outline: #334155;

  /* Class Colors */
  --class-ghost-bat: #F97316;
  --class-other-bat: #A855F7;
  --class-pup: #84CC16;
  --class-false-positive: #64748B;

  /* Evaluation Colors */
  --ground-truth: #22C55E;
  --model-prediction: #EF4444;

  /* Fonts */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'Roboto Mono', monospace;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-med: 0.3s ease;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--background);
  color: var(--on-surface);
  line-height: 1.5;
  overflow: hidden;
  font-size: 14px;
}

h1, h2, h3, h4 {
  font-weight: 600;
  color: var(--on-surface);
}

p {
  color: var(--on-surface-variant);
}

.hidden {
  display: none !important;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--background);
}
::-webkit-scrollbar-thumb {
  background: var(--surface-variant);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* ==================== LOGIN COMPONENT ==================== */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background: radial-gradient(circle at center, #111a30 0%, #090d16 100%);
}

.login-card {
  width: 100%;
  max-width: 480px;
  background-color: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 12px;
  padding: 2.5rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  text-align: center;
  animation: fadeIn 0.4s ease-out;
}

.login-header .logo-icon,
.login-header .login-logo {
  height: 180px;
  max-width: 100%;
  width: auto;
  margin-bottom: 1rem;
  filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.6));
}

.login-header h1 {
  font-size: 1.8rem;
  margin-bottom: 0.25rem;
}

.login-header .subtitle {
  font-size: 0.9rem;
}

.co-brand {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
  padding: 0.5rem;
  background-color: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--on-surface-variant);
}

.co-brand .brand-adr {
  color: var(--primary);
}

.co-brand .brand-rt {
  color: #FFF;
  border-bottom: 2px solid var(--secondary);
}

.login-form {
  margin-bottom: 2rem;
  text-align: left;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--on-surface-variant);
  margin-bottom: 0.5rem;
}

.form-input, input[type="text"], input[type="password"], input[type="number"], select.form-select {
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: var(--background);
  border: 1px solid var(--outline);
  border-radius: 6px;
  color: var(--on-surface);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color var(--transition-fast);
}

.form-input:focus, input[type="text"]:focus, input[type="password"]:focus, select.form-select:focus {
  outline: none;
  border-color: var(--primary);
}

.login-error {
  margin-top: 1rem;
  padding: 0.75rem;
  background-color: rgba(205, 44, 44, 0.15);
  border: 1px solid var(--secondary);
  border-radius: 6px;
  color: #FCA5A5;
  font-size: 0.85rem;
}

.login-presets {
  border-top: 1px solid var(--outline);
  padding-top: 1.5rem;
}

.login-presets h3 {
  font-size: 0.85rem;
  color: var(--on-surface-variant);
  margin-bottom: 0.75rem;
  text-align: left;
}

.preset-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.preset-card {
  display: flex;
  flex-direction: column;
  padding: 0.5rem;
  background-color: var(--background);
  border: 1px solid var(--outline);
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.preset-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.preset-card .role {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--on-surface);
}

.preset-card .desc {
  font-size: 0.65rem;
  color: var(--on-surface-variant);
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast), opacity var(--transition-fast);
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-primary {
  background-color: var(--primary);
  color: #000;
  font-weight: 600;
}

.btn-primary:hover {
  background-color: #38bdf8;
}

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--outline);
  color: var(--on-surface);
}

.btn-outline:hover {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: var(--on-surface-variant);
}

.btn-critical {
  background-color: var(--secondary);
  color: var(--on-surface);
}

.btn-critical:hover {
  background-color: #ef4444;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--on-surface-variant);
  cursor: pointer;
  display: flex;
  padding: 0.5rem;
  border-radius: 50%;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.btn-icon:hover {
  background-color: var(--surface-variant);
  color: var(--on-surface);
}

.btn-xs {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border-radius: 4px;
}

/* ==================== APP LAYOUT ==================== */
.app-layout {
  display: grid;
  grid-template-rows: 64px 1fr;
  height: 100vh;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background-color: var(--surface);
  border-bottom: 1px solid var(--outline);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.menu-icon {
  color: var(--on-surface-variant);
  cursor: pointer;
}

.header-brand-logo {
  height: 52px;
  max-height: 52px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
}

.portal-brand {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.portal-brand .tag {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  background-color: var(--primary);
  color: #000;
  border-radius: 4px;
}

.project-id {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--on-surface-variant);
  background-color: var(--background);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--outline);
}

.workspace-isolation {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.2);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.8rem;
}

.workspace-isolation .lock-icon {
  color: var(--ground-truth);
  font-size: 1.1rem;
}

.workspace-isolation .workspace-text {
  color: #FFF;
  font-weight: 500;
}

.workspace-isolation .bucket-text {
  color: var(--on-surface-variant);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-details {
  display: flex;
  flex-direction: column;
}

.user-details .user-name {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
}

.user-details .user-role {
  font-size: 0.7rem;
  color: var(--on-surface-variant);
  text-transform: capitalize;
}

.app-body {
  display: grid;
  grid-template-columns: 80px 1fr;
  height: 100%;
  overflow: hidden;
}

/* ==================== NAV RAIL ==================== */
.nav-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 0;
  background-color: var(--surface);
  border-right: 1px solid var(--outline);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: transparent;
  border: none;
  color: var(--on-surface-variant);
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.nav-item span.material-symbols-outlined {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.nav-item .label {
  font-size: 0.65rem;
  font-weight: 500;
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.03);
  color: var(--on-surface);
}

.nav-item.active {
  background-color: rgba(14, 165, 233, 0.1);
  color: var(--primary);
}

/* ==================== PANES COMMON ==================== */
.workspace-content {
  position: relative;
  overflow: hidden;
  height: 100%;
}

.pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 2rem;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.pane-header {
  margin-bottom: 2rem;
}

.pane-header h2 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.pane-header .description {
  font-size: 0.9rem;
}

/* ==================== PANE: DASHBOARD ==================== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background-color: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 8px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--on-surface-variant);
  margin-bottom: 0.5rem;
}

.stat-card .stat-value {
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--on-surface);
  margin-bottom: 0.25rem;
}

.stat-card .stat-desc {
  font-size: 0.75rem;
  color: var(--on-surface-variant);
}

.dashboard-details {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 1.5rem;
}

.detail-card {
  background-color: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 8px;
  padding: 1.5rem;
}

.detail-card h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.chart-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 160px;
  justify-content: center;
}

.chart-empty {
  text-align: center;
  color: var(--on-surface-variant);
  font-size: 0.85rem;
}

/* CSS Distribution Bar */
.chart-bar-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.chart-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}

.chart-bar-track {
  height: 12px;
  background-color: var(--background);
  border-radius: 6px;
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  border-radius: 6px;
}

.job-status-summary {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--outline);
  padding-bottom: 0.75rem;
}

.status-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.tag-completed {
  background-color: rgba(34, 197, 94, 0.15);
  color: var(--ground-truth);
}

.status-time {
  font-size: 0.75rem;
  color: var(--on-surface-variant);
}

.status-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.status-item span.material-symbols-outlined {
  color: var(--primary);
  font-size: 1.25rem;
}

.status-item .status-details {
  display: flex;
  flex-direction: column;
}

.status-item .status-details strong {
  font-size: 0.85rem;
}

.status-item .status-details span {
  font-size: 0.75rem;
  color: var(--on-surface-variant);
  font-family: var(--font-mono);
  word-break: break-all;
}

/* ==================== PANE: INGESTION ==================== */
.ingestion-layout {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 1.5rem;
  height: 100%;
}

.upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
  background-color: var(--surface);
  border: 2px dashed var(--outline);
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.upload-dropzone:hover {
  border-color: var(--primary);
  background-color: rgba(14, 165, 233, 0.02);
}

.upload-dropzone .drop-icon {
  font-size: 3rem;
  color: var(--on-surface-variant);
  margin-bottom: 0.75rem;
}

.upload-dropzone h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.upload-dropzone p {
  font-size: 0.8rem;
  margin-bottom: 1rem;
}

.upload-progress {
  width: 100%;
  max-width: 320px;
  margin-top: 1rem;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.upload-progress-track {
  width: 100%;
  height: 6px;
  background-color: var(--background);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  background-color: var(--primary);
  transition: width 0.1s linear;
}

.progress-text {
  font-size: 0.8rem;
  color: var(--on-surface-variant);
}

.videos-list-section {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 8px;
  padding: 1.25rem;
}

.videos-list-section h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.table-container {
  overflow-y: auto;
  flex: 1;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th, .data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--outline);
}

.data-table th {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--on-surface-variant);
  background-color: rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table td {
  font-size: 0.85rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-unprocessed {
  background-color: rgba(148, 163, 184, 0.15);
  color: #CBD5E1;
}

.badge-processing {
  background-color: rgba(14, 165, 233, 0.15);
  color: var(--primary);
}

.badge-processed {
  background-color: rgba(34, 197, 94, 0.15);
  color: var(--ground-truth);
}

.badge-failed {
  background-color: rgba(205, 44, 44, 0.15);
  color: var(--secondary);
}

.badge-reviewed {
  background-color: rgba(168, 85, 247, 0.15);
  color: #c084fc;
}

/* Side Sheet / Drawer Component */
.side-sheet {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  background-color: var(--surface);
  border-left: 1px solid var(--outline);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.5);
  z-index: 10;
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.25s ease-out;
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.sheet-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem;
  border-bottom: 1px solid var(--outline);
}

.sheet-header .header-icon {
  color: var(--primary);
}

.sheet-header h3 {
  flex: 1;
  font-size: 1.1rem;
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--on-surface-variant);
  cursor: pointer;
  padding: 0.25rem;
}

.btn-close:hover {
  color: var(--on-surface);
}

.sheet-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.video-preview-card {
  background-color: var(--background);
  border: 1px solid var(--outline);
  border-radius: 6px;
  padding: 1rem;
}

.video-preview-card strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.video-preview-card p {
  font-size: 0.75rem;
}

.slider-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.slider-icon {
  color: var(--on-surface-variant);
}

#samplingSlider {
  flex: 1;
  height: 6px;
  background-color: var(--background);
  border-radius: 3px;
  outline: none;
  accent-color: var(--primary);
}

.slider-readout {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 0.5rem;
}

.slider-readout .value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
}

.slider-readout .calculation {
  font-size: 0.75rem;
  color: var(--on-surface-variant);
}

.info-alert {
  display: flex;
  gap: 0.75rem;
  background-color: rgba(14, 165, 233, 0.05);
  border: 1px solid rgba(14, 165, 233, 0.15);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
}

.info-alert span {
  color: var(--primary);
  font-size: 1.25rem;
}

/* ==================== PANE: LABELING STUDIO ==================== */
.labeling-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  height: 100%;
  overflow: hidden;
}

.labeling-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
  border-right: 1px solid var(--outline);
  padding-right: 1.5rem;
}

.sidebar-block {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-block h3 {
  font-size: 0.85rem;
  color: var(--on-surface-variant);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.flex-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.class-selector {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.class-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.8rem;
  background-color: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 6px;
  color: var(--on-surface);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
  justify-content: space-between;
}

.class-btn .delete-class-btn {
  font-size: 1rem;
  color: var(--on-surface-variant);
  opacity: 0.25;
  margin-left: 0.5rem;
  transition: opacity var(--transition-fast), color var(--transition-fast);
}

.class-btn .delete-class-btn:hover {
  opacity: 1.0;
  color: #ef4444 !important;
}

.class-btn:hover {
  background-color: rgba(255, 255, 255, 0.03);
}

.class-btn.active {
  border-width: 2px;
}

.class-btn.class-ghost-bat.active { border-color: var(--class-ghost-bat); }
.class-btn.class-other-bat.active { border-color: var(--class-other-bat); }
.class-btn.class-pup.active { border-color: var(--class-pup); }
.class-btn.class-false-positive.active { border-color: var(--class-false-positive); }

.color-badge {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
  flex-shrink: 0;
}

.bg-orange { background-color: var(--class-ghost-bat); }
.bg-purple { background-color: var(--class-other-bat); }
.bg-lime { background-color: var(--class-pup); }
.bg-slate { background-color: var(--class-false-positive); }

.class-btn .name {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 500;
}

.class-btn .key-badge {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  background-color: var(--background);
  color: var(--on-surface-variant);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  border: 1px solid var(--outline);
}

.shortcut-legend {
  margin-top: auto;
  padding: 1rem;
  background-color: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 8px;
}

.shortcut-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.shortcut-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
}

.shortcut-item .key {
  font-family: var(--font-mono);
  background-color: var(--background);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  border: 1px solid var(--outline);
}

/* Canvas Viewport */
.canvas-workspace {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  height: 100%;
  overflow: hidden;
  gap: 1rem;
  min-width: 0;
  min-height: 0;
}

.canvas-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.canvas-toolbar h3 {
  font-size: 1.1rem;
  margin: 0;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-outline.active {
  background-color: var(--primary) !important;
  color: #000 !important;
  border-color: var(--primary) !important;
}

.hide-bboxes .bbox-rect {
  display: none !important;
}

.hide-trajectories .trajectory-svg {
  display: none !important;
}

.metadata-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--primary);
  background-color: rgba(14, 165, 233, 0.08);
  border: 1px solid rgba(14, 165, 233, 0.15);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin-left: 0.5rem;
}

.canvas-container {
  position: relative;
  background-color: #000;
  border: 1px solid var(--outline);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  min-height: 0;
  min-width: 0;
}

#canvasImage {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.bbox-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.cursor-crosshair {
  cursor: crosshair;
}

/* Render Bounding Boxes */
.bbox-rect {
  position: absolute;
  border-width: 2px;
  border-style: solid;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: opacity var(--transition-fast), box-shadow var(--transition-fast);
  opacity: 0.45;
  background-color: rgba(0, 0, 0, 0.03);
}

.bbox-rect:hover, .bbox-rect.active {
  opacity: 0.95;
  background-color: rgba(0, 0, 0, 0.12);
}

.bbox-rect.active {
  box-shadow: 0 0 12px rgba(14, 165, 233, 0.8), inset 0 0 4px rgba(14, 165, 233, 0.4);
}

/* Accessible Label Tag inside absolute box container */
.bbox-label {
  position: absolute;
  bottom: 100%;
  left: -2px;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.1rem 0.3rem;
  color: #000;
  border-radius: 3px 3px 0 0;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Color codes mapping to classes */
.bbox-ghost-bat { border-color: var(--class-ghost-bat); }
.bbox-ghost-bat .bbox-label { background-color: var(--class-ghost-bat); color: #000; }

.bbox-other-bat { border-color: var(--class-other-bat); }
.bbox-other-bat .bbox-label { background-color: var(--class-other-bat); color: #FFF; }

.bbox-pup { border-color: var(--class-pup); }
.bbox-pup .bbox-label { background-color: var(--class-pup); color: #000; }

.bbox-false-positive { border-color: var(--class-false-positive); }
.bbox-false-positive .bbox-label { background-color: var(--class-false-positive); color: #FFF; }

/* Evaluation Overlay Colors */
.bbox-ground-truth { border-color: var(--ground-truth); }
.bbox-ground-truth .bbox-label { background-color: var(--ground-truth); color: #000; }

.bbox-prediction { border-color: var(--model-prediction); }
.bbox-prediction .bbox-label { background-color: var(--model-prediction); color: #FFF; }

/* Resize Handles on active bounding box */
.resize-handle {
  position: absolute;
  width: 8px;
  height: 8px;
  background-color: #FFF;
  border: 1px solid #000;
  border-radius: 50%;
  pointer-events: auto;
  z-index: 5;
}

.handle-tl { top: -4px; left: -4px; cursor: nwse-resize; }
.handle-tr { top: -4px; right: -4px; cursor: nesw-resize; }
.handle-bl { bottom: -4px; left: -4px; cursor: nesw-resize; }
.handle-br { bottom: -4px; right: -4px; cursor: nwse-resize; }

/* Navigation buttons */
.canvas-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 6px;
  padding: 0.5rem 1rem;
}

.frame-count-indicator {
  font-size: 0.9rem;
}

.frame-num-input {
  width: 50px;
  text-align: center;
  padding: 0.2rem;
  background-color: var(--background);
  border: 1px solid var(--outline);
  border-radius: 4px;
  color: var(--on-surface);
  font-weight: 600;
}

/* Horizontal Gallery Sheet */
.gallery-sheet {
  background-color: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.gallery-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gallery-title-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.gallery-title-left span {
  color: var(--primary);
}

.gallery-title-left h3 {
  font-size: 0.9rem;
}

.gallery-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0.5rem;
  background-color: rgba(14, 165, 233, 0.08);
  border-radius: 4px;
  border: 1px solid rgba(14, 165, 233, 0.15);
}

.gallery-actions .selected-count {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 500;
}

.gallery-filters {
  display: flex;
  gap: 0.35rem;
}

.filter-chip {
  background: transparent;
  border: 1px solid var(--outline);
  color: var(--on-surface-variant);
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.filter-chip:hover {
  background-color: rgba(255, 255, 255, 0.03);
}

.filter-chip.active {
  background-color: var(--primary);
  color: #000;
  border-color: var(--primary);
  font-weight: 600;
}

.gallery-carousel {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  min-width: 0;
}

.carousel-empty {
  text-align: center;
  color: var(--on-surface-variant);
  font-size: 0.85rem;
  width: 100%;
  padding: 1.5rem 0;
}

.gallery-card {
  width: 110px;
  flex-shrink: 0;
  background-color: var(--background);
  border: 2px solid var(--outline);
  border-radius: 6px;
  padding: 0.25rem;
  cursor: pointer;
  position: relative;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
  user-select: none;
}

.gallery-card:hover {
  transform: translateY(-2px);
}

.gallery-card.active {
  border-color: var(--primary);
}

.gallery-card.selected {
  border-color: var(--primary);
  background-color: rgba(14, 165, 233, 0.05);
}

.gallery-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 4px;
}

.gallery-card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--on-surface-variant);
  margin-top: 0.25rem;
}

.gallery-card .status-indicator-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

.gallery-card .status-indicator-badge.completed {
  background-color: var(--ground-truth);
}

.gallery-card .status-indicator-badge.partially-labeled {
  background-color: var(--class-ghost-bat);
}

.gallery-card .status-indicator-badge.unlabeled {
  background-color: #7f1d1d;
}

.gallery-card .select-checkbox {
  position: absolute;
  top: 4px;
  right: 4px;
  background-color: var(--background);
  border: 1px solid var(--outline);
  width: 16px;
  height: 16px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 0.75rem;
}

/* ==================== PANE: VERTEX AI TRAINING ==================== */
.training-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  height: 100%;
  overflow: hidden;
}

.training-config-card {
  background-color: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 8px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.training-config-card h3 {
  font-size: 1.25rem;
  border-bottom: 1px solid var(--outline);
  padding-bottom: 0.75rem;
}

.split-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.split-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.field-desc {
  font-size: 0.75rem;
  color: var(--on-surface-variant);
  margin-top: 0.5rem;
}

.training-logs-card {
  background-color: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 8px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.logs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--outline);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

.logs-header .status-indicator {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background-color: var(--background);
  border: 1px solid var(--outline);
}

.terminal-container {
  background-color: #000;
  border-radius: 6px;
  padding: 1rem;
  flex: 1;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #FFF;
  border: 1px solid var(--outline);
}

.terminal-container pre {
  white-space: pre-wrap;
  word-break: break-all;
}

/* ==================== PANE: EVALUATION & REVIEW ==================== */
.evaluation-metrics-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.eval-stat-card {
  background-color: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 8px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.eval-stat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.eval-stat-header .label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--on-surface-variant);
}

.eval-stat-header .formula {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--primary);
  background-color: rgba(14, 165, 233, 0.05);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.eval-stat-card .value {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--on-surface);
  line-height: 1.1;
  margin-bottom: 0.25rem;
}

.eval-stat-card .desc {
  font-size: 0.75rem;
  color: var(--on-surface-variant);
}

.evaluation-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.card-desc {
  font-size: 0.8rem;
  color: var(--on-surface-variant);
  margin-bottom: 1rem;
}

/* Confusion Matrix Grid Heatmap */
.matrix-grid-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 1rem 0;
}

.matrix-grid-wrapper {
  display: grid;
  grid-template-columns: 90px repeat(4, 60px);
  gap: 4px;
  align-items: center;
  text-align: center;
}

.matrix-header-cell {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--on-surface-variant);
  text-transform: uppercase;
  padding: 0.25rem;
}

.matrix-row-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-align: right;
  padding-right: 8px;
  color: var(--on-surface-variant);
}

.matrix-cell {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

/* Heatmap intensities based on mapping */
.intensity-high { background-color: var(--primary); color: #000; }
.intensity-med { background-color: rgba(14, 165, 233, 0.6); color: #FFF; }
.intensity-low { background-color: rgba(14, 165, 233, 0.25); color: var(--on-surface-variant); }
.intensity-zero { background-color: #0b111e; color: rgba(255, 255, 255, 0.1); }

.matrix-header-col-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.matrix-header-row-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  margin-top: 0.75rem;
  transform: rotate(0deg);
}

/* Test Split Frames Grid */
.eval-frames-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.eval-frame-card {
  background-color: var(--background);
  border: 1px solid var(--outline);
  border-radius: 6px;
  padding: 0.4rem;
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.eval-frame-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.eval-frame-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 4px;
}

.eval-frame-card .meta {
  font-size: 0.65rem;
  color: var(--on-surface-variant);
  margin-top: 0.25rem;
  display: block;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.eval-frame-card .badge-counts {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.2rem;
}

.eval-frame-card .count-chip {
  font-size: 0.6rem;
  font-weight: 600;
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
}

.eval-frame-card .count-chip.gt { background-color: rgba(34, 197, 94, 0.15); color: var(--ground-truth); }
.eval-frame-card .count-chip.pred { background-color: rgba(239, 68, 68, 0.15); color: var(--model-prediction); }

/* ==================== DIALOGS & OVERLAYS ==================== */
dialog {
  color: var(--on-surface);
  border: 1px solid var(--outline);
  border-radius: 12px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  outline: none;
  margin: auto;
}

dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.standard-dialog {
  width: 100%;
  max-width: 400px;
  background-color: var(--surface);
  padding: 1.5rem;
}

.dialog-form h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Side-by-Side Review Dialog */
.eval-dialog {
  width: 90vw;
  max-width: 1200px;
  background-color: var(--surface);
}

.eval-dialog-wrapper {
  display: flex;
  flex-direction: column;
  height: 80vh;
}

.eval-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--outline);
}

.eval-dialog-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  padding: 1.5rem;
  overflow: hidden;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: hidden;
}

.side-panel h4 {
  font-size: 0.9rem;
  border-bottom: 1px solid var(--outline);
  padding-bottom: 0.5rem;
}

.ground-truth-panel h4 { color: var(--ground-truth); }
.model-prediction-panel h4 { color: var(--model-prediction); }

.side-panel .image-wrapper {
  position: relative;
  background-color: #000;
  border: 1px solid var(--outline);
  border-radius: 6px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.side-panel .image-wrapper img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

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

/* Fade in keyframes */
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

/* ==================== ACTIVITY FEED LOGS ==================== */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.activity-item {
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0.75rem;
  background-color: var(--background);
  border: 1px solid var(--outline);
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  animation: fadeIn 0.2s ease-out;
}

.activity-item-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.2rem;
  font-size: 0.7rem;
  color: var(--on-surface-variant);
}

.activity-item-header .user {
  font-weight: 600;
  color: var(--primary);
}

.activity-item-header .time {
  font-family: var(--font-mono);
}

.activity-item .msg {
  color: var(--on-surface);
}

.feed-empty {
  text-align: center;
  color: var(--on-surface-variant);
  font-size: 0.8rem;
  padding: 2rem 0;
}

/* ==================== USER MANAGEMENT ==================== */
.users-layout {
  display: flex;
  flex-direction: column;
  background-color: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 8px;
  padding: 1.5rem;
  height: 100%;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.list-header h3 {
  font-size: 1.1rem;
}

.location-cell:hover .btn-edit-loc {
  opacity: 1 !important;
}

.material-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}
