/* Que UI — Font Imports */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* Que UI — Design System Variables */
:root {
  /* Brand */
  --brand-green: #00c97b;
  --brand-green-dark: #0a8a55;

  /* Background Tiers */
  --bg-base: #0A0A0A;
  --bg-surface: #111111;
  --bg-elevated: #1A1A1A;
  --bg-overlay: #222222;

  /* Borders & Dividers */
  --border-subtle: #1E1E1E;
  --border-default: #2A2A2A;
  --border-strong: #333333;

  /* Text Hierarchy */
  --text-primary: #EDEDED;
  --text-secondary: #A0A0A0;
  --text-tertiary: #666666;
  --text-disabled: #444444;

  /* Accent (derived from brand green #00c97b) */
  --accent: #00c97b;
  --accent-hover: #00b06c;
  --accent-muted: rgba(0, 201, 123, 0.15);
  --accent-border: rgba(0, 201, 123, 0.25);

  /* Semantic Colors */
  --success: #00c97b;
  --warning: #F5A623;
  --error: #E5484D;
  --info: #3B82F6;

  /* Typography */
  --font-brand: 'Space Grotesk', sans-serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;

  /* Spacing & Interaction */
  --radius-card: 8px;
  --radius-button: 6px;
  --radius-badge: 4px;
  --transition: 150ms ease;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 20px;
  color: var(--text-primary);
  background: var(--bg-base);
  color-scheme: dark;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Layout */
#app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--bg-base);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
}

.logo {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-default);
  height: 61px;
}

.logo-icon {
  width: 18px;
  height: 30px;
  color: var(--brand-green);
  flex-shrink: 0;
}

.logo-text {
  font-family: var(--font-brand);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.5px;
  color: var(--brand-green);
}

.logo-tld {
  font-family: var(--font-brand);
  font-weight: 400;
  font-size: 18px;
  color: var(--text-tertiary);
  letter-spacing: -0.5px;
}

.nav-links {
  list-style: none;
  padding: 12px;
}

.nav-links a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-button);
  transition: var(--transition);
  font-size: 13px;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Icon inside buttons (inline left) */
.btn-icon-left {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nav-links a:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.nav-links a.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 500;
}

.content {
  flex: 1;
  margin-left: 240px;
  display: flex;
  flex-direction: column;
}

.header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-base);
  height: 61px;
}

.header h1 {
  font-size: 20px;
  font-weight: 600;
  line-height: 28px;
  color: var(--text-primary);
}

#page-content {
  padding: 24px;
  flex: 1;
}

/* Page visibility */
.page {
  display: block;
}

.hidden {
  display: none !important;
}

.page.hidden {
  display: none;
}

/* Banner */
.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius-card);
  margin-bottom: 16px;
  font-size: 13px;
}

.banner-warning {
  background: rgba(245, 166, 35, 0.1);
  border: 1px solid rgba(245, 166, 35, 0.3);
  color: var(--warning);
}

.banner-link {
  color: var(--warning);
  text-decoration: underline;
  font-weight: 500;
  white-space: nowrap;
  margin-left: 16px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 16px 20px;
}

.stat-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--accent);
  font-family: var(--font-mono);
  line-height: 1;
}

.stat-label {
  color: var(--text-secondary);
  margin-top: 8px;
  font-size: 13px;
}

/* Sections */
.section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 20px 24px;
  margin-bottom: 24px;
}

.section h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-default);
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  max-height: 70vh;
  overflow-y: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.table-wrapper .table {
  border: none;
  border-radius: 0;
}

.table th,
.table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.table th {
  font-weight: 500;
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 2;
}

.table th::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--border-subtle);
}

/* Sortable columns */
.table th[data-sort] {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 28px;
  transition: color var(--transition);
}

.table th[data-sort]:hover {
  color: var(--text-secondary);
}

