/* AI Training Platform — shared shell & components */
:root {
  --bg: oklch(97% 0.004 250);
  --surface: oklch(100% 0 0);
  --fg: oklch(22% 0.02 250);
  --muted: oklch(52% 0.015 250);
  --border: oklch(91% 0.006 250);
  --accent: oklch(58% 0.20 255);
  --accent-hover: oklch(52% 0.20 255);
  --accent-soft: color-mix(in oklch, var(--accent) 12%, transparent);
  --fg-soft: color-mix(in oklch, var(--fg) 5%, transparent);

  --sidebar-bg: oklch(18% 0.025 250);
  --sidebar-fg: oklch(78% 0.01 250);
  --sidebar-muted: oklch(58% 0.01 250);
  --sidebar-active-bg: color-mix(in oklch, var(--accent) 18%, transparent);
  --sidebar-active-fg: oklch(72% 0.12 255);
  --rail-w: 48px;
  --sidebar-w: 200px;

  --status-orange: oklch(72% 0.16 55);
  --status-green: oklch(62% 0.17 145);
  --status-red: oklch(55% 0.20 25);
  --status-gray: oklch(55% 0.01 250);
  --status-blue: oklch(58% 0.20 255);
  --status-purple: oklch(58% 0.14 290);

  --info-bg: oklch(95% 0.04 240);
  --info-border: color-mix(in oklch, var(--accent) 25%, transparent);
  --warn-bg: oklch(96% 0.04 25);
  --success-bg: oklch(96% 0.04 145);

  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: ui-monospace, 'JetBrains Mono', Menlo, monospace;
  --radius: 6px;
  --radius-lg: 8px;
  --shadow-sm: 0 1px 2px color-mix(in oklch, var(--fg) 6%, transparent);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
button { font: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font: inherit; }

/* ─── App shell ─── */
.app {
  display: flex;
  min-height: 100vh;
}

.icon-rail {
  width: var(--rail-w);
  background: var(--sidebar-bg);
  border-right: 1px solid color-mix(in oklch, var(--fg) 20%, transparent);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 8px;
  flex-shrink: 0;
}
.rail-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--radius);
  color: var(--sidebar-muted);
}
.rail-btn:hover { background: color-mix(in oklch, var(--surface) 8%, transparent); color: var(--sidebar-fg); }
.rail-btn.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-fg); }
.rail-btn svg { width: 18px; height: 18px; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.2s ease, margin 0.2s ease;
  overflow: hidden;
}
.sidebar.collapsed { width: 0; margin-left: calc(var(--sidebar-w) * -1); }

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 12px;
  font-weight: 600; font-size: 15px;
  white-space: nowrap;
}
.sidebar-brand svg { width: 22px; height: 22px; flex-shrink: 0; color: var(--sidebar-active-fg); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 0 8px 16px; }

.nav-group { margin-bottom: 4px; }
.nav-group-title {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px;
  font-size: 13px; color: var(--sidebar-fg);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}
.nav-group-title:hover { background: color-mix(in oklch, var(--surface) 6%, transparent); }
.nav-group-title svg { width: 14px; height: 14px; color: var(--sidebar-muted); transition: transform 0.15s; }
.nav-group.collapsed .nav-group-title svg { transform: rotate(-90deg); }
.nav-group.collapsed .nav-items { display: none; }

.nav-items { list-style: none; margin: 0; padding: 0 0 4px 0; }
.nav-items li a {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px 8px 28px;
  color: var(--sidebar-muted);
  font-size: 13px;
  border-radius: var(--radius);
  white-space: nowrap;
}
.nav-items li a:hover { color: var(--sidebar-fg); background: color-mix(in oklch, var(--surface) 5%, transparent); }
.nav-items li a.active {
  color: var(--sidebar-active-fg);
  background: var(--sidebar-active-bg);
}

.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ─── Top bar + tabs ─── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 48px;
  flex-shrink: 0;
}
.tab-bar {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
}
.tab {
  display: flex; align-items: center; gap: 6px;
  padding: 0 16px;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  cursor: pointer;
  height: 48px;
}
.tab:hover { color: var(--fg); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }
.tab-close {
  width: 16px; height: 16px;
  display: grid; place-items: center;
  border-radius: 3px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
}
.tab-close:hover { background: var(--fg-soft); color: var(--fg); }

.topbar-actions {
  display: flex; align-items: center; gap: 4px;
  margin-left: 12px;
  flex-shrink: 0;
}
.topbar-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--radius);
  color: var(--muted);
}
.topbar-btn:hover { background: var(--fg-soft); color: var(--fg); }
.topbar-btn svg { width: 16px; height: 16px; }
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
  margin-left: 4px;
}

