:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #0f766e;
  --border: #d1d5db;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #eef5ff 0%, var(--bg) 100%);
}

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.header h1 {
  margin: 0;
  font-size: 26px;
}

.hero-title {
  margin: 0;
  font-size: 40px;
  line-height: 1.05;
}

.hero-subtitle {
  margin: 6px 0 0 0;
  font-size: 15px;
  color: var(--muted);
}

nav {
  display: flex;
  gap: 10px;
}

nav a {
  text-decoration: none;
  color: var(--text);
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

nav a.active {
  background: #dcfce7;
  border-color: #86efac;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 14px;
}

.panel h2 {
  margin-top: 0;
  font-size: 20px;
}

.how-it-works-panel {
  padding: 12px 14px;
  background: #ecfdf3;
  border-color: #86efac;
}

.how-it-works-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.how-it-works-head h2 {
  margin: 0;
  font-size: 16px;
  color: #166534;
}

.how-it-works-close {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid #86efac;
  border-radius: 8px;
  background: transparent;
  color: #166534;
  font-size: 20px;
  line-height: 1;
}

.how-it-works-close:hover {
  background: #dcfce7;
  border-color: #4ade80;
  color: #14532d;
}

.how-it-works-list {
  margin: 10px 0 0 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  color: #14532d;
}

.parse-form {
  display: grid;
  gap: 16px;
}

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

.parse-actions {
  margin-top: 4px;
}

.progress-actions {
  margin-top: 10px;
}

.keyword-actions {
  margin-top: 4px;
}

#clearKeywordsBtn {
  background: transparent;
  color: #475569;
  border: 1px solid #cbd5e1;
}

#clearKeywordsBtn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.parse-pages-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.parse-pages-row label {
  margin: 0;
  white-space: nowrap;
}

.parse-pages-row input[type="number"] {
  width: 120px;
  padding: 8px 10px;
}

.parse-check-row {
  margin-top: -2px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 600;
}

.inline-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

textarea,
input[type="number"],
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
}

.hidden-field {
  display: none;
}

.tagify {
  width: 100%;
}

select[multiple] {
  min-height: 150px;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 12px;
}

legend {
  padding: 0 8px;
  color: var(--muted);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  padding: 8px;
}

.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  margin: 0;
}

small {
  color: var(--muted);
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

button,
.button {
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button.secondary,
.button.secondary {
  background: #334155;
}

.button.disabled {
  opacity: 0.6;
  pointer-events: none;
}

.progress-wrap {
  width: 100%;
  height: 18px;
  border-radius: 999px;
  overflow: hidden;
  background: #e5e7eb;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #16a34a, #22c55e);
  transition: width 0.3s;
}

.log-box {
  margin: 0;
  background: #0b1220;
  color: #d1fae5;
  border-radius: 8px;
  padding: 10px;
  min-height: 200px;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

.entity-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

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

.job-history-item {
  display: grid;
  gap: 8px;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
}

.job-history-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.job-history-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  color: #0f172a;
}

.job-history-status {
  color: #334155;
}

.job-history-keyword {
  color: #475569;
}

.job-history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.job-history-controls {
  margin-top: 10px;
}

.history-link {
  display: inline;
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.history-link:hover {
  color: #0b5f58;
}

.history-link:focus-visible {
  outline: 2px solid #99f6e4;
  outline-offset: 2px;
  border-radius: 2px;
}

.stat-chip {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.table-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.table-pagination select {
  width: auto;
  min-width: 80px;
  padding: 6px 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border: 1px solid #dbe3ee;
  padding: 7px;
  vertical-align: top;
  min-width: 110px;
}

th {
  background: #f1f5f9;
  position: sticky;
  top: 0;
}

td a {
  color: #0f766e;
  text-decoration: underline;
}

td a.truncate-link {
  display: inline-block;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: top;
}

tr.row-failed td {
  background: #ffe8e8;
}

.regex-preview {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.regex-preview-item {
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  padding: 8px 10px;
  background: #f8fafc;
}

.regex-preview-item code {
  white-space: pre-wrap;
  word-break: break-word;
}

.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 800px) {
  .container {
    padding: 12px;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-title {
    font-size: 32px;
  }

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

  .parse-pages-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .parse-pages-row input[type="number"] {
    width: 100%;
  }
}