.table th[data-sort] .sort-indicator {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  font-size: 8px;
  line-height: 1;
  color: var(--text-disabled);
  transition: color var(--transition);
}

.table th[data-sort].sort-asc .sort-indicator .sort-asc-icon,
.table th[data-sort].sort-desc .sort-indicator .sort-desc-icon {
  color: var(--accent);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover td {
  background: var(--bg-elevated);
  transition: background-color 150ms ease;
}

.mono,
.table td.mono {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
}

/* Truncated text with tooltip */
.table td.truncate {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  position: relative;
}

.table td.truncate[data-full]:hover::after {
  content: attr(data-full);
  position: absolute;
  left: 8px;
  top: calc(100% + 2px);
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-badge);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-primary);
  white-space: normal;
  max-width: 320px;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-badge);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid;
}

.status-pending {
  background: rgba(245, 166, 35, 0.15);
  color: var(--warning);
  border-color: rgba(245, 166, 35, 0.25);
}

.status-running {
  background: rgba(59, 130, 246, 0.15);
  color: var(--info);
  border-color: rgba(59, 130, 246, 0.25);
}

.status-completed {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: var(--accent-border);
}

.status-failed {
  background: rgba(229, 72, 77, 0.15);
  color: var(--error);
  border-color: rgba(229, 72, 77, 0.25);
}

.status-cancelled {
  background: rgba(102, 102, 102, 0.15);
  color: var(--text-tertiary);
  border-color: rgba(102, 102, 102, 0.25);
}

.status-connected {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: var(--accent-border);
}

.status-disconnected {
  background: rgba(229, 72, 77, 0.15);
  color: var(--error);
  border-color: rgba(229, 72, 77, 0.25);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-button);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary);
  transition: var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #000000;
  border: none;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-default);
}

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

.btn-danger {
  background: rgba(229, 72, 77, 0.15);
  color: var(--error);
  border: 1px solid rgba(229, 72, 77, 0.25);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(229, 72, 77, 0.25);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
}

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

.btn-sm {
  padding: 4px 8px;
  font-size: 12px;
}

.btn-icon {
  padding: 6px;
  min-width: 32px;
  justify-content: center;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

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

.input,
.select,
.textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-button);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  transition: var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

/* Prevent browser autofill from overriding dark theme */
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus,
.input:-webkit-autofill:active,
.textarea:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 9999px #0A0A0A inset !important;
  -webkit-text-fill-color: #EDEDED !important;
  border-color: var(--border-default) !important;
  background-color: #0A0A0A !important;
  background-clip: content-box !important;
  transition: background-color 5000s ease-in-out 0s;
  caret-color: #EDEDED;
}

.input::placeholder {
  color: var(--text-tertiary);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent-border);
  box-shadow: 0 0 0 1px var(--accent-border);
}

.textarea {
  resize: vertical;
  min-height: 100px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.input-group .input {
  flex: 1;
}

/* Page Actions */
.page-actions {
  margin-bottom: 16px;
  display: flex;
  gap: 8px;
}

.page-filters {
  margin-bottom: 16px;
  display: flex;
  gap: 8px;
}

.page-filters .select {
  width: auto;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease, visibility 200ms ease;
}

.modal.visible {
  opacity: 1;
  visibility: visible;
}

.modal.closing {
  opacity: 0;
  transition: opacity 150ms ease, visibility 150ms ease;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  transform: translateY(8px) scale(0.98);
  transition: transform 200ms ease;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.modal.visible .modal-content {
  transform: translateY(0) scale(1);
}

.modal.closing .modal-content {
  transform: translateY(4px) scale(0.99);
  transition: transform 150ms ease;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  line-height: 0;
  border-radius: var(--radius-badge);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close svg {
  width: 18px;
  height: 18px;
}

.modal-close:hover {
  color: var(--text-primary);
}

#modal-body {
  padding: 24px;
}

/* Text utilities */
.text-muted {
  color: var(--text-tertiary);
}

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

/* Code blocks */
pre {
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-button);
  padding: 12px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 18px;
}

/* Empty states (base — overridden below with full component styles) */

/* Action buttons in tables */
.actions {
  display: flex;
  gap: 4px;
}

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 24px;
  transition: var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 2px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: var(--transition);
}