/* ─── Page content ─── */
.page {
  flex: 1;
  padding: 20px 24px 32px;
  overflow-y: auto;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-title { font-size: 20px; font-weight: 600; margin: 0 0 4px; line-height: 1.3; }
.page-desc { font-size: 13px; color: var(--muted); margin: 0; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: var(--surface);
  border: 1px solid var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--muted); }
.btn-link { color: var(--accent); padding: 0; font-size: 13px; }
.btn-link:hover { text-decoration: underline; }

/* ─── Stat cards ─── */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-icon.orange { background: color-mix(in oklch, var(--status-orange) 18%, transparent); color: var(--status-orange); }
.stat-icon.green  { background: color-mix(in oklch, var(--status-green) 18%, transparent); color: var(--status-green); }
.stat-icon.red    { background: color-mix(in oklch, var(--status-red) 18%, transparent); color: var(--status-red); }
.stat-icon.gray   { background: color-mix(in oklch, var(--status-gray) 15%, transparent); color: var(--status-gray); }
.stat-icon.blue   { background: color-mix(in oklch, var(--status-blue) 18%, transparent); color: var(--status-blue); }
.stat-icon.purple { background: color-mix(in oklch, var(--status-purple) 18%, transparent); color: var(--status-purple); }
.stat-num { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ─── Panel / table block ─── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.panel-title { font-size: 15px; font-weight: 600; margin: 0; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-width: 200px;
}
.search-box svg { width: 14px; height: 14px; color: var(--muted); flex-shrink: 0; }
.search-box input {
  border: none; outline: none; background: transparent;
  font-size: 13px; width: 100%; min-width: 0;
  color: var(--fg);
}
.search-box input::placeholder { color: var(--muted); }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-weight: 500;
  color: var(--muted);
  background: color-mix(in oklch, var(--bg) 50%, var(--surface));
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--fg-soft); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ─── Pills / tags ─── */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.pill-gray   { background: color-mix(in oklch, var(--status-gray) 12%, transparent); color: var(--status-gray); }
.pill-blue   { background: color-mix(in oklch, var(--status-blue) 14%, transparent); color: var(--status-blue); }
.pill-green  { background: color-mix(in oklch, var(--status-green) 14%, transparent); color: var(--status-green); }
.pill-orange { background: color-mix(in oklch, var(--status-orange) 14%, transparent); color: var(--status-orange); }
.pill-purple { background: color-mix(in oklch, var(--status-purple) 14%, transparent); color: var(--status-purple); }
.pill-red    { background: color-mix(in oklch, var(--status-red) 14%, transparent); color: var(--status-red); }
.pill-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}

.tag-modality {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  background: var(--fg-soft);
  color: var(--fg);
}

.parsing {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--status-orange);
  font-size: 13px;
}
.parsing svg { width: 14px; height: 14px; animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.action-link { color: var(--accent); font-size: 13px; cursor: pointer; }
.action-link:hover { text-decoration: underline; }

.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ─── Modal dialog ─── */
body.modal-open { overflow: hidden; }

.od-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.od-modal.is-open { display: flex; }
.od-modal-backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in oklch, var(--fg) 45%, transparent);
}
.od-modal-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(920px, 100%);
  max-height: min(90vh, 880px);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 48px color-mix(in oklch, var(--fg) 22%, transparent);
  overflow: hidden;
}
.od-modal-panel.od-modal-lg { width: min(1040px, 100%); }
.od-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.od-modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.od-modal-close {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: var(--muted);
  flex-shrink: 0;
}
.od-modal-close:hover {
  background: var(--fg-soft);
  color: var(--fg);
}
.od-modal-close svg { width: 18px; height: 18px; }
.od-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  background: var(--bg);
}
.od-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.od-modal-body .form-section {
  margin-bottom: 0;
}
.od-modal-body .form-tip { margin: 0; }
.od-modal .modal-form > .form-footer { display: none; }

/* ─── Form pages ─── */
.form-page {
  width: 100%;
  max-width: none;
}

.form-page > form,
.od-modal .modal-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  width: 100%;
}

