/* Teleios Studio — "Daylight Studio" theme (direction 1a) */

:root {
  /* Surfaces — ice blue */
  --bg-primary: #EEF4FB;
  --bg-white: #FFFFFF;
  --bg-hover: #F1F5FB;

  /* Text — soft slate, never pure black */
  --text-primary: #1F2D43;
  --text-secondary: #5D6F8D;
  --text-muted: #93A5C4;

  /* Primary action — crisp blue */
  --accent: #2F7EF6;
  --accent-hover: #1B62D6;
  --accent-light: rgba(47, 126, 246, 0.09);

  /* Status — muted, not neon */
  --success: #3BA55D;
  --success-light: rgba(59, 165, 93, 0.12);
  --error: #C96A6A;
  --error-light: rgba(201, 106, 106, 0.10);
  --badge-alert: #C62828; /* white text on it passes WCAG AA (5.6:1) */
  --warning: #E0A458;
  --warning-light: rgba(224, 164, 88, 0.13);
  --info: #2F7EF6;
  --info-light: rgba(47, 126, 246, 0.09);

  /* Hairlines */
  --border: #E2EAF5;
  --border-light: #EEF2F8;

  /* Layered, blue-tinted shadows */
  --shadow-sm: 0 1px 2px rgba(31, 45, 67, 0.05);
  --shadow-card: 0 1px 2px rgba(31, 45, 67, 0.05);
  --shadow-hover: 0 12px 30px -16px rgba(31, 45, 67, 0.30);
  --shadow-lg: 0 26px 56px -30px rgba(31, 45, 67, 0.40);

  /* Softer corners */
  --radius-card: 16px;
  --radius-button: 11px;
  --radius-input: 11px;

  /* Sidebar — same ink family as the landing pages */
  --sidebar-width: 260px;
  --sidebar-bg: #16202F;
  --sidebar-text: #8FA2BE;
  --sidebar-text-active: #FFFFFF;
  --sidebar-hover: rgba(255, 255, 255, 0.05);
  --sidebar-active: rgba(47, 126, 246, 0.16);

  --transition-fast: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, 'Segoe UI', sans-serif;
  letter-spacing: -0.005em;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 50;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 16px;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: -0.02em;
}

/* Organization branding: the customer's logo sits on a white tile (a dark
   logo would vanish on the dark sidebar); department name underneath. */
.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}
.sidebar-brand.branded .sidebar-title {
  font-size: 15px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-subtitle {
  font-size: 12.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-powered {
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.02em;
}
/* Teleios look: wordmark with a small product label beside it (as on Edge). */
.sidebar-wordmark {
  height: 16px;
  width: auto;
  display: block;
}
.sidebar-brand:not(.branded) .sidebar-brand-text {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}
.sidebar-brand:not(.branded) .sidebar-subtitle {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}
.sidebar-logo.has-image {
  background: #FFFFFF;
  border-radius: 8px;
  padding: 3px;
  overflow: hidden;
}
.sidebar-brand-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(148, 163, 184, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 12px 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
  position: relative;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}

.sidebar-link.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
}

/* Count of items waiting on a page (Requirements, staff only). */
.sidebar-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--badge-alert);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
  background: rgba(255,255,255,0.1);
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #E2E8F0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--sidebar-text);
  text-transform: none;  /* role names are cased as written (roles.js) */
}