.toggle input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: #000;
}

/* Run Detail Page */
.run-detail {
  max-width: 900px;
}

.run-header {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.run-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.run-id {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
}

.run-times {
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
}

/* Conversation Thread */
.conversation {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  border-radius: var(--radius-card);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.message-header {
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

.message-role {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.message-time {
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.message-content {
  padding: 16px;
  font-size: 13px;
  line-height: 18px;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: var(--font-mono);
  max-height: 500px;
  overflow-y: auto;
}

.message-user {
  background: var(--bg-surface);
}

.message-user .message-header {
  background: var(--bg-elevated);
  color: var(--info);
}

.message-user .message-content {
  background: var(--bg-surface);
}

.message-assistant {
  background: var(--bg-surface);
}

.message-assistant .message-header {
  background: var(--accent-muted);
  color: var(--accent);
}

.message-assistant .message-content {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.message-error {
  background: var(--bg-surface);
}

.message-error .message-header {
  background: rgba(229, 72, 77, 0.15);
  color: var(--error);
}

.message-error .message-content {
  background: var(--bg-surface);
  color: var(--error);
}

.message-pending {
  background: var(--bg-surface);
  border-style: dashed;
}

.message-pending .message-header {
  background: rgba(245, 166, 35, 0.15);
  color: var(--warning);
}

.message-pending .message-content {
  color: var(--text-tertiary);
  font-style: italic;
}

/* Clickable table rows */
.table tr.clickable {
  cursor: pointer;
}

.table tr.clickable:hover td {
  background: var(--bg-elevated);
}

/* Content Max Width */
#page-content {
  max-width: 1200px;
  margin: 0 auto;
}

/* Empty states — full component */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-tertiary);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.empty-state-icon {
  width: 24px;
  height: 24px;
  margin-bottom: 12px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state-icon svg {
  width: 24px;
  height: 24px;
}

.empty-state h3 {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
  line-height: 20px;
}

.empty-state p {
  font-size: 13px;
  color: var(--text-tertiary);
  margin: 0;
  line-height: 18px;
  max-width: 320px;
}

.empty-state .btn {
  margin-top: 16px;
}

/* Empty state inside table cells */
.table td.empty-state {
  padding: 48px 24px;
}

/* Empty state inside table row — prevent hover effect */
.table tr:has(> td.empty-state):hover td {
  background: transparent;
}

/* Specular Highlight — subtle light catching on card edges */
.stat-card::before,
.section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.04),
    transparent
  );
  pointer-events: none;
}

.stat-card,
.section {
  position: relative;
}

/* Smooth scrollbar styling for dark mode */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--text-tertiary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-sm {
  width: 12px;
  height: 12px;
  border-width: 1.5px;
}

.spinner-lg {
  width: 24px;
  height: 24px;
  border-width: 2.5px;
}

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

/* Stat card loading state */
.stat-card.loading .stat-value {
  display: flex;
  align-items: center;
  min-height: 32px;
}

/* Table loading row */
.table-loading-row td {
  text-align: center;
  padding: 24px 16px;
}

.table-loading-row:hover td {
  background: transparent !important;
}

.loading-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-tertiary);
}

/* Button loading state */
.btn.btn-loading {
  pointer-events: none;
  opacity: 0.7;
  position: relative;
}

.btn.btn-loading .spinner {
  border-color: currentColor;
  border-top-color: transparent;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-primary);
  min-width: 280px;
  max-width: 420px;
  pointer-events: auto;
  border-left: 3px solid var(--border-default);
  animation: toast-in 200ms ease forwards;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.toast.toast-out {
  animation: toast-out 200ms ease forwards;
}

