:root {
  --bg: #0f1117;
  --bg-raised: #1a1d27;
  --bg-surface: #22262f;
  --bg-hover: #2a2e3a;
  --border: rgba(255, 255, 255, 0.08);
  --border-active: rgba(99, 102, 241, 0.5);
  --text: #e8eaed;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-subtle: rgba(99, 102, 241, 0.12);
  --green: #10b981;
  --green-subtle: rgba(16, 185, 129, 0.12);
  --yellow: #f59e0b;
  --yellow-subtle: rgba(245, 158, 11, 0.12);
  --red: #ef4444;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────────────────────────────── */

.sidebar {
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 20px;
}

.logo-text {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.create-form {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.create-form input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 13px;
  transition: border-color 0.15s;
}

.create-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.create-form input::placeholder {
  color: var(--text-muted);
}

.sidebar-section {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 10px;
}

.sidebar-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.job-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.job-item {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.job-item:hover {
  background: var(--bg-hover);
}

.job-item.is-active {
  background: var(--accent-subtle);
  border-color: var(--border-active);
}

.job-item-url {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.job-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.job-item-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}

.job-item-dot.crawled,
.job-item-dot.generated { background: var(--yellow); }
.job-item-dot.deployed { background: var(--green); }
.job-item-dot.error { background: var(--red); }

/* ─── Main Content ────────────────────────────────────────────────────────── */

.main-content {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  text-transform: capitalize;
}

.status-badge.active {
  background: var(--accent-subtle);
  border-color: var(--border-active);
  color: var(--accent-hover);
}

.status-badge.done {
  background: var(--green-subtle);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--green);
}

.content-area {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ─── Pipeline Steps ──────────────────────────────────────────────────────── */

.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.pipeline-steps {
  display: flex;
  flex-direction: column;
}

.pipeline-step {
  display: flex;
  gap: 16px;
}

.step-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 4px;
}

.step-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  transition: border-color 0.2s, background 0.2s;
}

.pipeline-step.complete .step-dot {
  border-color: var(--green);
  background: var(--green);
}

.pipeline-step.active .step-dot {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-subtle);
}

.step-line {
  width: 2px;
  flex: 1;
  min-height: 24px;
  background: var(--border);
  margin: 6px 0;
}

.pipeline-step.complete .step-line {
  background: var(--green);
}

.step-content {
  flex: 1;
  padding-bottom: 20px;
}

.step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.step-title {
  font-size: 14px;
  font-weight: 600;
}

.step-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-surface);
  color: var(--text-muted);
}

.step-badge.done {
  background: var(--green-subtle);
  color: var(--green);
}

.step-badge.running {
  background: var(--accent-subtle);
  color: var(--accent-hover);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.step-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* ─── Panels ──────────────────────────────────────────────────────────────── */

.panels-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}

.panel {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.panel-header {
  margin-bottom: 16px;
}

.panel-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

.panel-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.preview-container {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: white;
}

.preview-frame {
  width: 100%;
  height: 480px;
  border: 0;
  display: block;
  background: white;
}

/* ─── Stats ───────────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stat {
  padding: 12px;
  border-radius: var(--radius);
  background: var(--bg-surface);
  border: 1px solid var(--border);
}

.stat-value {
  display: block;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 2px;
}

.stat-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

/* ─── Content Summary ─────────────────────────────────────────────────────── */

.content-summary {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}

.summary-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.summary-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.summary-item-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.summary-item-value {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  word-break: break-all;
}

/* ─── Edit Panel ──────────────────────────────────────────────────────────── */

.edit-panel {
  border: 1px solid var(--border);
}

.edit-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.edit-form textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  resize: vertical;
  min-height: 80px;
  font-size: 13px;
  line-height: 1.6;
  transition: border-color 0.15s;
}

.edit-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.edit-form textarea::placeholder {
  color: var(--text-muted);
}

.edit-footer {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ─── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

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

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

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

.btn-secondary {
  background: var(--accent-subtle);
  border-color: var(--border-active);
  color: var(--accent-hover);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(99, 102, 241, 0.2);
}

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

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

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.btn-full {
  width: 100%;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

.btn-icon {
  font-size: 16px;
  line-height: 1;
}

/* ─── Crawl Summary ──────────────────────────────────────────────────────── */

.crawl-brand {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.crawl-brand-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
}

.crawl-brand-tagline {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

.crawl-group {
  margin-bottom: 14px;
}

.crawl-group-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.crawl-count {
  background: var(--surface-hover);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
}

.crawl-group-value {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

.crawl-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.crawl-tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--surface-hover);
  color: var(--text-secondary);
  font-weight: 500;
}

.crawl-tag--nav {
  background: rgba(99, 102, 241, 0.12);
  color: var(--primary);
}

.crawl-sections {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.crawl-section-item {
  display: grid;
  grid-template-columns: 80px 1fr;
  grid-template-rows: auto auto;
  gap: 0 8px;
  padding: 6px 8px;
  background: var(--surface-hover);
  border-radius: 6px;
  align-items: baseline;
}

.crawl-section-kind {
  grid-row: 1 / -1;
  font-size: 10px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding-top: 1px;
}

.crawl-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crawl-section-body {
  grid-column: 2;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crawl-source {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.crawl-source-link,
.crawl-deploy-link {
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
  word-break: break-all;
}

.crawl-source-link:hover,
.crawl-deploy-link:hover {
  text-decoration: underline;
}

/* ─── Utilities ───────────────────────────────────────────────────────────── */

.feedback {
  font-size: 12px;
  color: var(--text-muted);
  min-height: 18px;
}

.feedback.error {
  color: var(--red);
}

.hidden {
  display: none !important;
}

/* ─── Generate Progress ──────────────────────────────────────────────────── */

.generate-progress {
  margin-top: 0.75rem;
  padding: 0.75rem 0;
}

.progress-bar-track {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-step-label {
  margin: 0.5rem 0 0.125rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
}

.progress-step-counter {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ─── Responsive ──────────────────────────────────────────────────────────── */

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

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

  .sidebar {
    position: relative;
    height: auto;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .topbar {
    position: relative;
  }
}