.sidebar-user-dept {
  font-size: 11px;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Profile menu (sidebar footer) ─────────────────────────────────────────
   Replaces the old avatar card + separate logout button. The panel itself is
   position:fixed and lives on <body>, because .sidebar is overflow:hidden and
   would clip an in-flow popover. */
.sidebar-user-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  background: transparent;
  border: none;
  border-radius: var(--radius-button);
  cursor: pointer;
  text-align: left;
  color: inherit;
  transition: background 0.15s;
}
.sidebar-user-trigger:hover {
  background: rgba(255, 255, 255, 0.08);
}
.sidebar-user-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.profile-avatar {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  user-select: none;
}
.profile-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-menu {
  position: fixed;
  z-index: 90; /* above .sidebar (50), below .modal-overlay (100) */
  min-width: 260px;
  max-width: calc(100vw - 16px);
  padding: 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lg, 0 12px 32px rgba(0, 0, 0, 0.18));
}
.profile-menu-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 10px;
}
.profile-menu-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.profile-menu-meta strong {
  font-size: 14px;
  color: var(--text-primary, #111827);
}
.profile-menu-meta span {
  font-size: 12px;
  color: var(--text-muted, #6b7280);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-menu-role {
  margin-top: 2px;
  font-weight: 600;
  text-transform: none;  /* role names are cased as written (roles.js) */
}
.profile-menu-depts {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.profile-menu-depts-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.profile-menu-sep {
  height: 1px;
  margin: 6px 0;
  background: var(--border);
}
.profile-menu-label {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted, #6b7280);
}
.profile-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: var(--radius-button);
  font-size: 14px;
  color: var(--text-primary, #111827);
  cursor: pointer;
  text-align: left;
}
.profile-menu-item:hover {
  background: var(--bg-hover, #f3f4f6);
}
.profile-menu-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.profile-menu-check {
  width: 16px;
  flex-shrink: 0;
  color: var(--accent);
}
.profile-menu-danger {
  color: var(--error, #ef4444);
}

.sidebar-logout {
  background: none;
  border: none;
  color: var(--sidebar-text);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.sidebar-logout:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #EF4444;
}

/* ─── Main Content ─── */
.main-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-header {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 20px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
}

.main-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.main-header p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.main-body {
  flex: 1;
  padding: 24px 32px;
}

/* ─── Cards ─── */
.card {
  background: var(--bg-white);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  padding: 20px;
  transition: all var(--transition-normal);
}

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

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

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

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-button);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  font-family: inherit;
  line-height: 1.4;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 1px 2px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
  transform: translateY(-1px);
}

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

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

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

.btn-danger:hover:not(:disabled) {
  background: #DC2626;
}

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

.btn-success:hover:not(:disabled) {
  background: #059669;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 10px;
}

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

.btn-sm {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
}

.btn-lg {
  font-size: 15px;
  padding: 12px 24px;
  border-radius: 10px;
}

/* ─── Inputs ─── */
input, select, textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  padding: 9px 14px;
  font-size: 14px;
  width: 100%;
  outline: none;
  transition: all var(--transition-fast);
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-white);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}

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

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-ready, .badge-approved, .badge-published, .badge-labeled, .badge-reviewed {
  background: var(--success-light);
  color: #065F46;
}
.badge-processing, .badge-submitted, .badge-uploading, .badge-extracting, .badge-deduplicating, .badge-pre-labeling, .badge-converting {
  background: var(--warning-light);
  color: #92400E;
}
.badge-error, .badge-rejected {
  background: var(--error-light);
  color: #991B1B;
}
.badge-uploaded, .badge-active, .badge-trained {
  background: var(--info-light);
  color: #1E40AF;
}
.badge-prelabeled, .badge-converted {
  background: #F5F3FF;
  color: #5B21B6;
}
.badge-validating {
  background: #FDF4FF;
  color: #86198F;
  animation: pulse 2s ease-in-out infinite;
}
.badge-pending_review {
  background: var(--warning-light);
  color: #92400E;
  animation: pulse 2s ease-in-out infinite;
}
.badge-rolled_back {
  background: #F3F4F6;
  color: #6B7280;
}
.badge-not_promoted {
  background: #F3F4F6;
  color: #9CA3AF;
}
.badge-validation_failed {
  background: var(--error-light);
  color: #991B1B;
}
.badge-unlabeled {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

/* ─── Tables ─── */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
}

td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light);
}

tr:hover td {
  background: rgba(99, 102, 241, 0.02);
}

tr.cursor-pointer {
  cursor: pointer;
}

/* ─── Upload Zone ─── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-card);
  padding: 48px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  background: var(--bg-white);
}

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

/* ─── Progress Bar ─── */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border-light);
  border-radius: 100px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #818CF8);
  border-radius: 100px;
  transition: width 0.3s ease;
}

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--bg-white);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 28px;
  max-width: 520px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

