/* AlphaHub — dashboard UI (taste-skill: calm quant cockpit, no AI-slop gradients) */
:root {
  --bg: #f4f6f9;
  --bg-elevated: #ffffff;
  --bg-subtle: #e8ecf2;
  --surface: #ffffff;
  --border: #d4dae3;
  --border-strong: #b8c2d0;
  --text: #141c2b;
  --text-secondary: #3d4a5f;
  --muted: #64748b;
  --top: #0f172a;
  --top-muted: #94a3b8;
  --accent: #0d6e6e;
  --accent-soft: #e6f4f4;
  --accent-hover: #0a5555;
  --accent-glow: rgba(13, 110, 110, 0.22);
  --accent-light: #14b8a6;
  --good: #15803d;
  --warn: #c2410c;
  --danger: #b91c1c;
  --avg: #64748b;
  --gold: #b8860b;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --font-sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "Cascadia Code", "JetBrains Mono", ui-monospace, Consolas, monospace;
  --bg-even-row: rgba(244, 246, 249, 0.6);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 120% 80% at 100% -20%, rgba(13, 110, 110, 0.07), transparent 50%),
    radial-gradient(ellipse 80% 50% at 0% 100%, rgba(15, 23, 42, 0.04), transparent 45%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  min-height: 100vh;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
}

.brand h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--top);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 0.8rem;
}

.brand-mark.sm {
  width: 34px;
  height: 34px;
  font-size: 0.7rem;
  border-radius: 9px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.8125rem;
  line-height: 1.55;
}

.hidden {
  display: none !important;
}

.error {
  color: var(--danger);
  font-size: 0.875rem;
}

.auth-card label {
  display: block;
  margin-top: 14px;
  margin-bottom: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.auth-card input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.topbar {
  background: var(--top);
  color: #f1f5f9;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow-sm);
}

.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.875rem;
  color: var(--top-muted);
}

.tab-bar-wrap {
  max-width: 1320px;
  margin: 0 auto;
  padding: 16px 24px 0;
}

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.tab {
  padding: 10px 18px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  border-radius: calc(var(--radius-md) - 4px);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  border-bottom: 2px solid transparent;
}

.tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.6);
}

.tab.active {
  color: var(--accent);
  font-weight: 600;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  border-bottom: 2px solid var(--accent);
}

.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 24px 40px;
}

.panel {
  display: none;
  animation: panel-in 0.25s ease;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel.active {
  display: block;
}

.panel > h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.panel > h3 {
  margin: 20px 0 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.genius-overview {
  margin-bottom: 22px;
  background: var(--surface);
  border-top: 3px solid var(--top);
  border-bottom: 1px solid var(--border);
}

.genius-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 2px 16px;
}

.genius-kicker {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.genius-title-line {
  display: flex;
  align-items: center;
  gap: 12px;
}

.genius-title-line h2 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.2;
}

.genius-level {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 9px;
  border: 1px solid color-mix(in srgb, var(--genius-level-color, var(--gold)) 60%, #ffffff);
  border-radius: 999px;
  background: color-mix(in srgb, var(--genius-level-color, var(--gold)) 14%, #ffffff);
  color: color-mix(in srgb, var(--genius-level-color, var(--gold)) 72%, #111827);
  font-size: 0.75rem;
  font-weight: 800;
}

.genius-period,
.genius-updated {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.genius-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.genius-refresh,
.genius-link {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  min-height: 34px;
  padding: 7px 11px;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
}

.genius-refresh {
  cursor: pointer;
}

.genius-refresh:hover:not(:disabled),
.genius-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.genius-refresh:disabled {
  cursor: wait;
  opacity: 0.65;
}

.genius-error {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-left: 3px solid var(--danger);
  background: #fef2f2;
  color: var(--danger);
  font-size: 0.8125rem;
}

.genius-priority-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}

.genius-priority {
  display: grid;
  grid-template-columns: 42px minmax(240px, 0.9fr) minmax(520px, 1.7fr);
  align-items: center;
  gap: 16px;
  min-height: 126px;
  padding: 17px 2px;
  border-bottom: 1px solid var(--bg-subtle);
}

.genius-priority:last-child {
  border-bottom: none;
}

.genius-priority-index {
  align-self: start;
  padding-top: 3px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
}

.genius-priority-copy {
  align-self: start;
}

.genius-priority-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.genius-priority-title h3 {
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.35;
}

.genius-priority-title span {
  color: var(--accent);
  font-size: 0.6875rem;
  font-weight: 700;
}

.genius-priority-copy p {
  max-width: 430px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

.genius-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(105px, 1fr));
  gap: 1px;
  margin: 0;
  background: var(--border);
  border: 1px solid var(--border);
  overflow: hidden;
}

.genius-metrics > div {
  min-width: 0;
  min-height: 66px;
  padding: 10px 12px;
  background: var(--bg);
}

.genius-metrics dt {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.6875rem;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.genius-metrics dd {
  margin: 5px 0 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.genius-metrics dd.pending {
  color: var(--warn);
  font-size: 0.8125rem;
}

.genius-metrics dd.genius-text-value {
  font-size: 0.8125rem;
}

.genius-priority-level .genius-metrics {
  grid-template-columns: repeat(4, minmax(105px, 1fr));
}

.genius-osmosis-block {
  min-width: 0;
}

.genius-osmosis-metrics {
  grid-template-columns: repeat(3, minmax(120px, 1fr));
}

.genius-progress {
  height: 5px;
  margin-top: 9px;
  overflow: hidden;
  background: var(--bg-subtle);
}

.genius-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.25s ease;
}

.genius-scopes {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.6875rem;
}

.genius-scopes strong {
  color: var(--text-secondary);
}

.genius-scope-empty {
  font-style: italic;
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px var(--accent-glow);
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn.success {
  background: var(--good);
  color: #fff;
  box-shadow: 0 1px 2px rgba(21, 128, 61, 0.2);
}

.btn.success:hover:not(:disabled) {
  background: #166534;
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn.ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
}

.btn.danger.ghost {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(185, 28, 28, 0.35);
}

.btn.full {
  width: 100%;
  margin-top: 20px;
}

.alpha-summary-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px;
  margin-bottom: 14px;
}

.split-sync {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  border-radius: var(--radius-sm);
  overflow: visible;
  box-shadow: var(--shadow-sm);
}

.split-sync .btn.primary {
  margin: 0;
  border-radius: 0;
}

.split-sync-main {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm) !important;
  padding-left: 18px;
  padding-right: 16px;
  height: 42px;
  line-height: 42px;
  padding-top: 0;
  padding-bottom: 0;
}

.split-sync-caret {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0 !important;
  padding: 0 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.2) !important;
  min-width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.caret-icon {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.split-sync-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  margin: 0;
  padding: 6px;
  list-style: none;
  min-width: 168px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 50;
}

.split-sync-menu li button {
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: transparent;
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--text);
  border-radius: 6px;
  font-family: inherit;
}

.split-sync-menu li button:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.alpha-filter-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.alpha-filter-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  height: 44px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  border-left-width: 3px;
  text-align: left;
}

.alpha-filter-btn.all {
  border-left-color: #2563eb;
}
.alpha-filter-btn.backtested {
  border-left-color: #0d9488;
}
.alpha-filter-btn.qualified {
  border-left-color: #7c3aed;
}
.alpha-filter-btn.submittable {
  border-left-color: var(--warn);
}
.alpha-filter-btn.submitted {
  border-left-color: var(--avg);
}

.alpha-filter-btn:hover {
  background: var(--bg);
  box-shadow: var(--shadow-sm);
}

.alpha-filter-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  color: var(--accent-hover);
}

