* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, #1e293b 0%, #0b1220 50%, #070b16 100%);
  color: #e2e8f0;
  min-height: 100vh;
}

header {
  padding: 1.6rem 2rem 1.2rem;
  border-bottom: 1px solid #1e293b;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(6px);
}
.brand h1 {
  margin: 0;
  font-size: 1.6rem;
  background: linear-gradient(90deg, #38bdf8, #a78bfa);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.subtitle { margin: 0.4rem 0 0; color: #94a3b8; font-size: 0.92rem; }

.legend { display: flex; gap: 0.9rem; flex-wrap: wrap; font-size: 0.78rem; color: #94a3b8; }
.legend-item { display: flex; align-items: center; gap: 0.4rem; }

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 2rem 4rem;
  display: grid;
  gap: 1.4rem;
}

.input-card {
  background: linear-gradient(180deg, rgba(30,41,59,0.95), rgba(30,41,59,0.7));
  padding: 1.2rem 1.5rem;
  border-radius: 14px;
  border: 1px solid #1e293b;
  display: grid;
  gap: 1rem;
}
.input-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 1rem;
}
@media (max-width: 800px) {
  .input-grid { grid-template-columns: 1fr; }
}

.input-card label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: #cbd5e1;
}

.input-card input,
.input-card textarea {
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
}
.input-card input:focus,
.input-card textarea:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.actions { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }

button {
  background: #334155;
  color: #f1f5f9;
  border: none;
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  transition: transform 0.05s ease, background 0.15s ease;
}
button:hover:not(:disabled) { background: #475569; transform: translateY(-1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary {
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  color: #0f172a;
}
button.primary:hover:not(:disabled) { filter: brightness(1.08); }

.session { margin: 0; font-size: 0.8rem; color: #64748b; font-family: monospace; }

#steps { display: grid; gap: 0.9rem; }

.step {
  background: #1e293b;
  border-radius: 12px;
  border: 1px solid #1e293b;
  border-left: 4px solid #475569;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.step.in-progress { border-left-color: #fbbf24; box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.25); }
.step.success     { border-left-color: #34d399; }
.step.error       { border-left-color: #f87171; box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.25); }
.step.skipped     { border-left-color: #64748b; }
.step.awaiting    { border-left-color: #a78bfa; box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.25); }

.step header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.85rem 1.2rem;
  background: rgba(15, 23, 42, 0.5);
  border-bottom: 1px solid #1e293b;
}
.step header h2 { margin: 0; font-size: 1rem; flex: 1; color: #f1f5f9; }
.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #475569;
  flex-shrink: 0;
}
.dot.pending      { background: #475569; }
.dot.in-progress  { background: #fbbf24; animation: pulse 1.2s infinite; }
.dot.success      { background: #34d399; }
.dot.error        { background: #f87171; }
.step.in-progress > header .dot { background: #fbbf24; animation: pulse 1.2s infinite; }
.step.success     > header .dot { background: #34d399; }
.step.error       > header .dot { background: #f87171; }
.step.skipped     > header .dot { background: #64748b; }
.step.awaiting    > header .dot { background: #a78bfa; animation: pulse 1.6s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(1.2); }
}

.step .status {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  background: rgba(15, 23, 42, 0.6);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}
.step.success  > header .status { color: #6ee7b7; }
.step.error    > header .status { color: #fca5a5; }
.step.awaiting > header .status { color: #c4b5fd; }

.activity {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
  padding: 0 1.2rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.78rem;
  color: #94a3b8;
}
.step.in-progress .activity,
.step.error .activity,
.step.awaiting .activity {
  max-height: 200px;
  overflow-y: auto;
  padding: 0.5rem 1.2rem;
  border-bottom: 1px dashed #1e293b;
}
.activity-line { padding: 0.1rem 0; }
.activity-line .time { color: #64748b; margin-right: 0.5rem; }

.step .content {
  padding: 1rem 1.2rem 1.25rem;
  display: grid;
  gap: 0.9rem;
  font-size: 0.92rem;
  line-height: 1.5;
}
.step .content:empty { display: none; }

.step .content pre {
  background: #0f172a;
  padding: 0.8rem 1rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.78rem;
  max-height: 360px;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.step .content img {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid #334155;
}

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td {
  text-align: left;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid #334155;
  vertical-align: top;
}
th { color: #94a3b8; font-weight: 600; }

.tag {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #334155;
  color: #e2e8f0;
}
.tag.passed  { background: #064e3b; color: #6ee7b7; }
.tag.failed  { background: #7f1d1d; color: #fca5a5; }
.tag.skipped { background: #334155; color: #cbd5e1; }
.tag.high    { background: #7f1d1d; color: #fecaca; }
.tag.medium  { background: #78350f; color: #fed7aa; }
.tag.low     { background: #1e3a8a; color: #bfdbfe; }

.kpi-row { display: flex; gap: 0.8rem; flex-wrap: wrap; }
.kpi {
  background: #0f172a;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  border: 1px solid #334155;
  min-width: 120px;
  flex: 1;
}
.kpi .label { font-size: 0.7rem; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; }
.kpi .value { font-size: 1.4rem; font-weight: 600; color: #f1f5f9; }
.kpi.passed { border-color: #065f46; background: linear-gradient(180deg, #052e2b, #0f172a); }
.kpi.passed .value { color: #6ee7b7; }
.kpi.failed { border-color: #7f1d1d; background: linear-gradient(180deg, #2a0e0e, #0f172a); }
.kpi.failed .value { color: #fca5a5; }

.muted { color: #94a3b8; font-size: 0.85rem; }
.small { font-size: 0.78rem; }

/* ---------- Crawler gallery ---------- */
.page-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.8rem;
}
.page-card {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 10px;
  overflow: hidden;
  margin: 0;
  display: flex;
  flex-direction: column;
}
.page-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top center;
  border-radius: 0;
  border: 0;
  border-bottom: 1px solid #334155;
}
.page-card .placeholder {
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  color: #64748b;
  background: #1e293b;
}
.page-card figcaption {
  padding: 0.5rem 0.7rem 0.7rem;
  display: grid;
  gap: 0.2rem;
}
.page-card .page-title { font-weight: 600; font-size: 0.85rem; color: #f1f5f9;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-card .page-url {
  font-family: ui-monospace, Menlo, monospace; font-size: 0.7rem; color: #64748b;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- Review (human-in-the-loop) ---------- */
.review-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}
.review-actions { display: flex; gap: 0.5rem; }

.review-table-wrap { overflow-x: auto; }
.review-table {
  min-width: 1500px;
  font-size: 0.82rem;
}
.review-table select.cell-input { padding-right: 1.6rem; }
.review-table th { font-size: 0.7rem; }
.cell-input {
  width: 100%;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font-family: inherit;
  font-size: 0.82rem;
  resize: vertical;
}
.cell-input:focus { outline: none; border-color: #38bdf8; }
textarea.cell-input { min-height: 60px; }
.row-delete {
  background: #7f1d1d;
  color: #fee2e2;
  padding: 0.3rem 0.55rem;
  font-size: 0.8rem;
}
.row-delete:hover:not(:disabled) { background: #991b1b; }
