/* ============================================================
   Shelf Pipeline - UI tokens
   ============================================================ */
:root {
  /* Surfaces — clean neutrals */
  --bg: #f6f7f9;
  --bg-grad-1: #f9fafb;
  --bg-grad-2: #eef0f3;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef0f3;

  /* Ink */
  --ink: #15181d;
  --ink-muted: #485058;
  --ink-soft: #697079;
  --ink-faint: #9aa1aa;

  /* Lines */
  --line: #e3e6eb;
  --line-soft: #eef0f3;
  --line-strong: #cdd2d9;

  /* Accent (forest green) */
  --accent: #386641;
  --accent-600: #2c5234;
  --accent-700: #213d27;
  --accent-soft: #ecf2ec;
  --accent-tint: #cfdfca;
  --accent-ink: #1c3320;

  /* Secondary (slate) */
  --indigo: #4b5563;
  --indigo-soft: #f1f3f6;
  --indigo-ink: #1f2937;

  /* Status */
  --warn: #b45309;
  --warn-soft: #fcedd1;
  --warn-ink: #6f3909;
  --danger: #b3261e;
  --danger-soft: #fbe3e0;
  --danger-ink: #6f1c17;
  --success: #386641;

  /* Effects */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 28px rgba(15, 23, 42, 0.08), 0 4px 10px rgba(15, 23, 42, 0.05);
  --ring: 0 0 0 3px rgba(56, 102, 65, 0.18);

  --t-fast: 120ms ease;
  --t-med: 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Segoe UI", system-ui, -apple-system, "Noto Sans", sans-serif;
  font-size: 17px;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-grad-1) 0%, var(--bg-grad-2) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

code, .mono { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

h1, h2, h3, h4 { color: var(--ink); margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 32px; font-weight: 700; }
h2 { font-size: 30px; font-weight: 700; letter-spacing: -0.015em; }
h3 { font-size: 22px; font-weight: 600; }
h4 { font-size: 14.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); }
p  { margin: 0; color: var(--ink-muted); }
a  { color: var(--accent-600); }

/* ============================================================
   App shell
   ============================================================ */
.app-shell {
  max-width: 1640px;
  margin: 0 auto;
  padding: 28px 32px 60px;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
  padding: 8px 4px 28px;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 720px;
}

.brand-eyebrow {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--indigo);
  text-transform: uppercase;
}

.brand h1 {
  font-size: 45.5px;
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.brand p {
  font-size: 17px;
  color: var(--ink-soft);
  max-width: 620px;
  line-height: 1.5;
}

.header-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.deployment-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-xs);
  backdrop-filter: blur(10px);
}

.deployment-chip-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.auth-panel {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
}

.auth-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}

.auth-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

.auth-status.is-ok {
  background: var(--accent-soft);
  border-color: var(--accent-tint);
  color: var(--accent-ink);
}

.auth-status.is-warn {
  background: var(--warn-soft);
  border-color: #f1c981;
  color: var(--warn-ink);
}

.auth-user {
  font-size: 14px;
  color: var(--ink-soft);
}

.auth-login-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.auth-login-form input {
  min-width: 168px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  font: inherit;
}

.btn-auth {
  min-height: 40px;
}

.hidden {
  display: none !important;
}

.auth-gate {
  display: grid;
  place-items: center;
  min-height: min(68vh, 760px);
  padding: 10px 0 24px;
}

.auth-gate-card {
  width: min(760px, 100%);
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid rgba(56, 102, 65, 0.18);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(247, 248, 250, 0.96) 100%);
  box-shadow: 0 24px 60px rgba(21, 24, 29, 0.12), 0 6px 18px rgba(21, 24, 29, 0.06);
  backdrop-filter: blur(10px);
}

.auth-gate-badge {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-tint);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.auth-gate-copy {
  display: grid;
  gap: 8px;
}

.auth-gate-copy h2 {
  font-size: 34px;
  letter-spacing: -0.02em;
}

.auth-gate-copy p {
  max-width: 56ch;
  line-height: 1.6;
  color: var(--ink-soft);
}

.auth-gate-deployment {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-self: start;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  color: var(--ink);
}

.auth-gate-deployment-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.auth-gate-login-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.auth-gate-login-form input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  font: inherit;
}

.auth-gate-submit {
  min-height: 48px;
  padding-inline: 18px;
}

.auth-gate-hint {
  font-size: 14px;
  color: var(--ink-soft);
}

body.auth-gate-active .app-shell {
  max-width: none;
  min-height: 100vh;
  padding: 24px;
  display: grid;
  place-items: center;
}

body.auth-gate-active .app-header,
body.auth-gate-active .app-main {
  display: none;
}

body.auth-gate-active .auth-gate {
  min-height: auto;
  width: min(760px, 100%);
  padding: 0;
}


@media (max-width: 900px) {
  .brand h1 { font-size: 33.5px; }
  .app-shell { padding: 20px 18px 60px; }
  .panel-inline-select { min-width: 0; width: 100%; }
}

/* ============================================================
   Top-level tab navigation (top-right pills)
   ============================================================ */
.tab-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.tab-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 500;
  color: var(--ink-muted);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.tab-nav-btn:hover:not(:disabled):not(.active) {
  background: var(--surface-3);
  color: var(--ink);
}
.tab-nav-btn.active {
  background: var(--ink);
  color: var(--surface);
  cursor: default;
  font-weight: 600;
}
.tab-nav-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 700px) {
  .header-meta { width: 100%; align-items: stretch; }
  .auth-panel, .auth-summary { justify-content: flex-start; }
  .auth-login-form input { min-width: 0; flex: 1 1 180px; }
  .tab-nav { width: 100%; justify-content: stretch; }
  .tab-nav-btn { flex: 1 1 0; padding: 8px 10px; font-size: 15px; }
  .auth-gate { min-height: auto; padding-top: 8px; }
  body.auth-gate-active .app-shell { padding: 18px; }
  body.auth-gate-active .auth-gate { width: 100%; }
  .auth-gate-card { padding: 22px 18px; border-radius: 22px; }
  .auth-gate-copy h2 { font-size: 28px; }
  .auth-gate-login-form { grid-template-columns: 1fr; }
}

/* ============================================================
   Tab panels
   ============================================================ */
.app-main { display: grid; gap: 20px; }

.tab-panel { display: grid; gap: 14px; }
.tab-panel[hidden] { display: none; }

.sorting-empty {
  text-align: center;
  padding: 48px 24px;
}
.sorting-empty h2 {
  margin-bottom: 6px;
}
.workspace-content { display: grid; gap: 14px; }