.toast-success {
  border-left-color: var(--success);
}

.toast-error {
  border-left-color: var(--error);
}

.toast-info {
  border-left-color: var(--info);
}

.toast-warning {
  border-left-color: var(--warning);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

/* Run Timeline — Resend-style event flow */
.run-timeline {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 24px 28px;
  margin-bottom: 20px;
  position: relative;
}

.timeline-steps {
  display: flex;
  align-items: flex-start;
  position: relative;
}

.timeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
  z-index: 1;
}

/* Connecting lines between nodes */
.timeline-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 15px;
  left: calc(50% + 18px);
  width: calc(100% - 36px);
  height: 2px;
  background: none;
  border-bottom: 2px dotted var(--border-strong);
}

.timeline-step.step-reached:not(:last-child)::after {
  border-bottom-style: solid;
}

.timeline-step.step-reached.step-queued:not(:last-child)::after {
  border-bottom-color: var(--warning);
}

.timeline-step.step-reached.step-running:not(:last-child)::after {
  border-bottom-color: var(--info);
}

.timeline-step.step-reached.step-completed:not(:last-child)::after {
  border-bottom-color: var(--success);
}

.timeline-step.step-reached.step-failed:not(:last-child)::after {
  border-bottom-color: var(--error);
}

/* Node circle */
.timeline-node {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  border: 2px solid var(--border-default);
  background: var(--bg-base);
  color: var(--text-disabled);
  transition: all 200ms ease;
  flex-shrink: 0;
}

.timeline-node svg {
  width: 16px;
  height: 16px;
}

.timeline-step.step-reached .timeline-node {
  border-color: transparent;
}

.timeline-step.step-reached.step-queued .timeline-node {
  background: rgba(245, 166, 35, 0.15);
  color: var(--warning);
  border-color: rgba(245, 166, 35, 0.35);
}

.timeline-step.step-reached.step-running .timeline-node {
  background: rgba(59, 130, 246, 0.15);
  color: var(--info);
  border-color: rgba(59, 130, 246, 0.35);
}

.timeline-step.step-reached.step-completed .timeline-node {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: var(--accent-border);
}

.timeline-step.step-reached.step-failed .timeline-node {
  background: rgba(229, 72, 77, 0.15);
  color: var(--error);
  border-color: rgba(229, 72, 77, 0.25);
}

/* Active node pulse animation */
.timeline-step.step-active .timeline-node {
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
  animation: timeline-pulse 2s ease-in-out infinite;
}

@keyframes timeline-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1); }
  50% { box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.05); }
}

/* Step label */
.timeline-label {
  margin-top: 10px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-disabled);
  text-align: center;
}

.timeline-step.step-reached .timeline-label {
  color: var(--text-secondary);
}

.timeline-step.step-active .timeline-label {
  color: var(--text-primary);
}

/* Step timestamp */
.timeline-time {
  margin-top: 4px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  text-align: center;
  min-height: 16px;
}

/* Search Group */
.search-group {
  position: relative;
  flex: 1;
  max-width: 320px;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-input {
  padding-left: 32px;
}

/* Skills Card Grid */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.skill-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 20px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.skill-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}

.skill-card-header {
  margin-bottom: 8px;
}

.skill-card-name {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 20px;
}

.skill-card-slug {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.skill-card-description {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 18px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.skill-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.skill-card-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.skill-card-actions {
  display: flex;
  gap: 4px;
}

/* Slug preview in form */
.slug-preview {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.slug-preview code {
  color: var(--accent);
  background: var(--accent-muted);
  padding: 1px 6px;
  border-radius: var(--radius-badge);
}

/* Token count */
.token-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
  text-align: right;
}

/* Skills empty state */
.skills-grid .empty-state {
  grid-column: 1 / -1;
}

/* Skill Picker — Prompt Template Integration */
.prompt-template-group {
  position: relative;
}

.prompt-template-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.prompt-template-toolbar label {
  margin-bottom: 0;
}

.skill-picker-wrapper {
  position: relative;
  display: inline-block;
}

.skill-picker-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 320px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: none;
}

.skill-picker-dropdown.visible {
  display: block;
}

.skill-picker-search {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  background: var(--bg-overlay);
  z-index: 1;
}

.skill-picker-search input {
  width: 100%;
  padding: 6px 10px;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-button);
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
}

