:root {
  --bg: #f8f4eb;
  --bg-alt: #fffdfa;
  --text: #1f1a16;
  --muted: #6f635a;
  --line: #dfd2c0;
  --accent: #b20017;
  --accent-soft: #ffe6d9;
  --success: #0f7a57;
  --danger: #9f1d2c;
  --neutral: #625850;
  --shadow: 0 12px 30px rgba(77, 45, 24, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 90% -10%, #f6d9be 0%, transparent 44%),
    radial-gradient(circle at -5% 95%, #e9d6ff20 0%, transparent 40%),
    var(--bg);
}

.page-shell {
  width: min(1200px, 96vw);
  margin: 24px auto 40px;
  display: grid;
  gap: 16px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  padding: 12px 6px;
}

.kicker {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

h1,
h2 {
  font-family: "Newsreader", Georgia, serif;
  margin: 0;
}

h1 {
  font-size: clamp(1.6rem, 2.2vw, 2.1rem);
  line-height: 1.1;
}

h2 {
  font-size: 1.3rem;
}

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

.pill {
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid currentColor;
}

.pill.neutral {
  color: var(--neutral);
}

.pill.ok {
  color: var(--success);
}

.pill.error {
  color: var(--danger);
}

.config-card,
.panel {
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.config-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  align-items: end;
}

.config-actions {
  display: flex;
  gap: 8px;
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 16px;
}

.panel {
  padding: 16px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

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

.templates-list {
  display: grid;
  gap: 8px;
}

.template-card {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  padding: 12px;
  display: grid;
  gap: 5px;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.template-card:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.template-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px #b2001722 inset;
}

.template-name {
  font-weight: 700;
}

.template-desc {
  font-size: 13px;
  color: var(--muted);
}

.template-acquisition {
  display: inline-flex;
  font-size: 11px;
  border-radius: 999px;
  padding: 4px 8px;
  width: fit-content;
  background: var(--accent-soft);
  color: #703100;
}

.job-form,
.template-fields {
  display: grid;
  gap: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.field-row {
  display: grid;
  gap: 6px;
}

.field-row.dynamic {
  animation: rise-in 220ms ease;
}

.field-row.full {
  grid-column: 1 / -1;
}

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 11px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #b2001733;
  border-color: var(--accent);
}

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

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

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

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

.form-actions {
  display: flex;
  gap: 8px;
}

.divider {
  height: 1px;
  background: var(--line);
}

.options-card {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 10px;
}

.options-card > summary {
  cursor: pointer;
  font-weight: 700;
  margin-bottom: 8px;
}

.table-wrap {
  overflow: auto;
}

.jobs-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 850px;
}

.jobs-table th,
.jobs-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

.jobs-table th {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.status-badge {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-badge.queued {
  background: #f6ebd9;
  color: #805200;
}

.status-badge.running {
  background: #dff1ff;
  color: #0a4c8b;
}

.status-badge.completed {
  background: #dff7ea;
  color: #0c6948;
}

.status-badge.failed {
  background: #ffdfe4;
  color: #8d1e2c;
}

code {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 12px;
  white-space: nowrap;
}

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

@media (max-width: 980px) {
  .config-card {
    grid-template-columns: 1fr;
  }
  .main-grid {
    grid-template-columns: 1fr;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
}
