:root {
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17202a;
  background: #f3f5f7;
}

body {
  margin: 0;
  min-width: 320px;
  background: #f3f5f7;
}

.shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 2.5rem auto 5rem;
}

.masthead {
  display: flex;
  align-items: center;
  gap: 2rem;
  min-height: 4.5rem;
  padding: 0 2rem;
  border-bottom: 1px solid #d9e0e5;
  background: rgb(255 255 255 / 96%);
}

.brand {
  display: grid;
  color: inherit;
  text-decoration: none;
}

.brand-title {
  font-size: 1.18rem;
  font-weight: 800;
}

.eyebrow {
  color: #186a7b;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.main-nav {
  display: flex;
  gap: 0.3rem;
}

.main-nav a {
  padding: 0.65rem 0.8rem;
  border-radius: 0.45rem;
  color: #33424d;
  font-weight: 650;
  text-decoration: none;
}

.main-nav a:hover {
  background: #eef3f4;
  color: #0f5968;
}

.account-menu {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
  color: #5f6b75;
  font-size: 0.9rem;
}

.account-menu form,
.inline-form {
  margin: 0;
}

.card {
  padding: 1.75rem;
  border: 1px solid #d9e0e5;
  border-radius: 0.85rem;
  background: white;
  box-shadow: 0 0.8rem 2.2rem rgb(23 32 42 / 8%);
}

.card h2 {
  margin-top: 0;
}

h1 {
  margin: 0.25rem 0 0;
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.05;
}

h2,
h3 {
  line-height: 1.2;
}

a {
  color: #126478;
}

.lead {
  max-width: 720px;
  margin-bottom: 0;
  color: #52616c;
  font-size: 1.08rem;
  line-height: 1.55;
}

.muted {
  color: #5f6b75;
}

.auth-form {
  display: grid;
  gap: 1rem;
  margin: 1.5rem 0;
}

.stack-form {
  display: grid;
  gap: 1rem;
}

.compact-form {
  margin-top: 1rem;
}

.form-field {
  display: grid;
  gap: 0.35rem;
}

.form-field label {
  font-weight: 650;
}

.form-field input,
.form-field select,
.form-field textarea,
.stack-form > textarea {
  box-sizing: border-box;
  width: 100%;
  padding: 0.72rem 0.8rem;
  border: 1px solid #9aa8b2;
  border-radius: 0.45rem;
  background: white;
  font: inherit;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus,
.stack-form > textarea:focus {
  border-color: #186a7b;
  outline: 3px solid rgb(24 106 123 / 18%);
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  padding: 0.72rem 1.1rem;
  border: 0;
  border-radius: 0.45rem;
  color: white;
  background: #186a7b;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.button-secondary,
.button-link {
  color: #17202a;
  background: #e7ecef;
}

.button-link {
  padding: 0.25rem 0.4rem;
  background: transparent;
  color: #126478;
}

.button-danger {
  background: #a63b32;
}

.button-disabled {
  cursor: not-allowed;
  color: #67757f;
  background: #edf0f2;
}

.full-width {
  box-sizing: border-box;
  width: 100%;
}

.form-errors,
.errorlist {
  color: #9c2f24;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2rem;
}

.page-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 0.8rem;
  color: #52616c;
  text-decoration: none;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.metric-grid.compact {
  margin-bottom: 2rem;
}

.metric-card {
  display: grid;
  gap: 0.25rem;
  min-height: 9rem;
  padding: 1.5rem;
  border: 1px solid #d9e0e5;
  border-radius: 0.85rem;
  color: #17202a;
  background: white;
  box-shadow: 0 0.8rem 2.2rem rgb(23 32 42 / 6%);
  text-decoration: none;
}

.metric-card:not(.static):hover {
  border-color: #84aeb7;
  transform: translateY(-1px);
}

.metric-card span:last-child {
  align-self: end;
  color: #697680;
}

.metric-value {
  color: #186a7b;
  font-size: 2.6rem;
  font-weight: 800;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.source-card {
  color: inherit;
  text-decoration: none;
}

.source-card:hover {
  border-color: #84aeb7;
}

.card-heading,
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.card-heading h2,
.card-heading h3,
.section-heading h2 {
  margin: 0;
}

.url-text {
  overflow-wrap: anywhere;
  color: #126478;
}

.mini-metrics,
.run-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 0.5rem;
  margin: 1.5rem 0 0;
}

.mini-metrics div,
.run-stats div {
  display: grid;
  gap: 0.15rem;
}

.mini-metrics dt,
.run-stats dt,
.detail-list dt {
  color: #697680;
  font-size: 0.82rem;
}

.mini-metrics dd,
.run-stats dd,
.detail-list dd {
  margin: 0;
  font-weight: 750;
}

.status,
.tag,
.count-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  background: #edf0f2;
  color: #4e5c66;
  font-size: 0.78rem;
  font-weight: 750;
}

.status-success {
  color: #23623d;
  background: #e4f3e9;
}

.status-warning {
  color: #805812;
  background: #fff0cc;
}

.status-danger {
  color: #922f27;
  background: #fae6e4;
}

.status-muted {
  color: #5c6770;
  background: #edf0f2;
}

.count-badge {
  min-width: 2rem;
  justify-content: center;
  color: #126478;
  background: #deeff2;
  font-size: 1rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.two-column,
.document-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.7fr);
  gap: 1.25rem;
  align-items: start;
}

.two-column.wide-left {
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.75fr);
}