.sub-session-tabs {
  display: flex;
  gap: 8px;
  padding: 0 2px;
  overflow-x: auto;
}

.sub-session-tab {
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}

.sub-session-tab:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.sub-session-tab.active,
.sub-session-tab[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.sub-session-tab[data-done="true"]::after {
  content: " ✓";
  opacity: 0.8;
}

.sub-session-tab:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.phase-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
}

@media (max-width: 1100px) {
  .phase-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t-med);
}
.card:hover { box-shadow: var(--shadow-md); }

/* Collapsible detail blocks for low-priority info (e.g. detector paths) */
.field-details {
  font-size: 14px;
  color: var(--ink-soft);
}
.field-details > summary {
  cursor: pointer;
  user-select: none;
  font-weight: 500;
  color: var(--ink-soft);
  padding: 4px 0;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color var(--t-fast);
}
.field-details > summary::-webkit-details-marker { display: none; }
.field-details > summary::before {
  content: "▸";
  font-size: 12px;
  transition: transform var(--t-fast);
  display: inline-block;
}
.field-details[open] > summary::before { transform: rotate(90deg); }
.field-details > summary:hover { color: var(--ink); }
.field-details > .field-meta { margin-top: 6px; }
.field-details-icon {
  position: relative;
  display: inline-flex;
  align-self: flex-start;
}
.field-details-icon > summary {
  padding: 0;
  gap: 0;
}
.field-details-icon > summary::before { content: none; }
.field-details-icon > summary:focus-visible {
  outline: none;
}
.field-details-icon > summary:focus-visible .field-info-badge {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.field-info-badge {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.field-details-icon > summary:hover .field-info-badge,
.field-details-icon[open] > summary .field-info-badge {
  background: var(--accent-soft);
  border-color: var(--accent-tint);
  color: var(--accent-ink);
}
.field-help-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  width: min(320px, calc(100vw - 64px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.field-meta-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  width: min(360px, calc(100vw - 64px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.card-head h2 { font-size: 28px; }
.card-sub {
  font-size: 15px;
  color: var(--ink-soft);
  margin-top: 6px;
}
.muted { color: var(--ink-faint); font-weight: 400; }

.card-create { display: flex; flex-direction: column; }
.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

/* ============================================================
   Forms / inputs
   ============================================================ */
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel-inline-select { min-width: 280px; flex: 1 1 320px; }
.sorting-catalog-row {
  margin-top: 12px;
}
.sorting-catalog-select {
  flex: 1 1 100%;
  min-width: 0;
}
.sorting-catalog-actions {
  align-items: center;
}
.sorting-catalog-actions .btn-ghost,
.sorting-catalog-actions .btn-secondary,
.sorting-catalog-actions .btn-primary {
  flex: 0 0 auto;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.field-block-wide { grid-column: 1 / -1; }

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
}

.field-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field-block label {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.01em;
}
.field-label-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

input, select, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
  min-width: 0;
}
input::placeholder { color: var(--ink-faint); }
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); background: var(--surface); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: var(--ring);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  padding-right: 32px;
  cursor: pointer;
}

.field-help {
  font-size: 14.5px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 0;
}
.field-help code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 14px;
  background: var(--surface-3);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--line-soft);
}
.field-help strong { color: var(--ink-muted); font-weight: 600; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.field-meta {
  font-size: 14px;
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  background: var(--surface-2);
  border-radius: 6px;
  padding: 8px 10px;
  border: 1px dashed var(--line);
  max-height: 110px;
  overflow: auto;
}
.field-meta:empty { display: none; }

.upload-block { margin-top: 0; margin-bottom: 14px; }
.upload-block input[type="file"] { display: none; }

.upload-dropzone {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 18px 18px;
  background: var(--surface-2);
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color var(--t-med), background var(--t-med), color var(--t-med), transform var(--t-med);
}
.upload-dropzone:hover,
.upload-dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
  transform: translateY(-1px);
}
.upload-dropzone .upload-icon {
  flex: 0 0 auto;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 8px;
  width: 44px;
  height: 44px;
}
.upload-dropzone-text { display: flex; flex-direction: column; gap: 2px; }
.upload-dropzone-text strong { color: var(--ink); font-size: 17px; font-weight: 600; }
.upload-dropzone-text span { font-size: 15px; }

/* ============================================================
   Buttons
   ============================================================ */
button {
  cursor: pointer;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  padding: 8px 14px;
  background: var(--surface);
  color: var(--ink);
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}
button:hover { background: var(--surface-3); border-color: var(--ink-faint); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: none; box-shadow: var(--ring); }
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-600) 100%);
  border-color: var(--accent-600);
  color: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 10px rgba(56, 102, 65, 0.25);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-600) 0%, var(--accent-700) 100%);
  border-color: var(--accent-700);
  color: #fff;
}

.btn-secondary {
  background: var(--accent-soft);
  border-color: var(--accent-tint);
  color: var(--accent-ink);
}
.btn-secondary:hover {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-muted);
}
.btn-ghost:hover {
  background: var(--surface-3);
  color: var(--ink);
  border-color: var(--line-strong);
}

.danger {
  background: var(--danger-soft);
  border-color: #fca5a5;
  color: var(--danger-ink);
}
.danger:hover {
  background: #fecaca;
  border-color: #f87171;
  color: var(--danger-ink);
}
.btn-icon-only {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
}

/* ============================================================
   Run header / picker
   ============================================================ */
.card-runs {
  padding: 0;
  overflow: hidden;
  border-color: #dbe3dd;
  background:
    radial-gradient(circle at top left, rgba(56, 102, 65, 0.08), transparent 34%),
    var(--surface);
}
.run-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 24px 28px 20px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(249, 251, 249, 0.96) 0%, rgba(255, 255, 255, 0.86) 100%);
}
.run-head-titles { min-width: 0; flex: 1 1 auto; }
.run-head-titles h2 {
  font-size: 30px;
  line-height: 1.12;
  letter-spacing: 0;
}
.run-head-titles .card-sub {
  margin-top: 6px;
  font-size: 15px;
}
.run-head-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-xs);
}
.run-picker-field {
  display: flex;
  align-items: center;
  gap: 8px;
}
.run-picker-field > span {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--ink-soft);
}
.run-picker-field select {
  min-width: 310px;
  font-family: inherit;
  font-size: 14.5px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}

/* ============================================================
   Pipeline progress strip
   ============================================================ */
