:root {
  color-scheme: light;
  --background: #ffffff;
  --foreground: #171717;
  --muted-foreground: #666666;
  --border: #e4e4e7;
  --soft-border: #f0f0f0;
  --surface: #ffffff;
  --surface-muted: #fafafa;
  --primary: #18181b;
  --primary-soft: #f4f4f5;
  --success: #16803a;
  --success-soft: #ecfdf3;
  --warning: #a15c07;
  --warning-soft: #fff8e6;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --focus: #2563eb;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.shell {
  width: min(1280px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.page-header h1,
.section-heading h2,
.table-header h3 {
  margin: 0;
  letter-spacing: 0;
}

.page-header h1 {
  font-size: 26px;
  font-weight: 650;
}

.operator-menu {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.operator-menu span {
  color: var(--muted-foreground);
  font-size: 12px;
}

.operator-menu a {
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 650;
  padding: 6px 10px;
}

.page-header p,
.section-heading p,
.metric-card p,
.empty-panel p {
  margin: 4px 0 0;
  color: var(--muted-foreground);
}

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
}

.tab {
  border-bottom: 2px solid transparent;
  color: var(--muted-foreground);
  flex: 0 0 auto;
  font-weight: 550;
  padding: 10px 14px;
}

.tab.active {
  border-bottom-color: var(--primary);
  color: var(--primary);
}

.section-heading,
.table-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.section-heading {
  margin-bottom: 18px;
}

.compact-heading {
  margin-top: 26px;
}

.section-heading h2 {
  font-size: 22px;
  font-weight: 650;
}

.table-header {
  margin: 24px 0 12px;
}

.filter-bar {
  display: grid;
  align-items: end;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px;
}

.submit-grid {
  grid-template-columns:
    minmax(220px, 1.3fr)
    minmax(320px, 1.7fr)
    repeat(2, minmax(140px, 1fr))
    max-content;
}

.batch-grid {
  grid-template-columns:
    minmax(240px, 1.5fr)
    minmax(320px, 1.6fr)
    repeat(2, minmax(140px, 1fr))
    max-content;
}

label {
  color: var(--muted-foreground);
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--foreground);
  background: var(--surface);
  height: 36px;
  padding: 0 10px;
}

textarea {
  min-height: 72px;
  padding: 8px 10px;
  resize: vertical;
}

input[type="file"] {
  padding: 6px 10px;
}

.span-all {
  grid-column: 1 / -1;
}

.field-help {
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 450;
}

button,
.button-link {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: var(--primary);
  color: white;
  cursor: pointer;
  font-weight: 600;
  padding: 0 12px;
}

.button-link:hover {
  text-decoration: none;
}

button.secondary-action,
.button-link.secondary-action {
  background: var(--surface);
  border-color: var(--border);
  color: var(--foreground);
}

.job-layout {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(280px, 420px) 1fr;
}

.image-panel {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: grid;
  min-height: 280px;
  overflow: hidden;
  place-items: center;
}

.image-panel img {
  display: block;
  height: auto;
  max-height: 520px;
  max-width: 100%;
  object-fit: contain;
  width: 100%;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.metric-card,
.empty-panel,
.notice {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.metric-card span {
  color: var(--muted-foreground);
  display: block;
  font-size: 12px;
  font-weight: 600;
}

.metric-card strong {
  display: block;
  font-size: 22px;
  font-weight: 650;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
}

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

th {
  background: var(--surface-muted);
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 650;
}

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

.badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 650;
  padding: 2px 8px;
}

.badge.completed {
  background: var(--success-soft);
  color: var(--success);
}

.badge.failed {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.running,
.badge.queued,
.badge.accepted {
  background: var(--warning-soft);
  color: var(--warning);
}

.decision-flag {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  gap: 6px;
  padding: 3px 9px;
  text-transform: uppercase;
}

.decision-dot {
  border-radius: 999px;
  display: inline-block;
  height: 8px;
  width: 8px;
}

.decision-flag.fake {
  background: var(--danger-soft);
  color: var(--danger);
}

.decision-flag.fake .decision-dot {
  background: var(--danger);
}

.decision-flag.abstain {
  background: var(--warning-soft);
  color: var(--warning);
}

.decision-flag.abstain .decision-dot {
  background: var(--warning);
}

.decision-flag.real {
  background: var(--success-soft);
  color: var(--success);
}

.decision-flag.real .decision-dot {
  background: var(--success);
}

.notice {
  margin-top: 16px;
}

.notice.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.notice.success {
  background: var(--success-soft);
  color: var(--success);
}

.json-output {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
}

@media (max-width: 900px) {
  .submit-grid,
  .batch-grid,
  .job-layout,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .page-header {
    display: block;
  }

  .operator-menu {
    justify-content: flex-start;
    margin-top: 12px;
  }
}