.stack-list,
.document-list,
.timeline,
.entity-list {
  display: grid;
  gap: 1rem;
}

.criterion-card.is-disabled {
  opacity: 0.72;
}

.prompt-text,
.long-text {
  line-height: 1.62;
}

.add-criterion {
  margin-top: 1rem;
}

.timeline-item {
  display: grid;
  gap: 0.35rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e3e8eb;
}

.timeline-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.timeline-item p {
  margin: 0;
}

.archive-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.filters {
  position: sticky;
  top: 1rem;
}

.queue-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr)) auto;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1rem;
}

.queue-state-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.queue-state-grid .metric-card {
  min-height: 6rem;
  padding: 1rem;
}

.queue-notice {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.queue-event-detail {
  margin-top: 1.25rem;
}

.queue-orphan-table {
  margin-bottom: 1rem;
}

.break-anywhere {
  overflow-wrap: anywhere;
}

.document-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.5rem;
  color: inherit;
  text-decoration: none;
}

.document-row:hover {
  border-color: #84aeb7;
}

.document-row h2 {
  margin: 0.35rem 0 0.5rem;
  font-size: 1.25rem;
}

.document-row p {
  margin: 0 0 0.8rem;
  color: #52616c;
  line-height: 1.5;
}

.source-label {
  color: #186a7b;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.document-meta {
  display: grid;
  align-content: start;
  gap: 0.55rem;
  min-width: 125px;
  color: #68747e;
  font-size: 0.84rem;
  text-align: right;
}

.document-header {
  align-items: flex-end;
}

.document-detail-grid {
  grid-template-columns: minmax(0, 1fr) 280px;
}

.link-panel {
  position: sticky;
  top: 1rem;
  display: grid;
  gap: 0.75rem;
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 0;
}

.detail-list div {
  display: grid;
  gap: 0.25rem;
}

.entity-row {
  display: grid;
  grid-template-columns: 110px minmax(160px, 0.6fr) minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e3e8eb;
}

.entity-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.review-form {
  display: grid;
  gap: 1rem;
}

.review-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.review-actions button {
  width: 100%;
}

.entity-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-start;
  margin: 0;
  padding: 0;
  list-style: none;
}

.entity-chip {
  box-sizing: border-box;
  display: inline-grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.25rem 0.55rem;
  min-width: 0;
  max-width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid #d9e0e5;
  border-radius: 0.75rem;
  background: #f8fafb;
}

.entity-chip-label,
.entity-chip-relation {
  overflow-wrap: anywhere;
}

.entity-chip-relation {
  grid-column: 2;
  color: #52616c;
  font-size: 0.84rem;
}

.entity-chip-status {
  grid-column: 1 / -1;
  width: fit-content;
  color: #5c6770;
  font-size: 0.76rem;
  font-weight: 700;
}

.entity-chip-status-candidate {
  color: #23623d;
}

.entity-chip-status-ambiguous {
  color: #805812;
}

.entity-chip-status-unavailable {
  color: #922f27;
}

.entity-chip-list > .empty-state {
  flex-basis: 100%;
  margin: 0;
}

.table-wrap {
  overflow-x: auto;
}

.card.flush {
  padding: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 1rem;
  border-bottom: 1px solid #e3e8eb;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #5a6872;
  background: #f8fafb;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.align-right {
  text-align: right;
}

.empty-state,
.empty-cell {
  padding: 2rem;
  color: #697680;
  text-align: center;
}

.checkbox-list ul {
  display: grid;
  gap: 0.65rem;
  padding: 0;
  list-style: none;
}

.checkbox-list label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.checkbox-list input {
  width: 1rem;
  height: 1rem;
}

.hint {
  color: #697680;
  font-size: 0.86rem;
  line-height: 1.45;
}

.danger-text {
  color: #9c2f24;
}

.crawl-action {
  margin-top: 1rem;
}

.prompt-details {
  margin: 1rem 0;
}

.messages {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.message {
  padding: 0.8rem 1rem;
  border-radius: 0.55rem;
  color: #244e35;
  background: #e4f3e9;
}

.message-error {
  color: #922f27;
  background: #fae6e4;
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

details summary {
  cursor: pointer;
  color: #126478;
  font-weight: 650;
}

@media (max-width: 860px) {
  .masthead {
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    padding: 0.8rem 1rem;
  }

  .main-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }

  .account-menu span {
    display: none;
  }

  .metric-grid,
  .card-grid,
  .two-column,
  .two-column.wide-left,
  .archive-layout,
  .document-detail-grid {
    grid-template-columns: 1fr;
  }

  .filters,
  .link-panel {
    position: static;
  }

  .queue-filters,
  .queue-state-grid {
    grid-template-columns: 1fr;
  }

  .page-header,
  .document-row {
    display: grid;
  }

  .document-meta {
    grid-template-columns: repeat(3, auto);
    text-align: left;
  }
}

@media (max-width: 560px) {
  .main-nav {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .main-nav a {
    padding: 0.5rem 0.65rem;
  }

  .shell {
    width: min(100% - 1rem, 1180px);
    margin-top: 1.25rem;
  }

  .card {
    padding: 1.1rem;
  }

  .metric-grid,
  .detail-list,
  .mini-metrics,
  .run-stats {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: auto;
  }

  .document-meta,
  .entity-row {
    grid-template-columns: 1fr;
  }

  .entity-chip-list {
    display: grid;
    grid-template-columns: 1fr;
  }
}

.errorlist {
  margin: 0;
  padding-left: 1.25rem;
}