.hint-details {
  margin: 0 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.8125rem;
}

.hint-details summary {
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-secondary);
  list-style: none;
}

.hint-details summary::-webkit-details-marker {
  display: none;
}

.hint-details[open] summary {
  border-bottom: 1px solid var(--bg-subtle);
}

.hint-details .hint-body {
  padding: 12px 14px;
  color: var(--muted);
  line-height: 1.6;
}

.hint-details code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 4px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  max-height: min(70vh, 720px);
}

.brain-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.brain-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  padding: 11px 14px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.brain-table td {
  padding: 14px 14px;
  border-bottom: 1px solid var(--bg-subtle);
  vertical-align: top;
  font-variant-numeric: tabular-nums;
}

.brain-table tbody tr {
  transition: background 0.12s ease;
}

.brain-table tbody tr:hover {
  background: var(--accent-soft);
}

.brain-table tbody tr:nth-child(even) {
  background: var(--bg-even-row);
}

.brain-table tbody tr:nth-child(even):hover {
  background: var(--accent-soft);
}

.brain-table td.table-empty-hint {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: normal;
}

.alpha-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.alpha-pager .pager-meta {
  font-size: 0.8125rem;
  color: var(--muted);
}

.alpha-pager .pager-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}

.alpha-pager .btn.ghost {
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--border);
}

.alpha-pager .btn.ghost:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.alpha-pager button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#alpha-status-msg {
  margin-top: 10px;
  font-size: 0.8125rem;
  color: var(--muted);
}

.sync-progress {
  margin: 12px 0;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.sync-progress-track {
  height: 6px;
  background: var(--bg-subtle);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}

.sync-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 999px;
  transition: width 0.3s ease;
}

.sync-progress-text {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.brain-table tr.skeleton-row td {
  padding: 14px;
}

.skeleton-bar {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-subtle) 0%, #dfe4eb 50%, var(--bg-subtle) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.1s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.expr-cell {
  max-width: 440px;
  word-break: break-all;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-variant-numeric: normal;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge.good {
  background: #dcfce7;
  color: var(--good);
}

.badge.avg {
  background: #f1f5f9;
  color: var(--avg);
}

.badge.sub {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.filter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  transition: border-color 0.15s ease;
}

.filter-card:hover {
  border-color: var(--border-strong);
}

.filter-card h4 {
  margin: 0 0 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.filter-card .val {
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.pipeline-controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin: 16px 0;
}

.pipeline-controls .row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
}

.pipeline-controls label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.pipeline-controls select,
.pipeline-controls input[type="number"] {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 0.875rem;
}

.pipeline-controls select:focus,
.pipeline-controls input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.pipeline-auto-submit-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  cursor: pointer;
}

.input-mono {
  width: 100%;
  max-width: 720px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  resize: vertical;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-mono:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.pill {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.code-block {
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  overflow: auto;
  max-height: 420px;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  line-height: 1.55;
  border: 1px solid #1e293b;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  transition: border-color 0.15s ease;
}

.ai-card:hover {
  border-color: var(--border-strong);
}

.ai-card h4 {
  margin: 0 0 8px;
  font-size: 0.875rem;
  font-weight: 600;
}

.ai-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.8125rem;
}

.ai-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ai-chat-shell {
  margin: 16px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.ai-chat-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.ai-chat-head h3 {
  margin: 0 0 4px;
  font-size: 0.95rem;
}

.ai-chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 520px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.ai-chat-message {
  display: flex;
}

.ai-chat-message.user {
  justify-content: flex-end;
}

.ai-chat-message.user p {
  max-width: min(760px, 90%);
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  white-space: pre-wrap;
}

.ai-chat-message.assistant {
  justify-content: flex-start;
}

.ai-chat-message.pending {
  opacity: 0.72;
}

.ai-chat-card {
  width: min(900px, 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 12px 14px;
}

.ai-chat-card.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--danger);
}

.ai-chat-card + .ai-chat-card {
  margin-top: 10px;
}

.ai-chat-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}

.ai-chat-card h4 {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.ai-chat-card p {
  margin: 6px 0;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.55;
}

.ai-chat-expr-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.ai-chat-expr {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 10px 12px;
}

.ai-chat-expr code {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  word-break: break-all;
  color: var(--text-secondary);
}

.ai-chat-expr-actions,
.ai-chat-prompts,
.ai-chat-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-chat-expr-actions {
  margin-top: 8px;
}

.ai-chat-expr-actions .btn,
.ai-chat-prompts .btn {
  padding: 7px 10px;
  font-size: 0.75rem;
}

.ai-chat-expr-actions .btn.ghost,
.ai-chat-prompts .btn.ghost {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--border);
}

