:root {
  --brand-25: #f8f9fc;
  --brand-50: #f1f2f9;
  --brand-100: #dddfe9;
  --brand-300: #8488b6;
  --brand-500: #2a2d78;
  --brand-600: #121541;
  --brand-700: #0e1034;
  --brand-800: #0a0c28;
  --accent: #f7ec33;
  --accent-50: #fef8b8;
  --link: #1e96fc;
  --paper: #ffffff;
  --neutral-25: #fcfcfd;
  --neutral-50: #f9fafb;
  --neutral-100: #f2f4f7;
  --neutral-200: #eaecf0;
  --neutral-300: #d0d5dd;
  --neutral-500: #667085;
  --neutral-700: #344054;
  --neutral-900: #101828;
  --success: #17b26a;
  --warning: #f79009;
  --error: #f04438;
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--neutral-50);
  color: var(--neutral-900);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 84px;
  padding: 18px 28px;
  background: var(--brand-600);
  color: var(--paper);
  border-bottom: 4px solid var(--accent);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.brand-logo {
  width: 152px;
  height: auto;
  display: block;
}

.eyebrow {
  color: var(--brand-300);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1;
  text-transform: uppercase;
}

.topbar .eyebrow {
  color: var(--accent);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin: 6px 0 0;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: 0;
}

.topbar-actions,
.viewer-actions,
.browser-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button-primary {
  background: var(--accent);
  color: var(--brand-600);
}

.button-secondary {
  background: var(--paper);
  border-color: var(--neutral-300);
  color: var(--brand-600);
}

.button-link {
  background: transparent;
  border-color: var(--neutral-200);
  color: var(--brand-600);
}

.button:focus-visible,
.text-input:focus,
.select-input:focus,
.tab:focus-visible {
  outline: 3px solid rgba(247, 236, 51, 0.55);
  outline-offset: 2px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
  min-height: calc(100vh - 88px);
}

.rail {
  border-right: 1px solid var(--neutral-200);
  background: var(--paper);
  min-height: 100%;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--neutral-200);
  border-bottom: 1px solid var(--neutral-200);
}

.stat-strip > div {
  padding: 16px;
  background: var(--paper);
}

.stat-value {
  display: block;
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  line-height: 1.1;
  font-weight: 700;
  color: var(--brand-600);
}

.stat-date {
  font-size: 13px;
  line-height: 1.2;
}

.stat-label,
.field-label,
.muted-line,
.path-line {
  color: var(--neutral-500);
  font-size: 12px;
  line-height: 1.5;
  font-weight: 500;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 10px;
  gap: 6px;
  border-bottom: 1px solid var(--neutral-200);
}

.tab {
  min-height: 34px;
  border: 1px solid var(--neutral-200);
  border-radius: 6px;
  background: var(--neutral-50);
  color: var(--neutral-700);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.tab.is-active {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: var(--paper);
}

.panel {
  display: none;
  padding: 16px;
}

.panel-active {
  display: block;
}

.text-input,
.select-input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--neutral-300);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--neutral-900);
  background: var(--paper);
}

.text-input {
  margin: 6px 0 12px;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 132px;
  gap: 10px;
  margin-bottom: 12px;
}

.result-list,
.browser-list,
.collection-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-button,
.browser-button,
.collection-button {
  width: 100%;
  text-align: left;
  border: 1px solid var(--neutral-200);
  border-radius: 6px;
  background: var(--paper);
  padding: 10px;
  cursor: pointer;
}

.result-button:hover,
.browser-button:hover,
.collection-button:hover,
.result-button.is-active {
  border-color: var(--brand-300);
  background: var(--brand-25);
}

.result-title,
.browser-title,
.collection-title {
  display: block;
  color: var(--neutral-900);
  font-size: 14px;
  line-height: 1.35;
  font-weight: 600;
}

.result-path,
.result-snippet,
.browser-meta,
.collection-meta {
  display: block;
  margin-top: 4px;
  color: var(--neutral-500);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.chips {
  display: flex;
  gap: 4px;
  margin-top: 7px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--neutral-100);
  color: var(--neutral-700);
  font-size: 11px;
  font-weight: 600;
}

.chip-status-extracted {
  background: #ecfdf3;
  color: #067647;
}

.chip-status-partial,
.chip-status-metadata_only {
  background: #fffaeb;
  color: #b54708;
}

.chip-status-failed {
  background: #fef3f2;
  color: #b42318;
}

.viewer {
  min-width: 0;
  background: var(--neutral-50);
}

.viewer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 28px 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--neutral-200);
}

.viewer h2 {
  margin: 6px 0 0;
  font-size: 24px;
  line-height: 1.25;
  font-weight: 600;
  color: var(--brand-600);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--neutral-200);
  border-bottom: 1px solid var(--neutral-200);
}

.meta-item {
  padding: 12px 16px;
  background: var(--paper);
  min-width: 0;
}

.meta-label {
  display: block;
  color: var(--neutral-500);
  font-size: 11px;
  line-height: 1.4;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.meta-value {
  display: block;
  margin-top: 3px;
  color: var(--neutral-900);
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.viewer-body {
  max-width: 1120px;
  padding: 28px;
}

.document {
  background: var(--paper);
  border: 1px solid var(--neutral-200);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.document h1,
.document h2,
.document h3 {
  color: var(--brand-600);
  letter-spacing: 0;
}

.document h1 {
  font-size: 28px;
  line-height: 1.2;
}

.document h2 {
  margin-top: 28px;
  font-size: 20px;
  line-height: 1.3;
}

.document h3 {
  margin-top: 22px;
  font-size: 16px;
  line-height: 1.4;
}

.document p,
.document li {
  font-size: 14px;
  line-height: 1.65;
  color: var(--neutral-700);
}

.document code,
.mono {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.document pre,
.object-pre {
  overflow: auto;
  max-height: 68vh;
  padding: 16px;
  border-radius: 6px;
  background: var(--brand-800);
  color: var(--paper);
  font-size: 12px;
  line-height: 1.55;
}

.document a {
  color: var(--link);
}

.empty-state,
.large-object {
  margin: 0;
  padding: 22px;
  border: 1px dashed var(--neutral-300);
  border-radius: 8px;
  background: var(--paper);
  color: var(--neutral-500);
}

.pdf-frame {
  width: 100%;
  height: min(72vh, 920px);
  border: 1px solid var(--neutral-200);
  border-radius: 8px;
  background: var(--paper);
}

.image-preview {
  display: block;
  max-width: 100%;
  max-height: 72vh;
  border: 1px solid var(--neutral-200);
  border-radius: 8px;
  background: var(--paper);
}

.browser-toolbar {
  margin-bottom: 10px;
}

.path-line {
  margin-bottom: 12px;
  overflow-wrap: anywhere;
}

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

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

  .rail {
    border-right: 0;
    border-bottom: 1px solid var(--neutral-200);
  }

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

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

  .brand-logo {
    width: 124px;
  }

  .filter-grid,
  .meta-grid {
    grid-template-columns: 1fr;
  }

  .viewer-header {
    flex-direction: column;
    padding: 18px 16px 12px;
  }

  .viewer-body {
    padding: 16px;
  }

  .document {
    padding: 18px;
  }
}
