@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Inter:wght@400;500;600&display=swap');

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

:root {
  --bg:       #f7f8fa;
  --surface:  #ffffff;
  --border:   #e4e7ec;
  --text:     #111827;
  --muted:    #6b7280;
  --accent:   #2563eb;
  --accent-bg:#eff6ff;
  --mono:     'JetBrains Mono', monospace;
  --sans:     'Inter', system-ui, sans-serif;

  --pending:    #f59e0b;
  --processing: #3b82f6;
  --completed:  #10b981;
  --failed:     #ef4444;
  --cancelled:  #9ca3af;
}

body {
  font-family: var(--sans);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: grid;
  grid-template-columns: 200px 1fr;
  grid-template-rows: 1fr;
}

/* ── Sidebar ── */
nav {
  background: #0f172a;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.nav-logo {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0 20px 20px;
  border-bottom: 1px solid #1e293b;
  margin-bottom: 8px;
}

nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 20px;
  border-radius: 0;
  transition: color 0.15s, background 0.15s;
}
nav a:hover { color: #f1f5f9; background: #1e293b; }
nav a.active { color: #f1f5f9; background: #1e293b; border-left: 2px solid var(--accent); }

/* ── Main ── */
main {
  padding: 32px;
  overflow-y: auto;
  min-width: 0;
}

.page-header {
  margin-bottom: 28px;
}
.page-header h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}
.page-header p {
  color: var(--muted);
  margin-top: 4px;
  font-size: 12px;
}

/* ── Pipeline bar (signature element) ── */
.pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 28px;
}

.pipeline-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 12px;
  position: relative;
  border-right: 1px solid var(--border);
  gap: 6px;
}
.pipeline-stage:last-child { border-right: none; }

.pipeline-stage .count {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 600;
  line-height: 1;
}
.pipeline-stage .label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.pipeline-stage.pending    .count { color: var(--pending); }
.pipeline-stage.processing .count { color: var(--processing); }
.pipeline-stage.completed  .count { color: var(--completed); }
.pipeline-stage.failed     .count { color: var(--failed); }
.pipeline-stage.cancelled  .count { color: var(--cancelled); }

.pipeline-arrow {
  color: var(--border);
  font-size: 16px;
  flex-shrink: 0;
  padding: 0 4px;
  position: absolute;
  right: -9px;
  z-index: 1;
  background: var(--surface);
}

/* ── Cards / surfaces ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
}

/* ── Jobs page layout ── */
.jobs-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
  align-items: start;
}