.pipeline-progress {
  padding: 10px 28px 4px;
  overflow-x: auto;
  margin: 18px 28px 18px;
}
.pipeline-progress[hidden] { display: none; }
.progress-stepper {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  align-items: start;
  min-width: 620px;
  margin: 0;
  padding: 0;
}
.progress-step {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.progress-step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 16px;
  left: calc(50% + 24px);
  width: calc(100% - 48px);
  height: 2px;
  background: #d8deea;
  border-radius: 999px;
}
.progress-step[data-state="done"]::after {
  background: linear-gradient(90deg, #4f46e5 0%, #4f46e5 100%);
}
.progress-step-node {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 2px solid #cfd6e4;
  background: #ffffff;
  color: #667085;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
}
.progress-step-check {
  display: none;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}
.progress-step-number {
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
}
.progress-step-label {
  font-size: 14px;
  font-weight: 600;
  color: #667085;
  white-space: nowrap;
}
.progress-step[data-state="done"] .progress-step-node {
  border-color: #4f46e5;
  background: #4f46e5;
  color: #ffffff;
}
.progress-step[data-state="done"] .progress-step-check {
  display: inline;
}
.progress-step[data-state="done"] .progress-step-number {
  display: none;
}
.progress-step[data-state="done"] .progress-step-label,
.progress-step[data-state="current"] .progress-step-label {
  color: #344054;
}
.progress-step[data-state="current"] .progress-step-node {
  border-color: #b9c4dc;
  color: #475467;
  box-shadow: 0 8px 18px rgba(79, 70, 229, 0.08);
}

/* ============================================================
   Stage timeline
   ============================================================ */
.stage-timeline {
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: relative;
  padding: 8px 28px 32px 52px;
}
.stage-timeline::before {
  content: "";
  position: absolute;
  left: 24px;
  top: 20px;
  bottom: 36px;
  width: 2px;
  border-radius: 999px;
  background: linear-gradient(180deg, #d9d2ff 0%, #e9e5fb 100%);
  pointer-events: none;
}
.stage-empty {
  padding: 24px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 15px;
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.stage-card {
  border: 1px solid #ebe8f6;
  border-radius: 18px;
  background: var(--surface);
  padding: 20px 22px 20px 18px;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
  position: relative;
  box-shadow: 0 8px 26px rgba(91, 83, 214, 0.06);
  overflow: visible;
}
.stage-card.stage-locked {
  background: linear-gradient(180deg, #fcfbff 0%, #f7f6fb 100%);
  border-color: #eceaf3;
}
.stage-card.stage-done {
  background: linear-gradient(180deg, #ffffff 0%, #fcfbff 100%);
  border-color: #e7e2fb;
}
.stage-card.stage-active {
  border-color: #ddd7ff;
  box-shadow: 0 0 0 3px rgba(103, 82, 255, 0.08), 0 10px 26px rgba(91, 83, 214, 0.08);
}
.stage-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}
.stage-head-main {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  min-width: 0;
  flex: 1 1 auto;
}
.stage-head-text { min-width: 0; flex: 1 1 auto; }
.stage-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0;
  color: #1f2437;
}
.stage-title-stat {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-soft);
}
.stage-sub {
  font-size: 14px;
  color: #667085;
  margin: 8px 0 0;
  line-height: 1.55;
}
.stage-marker {
  position: absolute;
  left: -40px;
  top: 42px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  background: #ffffff;
  border: 2px solid #d9d2ff;
  color: #7c6cff;
  z-index: 1;
  box-shadow: 0 0 0 6px #f8f7fc;
}
.stage-marker.stage-marker-done {
  background: #5c4df6;
  border-color: #5c4df6;
  color: #fff;
}
.stage-marker.stage-marker-ready,
.stage-marker.stage-marker-active {
  background: #ffffff;
  border-color: #8e84ff;
  color: #8e84ff;
}
.stage-marker.stage-marker-awaiting-cvat {
  background: #ede9ff;
  border-color: #7d6bf8;
  color: #5c4df6;
}
.stage-marker.stage-marker-locked {
  background: #f8f7fc;
  border-color: #d7d6e3;
  color: transparent;
}
.stage-hero {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.stage-hero svg {
  width: 30px;
  height: 30px;
}
.stage-hero-run {
  background: linear-gradient(135deg, #edf8ef 0%, #dff2e3 100%);
  color: #38936a;
}
.stage-hero-shelf {
  background: linear-gradient(135deg, #f4f1ff 0%, #ebe6ff 100%);
  color: #6957f5;
}
.stage-hero-product {
  background: linear-gradient(135deg, #eef7ff 0%, #e3f1ff 100%);
  color: #3b82f6;
}
.stage-hero-sort {
  background: linear-gradient(135deg, #fff4ea 0%, #ffeddc 100%);
  color: #ef7d32;
}
.stage-head-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  flex: 0 0 auto;
  min-width: 184px;
}
.stage-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.stage-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f5f4f8;
  border: 1px solid #ebe8f3;
  color: #5f6576;
  font-size: 12.5px;
  font-weight: 600;
}
.stage-pill-done {
  background: #edf8ef;
  border-color: #d5eadb;
  color: #2f8a5d;
}
.stage-pill-ready,
.stage-pill-active {
  background: #efedff;
  border-color: #ddd7ff;
  color: #5c4df6;
}
.stage-pill-awaiting-cvat {
  background: #fff5e6;
  border-color: #f2d5a5;
  color: #a66400;
}
.stage-pill-locked {
  background: #f3f2f7;
  border-color: #e6e4ed;
  color: #8b8f9b;
}
.stage-timestamp {
  margin-top: 12px;
  font-size: 13px;
  color: #667085;
}
.stage-action-hero {
  min-height: 44px;
  min-width: 196px;
  padding-inline: 16px;
  font-size: 13.5px;
}
.btn-inline-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-inline-icon svg {
  width: 15px;
  height: 15px;
}
.stage-body {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-left: 82px;
}
.stage-body-text {
  margin: 0;
  font-size: 14px;
  color: #667085;
  line-height: 1.6;
}
.stage-callout {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(180deg, #fffaf0 0%, #fff6e7 100%);
  border: 1px solid #f4d9a4;
  color: #9a6505;
}
.stage-callout strong {
  font-size: 14px;
  color: #8a5a02;
}
.stage-callout span {
  font-size: 13px;
  line-height: 1.55;
}
.stage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.stage-export-panel {
  border: 0;
  background: transparent;
  padding: 0;
  margin-top: 2px;
}
.stage-export-panel > summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: #5c4df6;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  width: fit-content;
}
.stage-export-panel > summary:hover {
  color: #4538c7;
}
.stage-export-panel > summary::-webkit-details-marker { display: none; }
.stage-export-panel > summary::before {
  content: "▸";
  font-size: 11px;
  color: #8b84c9;
  transition: transform var(--t-fast);
}
.stage-export-panel[open] > summary::before {
  transform: rotate(90deg);
}
.stage-export-panel-body {
  margin-top: 10px;
  padding: 14px 16px;
  border: 1px solid #ebe8f6;
  border-radius: 14px;
  background: linear-gradient(180deg, #fcfbff 0%, #f8f7fc 100%);
  display: grid;
  gap: 10px;
}
.stage-output-meta {
  display: grid;
  gap: 4px;
  color: #667085;
  font-size: 13px;
}
.stage-output-meta code {
  word-break: break-all;
  font-size: 12.5px;
}
.stage-export-item {
  background: var(--surface);
}
.stage-card.stage-done .stage-export-panel .btn-copy-path:not(:disabled) {
  background: #efedff;
  border-color: #ddd7ff;
  color: #5c4df6;
}
.stage-card.stage-done .stage-export-panel .btn-copy-path:not(:disabled):hover {
  background: #e5e0ff;
  border-color: #bcb2ff;
  color: #4538c7;
}
.stage-action-rerun {
  font-size: 13px;
}
.btn-stage-export-preview {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.preview-chevron {
  display: inline-block;
  transition: transform var(--t-fast);
}
.btn-stage-export-preview[data-expanded="true"] .preview-chevron {
  transform: rotate(180deg);
}
.cvat-task-stack {
  display: grid;
  gap: 12px;
}
.cvat-task-row {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid #ece8f7;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.cvat-task-row-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.cvat-task-row-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f1eeff;
  color: #6957f5;
  flex: 0 0 auto;
}
.cvat-task-row-icon svg {
  width: 18px;
  height: 18px;
}
.cvat-task-row-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.cvat-task-row-copy strong {
  font-size: 13.5px;
  color: #1f2437;
}
.cvat-task-row-copy span {
  font-size: 12.5px;
  color: #7b8190;
}
.cvat-task-row-link {
  min-width: 0;
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid #ded9fb;
  background: #fbfaff;
  color: #5c4df6;
  text-decoration: none;
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cvat-task-row-link:hover {
  background: #f3f0ff;
  border-color: #cfc7ff;
}
.cvat-task-row-open {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid #ddd7ff;
  background: #ffffff;
  color: #5c4df6;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cvat-task-row-open:hover {
  background: #f5f3ff;
  border-color: #c9c1ff;
}
.cvat-task-row-open::after {
  content: "↗";
  margin-left: 6px;
  font-size: 11px;
}
.stage-session-list {
  display: grid;
  gap: 12px;
}
.stage-session-entry {
  display: grid;
  gap: 10px;
}
.stage-session-entry.is-export-selected .stage-session-row {
  border-color: #cfc7ff;
  box-shadow: 0 0 0 2px rgba(105, 87, 245, 0.08);
}
.stage-session-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid #ece8f7;
  border-radius: 14px;
  background: #ffffff;
}
.stage-session-row-titleline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.stage-session-row-copy strong {
  display: block;
  font-size: 14px;
  color: #1f2437;
}
.stage-session-row-copy small {
  display: block;
  margin-top: 4px;
  color: #667085;
  font-size: 13px;
}
.stage-session-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}
.stage-session-pill-done {
  background: #edf8ef;
  border-color: #d5eadb;
  color: #2f8a5d;
}
.stage-session-pill-active {
  background: #efedff;
  border-color: #ddd7ff;
  color: #5c4df6;
}
.stage-session-row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.stage-session-row-actions button {
  min-width: 94px;
}
.btn-toggle-session-export.active {
  background: #efedff;
  border-color: #cfc7ff;
  color: #5142d6;
}
.session-sort-export-panel {
  margin: 0 10px 4px;
}
.sort-export-panel > summary {
  display: none;
}
.sort-export-panel-body {
  gap: 14px;
}
.sort-export-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #ece8f7;
}
.sort-export-hero-main {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}
.sort-export-hero-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f4f1ff 0%, #ebe6ff 100%);
  color: #6957f5;
  flex: 0 0 auto;
}
.sort-export-hero-icon svg {
  width: 24px;
  height: 24px;
}
.sort-export-hero-copy strong {
  display: block;
  font-size: 18px;
  color: #1f2437;
}
.sort-export-hero-copy p {
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.55;
  color: #667085;
}
.sort-export-hero-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.sort-export-stat {
  min-width: 108px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #e9e5f7;
  background: #ffffff;
  display: grid;
  gap: 2px;
}
.sort-export-stat strong {
  font-size: 18px;
  color: #1f2437;
}
.sort-export-stat span {
  font-size: 12.5px;
  color: #667085;
}
.session-list-inline {
  margin-top: 0;
}
.btn-delete-run {
  font-size: 13.5px;
}
@media (max-width: 720px) {
  .run-head {
    flex-direction: column;
    align-items: stretch;
    padding: 20px 18px 16px;
  }
  .run-head-tools {
    width: 100%;
    justify-content: stretch;
  }
  .run-head-tools > button {
    flex: 1 1 auto;
  }
  .pipeline-progress {
    margin: 14px 18px;
    padding: 8px 0 2px 0;
  }
  .stage-timeline {
    padding: 0 18px 22px 34px;
  }
  .stage-timeline::before {
    left: 14px;
  }
  .stage-card {
    padding: 18px 16px;
  }
  .stage-marker {
    left: -30px;
    top: 32px;
    box-shadow: 0 0 0 4px #f8f7fc;
  }
  .stage-head {
    flex-direction: column;
  }
  .stage-head-main {
    gap: 14px;
  }
  .stage-head-side {
    width: 100%;
    min-width: 0;
    align-items: stretch;
  }
  .stage-action-hero {
    width: 100%;
  }
  .stage-body {
    padding-left: 0;
  }
  .cvat-task-row {
    grid-template-columns: 1fr;
  }
  .cvat-task-row-link,
  .cvat-task-row-open {
    width: 100%;
  }
  .stage-session-row {
    flex-direction: column;
    align-items: stretch;
  }
  .stage-session-row-titleline {
    align-items: flex-start;
  }
  .stage-session-row-actions {
    justify-content: stretch;
  }
  .stage-session-row-actions > button {
    flex: 1 1 auto;
  }
  .sort-export-hero {
    flex-direction: column;
  }
  .sort-export-hero-stats {
    width: 100%;
    justify-content: stretch;
  }
  .sort-export-stat {
    flex: 1 1 0;
  }
  .run-alert {
    margin-left: 18px;
    margin-right: 18px;
  }
  .run-picker-field select { min-width: 0; width: 100%; }
}

/* ============================================================
   Run info
   ============================================================ */
.run-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.run-alert {
  max-height: 0;
  opacity: 0;
  transform: translateY(-8px);
  overflow: hidden;
  transition: max-height var(--t-med), opacity var(--t-med), transform var(--t-med), margin-bottom var(--t-med);
  margin: 0 28px;
}
.run-alert.visible {
  max-height: 240px;
  opacity: 1;
  transform: translateY(0);
  margin-bottom: 14px;
}
.run-alert-body {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  background: #fff8dd;
  border: 1px solid #f9d77a;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.run-alert-text {
  flex: 1 1 auto;
  min-width: 0;
  white-space: pre-wrap;
  font-size: 15px;
  color: #6b4d00;
  line-height: 1.5;
}
.run-alert-dismiss {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 999px;
  padding: 0;
  margin-top: 1px;
  font-size: 18px;
  line-height: 1;
  color: #8a6a16;
  background: rgba(255, 248, 221, 0.8);
  border: 1px solid #e6c76f;
}
.run-alert-dismiss:hover {
  color: #6b4d00;
  background: #f9e7b5;
  border-color: #d3ab43;
}
.info-block h4 { margin-bottom: 6px; }
.info-block-wide { grid-column: 1 / -1; }
.runs-block { margin-top: 10px; }
.cvat-block { margin-top: 12px; }
.sorting-sessions-block { margin-top: 12px; }
@media (max-width: 800px) {
  .run-info-grid { grid-template-columns: 1fr; }
  .runs-block { margin-top: 8px; }
  .cvat-block,
  .sorting-sessions-block { margin-top: 10px; }
}

/* ============================================================
   Session/project list
   ============================================================ */
.session-list { display: grid; gap: 8px; }
.session-list:empty::before {
  content: "Nothing here yet.";
  color: var(--ink-faint);
  font-size: 15.5px;
  padding: 6px 4px;
}

.session-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--surface);
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}
.session-item:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
  transform: translateY(-1px);
}
.session-item strong { font-size: 16px; display: block; margin-bottom: 2px; }
.session-item small { color: var(--ink-soft); font-size: 14.5px; }
.session-item-info { min-width: 0; flex: 1 1 auto; }
.session-item-info small { display: block; word-break: break-all; }

.badge {
  border-radius: 999px;
  padding: 3px 10px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--accent-tint);
}