.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 0;
  box-shadow: var(--shadow-sm);
}
.form-section-title {
  font-size: 15px; font-weight: 600;
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.form-row { margin-bottom: 16px; }
.form-row:last-child { margin-bottom: 0; }
.form-label {
  display: block;
  font-size: 13px;
  color: var(--fg);
  margin-bottom: 6px;
  font-weight: 500;
}
.form-label .req { color: var(--status-red); margin-left: 2px; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-error {
  font-size: 12px;
  color: var(--status-red);
  margin: 0 0 12px;
}
.form-section.has-error {
  border-color: var(--status-red);
}
.form-section.has-error .card-grid .select-card {
  border-color: color-mix(in oklch, var(--status-red) 35%, var(--border));
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  max-width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  font-size: 14px;
}

/* Keep single-line fields readable in side-by-side sections */
@media (min-width: 1024px) {
  .form-section[data-od-id="basic-info"] .form-input,
  .form-section[data-od-id="data-source"] .form-input,
  .form-section[data-od-id="project-info"] .form-input,
  .form-section[data-od-id="project-info"] .form-textarea,
  .form-section[data-od-id="dataset-select"] .form-select {
    max-width: none;
  }
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}
.form-textarea { min-height: 80px; resize: vertical; line-height: 1.5; }

/* Toggle group */
.toggle-group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.toggle-btn {
  padding: 7px 20px;
  font-size: 13px;
  color: var(--muted);
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.toggle-btn:last-child { border-right: none; }
.toggle-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

/* Tab strip */
.tab-strip {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab-strip-btn {
  padding: 8px 20px;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab-strip-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 500;
}

/* Selection cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 12px;
}
.select-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  position: relative;
}
.select-card:hover { border-color: var(--accent); }
.select-card.selected {
  border: 2px solid var(--accent);
  padding: 15px;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.select-card.recommended::after {
  content: '推荐';
  position: absolute;
  top: 8px; right: 8px;
  font-size: 11px;
  padding: 2px 6px;
  background: var(--accent);
  color: var(--surface);
  border-radius: 3px;
}
.select-card-icon {
  width: 48px; height: 48px;
  background: var(--fg-soft);
  border-radius: var(--radius);
  display: grid; place-items: center;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
  font-family: var(--font-mono);
}
.select-card-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.select-card-desc { font-size: 12px; color: var(--muted); line-height: 1.45; }

/* Info banner */
.info-banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px;
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--fg);
}
.info-banner svg { width: 18px; height: 18px; color: var(--accent); flex-shrink: 0; margin-top: 1px; }

.form-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 8px;
}
.form-tip {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
}

/* Radio cards for mode selection */
.mode-group { margin-bottom: 20px; }
.mode-group-title { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.mode-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 12px;
}

/* Source radio */
.radio-row {
  display: flex; gap: 16px; flex-wrap: wrap;
}
.radio-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; cursor: pointer;
}
.radio-label input { accent-color: var(--accent); }

/* Responsive */
@media (max-width: 640px) {
  .od-modal { padding: 0; align-items: stretch; }
  .od-modal-panel,
  .od-modal-panel.od-modal-lg {
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
}

@media (min-width: 1440px) {
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  }
}

@media (max-width: 1024px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .detail-info-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .sidebar { position: fixed; z-index: 100; height: 100vh; }
  .sidebar.collapsed { margin-left: calc(var(--sidebar-w) * -1); }
  .stat-row { grid-template-columns: 1fr; }
  .page { padding: 16px; }
  .data-table { display: block; overflow-x: auto; }
  .mode-cards { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .detail-info-grid { grid-template-columns: 1fr; }
  .detail-tabs { overflow-x: auto; }
}
@media (max-width: 600px) {
  .icon-rail { display: none; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header-actions { width: 100%; }
  .page-header-actions .btn { flex: 1; justify-content: center; }
}

/* ─── Project detail: stage progress bar (§4.3) ─── */
.stage-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.stage-bar-title { font-size: 13px; color: var(--muted); margin: 0 0 20px; }
.stage-track {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: relative;
  gap: 8px;
}
.stage-track::before {
  content: '';
  position: absolute;
  top: 16px;
  left: 32px;
  right: 32px;
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.stage-node {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  z-index: 1;
  min-width: 0;
}
.stage-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface);
  border: 2px solid var(--border);
  margin-bottom: 8px;
  flex-shrink: 0;
}
.stage-dot svg { width: 16px; height: 16px; }
.stage-dot.done { border-color: var(--status-green); background: color-mix(in oklch, var(--status-green) 12%, var(--surface)); color: var(--status-green); }
.stage-dot.active { border-color: var(--accent); background: color-mix(in oklch, var(--accent) 12%, var(--surface)); color: var(--accent); }
.stage-dot.active svg.spin { animation: spin 1.2s linear infinite; }
.stage-dot.failed { border-color: var(--status-red); background: color-mix(in oklch, var(--status-red) 12%, var(--surface)); color: var(--status-red); }
.stage-dot.pending { border-color: var(--border); color: var(--muted); }
.stage-label { font-size: 13px; font-weight: 500; margin-bottom: 2px; }
.stage-sub { font-size: 11px; color: var(--muted); }
.stage-subpanel {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  text-align: left;
  font-size: 12px;
}
.stage-subpanel-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  gap: 8px;
}
.stage-subpanel-row + .stage-subpanel-row { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px; }

