:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #17202a;
  --muted: #6a7380;
  --line: #dfe4ea;
  --primary: #155eef;
  --primary-dark: #0f47bd;
  --accent: #12a594;
  --danger: #c53434;
  --shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 64px;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.brand { font-weight: 800; letter-spacing: 0; }
.topbar nav { display: flex; gap: 14px; flex: 1; }
.topbar nav a { color: var(--muted); font-size: 14px; }
.topbar form { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.shell { width: min(1440px, calc(100vw - 32px)); margin: 28px auto 64px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 18px; gap: 16px; }
h1 { margin: 0; font-size: 32px; line-height: 1.15; }
h2 { margin: 0 0 16px; font-size: 18px; }
h3 { margin: 0 0 14px; font-size: 17px; }
.eyebrow { color: var(--accent); font-weight: 700; text-transform: uppercase; font-size: 12px; margin: 0 0 8px; }
.source-link {
  display: inline-flex;
  margin-top: 10px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
}
.source-link:hover { color: var(--primary-dark); }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: 0; }
.status-message {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 18px;
  padding: 12px 14px;
  background: var(--surface);
  font-weight: 700;
}
.error-message {
  border-color: rgba(197, 52, 52, 0.28);
  color: var(--danger);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.grid.wide-left { grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr); }