/* ─── Stat Cards ─── */
.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.stat-card .stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

/* ─── Spinner ─── */
.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

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

@keyframes progress-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

@keyframes pipeline-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 113, 227, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(0, 113, 227, 0); }
}

/* ─── Toast ─── */
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-button);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  transition: opacity 300ms;
  pointer-events: auto;
}

/* ─── Empty State ─── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.4;
}

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

/* ─── Labeling Editor Overrides ─── */
body.editor-mode {
  overflow: hidden;
  height: 100vh;
}

body.editor-mode .sidebar {
  width: 64px;
}

body.editor-mode .sidebar .sidebar-title,
body.editor-mode .sidebar .sidebar-brand-text,
body.editor-mode .sidebar .sidebar-section-label,
body.editor-mode .sidebar .sidebar-link span,
body.editor-mode .sidebar .sidebar-user-info,
body.editor-mode .sidebar .sidebar-logout,
body.editor-mode .sidebar .profile-menu-label {
  display: none;
}

body.editor-mode .sidebar .sidebar-brand {
  justify-content: center;
  padding: 16px 0;
}

body.editor-mode .sidebar .sidebar-link {
  justify-content: center;
  padding: 10px;
  margin: 2px 8px;
}

body.editor-mode .sidebar .sidebar-link.active::before {
  left: -8px;
}

body.editor-mode .sidebar .sidebar-footer {
  justify-content: center;
  padding: 12px 8px;
}

body.editor-mode .sidebar .sidebar-avatar {
  width: 28px;
  height: 28px;
}

body.editor-mode .main-content {
  margin-left: 64px;
}

/* Editor layout */
.editor-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Left sidebar (frame list) */
.editor-left-sidebar {
  width: 240px;
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.editor-sidebar-header {
  height: 40px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--border);
  background: var(--bg-white);
  flex-shrink: 0;
}

.frame-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.frame-list::-webkit-scrollbar { width: 5px; }
.frame-list::-webkit-scrollbar-track { background: transparent; }
.frame-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 100px; }

.frame-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-button);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.frame-item:hover {
  background: var(--bg-white);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.frame-item.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 1px 3px rgba(99, 102, 241, 0.3);
}

.frame-item .frame-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.frame-item .frame-status.prelabeled { background: var(--warning); }
.frame-item .frame-status.unlabeled { background: var(--border); }
.frame-item .frame-status.reviewed { background: var(--success); }

.frame-item.missing-bbox {
  border-color: var(--error);
  background: rgba(255, 59, 48, 0.08);
}
.frame-item.missing-bbox .frame-status {
  background: var(--error);
}
.frame-item.active.missing-bbox {
  border-color: var(--error);
  background: var(--error);
  color: #fff;
}

