:root {
  --bg-dark: #0f1117;
  --bg-card: #1a1d27;
  --bg-card-hover: #222636;
  --bg-input: #12141c;
  --border: #2a2e3d;
  --border-focus: #6366f1;
  --text: #e2e8f0;
  --text-muted: #8892a8;
  --text-dim: #5a6378;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;
  --accent: #8b5cf6;
  --radius: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
}

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; }
.login-container { width: 100%; max-width: 400px; padding: 20px; }
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo h1 {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-logo p { color: var(--text-muted); margin-top: 4px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}
input, select, textarea, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
}
.form-textarea { resize: vertical; line-height: 1.5; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  gap: 6px;
}
.btn:hover { background: var(--bg-card-hover); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.9; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.btn-full { width: 100%; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Alerts */
.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 0.85rem; }
.alert-error { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }

/* Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand { display: flex; align-items: center; gap: 12px; }
.nav-brand h1 {
  font-size: 1.4rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.nav-subtitle { color: var(--text-dim); font-size: 0.85rem; }
.nav-back { color: var(--text-muted); text-decoration: none; font-size: 1.2rem; }
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-user { color: var(--text-muted); font-size: 0.85rem; }

/* Layout */
.main-layout {
  display: grid;
  grid-template-columns: 260px 1fr 300px;
  height: calc(100vh - 57px);
}
.pipeline-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  height: calc(100vh - 57px);
}

/* Sidebar */
.sidebar {
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
}
.sidebar-section { margin-bottom: 24px; }
.sidebar-section h3 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.project-list { display: flex; flex-direction: column; gap: 4px; }
.project-item {
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.project-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.project-item .project-type {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 2px;
}
.models-list { display: flex; flex-direction: column; gap: 4px; }
.model-item {
  padding: 6px 10px;
  font-size: 0.8rem;
  color: var(--text-dim);
  border-radius: var(--radius);
}

/* Content */
.content {
  padding: 24px;
  overflow-y: auto;
}
.pipeline-main {
  padding: 24px;
  overflow-y: auto;
}

/* Panels */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.panel-header h2 { font-size: 1rem; font-weight: 600; }
.panel-actions { display: flex; gap: 8px; }
.panel-body { padding: 20px; }

/* Pipelines Grid */
.pipelines-grid { padding: 12px; }
.pipeline-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.pipeline-card:last-child { border-bottom: none; }
.pipeline-card:hover { background: var(--bg-card-hover); }
.pipeline-card-info { flex: 1; }
.pipeline-card-title { font-size: 0.9rem; font-weight: 500; margin-bottom: 4px; }
.pipeline-card-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
  display: flex;
  gap: 12px;
}
.pipeline-card-progress {
  display: flex;
  align-items: center;
  gap: 8px;
}
.progress-bar {
  width: 80px;
  height: 4px;
  background: var(--bg-dark);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s;
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.status-pending { background: rgba(90,99,120,0.3); color: var(--text-dim); }
.status-planning { background: rgba(139,92,246,0.2); color: var(--accent); }
.status-planned { background: rgba(59,130,246,0.2); color: var(--info); }
.status-running { background: rgba(245,158,11,0.2); color: var(--warning); }
.status-completed { background: rgba(34,197,94,0.2); color: var(--success); }
.status-failed { background: rgba(239,68,68,0.2); color: var(--error); }
.status-partial { background: rgba(245,158,11,0.2); color: var(--warning); }

/* Steps */
.steps-list { padding: 20px; }
.steps-timeline { padding: 20px; }
.step-item {
  display: flex;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(42,46,61,0.5);
}
.step-item:last-child { border-bottom: none; }
.step-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-dark);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  flex-shrink: 0;
}
.step-number.completed { border-color: var(--success); color: var(--success); }
.step-number.running { border-color: var(--warning); color: var(--warning); animation: pulse 1.5s infinite; }
.step-number.failed { border-color: var(--error); color: var(--error); }
.step-info { flex: 1; }
.step-title { font-size: 0.9rem; font-weight: 500; margin-bottom: 4px; }
.step-type {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  margin-right: 8px;
}
.step-type.image { background: rgba(139,92,246,0.2); color: var(--accent); }
.step-type.video { background: rgba(236,72,153,0.2); color: #ec4899; }
.step-type.code { background: rgba(34,197,94,0.2); color: var(--success); }
.step-type.database { background: rgba(59,130,246,0.2); color: var(--info); }
.step-type.file_write { background: rgba(245,158,11,0.2); color: var(--warning); }
.step-type.design_analysis { background: rgba(99,102,241,0.2); color: var(--primary); }
.step-desc { font-size: 0.8rem; color: var(--text-muted); margin-top: 6px; line-height: 1.5; }
.step-actions { display: flex; gap: 6px; margin-top: 8px; }

/* Assets Grid */
.assets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  padding: 16px;
}
.asset-card {
  background: var(--bg-dark);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.asset-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
}
.asset-card-info {
  padding: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Log Panel */
.log-panel {
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.log-header h3 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}
.log-entries {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
}
.log-entry {
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 2px;
  line-height: 1.6;
  word-break: break-word;
}
.log-entry .log-time { color: var(--text-dim); margin-right: 6px; }
.log-entry.info { color: var(--text-muted); }
.log-entry.success { color: var(--success); }
.log-entry.warning { color: var(--warning); }
.log-entry.error { color: var(--error); background: rgba(239,68,68,0.08); }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 480px;
}
.modal-content h3 { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* Empty state */
.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
}

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

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 1200px) {
  .main-layout { grid-template-columns: 220px 1fr 260px; }
}
@media (max-width: 900px) {
  .main-layout { grid-template-columns: 1fr; }
  .sidebar, .log-panel { display: none; }
  .pipeline-layout { grid-template-columns: 1fr; }
}