.hidden { display: none !important; }

/* ============================================================
   Workspace (Phase 2)
   ============================================================ */
.workspace { display: grid; gap: 14px; }

.workspace-header {
  position: sticky;
  top: 8px;
  z-index: 10;
  backdrop-filter: blur(8px);
  background: rgba(255, 255, 255, 0.92);
}
.workspace-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
}
#workspace-title { font-size: 26px; }

.workspace-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14.5px;
  color: var(--ink-soft);
  font-weight: 600;
}
.inline-field select {
  width: auto;
  min-width: 140px;
  padding: 6px 28px 6px 10px;
  font-size: 15px;
}

.workspace .grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 14px;
}
.panel-scroll {
  max-height: 60vh;
  overflow: auto;
  padding-right: 4px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.panel-head-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.panel-hint {
  font-size: 15px;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.active-bin {
  font-size: 14.5px;
  color: var(--ink-soft);
  font-weight: 500;
  margin-left: 4px;
}

/* ============================================================
   Tabs
   ============================================================ */
.tab-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tab-button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-soft);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 500;
}
.tab-button:hover {
  background: var(--surface-3);
  color: var(--ink);
}
.tab-button.active {
  background: var(--accent-soft);
  border-color: var(--accent-tint);
  color: var(--accent-ink);
  font-weight: 600;
}