.skill-picker-search input:focus {
  outline: none;
  border-color: var(--accent-border);
}

.skill-picker-search input::placeholder {
  color: var(--text-tertiary);
}

.skill-picker-list {
  list-style: none;
  padding: 4px;
}

.skill-picker-item {
  padding: 8px 10px;
  cursor: pointer;
  border-radius: var(--radius-button);
  transition: background var(--transition);
}

.skill-picker-item:hover,
.skill-picker-item.highlighted {
  background: var(--bg-elevated);
}

.skill-picker-item-name {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}

.skill-picker-item-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-picker-empty {
  padding: 16px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* Inline autocomplete dropdown (appears under textarea) */
.skill-autocomplete {
  position: absolute;
  width: 280px;
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: none;
}

.skill-autocomplete.visible {
  display: block;
}

.skill-autocomplete-list {
  list-style: none;
  padding: 4px;
}

.skill-autocomplete-item {
  padding: 6px 10px;
  cursor: pointer;
  border-radius: var(--radius-button);
  transition: background var(--transition);
}

.skill-autocomplete-item:hover,
.skill-autocomplete-item.highlighted {
  background: var(--bg-elevated);
}

.skill-autocomplete-item-name {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
}

.skill-autocomplete-item-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Referenced skills tags */
.skill-refs-display {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.skill-ref-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--accent-muted);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-badge);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
}

.skill-ref-tag.skill-ref-warning {
  background: rgba(245, 166, 35, 0.15);
  border-color: rgba(245, 166, 35, 0.25);
  color: var(--warning);
}

.skill-ref-tag svg {
  width: 12px;
  height: 12px;
}

.skill-reference {
  display: inline-block;
  padding: 2px 6px;
  background: var(--accent-muted);
  border: 1px solid var(--accent-border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  transition: all 150ms ease;
}

.skill-reference:hover {
  background: var(--accent-border);
  border-color: var(--accent);
  color: var(--text-primary);
}

/* Skill Edit Page */
.skill-edit-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.skill-edit-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.skill-edit-header {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 20px 24px;
}

.skill-edit-header-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 16px;
}

.skill-name-group {
  margin: 0;
  min-width: 0;
}

.skill-slug-display {
  flex-shrink: 0;
  min-width: 280px;
}

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

.skill-slug {
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-muted);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--accent-border);
  display: block;
  font-family: var(--font-mono);
}

.skill-edit-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.skill-editor-container {
  flex: 1;
  display: flex;
  gap: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
  min-height: 600px;
}

.skill-editor-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.skill-editor-pane {
  display: flex;
  min-width: 0;
  border-right: 1px solid var(--border-subtle);
}

.skill-editor-textarea {
  width: 100%;
  height: 100%;
  padding: 16px;
  background: var(--bg-base);
  color: var(--text-primary);
  border: none;
  resize: none;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 20px;
  outline: none;
  tab-size: 2;
}

.skill-editor-textarea::placeholder {
  color: var(--text-tertiary);
}

.skill-preview-pane {
  overflow-y: auto;
  min-width: 0;
}

.skill-preview-content {
  padding: 20px;
  font-size: 14px;
  line-height: 22px;
  color: var(--text-primary);
}

/* Markdown preview styles */
.skill-preview-content h1 {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 16px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-default);
}

.skill-preview-content h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 24px 0 12px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.skill-preview-content h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 20px 0 8px 0;
}

