:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-alt: #eef4f2;
  --text: #17201d;
  --muted: #64736e;
  --line: #d9e2df;
  --primary: #147d6f;
  --primary-strong: #0f6259;
  --accent: #b7791f;
  --danger: #b42318;
  --success: #157347;
  --shadow: 0 16px 40px rgba(31, 45, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 12px;
  cursor: pointer;
}

button:hover {
  border-color: var(--primary);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.primary:hover {
  background: var(--primary-strong);
}

.danger {
  color: #ffffff;
  background: var(--danger);
  border-color: var(--danger);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px clamp(18px, 4vw, 44px);
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.15;
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px clamp(14px, 3vw, 34px) 36px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 22px 0 14px;
  overflow-x: auto;
}

.tab {
  min-width: max-content;
}

.tab.active {
  color: #ffffff;
  background: #263b36;
  border-color: #263b36;
}

.workspace {
  display: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.workspace.active {
  display: block;
}

.review-grid.active {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 18px;
}

.panel {
  min-width: 0;
}

.detail-panel {
  border-left: 1px solid var(--line);
  padding-left: 18px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-heading h2,
.section-heading p {
  margin: 0;
}

.section-heading p {
  margin-top: 4px;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th,
td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.file-title,
.dossier-title {
  font-weight: 700;
}

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

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--surface-alt);
  color: #28433d;
  font-size: 12px;
  font-weight: 700;
}

.status.COMMITTED,
.status.APPROVED,
.status.OCR_DONE {
  color: var(--success);
  background: #e7f6ed;
}

.status.NEED_REVIEW,
.status.EXTRACTED {
  color: var(--accent);
  background: #fff3da;
}

.status.REJECTED,
.status.OCR_FAILED {
  color: var(--danger);
  background: #fee4e2;
}

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

.ocr-job-actions {
  margin-top: 12px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
  color: var(--muted);
  font-size: 14px;
}

.pagination-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pagination-actions span {
  color: var(--text);
  font-weight: 600;
  min-width: 96px;
  text-align: center;
}

.catalog-tools {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.catalog-tools input {
  min-height: 38px;
  width: min(280px, 100%);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}

.subnav {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.subnav-item {
  min-width: max-content;
}

.subnav-item.active {
  color: #ffffff;
  background: var(--primary);
  border-color: var(--primary);
}

.catalog-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.summary-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-alt);
  color: #28433d;
  padding: 6px 10px;
  font-size: 13px;
}

.catalog-name {
  min-width: 260px;
  font-weight: 700;
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
}

.list-item.selected {
  border-color: var(--primary);
  box-shadow: inset 3px 0 0 var(--primary);
}

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

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

.field {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfb;
}

.field label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #ffffff;
  color: var(--text);
}

.field textarea {
  min-height: 78px;
  resize: vertical;
}

.evidence {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.ocr-preview {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.preview-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.ocr-page {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 10px;
}

.ocr-page pre {
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 8px 0 0;
  color: var(--text);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}

.confidence {
  color: var(--primary);
  font-weight: 700;
}

.warning-list {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.warning {
  border: 1px solid #f8d99d;
  background: #fff8eb;
  border-radius: 8px;
  padding: 10px 12px;
  color: #6f4d12;
}

.blocking {
  border-color: #f5b5ad;
  background: #fff1f0;
  color: #7a271a;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfb;
  text-align: center;
}

.empty-state.compact {
  padding: 14px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
  border-radius: 8px;
  background: #263b36;
  color: #ffffff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .detail-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 18px;
  }

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

@media (max-width: 560px) {
  .metrics {
    grid-template-columns: 1fr;
  }

  .section-heading,
  .dossier-header {
    flex-direction: column;
  }

  .catalog-tools {
    width: 100%;
    justify-content: flex-start;
  }

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

  .catalog-tools input,
  .catalog-tools button {
    width: 100%;
  }

  .row-actions button,
  .detail-actions button {
    width: 100%;
  }
}
