:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #18212f;
  --muted: #64748b;
  --line: #d9e2ef;
  --accent: #1d4ed8;
  --accent-soft: #dbeafe;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
}

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 800; color: var(--text); }
nav { display: flex; align-items: center; gap: 18px; }
.inline-form { display: inline; margin: 0; }
.link-button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.container {
  max-width: 1180px;
  margin: 28px auto;
  padding: 0 20px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.05);
}
.auth-card { max-width: 430px; margin: 70px auto; }
h1, h2 { margin-top: 0; }
.muted { color: var(--muted); }
.form-grid { display: grid; gap: 16px; max-width: 560px; }
label { display: grid; gap: 8px; font-weight: 650; }
input, select, button, .button-secondary {
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  font: inherit;
}
input, select { background: white; }
button, .button-secondary {
  background: var(--accent);
  color: white;
  cursor: pointer;
  border-color: var(--accent);
  font-weight: 700;
  text-align: center;
}
.button-secondary { background: var(--accent-soft); color: var(--accent); }
button:disabled { opacity: 0.6; cursor: not-allowed; }
.alert {
  margin: 16px 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
}
.alert-error { background: var(--danger-soft); color: var(--danger); }
.hidden { display: none; }
.progress-wrap { margin-top: 22px; }
.progress-line { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
progress { width: 100%; height: 18px; }
.results { display: grid; gap: 8px; margin-top: 14px; }
.result { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.result.failed { border-color: var(--danger); background: var(--danger-soft); }
.page-head { display: flex; justify-content: space-between; gap: 20px; align-items: start; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 14px; }
code { background: #eef2ff; padding: 2px 5px; border-radius: 6px; }
.details { display: grid; grid-template-columns: 160px 1fr; gap: 10px 18px; }
.details dt { font-weight: 800; color: var(--muted); }
.details dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.email-text {
  white-space: pre-wrap;
  overflow-x: auto;
  background: #f8fafc;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.stats { display: flex; gap: 16px; margin: 20px 0; flex-wrap: wrap; }
.stat-card {
  min-width: 170px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  background: #f8fafc;
}
.stat-value { display: block; font-size: 32px; font-weight: 900; }
.stat-label { color: var(--muted); }
.processing-link {
  display: inline-block;
  margin: 16px 0 0;
}
.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 13px;
  font-weight: 800;
  background: #e2e8f0;
  color: #334155;
}
.status-queued { background: #e0f2fe; color: #0369a1; }
.status-running { background: #fef3c7; color: #92400e; }
.status-finished { background: #dcfce7; color: #166534; }
.status-failed { background: var(--danger-soft); color: var(--danger); }
.mini-progress-label {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
}
.hidden { display: none !important; }
.subcard {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin: 16px 0;
  background: #f8fafc;
}
.subcard h3 { margin-top: 0; }
.details.compact { grid-template-columns: 140px 1fr; font-size: 14px; }
.status-not_attempted { background: #e2e8f0; color: #334155; }
.status-disabled { background: #e2e8f0; color: #475569; }
.status-success { background: #dcfce7; color: #166534; }
.status-empty { background: #fef3c7; color: #92400e; }
.status-unsupported { background: #e2e8f0; color: #475569; }
.document-text {
  max-height: 520px;
  overflow: auto;
}
.compact-text {
  max-height: 280px;
}
.text-meta { margin-bottom: 8px; }
.text-details {
  margin: 14px 0 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: white;
}
.text-details summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--accent);
}
.status-partial { background: #ffedd5; color: #9a3412; }
.status-pending { background: #e2e8f0; color: #334155; }
.status-created { background: #dcfce7; color: #166534; }
.status-duplicate { background: #f1f5f9; color: #475569; }
.checkbox-label {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  font-weight: 650;
}
.checkbox-label input { width: auto; }
.actions-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