.ai-chat-expr-actions .btn.ghost:hover:not(:disabled),
.ai-chat-prompts .btn.ghost:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.ai-chat-prompts {
  margin: 12px 0 10px;
}

.ai-chat-form {
  align-items: stretch;
}

.ai-chat-form textarea {
  flex: 1 1 420px;
  min-height: 74px;
}

.ai-chat-form .btn {
  align-self: stretch;
}

.ai-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 12px;
  margin: 12px 0 16px;
}

.ai-llm-settings {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin: 12px 0 16px;
  padding: 14px 16px;
}

.ai-llm-settings-head {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.ai-llm-settings-head h3 {
  margin: 0 0 5px;
}

.ai-llm-settings-head p {
  margin: 0;
}

.ai-llm-channel-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ai-llm-channel-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: grid;
  gap: 10px;
  margin: 0;
  min-width: 0;
  padding: 12px;
}

.ai-llm-channel-card legend {
  align-items: center;
  color: var(--text);
  display: flex;
  font-size: 0.94rem;
  font-weight: 700;
  gap: 8px;
  padding: 0 4px;
  width: 100%;
}

.ai-llm-channel-status {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 500;
  margin-left: auto;
  padding: 3px 8px;
}

.ai-llm-channel-status.is-testing {
  color: var(--text-secondary);
}

.ai-llm-channel-status.is-ok {
  border-color: color-mix(in srgb, #0f766e 35%, var(--border));
  color: #0f766e;
}

.ai-llm-channel-status.is-error {
  border-color: color-mix(in srgb, #b42318 35%, var(--border));
  color: #b42318;
}

.ai-llm-channel-card label,
.ai-llm-common-grid label {
  color: var(--text-secondary);
  display: grid;
  font-size: 0.78rem;
  gap: 5px;
}

.ai-llm-channel-card input,
.ai-llm-channel-card select,
.ai-llm-common-grid input {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  min-width: 0;
  padding: 8px 9px;
}

.ai-llm-channel-card input:focus,
.ai-llm-channel-card select:focus,
.ai-llm-common-grid input:focus {
  border-color: var(--accent);
  outline: 2px solid color-mix(in srgb, var(--accent) 22%, transparent);
}

.ai-llm-channel-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 32px;
}

.ai-llm-channel-actions .btn {
  padding: 7px 10px;
}

.ai-llm-common-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(160px, 240px);
  margin-top: 10px;
}

@media (max-width: 760px) {
  .ai-llm-channel-grid {
    grid-template-columns: 1fr;
  }

  .ai-llm-common-grid {
    grid-template-columns: 1fr;
  }
}

.ai-guide-card,
.ai-diagnosis {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.ai-guide-head,
.ai-diagnosis-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.ai-guide-card h3,
.ai-diagnosis h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 700;
}

.ai-guide-steps {
  margin: 8px 0 12px;
  padding-left: 20px;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.65;
}

.ai-rule-table {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.ai-rule-table > div {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--bg);
}

.ai-rule-table strong,
.ai-rule-table span {
  display: block;
  font-size: 0.78rem;
}

.ai-rule-table span {
  margin-top: 4px;
  color: var(--muted);
}

.ai-seed-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-seed-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--bg);
}

.ai-seed-item code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  word-break: break-all;
}

.ai-diagnosis {
  margin-top: 14px;
  border-left: 4px solid var(--avg);
}

.ai-diagnosis.good {
  border-left-color: var(--good);
}

.ai-diagnosis.warn {
  border-left-color: var(--warn);
}

.ai-diagnosis.danger {
  border-left-color: var(--danger);
}

.ai-verdict-badge {
  display: inline-flex;
  margin-bottom: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ai-diagnosis-explain {
  margin: 8px 0 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.ai-diagnosis-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.ai-diagnosis-metric {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--bg);
}

.ai-diagnosis-metric em,
.ai-diagnosis-metric span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
}

.ai-diagnosis-metric strong {
  display: block;
  margin: 3px 0;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.ai-diagnosis-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.ai-diagnosis-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--bg);
}

.ai-diagnosis-section h4 {
  margin: 0 0 8px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.ai-diagnosis-section ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.ai-diagnosis-section code {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  word-break: break-all;
}

.ai-variants {
  margin-top: 14px;
}

.ai-library-hit,
.ai-variant-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.ai-library-hit {
  margin-bottom: 12px;
  border-left: 4px solid var(--accent);
}

.ai-library-hit h4,
.ai-variants-head h3,
.ai-variant-card h4 {
  margin: 0 0 8px;
  font-size: 0.9rem;
}

.ai-variants-head {
  margin: 0 0 10px;
}

.ai-variant-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.ai-variant-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.ai-variant-card code {
  display: block;
  margin: 8px 0 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  word-break: break-all;
}

.ai-variant-card p {
  margin: 6px 0;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.55;
}

.ai-variant-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

/* Pipeline round output */
.pipeline-output {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-top: 8px;
}

.pipeline-output-empty {
  margin: 0;
  font-size: 0.875rem;
}

.pipeline-output-running .pipeline-progress-track {
  background: var(--bg-subtle);
}

.pipeline-output-running.pipeline-progress-indeterminate .pipeline-progress-fill {
  width: 38% !important;
  animation: pipeline-indeterminate 1.4s ease-in-out infinite;
}

.pipeline-progress-detail {
  margin: -8px 0 14px;
}

.pipeline-funnel-placeholder .pipeline-funnel-step {
  opacity: 0.55;
}

@keyframes pipeline-indeterminate {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(320%);
  }
}

.pipeline-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}

.pipeline-progress-head h4 {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
}

.pipeline-progress-pct {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.pipeline-progress-track {
  height: 8px;
  background: var(--bg-subtle);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 16px;
}

.pipeline-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 999px;
  transition: width 0.45s ease;
  min-width: 0;
}

.pipeline-funnel {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 18px;
}

.pipeline-funnel-step {
  text-align: center;
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  min-width: 0;
}

.pipeline-funnel-step.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.pipeline-funnel-step.done {
  border-color: #86efac;
  background: #f0fdf4;
}