/* ============================================================
   Crop grid
   ============================================================ */
.crop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  max-height: 60vh;
  overflow: auto;
  padding: 4px;
}
.crop-grid::-webkit-scrollbar,
.panel-scroll::-webkit-scrollbar,
.cluster-list::-webkit-scrollbar,
.export-preview-list::-webkit-scrollbar { width: 8px; height: 8px; }
.crop-grid::-webkit-scrollbar-thumb,
.panel-scroll::-webkit-scrollbar-thumb,
.cluster-list::-webkit-scrollbar-thumb,
.export-preview-list::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
}

/* "Load more" is appended INTO the crop/bin grid, so it becomes a grid item and
   gets sized like a 110px crop cell - far too narrow for "Load more (4288
   remaining)", which then spilled outside the button. Span the full row and
   allow wrapping so the label always stays inside. */
/* Gallery (.npz) option: greyed out when no product has enough train images.
   The note below it explains WHY rather than leaving a dead checkbox. */
.checkbox-row.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.checkbox-row.disabled input {
  cursor: not-allowed;
}
.export-npz-option {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}
.export-npz-controls {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}
.export-npz-note {
  display: block;
  margin: 0;
  line-height: 1.4;
}

.load-more {
  grid-column: 1 / -1;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
  line-height: 1.3;
  min-height: 40px;
  padding: 10px 12px;
  width: 100%;
}

.crop-card {
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 4px;
  background: var(--surface-2);
  cursor: pointer;
  transition: all var(--t-fast);
}
.crop-card:hover {
  border-color: var(--accent-tint);
  background: var(--surface);
  transform: translateY(-1px);
  box-shadow: var(--shadow-xs);
}
.crop-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm);
}
.thumb-shell {
  width: 100%;
  border-radius: 10px;
  background: linear-gradient(180deg, #f7f8f4 0%, #eef1e8 100%);
  border: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.thumb-shell img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  background: transparent;
}
.crop-thumb-shell {
  height: 90px;
  padding: 3px 10px 2px;
}
.crop-thumb-image {
  transform: scale(1.08);
}
.crop-card .name {
  font-size: 12.5px;
  margin-top: 4px;
  word-break: break-all;
  color: var(--ink-soft);
  line-height: 1.3;
}

/* ============================================================
   Bins
   ============================================================ */
.shelf-block { margin: 12px 0; }
.shelf-title {
  margin: 0 0 8px;
  font-size: 14.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  display: inline-block;
  transition: background var(--t-fast), color var(--t-fast);
}
.shelf-title:hover { background: var(--surface-3); color: var(--ink); }

.bin-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
}
.bin {
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  background: var(--surface);
  cursor: pointer;
  transition: all var(--t-fast);
}
.bin:hover {
  border-color: var(--accent-tint);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.bin.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm);
}
.bin-header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-left: auto;
  flex: 0 0 auto;
}
.bin-small-action {
  font-size: 12.5px;
  padding: 3px 8px;
  border-radius: 6px;
}
.bin .top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
  font-size: 15px;
  min-width: 0;
}
.bin .top strong {
  color: var(--ink);
  min-width: 0;
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bin .top span { color: var(--ink-soft); font-weight: 600; font-size: 14px; }
.bin .meta {
  font-size: 14px;
  color: var(--ink-soft);
  margin-top: 4px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.bin-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
}
.bin-title-input {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  height: 30px;
  padding: 4px 8px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  border-radius: 8px;
}
.btn-delete-custom-bin {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
}
.bin .ref-shell {
  height: 92px;
  padding: 2px 10px 1px;
  margin-bottom: 8px;
  position: relative;
}
.bin .ref {
  transform: scale(1.12);
}
/* Greyed silhouette placeholder behind the image; image fades in once loaded so
   empty/loading bins show a stable placeholder instead of flashing. */
.ref-shell .thumb-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--line-strong, #c2c7cf);
  pointer-events: none;
}
.ref-shell .thumb-placeholder svg { width: 42%; height: 42%; opacity: 0.7; }
.ref-shell.has-image .thumb-placeholder { display: none; }
.ref-shell .ref { opacity: 0; transition: opacity 0.2s ease; }
.ref-shell .ref.is-loaded { opacity: 1; }
/* No image loaded (showing the placeholder) -> hide the magnify button. */
.ref-shell:not(.has-image) .btn-view-ref { display: none; }
.thumb-shell .btn-view-ref {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 30px;
  height: 30px;
  min-width: 30px;
  padding: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(94, 110, 89, 0.22);
  box-shadow: var(--shadow-xs);
  color: #45613f;
}
.thumb-shell .btn-view-ref:hover {
  background: #ffffff;
  color: #26492a;
}
.thumb-shell .btn-view-ref .btn-inline-icon svg {
  width: 14px;
  height: 14px;
}