.error-banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px;
  background: var(--warn-bg);
  border: 1px solid color-mix(in oklch, var(--status-red) 25%, transparent);
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--fg);
}
.error-banner svg { width: 18px; height: 18px; color: var(--status-red); flex-shrink: 0; margin-top: 1px; }
.error-banner--after-stage {
  margin-top: 0;
}

.page-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* Project detail tabs */
.detail-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.detail-tab {
  position: relative;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.detail-tab:hover { color: var(--fg); }
.detail-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.detail-tab-panel { display: none; }
.detail-tab-panel.active { display: block; }

/* Unified basic info card */
.detail-info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.detail-info-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 14px;
}
.detail-info-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px 24px;
}
.detail-info-grid--compact {
  margin: 0;
  gap: 12px 16px;
}
.detail-info-item {
  min-width: 0;
  padding-left: 14px;
  border-left: 2px solid var(--border);
}
.detail-info-item:first-child { border-left-color: var(--accent); }
.detail-info-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.detail-info-value {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  word-break: break-word;
}

/* Collapsible panel */
.panel-head-toggle {
  cursor: pointer;
  user-select: none;
  justify-content: space-between;
}
.panel-head-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.collapse-chevron {
  width: 16px;
  height: 16px;
  color: var(--muted);
  transition: transform 0.15s;
  flex-shrink: 0;
}
.panel.is-collapsed .collapse-chevron { transform: rotate(-90deg); }
.panel.is-collapsed .panel-head { border-bottom: none; }
.collapse-hint {
  font-size: 12px;
  color: var(--muted);
}
.panel-collapse { border-top: 1px solid var(--border); }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.pagination-info { font-size: 12px; color: var(--muted); }
.pagination-btns { display: flex; gap: 8px; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.empty-state-icon {
  width: 48px; height: 48px;
  margin: 0 auto 16px;
  color: var(--muted);
}
.empty-state-icon svg { width: 48px; height: 48px; }
.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 8px;
}
.empty-state-desc {
  font-size: 13px;
  color: var(--muted);
  margin: 0 auto;
  max-width: 420px;
  line-height: 1.55;
}
.empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 28px 16px !important;
}

/* Legacy aliases used by quality dashboard */
.detail-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.detail-meta-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.detail-meta-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.detail-meta-value { font-size: 14px; font-weight: 500; }
.detail-actions {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 20px;
}