.pipeline-funnel-step.stalled {
  border-color: #fed7aa;
  background: #fff7ed;
}

.pipeline-funnel-step .step-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pipeline-funnel-step .step-val {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.pipeline-live-log {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #111827;
  overflow: hidden;
  margin-top: 14px;
}

.pipeline-live-log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.pipeline-live-log-head h4 {
  margin: 0;
  color: #e5e7eb;
  font-size: 0.8125rem;
  font-weight: 600;
}

.pipeline-live-log-count {
  color: #94a3b8;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pipeline-live-log-list {
  max-height: 220px;
  overflow: auto;
  padding: 8px 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.5;
}

.pipeline-live-log-row {
  display: grid;
  grid-template-columns: 72px minmax(70px, 0.6fr) 42px minmax(120px, 1.8fr) minmax(120px, 1.2fr);
  align-items: start;
  gap: 8px;
  padding: 4px 12px;
  color: #d1d5db;
}

.pipeline-live-log-row.warn {
  color: #fed7aa;
}

.pipeline-live-log-row.error {
  color: #fecaca;
}

.pipeline-live-log-row + .pipeline-live-log-row {
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.pipeline-live-log-time,
.pipeline-live-log-pct {
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pipeline-live-log-phase {
  color: #5eead4;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pipeline-live-log-msg,
.pipeline-live-log-data {
  min-width: 0;
  overflow-wrap: anywhere;
}

.pipeline-live-log-data {
  color: #a7f3d0;
  background: transparent;
  font-family: inherit;
  font-size: inherit;
}

.pipeline-live-log-empty {
  padding: 14px 12px;
  color: #94a3b8;
}

.pipeline-result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 16px;
  margin-bottom: 14px;
}

.pipeline-submit-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: var(--bg);
}

.pipeline-submit-box h4 {
  margin: 0 0 10px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.pipeline-submit-none {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.pipeline-submit-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pipeline-submit-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.8125rem;
}

.pipeline-submit-item .expr {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  word-break: break-all;
  margin-bottom: 6px;
}

.pipeline-submit-item .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.pipeline-expr-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.pipeline-expr-actions .btn,
.pipeline-variant-head .btn {
  padding: 7px 10px;
  font-size: 0.75rem;
}

.pipeline-submit-item .btn.ghost,
.pipeline-top-item .btn.ghost,
.pipeline-variant-result .btn.ghost {
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--border);
}

.pipeline-submit-item .btn.ghost:hover:not(:disabled),
.pipeline-top-item .btn.ghost:hover:not(:disabled),
.pipeline-variant-result .btn.ghost:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.pipeline-expr-feedback {
  margin-top: 10px;
}

.pipeline-expr-feedback-note {
  margin: 0;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--muted);
  font-size: 0.75rem;
}

.pipeline-live-result,
.pipeline-variant-result {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 12px;
}

.pipeline-live-result-head,
.pipeline-variant-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.pipeline-live-result-head h4,
.pipeline-variant-result h4 {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.pipeline-live-result-head span {
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
}

.pipeline-live-result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.pipeline-live-result-grid > div {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 8px 10px;
  min-width: 0;
}

.pipeline-live-result-grid em {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-style: normal;
}

.pipeline-live-result-grid strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.pipeline-live-result p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.pipeline-variant-result ol {
  margin: 0;
  padding-left: 18px;
}

.pipeline-variant-result li + li {
  margin-top: 12px;
}

.pipeline-variant-head strong {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.pipeline-variant-result code {
  display: block;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  word-break: break-all;
}

.pipeline-variant-result p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
}

.pipeline-top-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: var(--bg);
  margin-bottom: 14px;
}

.pipeline-top-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.pipeline-top-head h4 {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.pipeline-top-head span {
  color: var(--muted);
  font-size: 0.75rem;
}

.pipeline-top-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pipeline-top-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-width: 0;
}

.pipeline-top-rank {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.pipeline-top-body {
  min-width: 0;
}

.pipeline-top-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.pipeline-top-badge {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 0.6875rem;
  font-weight: 600;
}

.pipeline-top-badge.pass,
.pipeline-top-badge.keep {
  background: #dcfce7;
  border-color: #86efac;
  color: var(--good);
}

.pipeline-top-badge.drop {
  background: #f1f5f9;
  color: var(--muted);
}

.pipeline-top-item p {
  margin: 6px 0 0;
  color: var(--text-secondary);
  font-size: 0.75rem;
  line-height: 1.5;
}

.pipeline-diagnosis {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: var(--bg);
}

.pipeline-diagnosis h4 {
  margin: 0 0 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.pipeline-diagnosis-summary {
  margin: 0 0 10px;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--text);
}

.pipeline-reject-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0 12px;
}

.pipeline-reject-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 2fr) auto;
  gap: 10px;
  align-items: center;
  font-size: 0.8125rem;
}

.pipeline-reject-label {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pipeline-reject-track {
  height: 6px;
  background: var(--bg-subtle);
  border-radius: 999px;
  overflow: hidden;
}

.pipeline-reject-fill {
  height: 100%;
  background: #fb923c;
  border-radius: 999px;
}

.pipeline-reject-count {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 2.5em;
  text-align: right;
}

.pipeline-suggestions {
  margin: 0;
  padding-left: 18px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.pipeline-suggestions li + li {
  margin-top: 6px;
}

.pipeline-output-meta {
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--muted);
}

/* FASTEXPR annotated expression + hover dictionary */
.fastexpr-annotated-wrap {
  margin-top: 10px;
}

.fastexpr-annotated-wrap.compact {
  margin-top: 8px;
}

.fastexpr-annotated-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
  margin-bottom: 6px;
}

.fastexpr-annotated-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.fastexpr-annotated {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  min-height: 44px;
}

.fastexpr-annotated.has-expr {
  border-style: solid;
  background: var(--surface);
}

.fastexpr-annotated-empty {
  margin: 0;
}

.fastexpr-annotated-inner,
.fastexpr-annotated.compact-inline {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.65;
  word-break: break-all;
  color: var(--text-secondary);
}

