:root {
  --bg: #f4f5f7;
  --surface: #fff;
  --border: #d8dce3;
  --text: #1a1d24;
  --muted: #5c6470;
  --primary: #1e4d8c;
  --primary-hover: #163a6b;
  --error-bg: #fdecea;
  --error-text: #8b1e12;
  --success: #1b6b3a;
  --success-bg: #e8f5ec;
  --warn: #8a5a00;
  --warn-bg: #fff8e6;
  --danger: #a32020;
  --danger-bg: #fdecea;
  --mono: "SF Mono", "Consolas", "Liberation Mono", monospace;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}

.app__header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.app__brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.app__title {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app__context {
  flex: 1;
  color: var(--muted);
  font-size: 0.85rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app__actions {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.app__main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2rem;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.panel--narrow {
  max-width: 420px;
  margin: 2rem auto;
}

.panel__title {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
  font-weight: 600;
}

.panel__subtitle {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.panel__section-title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.banner {
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
}

.banner--error {
  background: var(--error-bg);
  color: var(--error-text);
  border-bottom: 1px solid #f5c4be;
}

.settings {
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.settings.is-open {
  background: var(--warn-bg);
  border-bottom: 2px solid var(--primary);
  box-shadow: var(--shadow);
}

.settings__hint {
  flex: 1 1 100%;
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.field--settings {
  flex: 1 1 280px;
  margin-bottom: 0;
}

.btn.is-active {
  color: var(--primary);
  font-weight: 600;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.field--inline {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0;
}

.field__label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.field__input {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  min-width: 0;
}

.field__input--mono {
  font-family: var(--mono);
  font-size: 0.8rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.85rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  color: var(--text);
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn--primary {
  background: var(--primary);
  color: #fff;
}

.btn--primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn--secondary {
  background: var(--surface);
  border-color: var(--border);
}

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

.btn--ghost:hover:not(:disabled) {
  color: var(--text);
  background: var(--bg);
}

.btn--sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

.btn--block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.link {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.875rem;
}

.link:hover {
  text-decoration: underline;
}

.hint {
  color: var(--warn);
  font-size: 0.85rem;
  margin: 0.5rem 0;
}

.token-panel {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.token-panel summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.875rem;
}

.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

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

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background: #f0f4fa;
}

.dropzone:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.dropzone__label {
  font-weight: 600;
  margin: 0 0 0.25rem;
}

.dropzone__hint {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0 0 0.5rem;
}

.dropzone__meta {
  font-size: 0.8rem;
  color: var(--muted);
  word-break: break-all;
}

.confirm {
  padding: 0.75rem;
  background: var(--warn-bg);
  border: 1px solid #e8d49a;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.confirm p {
  margin: 0 0 0.5rem;
}

/* Selected-PDF list (full width below the upload grid) */
.file-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.file-list__item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: var(--radius);
  background: var(--surface);
}

.file-list__item--invalid {
  border-left-color: var(--danger);
  background: var(--danger-bg);
}

.file-list__kind {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  background: #e3edf9;
  color: var(--primary);
  flex-shrink: 0;
}

.file-list__name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
}

.file-list__size {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.file-list__remove {
  flex-shrink: 0;
}

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

/* Job-level notice (e.g. unused PDFs) — amber, not danger */
.notice {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

/* `display: flex` would otherwise override the `hidden` attribute. */
.notice[hidden],
.file-list[hidden] {
  display: none;
}

.notice--warning {
  background: var(--warn-bg);
  border-color: #e8d49a;
  color: var(--warn);
}

.notice__icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: var(--warn);
  color: var(--warn-bg);
  font-weight: 700;
  font-size: 0.8rem;
  line-height: 1;
}

.notice__title {
  margin: 0 0 0.25rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.notice__text {
  margin: 0;
  font-size: 0.85rem;
}

.notice__list {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  font-size: 0.85rem;
  font-family: var(--mono);
}

.job-header,
.row-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.job-header__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.job-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.job-status__meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.polling-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.state-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.75rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge--pending {
  background: #eef0f3;
  color: #4a5568;
}
.badge--processing,
.badge--evidence {
  background: #e3edf9;
  color: #1e4d8c;
}
.badge--auto,
.badge--approved {
  background: var(--success-bg);
  color: var(--success);
}
.badge--review {
  background: var(--warn-bg);
  color: var(--warn);
}
.badge--rejected,
.badge--failed {
  background: var(--danger-bg);
  color: var(--danger);
}

.chip {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-right: 0.15rem;
}

.chip--match {
  background: var(--success-bg);
  color: var(--success);
}

.chip--mismatch {
  background: var(--danger-bg);
  color: var(--danger);
}

.chip--na {
  background: #eef0f3;
  color: var(--muted);
}

.queue-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.queue-toolbar__pager {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

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

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.table th,
.table td {
  padding: 0.5rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.table th {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.table tbody tr {
  cursor: pointer;
}

.table tbody tr:hover {
  background: #f8f9fb;
}

.table--comparison tbody tr {
  cursor: default;
}

.table--comparison tbody tr:hover {
  background: transparent;
}

.mono {
  font-family: var(--mono);
  font-size: 0.8rem;
  word-break: break-all;
}

.evidence-block {
  margin-bottom: 0.5rem;
  padding: 0.4rem 0.5rem;
  background: #f8f9fb;
  border-radius: 4px;
  font-size: 0.8rem;
}

.evidence-block:last-child {
  margin-bottom: 0;
}

.evidence-missing {
  color: var(--muted);
  font-style: italic;
}

.review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.review-form {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.override-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.voucher-banner {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-weight: 600;
  margin: 0.75rem 0;
}

.voucher-banner--verified {
  background: var(--success-bg);
  color: var(--success);
}

.voucher-banner--warning {
  background: var(--danger-bg);
  color: var(--danger);
}

.pill {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  background: #e3edf9;
  color: var(--primary);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.detail-list {
  display: grid;
  grid-template-columns: minmax(120px, auto) 1fr;
  gap: 0.35rem 1rem;
  margin: 1rem 0;
  font-size: 0.85rem;
}

.detail-list dt {
  color: var(--muted);
  font-weight: 500;
}

.detail-list dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.8rem;
  word-break: break-all;
}

.raw-json pre {
  margin: 0.5rem 0 0;
  padding: 0.75rem;
  background: #1a1d24;
  color: #e8eaed;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.75rem;
  max-height: 400px;
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}
