:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #162033;
  --muted: #5b6780;
  --border: #d8dfec;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --danger: #b91c1c;
  --success: #166534;
  --warning: #92400e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

.container {
  width: min(1080px, calc(100vw - 2rem));
  margin: 0 auto;
}

.topbar {
  background: #0f172a;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
}

.brand,
.nav a,
.link-button {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}

.nav {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.inline-form {
  margin: 0;
}

.link-button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.main-content {
  padding: 2rem 0 3rem;
}

.hero,
.page-header {
  margin-bottom: 1.5rem;
}

.hero h1,
.page-header h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(2rem, 4vw, 3rem);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.25rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.search-box {
  margin-bottom: 1rem;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

textarea {
  resize: vertical;
}

button {
  padding: 0.85rem 1.1rem;
  border: 0;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: var(--primary-hover);
}

button.secondary {
  background: #334155;
}

.form-grid {
  display: grid;
  gap: 1rem;
}

.wide-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.narrow-form {
  max-width: 420px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

label span {
  color: var(--muted);
  font-size: 0.95rem;
}

.full-width {
  grid-column: 1 / -1;
}

.actions {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 0.75rem;
}

.results-list,
.jobs-panel {
  display: grid;
  gap: 1rem;
}

.result-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.2rem;
}

.result-card a {
  color: var(--primary);
  text-decoration: none;
}

.result-url,
.result-meta,
.job-meta,
.hint {
  color: var(--muted);
  font-size: 0.92rem;
}

.result-snippet {
  margin: 0.65rem 0;
}

.result-meta,
.job-meta,
.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0;
}

.pagination a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.flash-list {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.flash {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
}

.flash-success {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.flash-error {
  border-color: #fecaca;
  background: #fef2f2;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.stat-card h2 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  color: var(--muted);
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
}

.stat-subvalue {
  font-size: 0.95rem;
}

.admin-actions {
  margin-bottom: 1rem;
}

.job-item {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 1rem;
}

.job-item:first-child {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.job-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.22rem 0.7rem;
  font-size: 0.84rem;
  font-weight: 700;
  text-transform: lowercase;
}

.badge-running,
.badge-queued {
  background: #fef3c7;
  color: var(--warning);
}

.badge-success {
  background: #dcfce7;
  color: var(--success);
}

.badge-failed,
.badge-aborted {
  background: #fee2e2;
  color: var(--danger);
}

.job-log,
.job-stats {
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 14px;
  padding: 1rem;
}

strong {
  background: #fef08a;
  padding: 0 0.12rem;
  border-radius: 0.18rem;
}

@media (max-width: 900px) {
  .wide-form,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .search-row {
    grid-template-columns: 1fr;
  }
}