.missing-bbox-banner {
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--error);
  background: rgba(255, 59, 48, 0.08);
  border-bottom: 1px solid rgba(255, 59, 48, 0.2);
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex-shrink: 0;
}
.missing-bbox-banner svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Canvas area */
.canvas-area {
  flex: 1;
  background: #1E1E2E;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.canvas-area canvas { display: block; }
.canvas-area .empty-msg { color: #6B7280; font-size: 14px; }

/* Right sidebar (annotations) */
.editor-right-sidebar {
  width: 280px;
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.label-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.label-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-button);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.label-item:hover {
  background: var(--bg-white);
  border-color: var(--border);
}

.label-item.selected {
  background: var(--bg-white);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
}

.label-item .color-dot {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
}

.label-item .label-name { flex: 1; font-weight: 500; }
.label-item .label-conf { font-size: 11px; color: var(--text-muted); font-weight: 500; }

.label-item .delete-btn {
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 0 2px;
  line-height: 1;
  transition: color var(--transition-fast);
}

.label-item .delete-btn:hover { color: var(--error); }

/* Bottom bar */
.bottom-bar {
  height: 52px;
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
}

.bottom-bar .shortcuts { font-size: 11px; color: var(--text-muted); }

.bottom-bar .shortcuts kbd {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-family: inherit;
  color: var(--text-secondary);
}

/* ─── Filter Bar ─── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.filter-bar select {
  flex: 1;
  max-width: 360px;
}

.filter-bar .filter-status {
  width: 160px;
  flex: none;
}

/* ─── Project Grid ─── */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 16px;
}

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

.project-card-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.project-card-body {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.label-chip {
  background: var(--bg-primary);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.project-meta {
  display: flex;
  gap: 16px;
  margin-top: 4px;
}

.project-meta strong {
  color: var(--text-primary);
}

/* ─── Video List ─── */
.video-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  background: var(--bg-primary);
}

.video-item-info {
  flex: 1;
  min-width: 0;
}

.video-item-name {
  font-size: 13px;
  font-weight: 600;
}

.video-item-stats {
  font-size: 12px;
  color: var(--text-muted);
}

.video-item-error {
  font-size: 12px;
  color: var(--error);
  margin-top: 4px;
}

.video-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.video-delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  border-radius: 4px;
  transition: color var(--transition-fast);
}

.video-delete-btn:hover {
  color: var(--error);
}

/* ─── Upload Progress ─── */
.upload-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.upload-progress-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.upload-filename {
  font-size: 13px;
  font-weight: 600;
}

.upload-percent {
  font-size: 13px;
  color: var(--text-secondary);
}

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

/* ─── Review Detail ─── */
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.detail-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 480px) {
  .detail-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.detail-frames-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.detail-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  justify-content: flex-end;
}

.frame-preview {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-primary);
  border: 1px solid var(--border);
}

.frame-preview img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}

.frame-preview .frame-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
}

.frame-preview .frame-label-count {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
}

/* ─── Model Pipeline ─── */
.pipeline-steps {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.pipeline-step {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pipeline-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  transition: all var(--transition-normal);
}

.pipeline-circle.active {
  background: var(--accent);
  color: #fff;
}

.pipeline-circle.active.current {
  animation: pipeline-pulse 2s ease-in-out infinite;
}

.pipeline-connector {
  width: 32px;
  height: 2px;
  background: var(--border);
  border-radius: 1px;
  transition: background 0.3s ease;
}

.pipeline-connector.done {
  background: var(--accent);
}

/* ─── Inline Status Progress (Models table) ─── */
.status-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 120px;
}

.status-progress {
  width: 100%;
  height: 4px;
  background: var(--border-light);
  border-radius: 100px;
  overflow: hidden;
}

.status-progress-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 0.5s ease;
}

.status-progress-fill.complete {
  width: 100%;
}

.status-message {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ─── Form Layout ─── */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

/* ─── Modal Title ─── */
.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
}

/* ─── Completion Modal ─── */
.completion-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--success-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

/* ─── Toast Container (standard position) ─── */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast-container.toast-center {
  top: 16px;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  pointer-events: none;
}

/* ─── Metric Item ─── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.metric-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-primary);
  border-radius: 6px;
  border: 1px solid var(--border-light);
}

.metric-item .metric-name {
  font-weight: 500;
}

.metric-item .metric-value {
  font-weight: 600;
}

.section-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* ─── Job Card ─── */
.job-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

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

.job-project {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 12px;
}

.job-stats {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 13px;
  color: var(--text-secondary);
}

.job-message {
  font-size: 12px;
  color: var(--text-muted);
}

.job-error {
  font-size: 12px;
  color: var(--error);
  margin-top: 8px;
}

.job-success {
  font-size: 13px;
  color: var(--success);
  font-weight: 500;
  margin-top: 4px;
}

/* ─── Section Spacing ─── */
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mt-16 { margin-top: 16px; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .sidebar {
    width: 64px;
  }
  .sidebar .sidebar-title,
  .sidebar .sidebar-brand-text,
  .sidebar .sidebar-section-label,
  .sidebar .sidebar-link span,
  /* Collapse the label text on the narrow rail, but keep the avatar trigger
     tappable — hiding it is what made sign-out unreachable on phones. */
  .sidebar .sidebar-user-info,
  .sidebar .sidebar-logout {
    display: none;
  }
  .sidebar .sidebar-brand {
    justify-content: center;
    padding: 16px 0;
  }
  .sidebar .sidebar-link {
    justify-content: center;
    padding: 10px;
    margin: 2px 8px;
  }
  .sidebar .sidebar-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 10px;
    line-height: 16px;
  }
  .sidebar .sidebar-footer {
    justify-content: center;
  }
  .main-content {
    margin-left: 64px;
  }
  .main-body {
    padding: 16px;
  }
}

