:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #151922;
  --muted: #697386;
  --line: #d8dde6;
  --primary: #1f6feb;
  --primary-dark: #174ea6;
  --danger: #b42318;
  --ok: #16794c;
  --warn: #ad5f00;
  --ok-bg: #edf8f1;
  --warn-bg: #fff8df;
  --danger-bg: #fff0f0;
  --processing-bg: #f4f8ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
}

.brand {
  color: var(--text);
  font-weight: 650;
  text-decoration: none;
}

.shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 32px auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.login-panel {
  max-width: 420px;
  margin: 80px auto;
}

h1 {
  margin: 0 0 16px;
  font-size: 24px;
  line-height: 1.2;
}

.stack {
  display: grid;
  gap: 16px;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

button,
.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  padding: 8px 14px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover {
  background: var(--primary-dark);
}

.ghost {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.ghost:hover {
  background: #eef1f5;
}

.section-head,
.actions,
.status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.actions {
  justify-content: flex-end;
}

.entry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.entry-card {
  display: grid;
  gap: 8px;
  min-height: 120px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
}

.entry-card:hover {
  border-color: var(--primary);
  background: #f7fbff;
}

.entry-card strong {
  font-size: 18px;
}

.entry-card span {
  color: var(--muted);
}

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

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.error {
  color: var(--danger);
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  background: #eef1f5;
  color: var(--muted);
  font-weight: 650;
}

.badge.completed {
  background: #e7f6ee;
  color: var(--ok);
}

.badge.matched {
  background: #dff3e8;
  color: var(--ok);
}

.badge.needs_resolution,
.badge.failed {
  background: #fff4e5;
  color: var(--warn);
}

.badge.processing {
  background: #eaf2ff;
  color: var(--primary-dark);
}

.table-wrap {
  margin-top: 18px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

th {
  background: #f9fafc;
  color: var(--muted);
  font-weight: 650;
}

tr:last-child td {
  border-bottom: 0;
}

tr.row-complete td {
  background: var(--ok-bg);
}

tr.row-warning td {
  background: var(--warn-bg);
}

tr.row-conflict td {
  background: var(--danger-bg);
}

tr.row-processing td {
  background: var(--processing-bg);
}

.filename {
  max-width: 260px;
  overflow-wrap: anywhere;
}

.hidden {
  display: none;
}

.row-actions {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 8px;
}

.page-ocr {
  display: grid;
  grid-template-columns: 58px minmax(220px, 1fr);
  gap: 8px;
  margin: 0 0 6px;
  overflow-wrap: anywhere;
}

.page-ocr.processing {
  color: var(--primary-dark);
}

.page-ocr.queued {
  color: var(--muted);
}

.page-ocr.matched {
  color: var(--ok);
}

.page-ocr.needs_resolution,
.page-ocr.unmatched {
  color: var(--warn);
}

.page-ocr.failed {
  color: var(--danger);
}

.page-index {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.file-progress {
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(105, 115, 134, 0.18);
}

.file-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 180ms ease;
}

.row-complete .file-progress-fill {
  background: var(--ok);
}

.row-warning .file-progress-fill {
  background: var(--warn);
}

.row-conflict .file-progress-fill {
  background: var(--danger);
}

.file-progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.progress-text {
  margin-top: 2px;
  font-size: 12px;
}

@media (max-width: 720px) {
  .topbar {
    padding: 0 16px;
  }

  .shell {
    width: calc(100vw - 20px);
    margin: 16px auto;
  }

  .section-head,
  .status-line,
  .entry-grid {
    align-items: flex-start;
    flex-direction: column;
  }

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