#product-bins.manual-planogram-mode {
  display: grid;
  gap: 14px;
  align-content: start;
}
.manual-planogram-lock {
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  justify-content: center;
  border-radius: 10px;
  border-color: #d8e2d4;
}
.manual-planogram-lock:hover {
  border-color: #b8cbb1;
}
.manual-planogram-lock.is-unlocked {
  background: linear-gradient(180deg, #eef8ea 0%, #e0f0db 100%);
  border-color: #9ec08e;
  color: #2f6a37;
}
.manual-planogram-block {
  margin: 0;
  padding: 14px;
  border: 1px dashed #dbe4d6;
  border-radius: 18px;
  background: linear-gradient(180deg, #fbfcfa 0%, #f6f8f4 100%);
}
.manual-planogram-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.manual-planogram-title {
  cursor: default;
  margin-bottom: 0;
  color: #57724e;
  background: #edf4ea;
}
.manual-planogram-title:hover {
  background: #edf4ea;
  color: #57724e;
}
.manual-planogram-row-delete {
  padding: 7px 11px;
  border-radius: 10px;
  border-color: #f0c9c2;
  color: var(--danger-ink);
  background: rgba(255, 245, 245, 0.92);
}
.manual-planogram-row-delete:hover {
  border-color: #e89f94;
  color: var(--danger-ink);
  background: #ffe7e4;
}
.manual-planogram-row {
  min-height: 116px;
  padding: 8px;
  border: 1px dashed transparent;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.unplaced-bin-row {
  background: linear-gradient(180deg, rgba(255, 251, 240, 0.88) 0%, rgba(255, 248, 231, 0.94) 100%);
}
.manual-row-empty {
  display: grid;
  place-items: center;
  min-height: 92px;
  padding: 14px;
  border: 1px dashed #d7dfd3;
  border-radius: 14px;
  background: rgba(249, 250, 248, 0.92);
  color: var(--ink-soft);
  font-size: 14px;
  text-align: center;
}
.btn-manual-add-row {
  width: 100%;
  justify-content: center;
  padding: 13px 16px;
  border-radius: 14px;
  font-weight: 700;
  background: linear-gradient(180deg, #eef9ea 0%, #ddf0d6 100%);
  border-color: #a8c79b;
  color: #2f6a37;
}
.btn-manual-add-row:hover {
  background: linear-gradient(180deg, #e5f5df 0%, #d4ebcb 100%);
  border-color: #8db67f;
  color: #24572d;
}
.manual-draggable {
  cursor: grab;
}
.manual-draggable:active {
  cursor: grabbing;
}
.manual-draggable.manual-dragging {
  opacity: 0.52;
  transform: scale(0.985);
  box-shadow: none;
}
.manual-drop-target {
  border-color: #8db67f;
  background: #f4faf1;
  box-shadow: 0 0 0 1px rgba(92, 133, 72, 0.18);
}
.manual-row-drop-active {
  border-color: #8db67f;
  background: rgba(235, 245, 230, 0.95);
  box-shadow: inset 0 0 0 1px rgba(92, 133, 72, 0.12);
}

.toast-stack {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 1100;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 24px));
}
.toast {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 14px 14px 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow-lg);
  animation: toast-enter 160ms ease-out;
}
.toast.is-info {
  border-color: #d8e2f3;
  background: linear-gradient(180deg, #ffffff 0%, #f6f9ff 100%);
}
.toast.is-success {
  border-color: #cfe0ca;
  background: linear-gradient(180deg, #ffffff 0%, #f2f8f1 100%);
}
.toast.is-warning {
  border-color: #edd3ab;
  background: linear-gradient(180deg, #fffdf8 0%, #fff7ea 100%);
}
.toast.is-danger {
  border-color: #efc5c0;
  background: linear-gradient(180deg, #fffdfd 0%, #fff2f0 100%);
}
.toast-text {
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.toast-close {
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
}
.toast-close:hover {
  background: var(--surface-3);
  color: var(--ink);
}
@keyframes toast-enter {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.app-dialog {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.app-dialog.hidden {
  display: none;
}
.app-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(19, 24, 18, 0.62);
  backdrop-filter: blur(3px);
}
.app-dialog-panel {
  position: relative;
  z-index: 1;
  width: min(540px, calc(100vw - 32px));
  display: grid;
  gap: 0;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(248, 249, 245, 0.98);
  box-shadow: 0 28px 80px rgba(12, 18, 10, 0.28);
}
.app-dialog-head {
  padding: 16px 18px 10px;
}
.app-dialog-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}
.app-dialog-body {
  display: grid;
  gap: 14px;
  padding: 0 18px 18px;
}
.app-dialog-message {
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-muted);
  white-space: pre-wrap;
}
.app-dialog-fields {
  display: grid;
  gap: 12px;
}
.app-dialog-fields.hidden {
  display: none;
}
.app-dialog-field {
  display: grid;
  gap: 6px;
}
.app-dialog-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}
.app-dialog-field input {
  width: 100%;
}
.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 18px 18px;
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.image-viewer.hidden {
  display: none;
}
.image-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(19, 24, 18, 0.72);
  backdrop-filter: blur(3px);
}
.image-viewer-dialog {
  position: relative;
  z-index: 1;
  width: min(900px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(248, 249, 245, 0.98);
  box-shadow: 0 28px 80px rgba(12, 18, 10, 0.28);
}
.image-viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.9) 0%, rgba(244,247,239,0.9) 100%);
}
.image-viewer-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.image-viewer-close {
  flex: 0 0 auto;
}
.image-viewer-body {
  padding: 18px;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #f8f9f5 0%, #edf1e5 100%);
}
.image-viewer-img {
  max-width: 100%;
  max-height: calc(100vh - 160px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 14px 36px rgba(25, 34, 23, 0.14);
}

.trash {
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  justify-content: center;
  gap: 6px;
  border-color: #fecaca;
  background: #fff5f5;
  color: var(--danger-ink);
  font-weight: 600;
  border-radius: 10px;
}
.trash:hover { background: var(--danger-soft); border-color: #fca5a5; color: var(--danger-ink); }
.trash.active {
  background: var(--danger-soft);
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger);
}
.trash-count {
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.top-gap { margin-top: 12px; }
#layout-csv-status { margin-top: 6px; min-height: 1.2em; }

/* ============================================================
   Cluster panel
   ============================================================ */
.cluster-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--line);
}

.cluster-status-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 12px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--accent-tint);
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--accent-soft) 0%, #f7fef9 100%);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 15.5px;
}
.cluster-status-banner::before {
  content: "";
  width: 14px;
  height: 14px;
  margin-top: 3px;
  border: 2px solid var(--accent-tint);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: cluster-spin 0.8s linear infinite;
  flex: 0 0 auto;
}
.cluster-status-copy {
  flex: 1 1 auto;
  min-width: 0;
}
.cluster-status-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.cluster-status-text {
  min-width: 0;
}
.cluster-status-percent {
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--accent-ink);
}
.cluster-progress-track {
  width: 100%;
  height: 7px;
  margin-top: 8px;
  border-radius: 999px;
  background: rgba(68, 114, 76, 0.14);
  overflow: hidden;
}
.cluster-progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent) 0%, #6fc982 100%);
  transition: width 0.25s ease;
}
.cluster-status-detail {
  margin-top: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-soft);
}
.cluster-meta {
  font-size: 15px;
  color: var(--ink-soft);
}
.similar-active {
  color: var(--accent-ink);
  font-weight: 600;
}