.metrics { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 18px; }
.metrics div { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.metrics strong { display: block; font-size: 30px; }
.metrics span { color: var(--muted); font-size: 13px; }
.dashboard-metrics { grid-template-columns: repeat(4, 1fr); }
.dashboard-section { margin-bottom: 18px; }
.dashboard-grid { margin-bottom: 18px; }
.progress-meter {
  width: 110px;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f7;
}
.progress-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}
.feedback-list {
  display: grid;
  gap: 12px;
}
.feedback-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}
.feedback-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.feedback-card p {
  display: grid;
  gap: 3px;
  margin: 0;
  color: #354152;
  font-size: 13px;
  line-height: 1.5;
}
.feedback-card p span,
.feedback-card-header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.login-panel {
  min-height: calc(100vh - 140px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  align-items: center;
  gap: 48px;
}
.login-panel h1 { font-size: 56px; }

.form-stack { display: grid; gap: 14px; align-content: start; }
label { display: grid; gap: 7px; color: #354152; font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  font: inherit;
  color: var(--text);
  background: #fff;
}
textarea { resize: vertical; line-height: 1.55; }
button, .button-link {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
.primary { background: var(--primary); color: #fff; }
.primary:hover { background: var(--primary-dark); }
.secondary { background: #e8f0ff; color: var(--primary-dark); }
.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.button-link { background: #eef2f7; color: #223047; }
.user-chip, .pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #eef2f7;
  color: #405066;
  font-size: 12px;
  font-weight: 700;
}
.pill.status-assigned,
.pill.status-pending {
  background: #eef2f7;
  color: #405066;
}
.pill.status-in_progress,
.pill.status-running {
  background: #fff4d6;
  color: #8a5a00;
}
.pill.status-completed {
  background: #daf7e7;
  color: #126b3d;
}
.pill.status-failed {
  background: #fde3e3;
  color: #9f2424;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }

.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 420px;
  gap: 18px;
  align-items: start;
}
.article-pane {
  min-height: 62vh;
  min-width: 0;
  overflow: hidden;
}
.article-pane > * {
  max-width: 100%;
}
.article-text {
  white-space: pre-wrap;
  line-height: 1.85;
  font-size: 16px;
  overflow-wrap: anywhere;
}
.article-blocks {
  display: grid;
  gap: 22px;
  min-width: 0;
}
.article-paragraph {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.85;
  font-size: 16px;
  overflow-wrap: anywhere;
}
.article-block {
  border-radius: 8px;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}
.article-block.is-linked {
  background: #eef6ff;
  box-shadow: 0 0 0 3px rgba(21, 94, 239, 0.16);
}
.article-block.is-selected {
  background: #fff8d8;
  box-shadow: 0 0 0 3px rgba(242, 183, 5, 0.28);
}
.article-paragraph.article-block {
  padding: 4px 6px;
  margin-inline: -6px;
}
.article-title-block {
  padding: 4px 6px;
  margin-inline: -6px;
  overflow-wrap: anywhere;
}
.article-image {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 2px 0 4px;
  min-width: 0;
  overflow: hidden;
  contain: paint;
}
.article-image img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: min(420px, 52vh);
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f0f3f7;
}
.article-image figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.span-highlight {
  background: #dff8ee;
  border-bottom: 2px solid #18a774;
  border-radius: 5px;
  padding: 1px 4px;
  cursor: pointer;
}
.span-highlight.is-active {
  background: #bff0dc;
  box-shadow: 0 0 0 3px rgba(18, 165, 148, 0.2);
}
.review-panel {
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 104px);
  overflow: auto;
}
.span-evaluation-panel,
.span-reviews-panel {
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 2px solid var(--line);
}
.span-review-form {
  display: grid;
  gap: 11px;
}
.span-review-form textarea {
  min-height: 74px;
}
.compact-stars span {
  font-size: 22px;
}
.span-review-item {
  display: grid;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}
.span-review-item.is-active {
  margin-inline: -10px;
  padding-inline: 10px;
  background: #f1fbf8;
  border-radius: 8px;
}
.span-review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.span-review-header span,
.span-review-item p span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.span-review-item p {
  display: grid;
  gap: 3px;
  margin: 0;
  color: #354152;
  font-size: 13px;
  line-height: 1.5;
}
.small-button {
  min-height: 30px;
  padding: 6px 9px;
  font-size: 12px;
}
.review-term {
  background: #fff2a8;
  border-bottom: 2px solid #e0a900;
  border-radius: 5px;
  padding: 1px 4px;
  cursor: pointer;
}
.term-badge {
  margin-left: 5px;
  color: #8a6400;
  font-size: 11px;
  font-weight: 800;
}
.term-form {
  display: grid;
  gap: 11px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.section-title-row h2 { margin: 0; }
.version-panel {
  padding-top: 18px;
  margin-top: 18px;
  border-top: 2px solid var(--line);
}
.version-item {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}
.version-item summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.version-text {
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.6;
  color: #354152;
}
.term-form.is-active {
  margin-inline: -10px;
  padding-inline: 10px;
  background: #f4f8ff;
  border-radius: 8px;
}
.term-header { display: flex; justify-content: space-between; gap: 10px; }
.term-header span { color: var(--muted); }
.stars-input { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: 2px; }
.stars-input label { display: inline-flex; cursor: pointer; }
.stars-input input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.stars-input span { color: #ccd2db; font-size: 25px; line-height: 1; }
.stars-input label:hover span,
.stars-input label:hover ~ label span,
.stars-input input:checked ~ span,
.stars-input label:has(input:checked) ~ label span { color: #f2b705; }
.document-review {
  display: grid;
  gap: 12px;
  padding-top: 18px;
  margin-top: 14px;
  border-top: 2px solid var(--line);
}
.inline-form { display: flex; gap: 8px; align-items: center; min-width: 340px; }
.inline-form select { min-width: 190px; }
.compact-inline { min-width: 260px; }
.compact-inline select { min-width: 150px; }
.table-note {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.45;
}
.review-language {
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 800;
}
.scraped-image-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.scraped-image-strip img {
  width: 72px;
  height: 54px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f0f3f7;
}

@media (max-width: 1100px) {
  .grid.two, .grid.wide-left, .review-layout, .login-panel { grid-template-columns: 1fr; }
  .review-panel { position: static; max-height: none; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .inline-form { min-width: 0; flex-direction: column; align-items: stretch; }
}
@media (max-width: 720px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 14px 16px; gap: 10px; }
  .topbar nav { flex-wrap: wrap; }
  .topbar form { margin-left: 0; }
  .shell { width: min(100vw - 20px, 1440px); margin-top: 18px; }
  h1, .login-panel h1 { font-size: 30px; }
  .metrics { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  table { display: block; overflow-x: auto; }
}