.fastexpr-raw {
  color: var(--text-secondary);
}

.fastexpr-part {
  cursor: help;
  border-radius: 4px;
  padding: 0 1px;
  border-bottom: 1px dotted var(--accent);
  color: var(--accent-hover);
  transition: background 0.12s ease, color 0.12s ease;
}

.fastexpr-part:hover,
.fastexpr-part:focus {
  outline: none;
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.fastexpr-part.fastexpr-num {
  border-bottom-color: #d97706;
  color: #b45309;
}

.fastexpr-part.fastexpr-num:hover,
.fastexpr-part.fastexpr-num:focus {
  background: #fff7ed;
  color: #9a3412;
}

.fastexpr-part.fastexpr-part-llm {
  border-bottom-color: #7c3aed;
  color: #6d28d9;
}

.fastexpr-part.fastexpr-part-llm:hover,
.fastexpr-part.fastexpr-part-llm:focus {
  background: #f5f3ff;
  color: #5b21b6;
}

.fastexpr-part.fastexpr-part-db {
  border-bottom-color: #0284c7;
  color: #0369a1;
}

.fastexpr-part.fastexpr-part-db:hover,
.fastexpr-part.fastexpr-part-db:focus {
  background: #f0f9ff;
  color: #075985;
}

.fastexpr-part.fastexpr-part-pending {
  border-bottom-style: dashed;
  border-bottom-color: #a78bfa;
  color: #7c3aed;
  animation: fastexpr-pulse 1.2s ease-in-out infinite;
}

@keyframes fastexpr-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.65;
  }
}

.fastexpr-tooltip-source {
  font-size: 0.6875rem;
  color: #94a3b8;
  margin-bottom: 6px;
}

.fastexpr-tooltip {
  position: fixed;
  z-index: 1200;
  max-width: min(320px, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--top);
  color: #f1f5f9;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.fastexpr-tooltip-kind {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 2px;
}

.fastexpr-tooltip-name {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 6px;
}

.fastexpr-tooltip-hint {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: #cbd5e1;
}

.ai-score-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}

.ai-score-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  margin-bottom: 12px;
}

.ai-score-metric {
  font-size: 0.875rem;
}

.ai-score-metric em {
  font-style: normal;
  color: var(--muted);
  margin-right: 4px;
}

.ai-score-metric strong {
  font-variant-numeric: tabular-nums;
}

.ai-score-metric.pill.good {
  background: #dcfce7;
  color: var(--good);
  border-color: #86efac;
}

.ai-score-metric.pill.warn {
  background: #ffedd5;
  color: var(--warn);
  border-color: #fdba74;
}