.cluster-list {
  display: grid;
  gap: 10px;
  max-height: 60vh;
  overflow: auto;
  padding-right: 4px;
}
.cluster-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface-2);
  transition: border-color var(--t-fast);
}
.cluster-card:hover { border-color: var(--line-strong); }
.cluster-card.completed { opacity: 0.6; }
.cluster-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.cluster-title { font-weight: 600; font-size: 16px; }

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

.cluster-preview-strip {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.cluster-preview-thumb {
  width: 78px;
  height: 78px;
  border-radius: 8px;
  flex: 0 0 auto;
}
.cluster-thumb-shell {
  height: 100%;
  padding: 2px 8px 1px;
}
.cluster-thumb-image {
  transform: scale(1.08);
}
.cluster-preview-label {
  font-size: 14px;
  color: var(--ink-soft);
  margin-top: 6px;
}
.cluster-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.cluster-body { margin-top: 10px; }
.cluster-helper {
  font-size: 14px;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.empty-note {
  color: var(--ink-faint);
  font-size: 15.5px;
  padding: 10px 4px;
  text-align: center;
}

.bin-contents-grid { max-height: 42vh; }

.move-row {
  margin: 10px 0;
  padding: 10px;
  background: var(--surface-3);
  border-radius: var(--radius-sm);
}
.move-row select { max-width: 320px; }

/* ============================================================
   Preview / output
   ============================================================ */
.preview {
  white-space: pre-wrap;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 15px;
  color: var(--ink-muted);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  line-height: 1.5;
  min-height: 38px;
  max-height: 180px;
  overflow: auto;
}
.preview:empty::before {
  content: "—";
  color: var(--ink-faint);
}
.preview a {
  color: var(--accent-600);
  text-decoration: underline;
  font-family: inherit;
}
.cvat-task-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.cvat-task-group {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.cvat-task-group-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.cvat-task-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.cvat-task-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  min-height: 64px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid #b7cfbf;
  background: #f4faf5;
  color: #1f3d25;
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.35;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.cvat-task-btn:hover {
  background: #e7f3ea;
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.cvat-task-btn-title {
  display: block;
}
.cvat-task-btn-sub {
  display: block;
  margin-top: 3px;
  font-size: 12.5px;
  font-weight: 500;
  color: #4b5c52;
}
@media (max-width: 860px) {
  .cvat-task-groups {
    grid-template-columns: 1fr;
  }
  .cvat-task-list {
    grid-template-columns: 1fr;
  }
  .cvat-task-btn {
    width: 100%;
  }
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15.5px;
  color: var(--ink-muted);
  cursor: pointer;
}
.checkbox-row input { width: auto; margin: 0; }

/* ============================================================
   Export preview
   ============================================================ */
.export-preview {
  display: grid;
  gap: 12px;
  white-space: normal;
  font-family: inherit;
  background: var(--surface-2);
  border: 1px solid var(--line);
  max-height: none;
  margin-top: 12px;
  padding: 14px;
}
.export-preview.hidden { display: none; }
.export-preview-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.export-preview-summary,
.export-selection-meta {
  color: var(--ink-soft);
  font-size: 15px;
  margin-top: 2px;
}
.export-preview-toolbar {
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}
.export-name-field {
  display: grid;
  gap: 4px;
  min-width: 280px;
  flex: 1;
}
.export-name-field span {
  font-size: 14.5px;
  color: var(--ink-muted);
  font-weight: 600;
}
.export-preview-list {
  display: grid;
  gap: 6px;
  max-height: 38vh;
  overflow: auto;
}
.export-preview-item {
  display: grid;
  grid-template-columns: 24px 48px minmax(0, 1fr) max-content;
  gap: 12px;
  align-items: center;
  min-height: 66px;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 12px 8px 8px;
  background: var(--surface);
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.export-preview-item:hover {
  border-color: var(--accent-tint);
  background: var(--accent-soft);
}
.export-preview-item.is-unselected {
  opacity: 0.5;
  background: var(--surface-3);
}
.export-preview-item input[type="checkbox"] {
  appearance: auto;
  margin: 0;
  width: 16px;
  height: 16px;
  min-width: 16px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  justify-self: center;
  align-self: center;
  accent-color: var(--accent);
}
.export-preview-item input[type="checkbox"]:hover,
.export-preview-item input[type="checkbox"]:focus {
  border: 0;
  background: transparent;
  box-shadow: none;
}
.export-preview-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-faint);
  font-size: 12px;
  text-align: center;
  padding: 4px;
}
.export-preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.export-preview-thumb.is-empty img { display: none; }
.export-preview-item-main { display: grid; gap: 2px; }
.export-preview-item-title { font-weight: 600; font-size: 15.5px; }
.export-preview-item-subtitle { color: var(--ink-soft); font-size: 14px; }
.export-preview-item-counts {
  color: var(--ink-muted);
  font-size: 14px;
  text-align: right;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 980px) {
  .workspace .grid { grid-template-columns: 1fr; }
  .app-shell { padding: 14px; }
  .workspace-header { position: static; }
}
@media (max-width: 600px) {
  .app-header { flex-direction: column; align-items: flex-start; }
  .header-meta { width: 100%; }
  .card { padding: 14px; border-radius: var(--radius); }
  .card.card-runs { padding: 0; }
  h1 { font-size: 21.5px; }
}

/* ============== Datasets tab (autodiscovery) ============== */
.card-head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dataset-item { flex-wrap: wrap; }
.badge-warn { background: #fbeecb; color: #8a6d15; }

.dataset-detail { flex-basis: 100%; width: 100%; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.dataset-detail.hidden { display: none; }

.dataset-batch-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.dataset-batch-row {
  display: flex; align-items: center; justify-content: flex-start; gap: 12px;
  padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); cursor: pointer; width: 100%;
}
.dataset-batch-row input[type="checkbox"] { margin: 0; flex: 0 0 auto; width: 16px; height: 16px; }
.dataset-batch-id { font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums; }
.dataset-batch-status {
  flex: 0 0 auto; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.03em; padding: 2px 9px; border-radius: 999px;
  background: rgba(0,0,0,0.06); color: var(--ink-soft);
}
.dataset-batch-status.status-done { background: #d5f2e0; color: #1f6b3b; }
.dataset-batch-status.status-in_progress { background: #fbeecb; color: #8a6d15; }
.dataset-batch-meta { color: var(--ink-soft); font-size: 13px; margin-left: auto; text-align: right; }

.dataset-start-form {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  padding-top: 12px; border-top: 1px solid var(--line);
}
.dataset-start-form .dataset-project-name { flex: 1 1 260px; min-width: 200px; }
.dataset-split-opt { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--ink-soft); white-space: nowrap; }
.dataset-start-form .btn-dataset-start { margin-left: auto; }

/* Multi-select: per-gondola include checkbox + aggregate start bar */
.dataset-include { flex: 0 0 auto; display: flex; align-items: center; padding-right: 4px; cursor: pointer; }
.dataset-include input { width: 17px; height: 17px; margin: 0; cursor: pointer; }
.dataset-start-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  margin: 4px 0 14px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2);
}
.dataset-startbar-label { font-weight: 600; color: var(--ink); }
.dataset-start-bar #btn-datasets-start { margin-left: auto; }
.create-autodisc-note {
  margin: 4px 0 14px; padding: 10px 12px; border-radius: 10px;
  background: #eef4ff; border: 1px solid #cfe0ff; color: #2c4a86; font-size: 13.5px;
}

/* Prelabel/job progress bar (rendered inside the active stage card) */
.job-progress { margin: 4px 0 14px; }
.job-progress.hidden { display: none; }
.stage-progress { margin: 2px 0 14px; }
.job-progress-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.job-progress-label { font-size: 13.5px; color: var(--ink-soft); }
.job-progress-pct { font-size: 13px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.job-progress-track { height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.job-progress-fill {
  position: relative; overflow: hidden;
  height: 100%; width: 0%; border-radius: 999px;
  background: var(--accent, #2f6b3a); transition: width 0.3s ease;
}
/* Always-on subtle sweep so a held percent never looks frozen. */
.job-progress-fill::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.3) 50%, transparent 80%);
  transform: translateX(-100%);
  animation: jobShimmer 1.8s ease-in-out infinite;
}
@keyframes jobShimmer { to { transform: translateX(100%); } }

/* Stall escalation: percent held too long -> moving stripe + a "still working" hint. */
.job-progress.is-stalled .job-progress-fill {
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.16) 0 8px, transparent 8px 16px);
  background-size: 22px 22px;
  animation: jobStripes 0.8s linear infinite;
}
@keyframes jobStripes { to { background-position: 22px 0; } }
.job-progress-hint { margin-top: 6px; font-size: 12px; color: var(--ink-soft); }
.job-progress.is-stalled .job-progress-hint::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: #d08a1a; margin-right: 6px; vertical-align: middle;
  animation: jobPulse 1.2s ease-in-out infinite;
}
@keyframes jobPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Motion-light users: drop the sweeps; the ticking elapsed timer carries liveness. */
@media (prefers-reduced-motion: reduce) {
  .job-progress-fill::after { display: none; }
  .job-progress.is-stalled .job-progress-fill { animation: none; }
  .job-progress.is-stalled .job-progress-hint::before { animation: none; }
}