.skill-preview-content h4 {
  font-size: 14px;
  font-weight: 600;
  margin: 16px 0 8px 0;
}

.skill-preview-content p {
  margin: 0 0 12px 0;
}

.skill-preview-content ul,
.skill-preview-content ol {
  margin: 0 0 12px 0;
  padding-left: 24px;
}

.skill-preview-content li {
  margin-bottom: 4px;
}

.skill-preview-content code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: var(--radius-badge);
  color: var(--accent);
}

.skill-preview-content pre {
  margin: 0 0 12px 0;
}

.skill-preview-content pre code {
  background: none;
  padding: 0;
  color: var(--text-primary);
}

.skill-preview-content blockquote {
  border-left: 3px solid var(--accent-border);
  margin: 0 0 12px 0;
  padding: 8px 16px;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border-radius: 0 var(--radius-badge) var(--radius-badge) 0;
}

.skill-preview-content hr {
  border: none;
  border-top: 1px solid var(--border-default);
  margin: 20px 0;
}

.skill-preview-content strong {
  font-weight: 600;
  color: var(--text-primary);
}

.skill-preview-content em {
  font-style: italic;
}

.skill-preview-content a {
  color: var(--accent);
  text-decoration: none;
}

.skill-preview-content a:hover {
  text-decoration: underline;
}

/* Skill Editor Header */
.skill-editor-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  margin-bottom: 16px;
}

.skill-editor-meta {
  display: flex;
  align-items: center;
  gap: 16px;
}

.skill-meta-item {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.skill-meta-item .mono {
  color: var(--text-primary);
}

#skill-ai-edit-toggle.active {
  background: var(--accent-muted);
  border-color: var(--accent-border);
  color: var(--accent);
}

/* AI Edit Panel */
.skill-ai-edit-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  padding: 12px;
  margin-bottom: 8px;
}

.ai-edit-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.ai-edit-instruction {
  flex: 1;
  font-size: 13px;
  min-height: 40px;
  resize: vertical;
}

.ai-edit-status {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.ai-edit-result {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ai-edit-result-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
}

/* Skill Creation Options */
.skill-creation-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  cursor: pointer;
  transition: all 150ms ease;
  text-align: left;
  width: 100%;
}

.option-card:hover {
  background: var(--bg-overlay);
  border-color: var(--border-default);
}

.option-card:active {
  transform: scale(0.99);
}

.option-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-muted);
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  color: var(--accent);
}

.option-icon svg,
.option-icon i {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.option-content {
  flex: 1;
  padding-top: 2px;
}

.option-content h4 {
  margin: 0 0 2px 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}

.option-content p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Validation Badges */
.validation-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-badge);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border: 1px solid;
  white-space: nowrap;
  flex-shrink: 0;
}

.validation-badge i,
.validation-badge svg {
  width: 12px;
  height: 12px;
}

.validation-badge-valid {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: var(--accent-border);
}

.validation-badge-invalid {
  background: rgba(229, 72, 77, 0.15);
  color: var(--error);
  border-color: rgba(229, 72, 77, 0.25);
}

.validation-badge-error {
  background: rgba(245, 166, 35, 0.15);
  color: var(--warning);
  border-color: rgba(245, 166, 35, 0.25);
}

.validation-badge-pending {
  background: rgba(102, 102, 102, 0.15);
  color: var(--text-tertiary);
  border-color: rgba(102, 102, 102, 0.25);
}

/* Skill Card Title Row (name + badge) */
.skill-card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Validation Panel (Skill Editor) */
.validation-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 12px 16px;
  margin-bottom: 8px;
}

.validation-panel:empty {
  display: none;
}

.validation-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.validation-panel-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.validation-panel-time {
  font-size: 11px;
  color: var(--text-tertiary);
}

.validation-panel-message {
  margin-top: 8px;
  font-size: 13px;
  line-height: 18px;
  padding: 8px 12px;
  border-radius: var(--radius-button);
  border-left: 3px solid;
}