.ai-score-reasons h4 {
  margin: 12px 0 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.ai-score-reasons ul {
  margin: 0;
  padding-left: 18px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.ai-score-disclaimer {
  margin: 12px 0 0;
}

.ai-score-raw {
  margin-top: 12px;
}

.code-block.small {
  max-height: 220px;
  font-size: 0.75rem;
}

@media (max-width: 900px) {
  .genius-head {
    align-items: flex-start;
  }

  .genius-priority {
    grid-template-columns: 34px minmax(0, 1fr);
    align-items: start;
  }

  .genius-metrics,
  .genius-osmosis-block {
    grid-column: 2;
    width: 100%;
  }

  .genius-priority-level .genius-metrics {
    grid-template-columns: repeat(4, minmax(100px, 1fr));
    overflow-x: auto;
  }

  .ai-workbench,
  .ai-llm-grid,
  .ai-diagnosis-grid {
    grid-template-columns: 1fr;
  }

  .ai-chat-head,
  .ai-chat-form {
    flex-direction: column;
  }

  .ai-chat-message.user p,
  .ai-chat-card {
    max-width: 100%;
    width: 100%;
  }

  .ai-rule-table,
  .ai-diagnosis-metrics {
    grid-template-columns: 1fr;
  }

  .ai-guide-head,
  .ai-diagnosis-head {
    flex-direction: column;
  }

  .pipeline-funnel {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .pipeline-result-grid {
    grid-template-columns: 1fr;
  }

  .pipeline-top-list {
    grid-template-columns: 1fr;
  }

  .pipeline-reject-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .pipeline-live-log-row {
    grid-template-columns: 62px 1fr 38px;
  }

  .pipeline-live-log-msg,
  .pipeline-live-log-data {
    grid-column: 1 / -1;
  }

  .alpha-summary-wrap {
    grid-template-columns: 1fr;
  }

  .alpha-filter-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split-sync {
    justify-self: start;
  }

  .container,
  .topbar-inner,
  .tab-bar-wrap {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (max-width: 620px) {
  .genius-head {
    flex-direction: column;
  }

  .genius-actions {
    justify-content: flex-start;
  }

  .genius-priority {
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 12px;
    padding: 15px 0;
  }

  .genius-metrics,
  .genius-priority-level .genius-metrics,
  .genius-osmosis-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: hidden;
  }

  .genius-metrics > div {
    min-height: 62px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .panel,
  .skeleton-bar,
  .btn,
  .alpha-filter-btn,
  .brain-table tbody tr,
  .pipeline-output-running.pipeline-progress-indeterminate .pipeline-progress-fill,
  .fastexpr-part.fastexpr-part-pending {
    animation: none;
    transition: none;
  }
}

.genius-priority, .filter-card, .ai-card, .hub-channel-card, .hub-overlap-card {
  transition: box-shadow 0.2s ease-in-out, transform 0.2s ease-in-out;
  animation: card-fade-in 0.5s ease-in-out;
}

.genius-priority:hover, .filter-card:hover, .ai-card:hover, .hub-channel-card:hover, .hub-overlap-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

@keyframes card-fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.genius-pyramid-distribution {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 14px);
  background: var(--surface);
}

.genius-pyramid-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.genius-pyramid-head h3 {
  margin: 0 0 4px;
}

.genius-pyramid-summary {
  margin-top: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.genius-pyramid-regions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.genius-pyramid-region {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
}

.genius-pyramid-towers {
  margin-top: 12px;
}

.genius-pyramid-matrix-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.genius-pyramid-matrix-meta strong {
  color: var(--text);
}

.genius-pyramid-matrix-scroll {
  margin-top: 10px;
  overflow-x: auto;
  border: 1px solid #dfe3e8;
  background: #f4f5f7;
}

.genius-pyramid-matrix {
  width: 100%;
  min-width: 720px;
  border-collapse: separate;
  border-spacing: 1px;
  table-layout: fixed;
  font-size: 12px;
}

.genius-pyramid-matrix th,
.genius-pyramid-matrix td {
  height: 34px;
  padding: 5px 8px;
  text-align: center;
  white-space: nowrap;
}

.genius-pyramid-matrix thead th {
  height: 30px;
  background: #151a21;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.genius-pyramid-matrix thead th:first-child {
  width: 150px;
  text-align: left;
}

.genius-pyramid-matrix tbody th {
  background: #edf0f3;
  color: #536171;
  font-size: 11px;
  font-weight: 500;
  text-align: left;
}

.genius-pyramid-matrix-total-row th,
.genius-pyramid-matrix .genius-pyramid-total-row th {
  background: #5c6b7d;
  color: #fff;
  font-weight: 700;
}

.genius-pyramid-total-cell {
  background: #e3e7eb;
  color: #5d6875;
  font-weight: 700;
}

.genius-pyramid-cell {
  background: #fff;
  color: #66717e;
  font-weight: 600;
  transition: filter 120ms ease, transform 120ms ease;
}

.genius-pyramid-cell span {
  display: inline-flex;
  min-width: 28px;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
}

.genius-pyramid-cell:hover {
  filter: saturate(1.15) brightness(.97);
  transform: translateY(-1px);
  outline: 2px solid #202831;
  outline-offset: -2px;
}

.genius-pyramid-cell.is-empty {
  background: #f0f1f3;
  color: #b6bdc6;
}

.genius-pyramid-cell.heat-1 span { background: #dcfce7; color: #3f684d; }
.genius-pyramid-cell.heat-2 span { background: #bbf7d0; color: #265a3a; }
.genius-pyramid-cell.heat-3 span { background: #86efac; color: #14532d; }
.genius-pyramid-cell.heat-4 span { background: #4ade80; color: #064e3b; }
.genius-pyramid-cell.heat-5 span { background: #00d916; color: #052e16; }

.genius-pyramid-cell.state-gap span {
  box-shadow: inset 0 -2px 0 #f59e0b;
}

.genius-pyramid-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}

.genius-pyramid-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.legend-swatch.heat-1 { background: #dcfce7; }
.legend-swatch.heat-3 { background: #86efac; }
.legend-swatch.heat-5 { background: #00d916; }

.genius-pyramid-tower-list {
  display: grid;
  gap: 6px;
  max-height: 320px;
  overflow: auto;
}

.genius-pyramid-tower {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  font-size: 12px;
}

.genius-pyramid-candidates {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

.genius-pyramid-candidate-summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.genius-pyramid-candidate-group {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-subtle);
}

.genius-pyramid-candidate-group header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.genius-pyramid-candidate-group ol {
  margin: 8px 0 0;
  padding-left: 24px;
}

.genius-pyramid-candidate-group li {
  margin: 6px 0;
  font-size: 12px;
}

.genius-pyramid-candidate-group details {
  display: inline-block;
  margin-left: 8px;
}

.genius-pyramid-candidate-group details summary {
  color: var(--accent);
  cursor: pointer;
}

.stage-panel-head,
.stage-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.stage-panel-head {
  margin-bottom: 16px;
}

.stage-panel-head h2,
.stage-card-head h3 {
  margin: 0;
}

.stage-eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.stage-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.stage-card {
  min-width: 0;
  padding: clamp(14px, 1.6vw, 18px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.stage-card-head {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.stage-card-head p {
  max-width: 760px;
  margin-bottom: 0;
}

.stage-status-card {
  position: relative;
}

.stage-current-task-row {
  /* The card is already first in the stage flow. Keep it at the top of the
     page without turning the whole status panel into a frozen overlay. */
  position: relative;
  margin-bottom: 12px;
  padding-top: 13px;
  padding-bottom: 13px;
}

.stage-current-task-row .stage-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 360px);
  align-items: center;
  gap: 14px;
  padding-bottom: 9px;
}

.stage-task-card {
  margin-top: 16px;
}

.stage-form {
  display: grid;
  gap: 11px;
  margin-top: 13px;
}

.stage-region-first {
  display: grid;
  grid-template-columns: minmax(160px, 0.45fr) minmax(0, 1.55fr);
  gap: 12px;
  align-items: stretch;
}

.stage-region-first > label,
.stage-mining-details {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.stage-flow-step-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 2px;
  color: var(--text-secondary);
}

.stage-flow-step-label > span {
  display: inline-grid;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 800;
}

.stage-flow-step-label div {
  display: grid;
  gap: 2px;
}

.stage-flow-step-label strong {
  color: var(--text);
  font-size: 0.82rem;
}

.stage-flow-step-label small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.45;
}

.stage-pyramid-summary {
  min-width: 0;
  color: var(--text-secondary);
}

.stage-pyramid-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.stage-pyramid-metrics span {
  min-width: 76px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.72rem;
}

.stage-pyramid-metrics b {
  display: block;
  color: var(--text);
  font-size: 0.95rem;
}

.stage-pyramid-summary details,
.stage-next-recommendation details {
  margin-top: 6px;
}

.stage-pyramid-summary ul,
.stage-next-recommendation ul {
  margin: 6px 0 0 18px;
  padding: 0;
}

.stage-confirm-row {
  display: flex !important;
  grid-template-columns: none;
  flex-direction: row;
  align-items: center;
  gap: 8px !important;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
}

.stage-confirm-row input {
  width: auto;
}

.stage-recommendation-progress {
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--bg-subtle), var(--bg));
}

.stage-recommendation-progress[data-state="complete"] {
  border-color: color-mix(in srgb, var(--good) 42%, var(--border));
}

.stage-recommendation-progress[data-state="empty"] {
  border-color: color-mix(in srgb, var(--warn) 42%, var(--border));
}

.stage-recommendation-progress[data-state="error"] {
  border-color: color-mix(in srgb, var(--danger) 42%, var(--border));
}

.stage-recommendation-progress-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 10px;
}

.stage-recommendation-progress-head strong {
  color: var(--text);
  font-size: 0.82rem;
}

.stage-recommendation-progress-head span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-recommendation-progress-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 10px;
  padding: 0;
  list-style: none;
}

.stage-recommendation-progress-steps li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 7px;
  align-items: center;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  opacity: 0.65;
  transition: border-color 160ms ease, background 160ms ease, opacity 160ms ease;
}

.stage-recommendation-progress-steps li span {
  grid-row: span 2;
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: var(--bg-subtle);
  font-size: 0.65rem;
  font-weight: 800;
}

.stage-recommendation-progress-steps li b,
.stage-recommendation-progress-steps li small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-recommendation-progress-steps li b {
  color: inherit;
  font-size: 0.72rem;
}

.stage-recommendation-progress-steps li small {
  font-size: 0.65rem;
}

.stage-recommendation-progress-steps li.is-active,
.stage-recommendation-progress-steps li.is-done {
  opacity: 1;
}

.stage-recommendation-progress-steps li.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.stage-recommendation-progress-steps li.is-done {
  border-color: color-mix(in srgb, var(--good) 38%, var(--border));
  color: var(--good);
}

.stage-recommendation-progress-track {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-subtle);
}

.stage-recommendation-progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  transition: width 220ms ease;
}

.stage-next-recommendation {
  margin-top: 14px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
}

.stage-next-recommendation p {
  margin: 0 0 6px;
}

.stage-next-recommendation p:last-of-type {
  margin-bottom: 10px;
}

.stage-form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.stage-form-grid label:nth-child(2) {
  grid-column: span 2;
}

.stage-form label {
  display: grid;
  gap: 5px;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
}

.stage-form label > .muted {
  font-weight: 400;
}

.stage-recommendation {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
}

.stage-recommendation[data-state="empty"] {
  border-color: color-mix(in srgb, var(--warn) 42%, var(--border));
  background: color-mix(in srgb, var(--warn) 5%, var(--bg-subtle));
}

.stage-recommendation[data-state="error"] {
  border-color: color-mix(in srgb, var(--danger) 42%, var(--border));
  background: color-mix(in srgb, var(--danger) 4%, var(--bg-subtle));
}

.stage-recommendation-state {
  display: grid;
  gap: 8px;
}

.stage-recommendation-state-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stage-state-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
}

.stage-state-tag.is-empty {
  background: color-mix(in srgb, var(--warn) 12%, var(--bg));
  color: var(--warn);
}

.stage-state-tag.is-error {
  background: color-mix(in srgb, var(--danger) 10%, var(--bg));
  color: var(--danger);
}

.stage-active-runs {
  padding-top: 5px;
}

.stage-subtitle {
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 700;
}

.stage-active-runs ul {
  display: grid;
  gap: 5px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.stage-active-runs li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 8px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.stage-active-runs li span,
.stage-active-runs li small {
  color: var(--muted);
  font-size: 0.68rem;
}

.stage-active-runs li small {
  grid-column: 1 / -1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
}

.stage-next-action {
  margin: 2px 0 0 !important;
  color: var(--text-secondary);
}

.stage-recommendation p {
  margin: 0 0 6px;
}

.stage-recommendation p:last-child {
  margin-bottom: 0;
}

.stage-recommendation ul {
  margin: 6px 0 0 18px;
  padding: 0;
}

.stage-recommendation code {
  color: var(--accent);
}

.stage-form input,
.stage-form select,
.stage-form textarea,
.stage-status-card select {
  width: 100%;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
}

.stage-form textarea {
  resize: vertical;
}

.stage-action-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.stage-action-row > #stage-form-msg {
  flex: 1 1 260px;
  min-width: 0;
}

.stage-generation-actions {
  justify-content: space-between;
}

.stage-action-buttons {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

/* Stage cards use the light dashboard surface, not the dark topbar palette
   used by the global ghost button. Keep these controls readable even while
   an IMA request temporarily disables the recommendation button. */
.stage-card .btn.ghost {
  background: var(--bg-elevated);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 38%, var(--border));
}

.stage-card .btn.ghost:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.stage-card .btn.ghost:disabled {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border-color: var(--border-strong);
  opacity: 0.82;
}

.stage-run-actions {
  margin-top: 14px;
}

.stage-run-summary {
  margin-top: 12px;
}

.stage-run-title,
.stage-run-metrics {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.stage-run-title strong {
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.stage-run-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 13px;
  gap: 8px;
}

.stage-run-metrics span {
  min-width: 82px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.75rem;
}

.stage-run-metrics b {
  display: block;
  color: var(--text);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.stage-progress-track {
  height: 8px;
  margin-top: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-subtle);
}

.stage-progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  transition: width 180ms ease;
}

.stage-message-ok { color: var(--good); }
.stage-message-warn { color: var(--warn); }
.stage-message-error { color: var(--danger); }

.stage-task-table {
  min-width: 980px;
  margin-top: 12px;
}

.stage-task-table .stage-expression-cell {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-task-table .stage-failure-cell {
  max-width: 260px;
  color: #c0392b;
  font-size: 0.74rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.stage-task-table code {
  font-size: 0.74rem;
}

@media (max-width: 700px) {
  .stage-recommendation-progress-head {
    grid-template-columns: 1fr auto;
  }

  .stage-recommendation-progress-head span:nth-child(2) {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .stage-recommendation-progress-steps {
    grid-template-columns: 1fr;
  }

  .stage-layout {
    grid-template-columns: 1fr;
  }

  .stage-current-task-row {
    position: relative;
  }

  .stage-current-task-row .stage-card-head {
    grid-template-columns: 1fr;
  }

  .stage-region-first {
    grid-template-columns: 1fr;
  }

  .stage-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stage-form-grid label:nth-child(2) {
    grid-column: span 2;
  }

  .stage-run-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stage-generation-actions {
    align-items: stretch;
  }

  .stage-generation-actions > #stage-form-msg,
  .stage-action-buttons {
    flex-basis: 100%;
  }

  .stage-action-buttons {
    justify-content: flex-end;
    margin-left: 0;
  }

  .genius-pyramid-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .genius-pyramid-head,
  .genius-pyramid-tower,
  .genius-pyramid-candidate-group header,
  .genius-pyramid-candidate-summary {
    display: block;
  }

  .genius-pyramid-matrix-meta {
    flex-wrap: wrap;
  }
}

@media (min-width: 701px) and (max-width: 980px) {
  .stage-layout {
    grid-template-columns: 1fr;
  }

  .stage-current-task-row {
    position: relative;
  }
}
/* 2026-08-09 Pyramid matrix and loading-state polish */
.genius-pyramid-distribution {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 100% 0%, rgba(21, 128, 61, 0.06), transparent 34%),
    var(--surface);
  box-shadow: 0 12px 28px rgba(29, 43, 58, 0.06);
}

.genius-pyramid-head {
  align-items: center;
  padding-bottom: 2px;
}

.genius-pyramid-head h3 {
  letter-spacing: -0.02em;
}

.genius-pyramid-summary {
  overflow: hidden;
  border: 1px solid #d8e0e8;
  border-radius: 12px;
  background: #f7f9fb;
  box-shadow: 0 4px 14px rgba(29, 43, 58, 0.04);
}

.genius-pyramid-summary > div {
  min-height: 70px;
  padding: 12px 14px;
  border-right: 1px solid #d8e0e8;
}

.genius-pyramid-summary > div:last-child {
  border-right: 0;
}

.genius-pyramid-summary dd {
  color: #142334;
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}

.genius-pyramid-matrix-meta {
  min-height: 28px;
  margin-top: 14px;
  padding: 0 2px;
  color: #667589;
}

.genius-pyramid-matrix-meta strong {
  color: #1d344c;
}

.genius-pyramid-matrix-scroll {
  margin-top: 10px;
  padding: 7px;
  border: 1px solid #dbe4ec;
  border-radius: 12px;
  background: #eaf0f5;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  scrollbar-color: #9eabb9 #eaf0f5;
}

.genius-pyramid-matrix {
  min-width: 820px;
  border-spacing: 2px;
  font-size: 0.75rem;
}

.genius-pyramid-matrix th,
.genius-pyramid-matrix td {
  height: 38px;
  padding: 5px 7px;
  border: 0;
}

.genius-pyramid-matrix thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  height: 34px;
  background: #172535;
  color: #f7fbff;
  font-size: 0.69rem;
  letter-spacing: 0.07em;
  box-shadow: 0 2px 0 rgba(11, 20, 31, 0.24);
}

.genius-pyramid-matrix thead th:first-child {
  left: 0;
  z-index: 5;
  width: 150px;
  border-radius: 7px 0 0 7px;
}

.genius-pyramid-matrix thead th:last-child {
  border-radius: 0 7px 7px 0;
}

.genius-pyramid-matrix tbody tr:not(.genius-pyramid-total-row):nth-child(even) th {
  background: #f2f6f9;
}

.genius-pyramid-matrix tbody th {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #e5ebf1;
  color: #40556b;
  font-size: 0.71rem;
  font-weight: 700;
  box-shadow: 4px 0 8px rgba(27, 43, 59, 0.08);
}

.genius-pyramid-matrix .genius-pyramid-total-row th {
  background: #51677e;
  color: #fff;
  letter-spacing: 0.01em;
}

.genius-pyramid-total-row td {
  background: #d8e1e9;
  color: #243b53;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.genius-pyramid-cell {
  position: relative;
  background: rgba(255, 255, 255, 0.82);
  color: #536579;
  font-variant-numeric: tabular-nums;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.genius-pyramid-cell span,
.genius-pyramid-total-cell span {
  display: inline-flex;
  min-width: 34px;
  min-height: 27px;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
}

.genius-pyramid-cell.is-zero span {
  border: 1px solid #e2e8ef;
  background: #fff;
  color: #7a8897;
  box-shadow: none;
}

.genius-pyramid-cell.is-empty {
  background: repeating-linear-gradient(135deg, #e4e9ee 0, #e4e9ee 8px, #edf1f4 8px, #edf1f4 16px);
  color: #aab5c0;
}

.genius-pyramid-cell.is-empty span {
  min-width: 27px;
  background: rgba(255, 255, 255, 0.42);
}

.genius-pyramid-cell:hover {
  z-index: 1;
  filter: none;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(33, 51, 70, 0.16);
  outline: 2px solid #38536d;
  outline-offset: -2px;
}

.genius-pyramid-cell.heat-1 span { background: #e7f8ee; color: #34704e; }
.genius-pyramid-cell.heat-2 span { background: #c9f0d7; color: #24613d; }
.genius-pyramid-cell.heat-3 span { background: #9de4b4; color: #155b35; }
.genius-pyramid-cell.heat-4 span { background: #5bd486; color: #084c2b; }
.genius-pyramid-cell.heat-5 span { background: #16b963; color: #fff; }

.genius-pyramid-cell.state-gap span {
  box-shadow: inset 0 -3px 0 #f59e0b;
}

.genius-pyramid-cell.state-lit span {
  box-shadow: inset 0 0 0 1px rgba(21, 128, 61, 0.2);
}

.genius-pyramid-legend {
  gap: 12px 18px;
  margin: 11px 2px 2px;
  color: #6c7d90;
}

.genius-pyramid-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.genius-pyramid-legend span:last-child {
  color: #8795a5;
}

.hub-data-warning {
  padding: 12px 14px;
  border: 1px solid #f2d29a;
  border-radius: 10px;
  background: #fffaf0;
}

.hub-data-warning p {
  margin: 0 0 8px;
}

.hub-data-warning p:last-child {
  margin-bottom: 0;
}

@media (max-width: 700px) {
  .genius-pyramid-summary > div {
    min-height: 62px;
    padding: 10px;
  }

  .genius-pyramid-summary dd {
    font-size: 1.05rem;
  }

  .genius-pyramid-matrix-scroll {
    margin-right: -4px;
    margin-left: -4px;
    border-radius: 10px;
  }
}