/* Create Project modal dialog (native <dialog>; distinct from the .app-dialog confirm modal) */
.create-dialog {
  border: none; border-radius: 16px; padding: 0; margin: auto;
  max-width: 720px; width: calc(100vw - 40px); max-height: calc(100vh - 80px);
  /* Clip so the inner scrollbar stays inside the rounded corners (no squared edges). */
  overflow: hidden; background: var(--surface); color: var(--ink);
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.create-dialog::backdrop { background: rgba(15,20,30,0.55); }
.create-dialog-inner {
  padding: 24px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  /* Discrete scrollbar, matching the sorting-page treatment. */
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.create-dialog-inner::-webkit-scrollbar { width: 8px; height: 8px; }
/* Inset the track from the ends so the thumb stops short of the rounded corners. */
.create-dialog-inner::-webkit-scrollbar-track { background: transparent; margin: 16px 0; }
.create-dialog-inner::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.btn-dialog-close { font-size: 18px; line-height: 1; padding: 4px 10px; flex: 0 0 auto; }
.btn-create-pill { flex: 0 0 auto; white-space: nowrap; }

/* Guarded project-list rows: name truncates, action buttons stay put */
.card-projects .session-item { gap: 12px; }
.card-projects .session-item-info { min-width: 0; }
.card-projects .session-item-info strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-projects .session-item .row { flex: 0 0 auto; flex-wrap: nowrap; }