.validation-panel-valid {
  background: rgba(0, 201, 123, 0.06);
  border-left-color: var(--success);
  color: var(--accent);
}

.validation-panel-pending {
  background: rgba(102, 102, 102, 0.06);
  border-left-color: var(--text-tertiary);
  color: var(--text-secondary);
}

.validation-panel-error {
  background: rgba(245, 166, 35, 0.06);
  border-left-color: var(--warning);
  color: var(--warning);
}

.validation-panel-invalid {
  background: rgba(229, 72, 77, 0.06);
  border-left-color: var(--error);
  color: var(--error);
}

/* Validation Details (expanded issues) */
.validation-panel-details {
  margin-top: 10px;
}

.validation-panel-summary {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.validation-issue {
  padding: 8px 12px;
  margin-bottom: 4px;
  border-radius: var(--radius-button);
  border-left: 3px solid;
  background: var(--bg-elevated);
}

.validation-issue:last-child {
  margin-bottom: 0;
}

.validation-issue-error {
  border-left-color: var(--error);
}

.validation-issue-warning {
  border-left-color: var(--warning);
}

.validation-issue-info {
  border-left-color: var(--info);
}

.validation-issue-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.validation-issue-severity {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.validation-issue-error .validation-issue-severity {
  color: var(--error);
}

.validation-issue-warning .validation-issue-severity {
  color: var(--warning);
}

.validation-issue-info .validation-issue-severity {
  color: var(--info);
}

.validation-issue-location {
  font-size: 11px;
  color: var(--text-tertiary);
}

.validation-issue-code {
  font-size: 10px;
  color: var(--text-disabled);
  margin-left: auto;
}

.validation-issue-message {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 18px;
}

.validation-issue-suggestion {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
}

.validation-ai-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(59, 130, 246, 0.06);
  border-radius: var(--radius-button);
  border: 1px solid rgba(59, 130, 246, 0.15);
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    width: 60px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .skill-edit-header-row {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .skill-slug-display {
    min-width: 0;
  }

  .skill-editor-meta {
    flex-wrap: wrap;
  }

  .logo-text,
  .logo-tld,
  .nav-links span {
    display: none;
  }

  .content {
    margin-left: 60px;
  }

  .skill-picker-dropdown {
    width: 260px;
  }

  .skill-edit-layout {
    grid-template-columns: 1fr;
  }
}

/* ──────────────────────────────────────
   Auth Page
   ────────────────────────────────────── */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-base);
  padding: 24px;
}

.auth-container {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  padding: 40px 32px;
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo-icon {
  width: 36px;
  height: 56px;
  color: var(--brand-green);
  margin-bottom: 16px;
}

.auth-brand {
  margin-bottom: 8px;
}

.auth-logo-text {
  font-family: var(--font-brand);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--brand-green);
}

.auth-logo-tld {
  font-family: var(--font-brand);
  font-size: 32px;
  font-weight: 400;
  letter-spacing: -0.5px;
  color: var(--text-tertiary);
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-button);
  overflow: hidden;
}

.auth-tab {
  flex: 1;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  background: transparent;
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
}

.auth-tab:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.auth-tab.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-submit-btn {
  margin-top: 4px;
  width: 100%;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  justify-content: center;
  text-align: center;
}

.auth-forgot-btn {
  width: 100%;
  font-size: 12px;
  justify-content: center;
  text-align: center;
  padding: 8px 12px;
}

.auth-message {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-card);
  font-size: 13px;
  line-height: 1.5;
  background: rgba(0, 201, 123, 0.08);
  border: 1px solid var(--accent-border);
  color: var(--accent);
}

.auth-error {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-card);
  font-size: 13px;
  line-height: 1.5;
  background: rgba(229, 72, 77, 0.08);
  border: 1px solid rgba(229, 72, 77, 0.25);
  color: var(--error);
}
