:root {
  --bg-main: #090d16;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-hover: rgba(30, 41, 59, 0.9);
  --border-color: rgba(51, 65, 85, 0.6);
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --accent: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Glassmorphism Header */
header {
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  font-size: 1.2rem;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.5);
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-badge {
  font-size: 0.7rem;
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(99, 102, 241, 0.3);
  margin-left: 6px;
}

/* Navigation Tabs */
nav.nav-tabs {
  display: flex;
  gap: 0.5rem;
}

.tab-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tab-btn:hover {
  color: var(--text-main);
  background: var(--bg-hover);
}

.tab-btn.active {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

/* Header Status Pills */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.status-pill {
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.dot-green { background: var(--success); box-shadow: 0 0 8px var(--success); }
.dot-blue { background: var(--accent); box-shadow: 0 0 8px var(--accent); }

/* Main Container */
main.main-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.2s ease-in-out;
}
.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cards & Layout */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 1.5rem;
}

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

/* Prompt Box */
.prompt-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.prompt-textarea {
  width: 100%;
  height: 180px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-main);
  padding: 0.75rem;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
}
.prompt-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.form-row {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

.form-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

select, input[type="text"], input[type="number"] {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-main);
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  outline: none;
}
select:focus, input:focus {
  border-color: var(--primary);
}

/* Buttons */
.btn {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.55rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}
.btn:hover { background: var(--bg-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-danger { background: var(--danger); border-color: var(--danger); color: #fff; }

/* Batch Action Bar */
.batch-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-color);
  padding: 0.6rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

/* Jobs Table */
.job-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem;
  border-bottom: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.4);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  gap: 1rem;
  transition: background 0.15s ease;
}
.job-item:hover {
  background: rgba(30, 41, 59, 0.4);
}

.job-thumb {
  width: 52px;
  height: 78px;
  border-radius: 6px;
  object-fit: cover;
  background: #1e293b;
  cursor: pointer;
}

.job-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.job-prompt {
  font-size: 0.9rem;
  font-weight: 500;
  color: #f1f5f9;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.job-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}
.badge-waiting { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; }
.badge-running { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.badge-done { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.badge-failed { background: rgba(239, 68, 68, 0.2); color: #f87171; }

/* Flow Studio Canvas */
.studio-canvas {
  width: 100%;
  height: 680px;
  background-color: #0b0f19;
  background-image: radial-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px);
  background-size: 24px 24px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
}

.canvas-card {
  position: absolute;
  width: 260px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  cursor: move;
  z-index: 10;
  user-select: none;
}
.canvas-card-header {
  padding: 0.5rem 0.75rem;
  background: rgba(30, 41, 59, 0.8);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
}
.canvas-card-body {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.canvas-card-img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 6px;
  background: #1e293b;
}

/* Post-production Lab */
.postprod-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
.video-preview-box {
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 480px;
  border: 1px solid var(--border-color);
}
.video-preview-box video {
  max-height: 520px;
  max-width: 100%;
}