/* ─── Utility ─── */
.hidden { display: none !important; }
.cursor-pointer { cursor: pointer; }

/* Sparkline — a tiny inline-SVG trend line. Hand-rolled because the dashboard
   deliberately ships no charting library. Promoted here from qc-report.html so
   the tracker drill-down can reuse it instead of re-inlining the same rules. */
.sparkline-container { width: 100%; height: 50px; margin: 8px 0; }
.sparkline-container svg { width: 100%; height: 100%; }
.sparkline-container polyline {
  fill: none; stroke: var(--accent); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.sparkline-container circle { fill: var(--accent); }


/* ═══════════════════════════════════════════════════════════════════════════
   Daylight Studio — refinements
   Appended over the existing rules, so nothing above needed editing.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Headings: 600 reads better than 700 at these sizes */
h1, h2, h3, .sidebar-title, .modal-title, .card-title {
  font-weight: 600;
  letter-spacing: -0.025em;
}

/* Frosted, translucent header */
.main-header {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}

.card { border: 1px solid #E8EEF6; }

/* Buttons — gentle lift, 200ms everywhere */
.btn {
  font-weight: 600;
  transition: background var(--transition-normal), box-shadow var(--transition-normal),
              transform var(--transition-normal), color var(--transition-normal);
}
.btn-primary { box-shadow: 0 6px 16px -8px rgba(47, 126, 246, 0.80); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary {
  background: var(--bg-white);
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.btn-secondary:hover:not(:disabled) {
  box-shadow: 0 10px 24px -14px rgba(31, 45, 67, 0.40);
  transform: translateY(-1px);
}

/* Inputs */
input, select, textarea {
  border-radius: var(--radius-input);
  border: 1px solid var(--border);
  background: var(--bg-white);
  color: var(--text-primary);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(47, 126, 246, 0.55);
  outline-offset: 1px;
  border-color: transparent;
}

/* Numbers line up */
td, th, kbd, .stat-value, .metric-value,
#frame-counter, #remaining-counter, #batch-label, #progress-text {
  font-variant-numeric: tabular-nums;
}

/* Keyboard hints */
kbd {
  background: #F1F5FB;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 10.5px;
  padding: 1px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Modals float on glass */
.modal-overlay { background: rgba(31, 45, 67, 0.28); backdrop-filter: blur(6px); }
.modal { border-radius: 20px; box-shadow: var(--shadow-lg); border: 1px solid #E8EEF6; }

/* ── Labeling page (annotate.html) ────────────────────────────────────────────
   The canvas stays dark on purpose: it is the only heavy element on the page,
   so the frame is where the eye lands. Everything around it goes light. */
#stage-container, .stage-container { background: #141821; }
#stage-card, .stage-card {
  border: 1px solid #DFE8F4;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 18px 40px -22px rgba(31, 45, 67, 0.60);
}

/* Frame list and box list rows */
.frame-thumb, .ann-row, .frame-item, .box-row {
  border-radius: 10px;
  border: 1px solid transparent;
  color: var(--text-secondary);
  transition: background var(--transition-normal), color var(--transition-normal);
}
.frame-thumb:hover, .ann-row:hover, .frame-item:hover, .box-row:hover {
  background: var(--bg-hover);
}
.frame-thumb.active, .ann-row.active, .frame-item.active, .box-row.active,
.frame-thumb.selected, .ann-row.selected {
  background: var(--accent-light);
  border-color: rgba(47, 126, 246, 0.30);
  color: var(--accent-hover);
  font-weight: 600;
}

/* Batch chips */
.batch-chip { border-radius: 6px; font-weight: 600; }
.batch-chip.done, .batch-chip.complete {
  background: var(--success-light); border-color: rgba(59,165,93,.35); color: #2C7A45;
}
.batch-chip.mine, .batch-chip.current {
  background: var(--accent); border-color: var(--accent); color: #FFFFFF;
}
.batch-chip.taken, .batch-chip.claimed {
  background: var(--warning-light); border-color: rgba(224,164,88,.40); color: #9A6A20;
}
.batch-chip.open, .batch-chip.available {
  background: var(--bg-white); border-color: var(--border); color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Annotate — direction 1a layout
   The theme above ships 1a's colours; these are the few structural rules the
   layout needs. Deliberately small: the page's own markup carries the grid,
   and the canvas sizing is computed in JS (fitImage) — nothing here may touch
   #stage-container's width/height or boxes land in the wrong place.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Header pickers as labelled chips. The <select> keeps every handler; the chip
   only supplies the label and the frame around it. */
.picker-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.picker-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 6px 0 12px;
  margin: 0;
  border-radius: 10px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-primary);
}
.picker-chip .picker-key { color: var(--text-muted); white-space: nowrap; }
.picker-chip select {
  width: auto;
  min-width: 118px;
  max-width: 210px;
  border: 0;
  background: transparent;
  padding: 4px 2px;
  font-size: 12.5px;
  font-weight: 600;
  color: inherit;
}
.picker-chip select:focus { outline: none; box-shadow: none; }
.picker-chip:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }

/* "Batch 3 of 12 · yours" — the one piece of state a labeler checks constantly.
   The dot pulses only while a batch is actually held. */
.batch-state-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--accent-light);
  border: 1px solid rgba(47, 126, 246, 0.18);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-hover);
  white-space: nowrap;
}
.batch-state-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  animation: tlPulse 2.4s ease-in-out infinite;
}
@keyframes tlPulse { 0%, 100% { opacity: .5 } 50% { opacity: 1 } }