/* ─── Annotation workbench (§4.4) ─── */
.workbench-page { padding: 0; display: flex; flex-direction: column; height: calc(100vh - 48px); overflow: hidden; }
.wb-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.wb-toolbar-left, .wb-toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wb-progress { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.wb-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in oklch, var(--accent) 20%, var(--border));
  border-radius: 999px;
}
.wb-body[hidden], .wb-multimodal-wrap[hidden] { display: none !important; }
.wb-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 280px;
  min-height: 0;
  overflow: hidden;
}
.wb-canvas-area {
  display: flex;
  flex-direction: column;
  background: color-mix(in oklch, var(--fg) 4%, var(--bg));
  min-height: 0;
  overflow: hidden;
}
.wb-canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: auto;
}
.wb-image-frame {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.wb-image-frame img, .wb-image-ph {
  display: block;
  width: min(720px, 100%);
  height: auto;
  aspect-ratio: 16/10;
  object-fit: cover;
  background: linear-gradient(135deg, color-mix(in oklch, var(--fg) 6%, var(--bg)), color-mix(in oklch, var(--accent) 8%, var(--bg)));
}
.wb-image-ph {
  display: grid; place-items: center;
  color: var(--muted); font-size: 13px;
}
.wb-box {
  position: absolute;
  border: 2px solid var(--accent);
  border-radius: 2px;
  cursor: move;
}
.wb-box.ai { border-style: dashed; opacity: 0.75; border-color: var(--status-orange); }
.wb-box-label {
  position: absolute;
  top: -22px; left: -2px;
  font-size: 11px;
  padding: 1px 6px;
  background: var(--accent);
  color: var(--surface);
  border-radius: 3px 3px 0 0;
  white-space: nowrap;
}
.wb-box.ai .wb-box-label { background: var(--status-orange); }
.wb-ai-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.wb-ai-label { font-size: 12px; color: var(--muted); }
.wb-ai-suggest {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-size: 13px;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
}
.wb-ai-conf { font-size: 11px; color: var(--muted); font-family: var(--font-mono); }
.wb-btn-sm { padding: 4px 12px; font-size: 12px; }
.wb-hint-bar {
  display: flex; align-items: center;
  padding: 8px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.wb-hint { font-size: 12px; color: var(--muted); }
.wb-seg-frame { cursor: crosshair; }
.wb-seg-mask {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.wb-seg-point {
  position: absolute;
  width: 12px; height: 12px;
  margin: -6px 0 0 -6px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 25%, transparent);
  pointer-events: none;
}
.wb-seg-bar { gap: 12px; }
.wb-seg-hint { font-size: 13px; color: var(--muted); flex: 1; }
.wb-seg-loading {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--accent);
}
.wb-seg-loading svg { width: 14px; height: 14px; animation: spin 0.8s linear infinite; }
.wb-multimodal-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.wb-sidebar {
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.wb-sidebar-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600;
}
.wb-label-wall {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wb-label-chip {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}
.wb-label-chip:hover { border-color: var(--accent); }
.wb-label-chip.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.wb-sidebar-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wb-shortcuts { font-size: 11px; color: var(--muted); line-height: 1.6; }

/* Audio / document / multimodal workbench variants */
.wb-audio-player {
  width: min(560px, 100%);
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.wb-audio-controls { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.wb-audio-progress {
  flex: 1; height: 6px;
  background: var(--border);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
}
.wb-audio-progress-fill {
  height: 100%;
  width: 35%;
  background: var(--accent);
  border-radius: 999px;
}
.wb-doc-text {
  width: min(640px, 100%);
  max-height: 360px;
  overflow-y: auto;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.7;
}
.wb-multimodal-cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 16px;
  flex: 1;
  overflow: auto;
  min-height: 0;
}
.wb-mm-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  min-height: 280px;
  overflow: hidden;
}
.wb-mm-col-head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600;
  display: flex; justify-content: space-between; align-items: center;
}
.wb-mm-col-body { flex: 1; padding: 12px; overflow-y: auto; font-size: 13px; }

/* ─── Consistency review (§4.5) ─── */
.review-queue-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.review-queue-item:hover { background: var(--fg-soft); }
.review-queue-item.active { background: var(--accent-soft); border-left: 3px solid var(--accent); }
.review-kappa {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  min-width: 48px;
  text-align: center;
}
.review-kappa.low { color: var(--status-red); }
.review-kappa.mid { color: var(--status-orange); }
.review-actions-bar {
  display: flex; gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.review-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  min-height: 480px;
}
.review-layout--embedded {
  min-height: min(620px, calc(100vh - 280px));
  height: min(620px, calc(100vh - 280px));
}
.review-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.review-queue-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.reject-reason-select { margin-top: 0; }

/* ─── Quality dashboard (§4.6) ─── */
.quality-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.quality-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.quality-card-title { font-size: 14px; font-weight: 600; margin: 0 0 16px; }
.score-bars { display: flex; flex-direction: column; gap: 10px; }
.score-bar-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.score-bar-label { min-width: 72px; color: var(--muted); }
.score-bar-track { flex: 1; height: 20px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 4px; }
.score-bar-fill.excellent { background: var(--status-green); }
.score-bar-fill.good { background: var(--status-blue); }
.score-bar-fill.review { background: var(--status-orange); }
.score-bar-fill.filtered { background: var(--status-gray); }
.score-bar-count { min-width: 36px; text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.filter-notice {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: color-mix(in oklch, var(--status-orange) 10%, var(--surface));
  border: 1px solid color-mix(in oklch, var(--status-orange) 25%, transparent);
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
}

/* ─── Settings toggle (§4.8) ─── */
.settings-section { max-width: 720px; }
.setting-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 24px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-info h3 { font-size: 14px; font-weight: 600; margin: 0 0 4px; }
.setting-info p { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.5; }
.toggle-switch {
  position: relative;
  width: 44px; height: 24px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: var(--surface);
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: var(--shadow-sm);
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }
.setting-expand {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

@media (max-width: 1024px) {
  .wb-body { grid-template-columns: 1fr; }
  .wb-sidebar { border-left: none; border-top: 1px solid var(--border); max-height: 240px; }
  .wb-multimodal-cols { grid-template-columns: 1fr; }
  .quality-grid { grid-template-columns: 1fr; }
  .review-layout { grid-template-columns: 1fr; }
  .stage-track { flex-wrap: wrap; }
  .stage-track::before { display: none; }
}