.form-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ── Form ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}
.form-group label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
input, select, textarea {
  font-family: var(--sans);
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  width: 100%;
  transition: border-color 0.15s;
}
textarea { font-family: var(--mono); font-size: 12px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.btn {
  width: 100%;
  padding: 9px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.15s;
  font-family: var(--sans);
}
.btn:hover { background: #1d4ed8; }
.btn:active { background: #1e40af; }

#form-result {
  margin-top: 10px;
  font-size: 12px;
  font-family: var(--mono);
  min-height: 18px;
}

/* ── Depends-on checklist ── */
.dep-list {
  max-height: 140px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}
.dep-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  cursor: pointer;
}
.dep-list label:last-child { border-bottom: none; }
.dep-list label:hover { background: var(--accent-bg); }
.dep-list input[type="checkbox"] { width: auto; accent-color: var(--accent); }
.dep-list .dep-id { font-family: var(--mono); color: var(--muted); font-size: 11px; }
.dep-empty { padding: 10px; color: var(--muted); font-size: 12px; text-align: center; }

/* ── Table ── */
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.table-title {
  font-size: 13px;
  font-weight: 600;
}
.table-meta {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

td.mono { font-family: var(--mono); font-size: 11px; color: var(--muted); }
td.type { font-family: var(--mono); font-size: 12px; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}
.badge.pending    { background: #fef3c7; color: #92400e; }
.badge.pending::before    { background: var(--pending); }
.badge.processing { background: #dbeafe; color: #1e40af; }
.badge.processing::before { background: var(--processing); animation: pulse 1.5s infinite; }
.badge.completed  { background: #d1fae5; color: #065f46; }
.badge.completed::before  { background: var(--completed); }
.badge.failed     { background: #fee2e2; color: #991b1b; }
.badge.failed::before     { background: var(--failed); }
.badge.cancelled  { background: #f3f4f6; color: #374151; }
.badge.cancelled::before  { background: var(--cancelled); }

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

/* ── Priority pip ── */
.priority {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
}
.priority-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
}
.priority-1 .priority-dot { background: var(--failed); }
.priority-2 .priority-dot { background: var(--pending); }
.priority-3 .priority-dot { background: var(--completed); }

/* ── DLQ ── */
.dlq-error {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--failed);
  max-width: 320px;
  word-break: break-word;
}

.retry-btn {
  padding: 4px 12px;
  background: var(--surface);
  border: 1px solid var(--failed);
  color: var(--failed);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sans);
  transition: background 0.15s;
}
.retry-btn:hover { background: #fee2e2; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty-state p { font-size: 13px; margin-top: 6px; }

/* ── Alerts ── */
.alert {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 12px;
  margin-bottom: 16px;
}
.alert-info { background: var(--accent-bg); color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Back link ── */
.back-link {
  display: inline-block;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 8px;
}
.back-link:hover { color: var(--accent); }

/* ── Detail page ── */
.detail-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
  align-items: start;
}

.detail-fields { display: flex; flex-direction: column; gap: 0; }

.detail-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.detail-row:last-of-type { border-bottom: none; }

.detail-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  min-width: 96px;
  padding-top: 2px;
}

.detail-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 16px 0 8px;
}

.payload-view {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text);
  margin-bottom: 16px;
}

.dep-ids { display: flex; flex-direction: column; gap: 4px; }
.dep-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 11px;
}
.dep-link:hover { text-decoration: underline; }

.btn-danger {
  background: var(--failed);
  width: 100%;
}
.btn-danger:hover { background: #dc2626; }

/* ── Timeline ── */
.timeline { display: flex; flex-direction: column; gap: 0; }

.timeline-item {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.timeline-item:last-child { border-bottom: none; }

.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
  background: var(--muted);
}
.timeline-dot.event-created   { background: var(--accent); }
.timeline-dot.event-started   { background: var(--processing); }
.timeline-dot.event-completed { background: var(--completed); }
.timeline-dot.event-failed    { background: var(--failed); }
.timeline-dot.event-retry     { background: var(--pending); }
.timeline-dot.event-cancelled { background: var(--cancelled); }

.timeline-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

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

.timeline-ts {
  font-size: 11px;
  color: var(--muted);
}

.timeline-msg {
  font-size: 12px;
  color: var(--muted);
}

/* ── Table toolbar (filters + count) ── */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filters select {
  width: auto;
  padding: 6px 10px;
  font-size: 12px;
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.page-info {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}

.page-controls {
  display: flex;
  gap: 4px;
}

.page-btn {
  padding: 5px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 12px;
  font-family: var(--sans);
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}
.page-btn:hover:not(:disabled) {
  background: var(--bg);
  border-color: var(--accent);
  color: var(--accent);
}
.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Clickable table rows ── */
.clickable-row { cursor: pointer; }
.clickable-row:hover td { background: var(--accent-bg); }

/* ── Event badge variants for timeline ── */
.badge.created   { background: #eff6ff; color: #1e40af; }
.badge.started   { background: #dbeafe; color: #1e40af; }
.badge.retry     { background: #fef3c7; color: #92400e; }
.badge.completed { background: #d1fae5; color: #065f46; }
.badge.failed    { background: #fee2e2; color: #991b1b; }
.badge.cancelled { background: #f3f4f6; color: #374151; }