/* Rail card headers — one rule replacing the repeated inline header divs. */
.rail-head {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Keyboard legend, moved out of the toolbar to sit under the frame. */
.shortcut-card {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 8px 14px;
  font-size: 11.5px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.shortcut-card span { display: inline-flex; align-items: center; gap: 5px; }

@media (max-width: 900px) {
  .picker-chip .picker-key { display: none; }
  .picker-chip select { min-width: 96px; }
}

/* ── Sign-in widget (js/sign-in.js) ─────────────────────────────────────
   Google button, "or" divider, email form, verify screen. Shared by
   index, invite, join and institution pages. Inputs and buttons reuse
   the global rules above; only the layout lives here. */
.auth-google { width: 100%; }
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.auth-divider::before,
.auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.auth-field input[aria-invalid="true"] { border-color: var(--error); }
.auth-field-error { font-size: 12px; font-weight: 400; color: var(--error); }
.auth-field-error:empty { display: none; }
.auth-hint { font-size: 12px; color: var(--text-muted); margin: 0; }
.auth-submit { width: 100%; }
.auth-message { font-size: 13px; margin-top: 12px; }
.auth-error { color: var(--error); }
.auth-notice { color: var(--text-secondary); }
.auth-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.auth-link {
  background: none;
  border: 0;
  padding: 4px 0;
  font: inherit;
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
}
.auth-link:hover { text-decoration: underline; }
.auth-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.auth-title { font-size: 18px; font-weight: 700; margin: 0 0 8px; }
.auth-note { font-size: 14px; color: var(--text-secondary); margin: 0 0 16px; }
.auth-actions { display: flex; flex-direction: column; gap: 8px; }

/* Optional profile prompts (js/profile-nudge.js). Always skippable. */
.nudge {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin: 12px 0;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--accent-light);
  font-size: 13px;
  color: var(--text-secondary);
}
.nudge-body { flex: 1 1 240px; min-width: 0; }
.nudge-title { font-weight: 600; color: var(--text-primary, #1D1D1F); margin-bottom: 4px; }
.nudge-fields { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.nudge-fields select, .nudge-fields input { min-width: 0; flex: 1 1 160px; }
.nudge-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.nudge a.btn { text-decoration: none; }
