:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --surface-muted: #eef2f5;
  --line: #d9e0e7;
  --line-strong: #bdc8d4;
  --text: #16181d;
  --muted: #657083;
  --muted-strong: #4c5868;
  --blue: #2563eb;
  --blue-strong: #1d4ed8;
  --blue-soft: #e9f0ff;
  --green: #0f8f69;
  --green-soft: #e7f7f1;
  --amber: #a86b00;
  --amber-soft: #fff4d6;
  --red: #b42318;
  --red-soft: #fff0ee;
  --shadow: 0 18px 42px rgba(20, 28, 38, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #ffffff 0, var(--bg) 260px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button,
select,
label {
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 68px;
  padding: 0 28px;
  border-bottom: 1px solid rgba(217, 224, 231, 0.9);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
}

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

.brand-mark {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--text);
  color: #ffffff;
  font-size: 12px;
  font-weight: 780;
}

.brand-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-text strong {
  font-size: 15px;
  font-weight: 780;
  line-height: 1.1;
}

.brand-text small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.topbar-meta span,
.workbench-model,
.status,
.counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 720;
  line-height: 1;
}

.topbar-meta span {
  max-width: 220px;
  padding: 0 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page {
  width: min(1180px, calc(100vw - 32px));
  margin: 30px auto 64px;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(320px, 410px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.upload-workbench,
.job-detail {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.upload-workbench {
  position: sticky;
  top: 92px;
  padding: 22px;
}

.workbench-head,
.board-head,
.detail-head,
.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.workbench-head {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 780;
  line-height: 1.2;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  font-weight: 780;
  line-height: 1.12;
}

h2 {
  font-size: 18px;
  font-weight: 760;
  line-height: 1.25;
}

p {
  color: var(--muted);
  line-height: 1.5;
}

.workbench-model {
  flex: 0 0 auto;
  padding: 0 10px;
  background: var(--surface-soft);
}

.drop-zone {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 8px 14px;
  align-items: center;
  min-height: 138px;
  padding: 22px;
  border: 1px dashed #9ba9b8;
  border-radius: var(--radius);
  background: var(--surface-soft);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--blue);
  background: #f6f9ff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.09);
}

.drop-zone input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.drop-zone input:focus-visible + .drop-icon {
  outline: 3px solid rgba(37, 99, 235, 0.25);
  outline-offset: 3px;
}

.drop-icon {
  display: grid;
  grid-row: span 2;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--blue);
  color: #ffffff;
  font-size: 24px;
  font-weight: 740;
  line-height: 1;
}

.drop-title {
  min-width: 0;
  overflow: hidden;
  font-size: 17px;
  font-weight: 760;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drop-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 620;
  line-height: 1.35;
}

.controls-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.8fr) minmax(180px, 1.2fr) 150px;
  gap: 12px;
  margin-top: 16px;
  align-items: end;
}

.field {
  display: grid;
  gap: 7px;
}

.field-label {
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 720;
}

select,
.primary-button {
  width: 100%;
  min-height: 44px;
  border-radius: var(--radius);
}

select {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  padding: 0 12px;
}

select:focus-visible,
.primary-button:focus-visible,
.downloads a:focus-visible,
.queue-item:focus-visible,
.crumb a:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: var(--blue);
  color: #ffffff;
  padding: 0 16px;
  font-weight: 760;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
}

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

.primary-button:active {
  transform: translateY(1px);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.workbench-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.workbench-footer span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--muted-strong);
  padding: 0 8px;
  font-size: 11px;
  font-weight: 780;
}

.workbench-footer span:first-child {
  background: var(--blue-soft);
  color: var(--blue-strong);
}

.queue-board {
  min-width: 0;
}

.board-head {
  margin-bottom: 14px;
}

.counter {
  min-width: 34px;
  padding: 0 9px;
}

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

.queue-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 148px;
  gap: 10px 18px;
  align-items: center;
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px 16px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.queue-item:hover {
  border-color: var(--line-strong);
  box-shadow: 0 10px 28px rgba(20, 28, 38, 0.07);
  transform: translateY(-1px);
}

.queue-file {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.queue-file strong {
  overflow: hidden;
  font-size: 15px;
  font-weight: 760;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-file span,
.queue-status span:last-child,
.queue-progress span,
.pending-result {
  color: var(--muted);
  font-size: 13px;
  font-weight: 620;
}

.queue-status {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.status {
  min-width: 88px;
  padding: 0 10px;
}

.status-running,
.status-queued {
  border-color: #efd28e;
  background: var(--amber-soft);
  color: var(--amber);
}

.status-completed {
  border-color: #a6dbc8;
  background: var(--green-soft);
  color: var(--green);
}

.status-failed {
  border-color: #efb1aa;
  background: var(--red-soft);
  color: var(--red);
}

.queue-progress {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.progress {
  overflow: hidden;
  height: 7px;
  border-radius: 999px;
  background: #e4eaf0;
}

.progress div {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), #14a38b);
  transition: width 0.25s ease;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 160px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 680;
}

.job-detail {
  padding: 24px;
}

.crumb {
  margin-bottom: 18px;
  color: var(--muted-strong);
  font-size: 14px;
  font-weight: 720;
}

.crumb a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 6px;
}

.detail-head {
  align-items: flex-start;
}

.detail-head h1 {
  max-width: 780px;
  overflow-wrap: anywhere;
}

.detail-head p:not(.eyebrow) {
  margin-top: 8px;
}

.progress-large {
  height: 10px;
  margin: 22px 0;
}

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

.metrics div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 13px 14px;
}

.metrics dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
  line-height: 1.2;
}

.metrics dd {
  margin: 7px 0 0;
  overflow: hidden;
  color: var(--text);
  font-size: 17px;
  font-weight: 780;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-area {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

.section-title {
  display: block;
  margin-bottom: 12px;
}

.downloads {
  display: grid;
  gap: 8px;
}

.downloads a,
.pending-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 9px 11px;
  font-weight: 780;
}

.downloads a:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.downloads a span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 660;
}

.pending-result {
  justify-content: center;
  border-style: dashed;
  background: var(--surface-soft);
}

.preview-block {
  min-width: 0;
}

pre {
  min-height: 260px;
  max-height: 58vh;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101318;
  color: #f1f5f9;
  padding: 16px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.error-box {
  margin-bottom: 18px;
  border: 1px solid #efb1aa;
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--red-soft);
  color: var(--red);
  font-weight: 680;
}

.is-hidden {
  display: none;
}

@media (max-width: 900px) {
  .dashboard,
  .result-area,
  .metrics {
    grid-template-columns: 1fr;
  }

  .upload-workbench {
    position: static;
  }

  .queue-item {
    grid-template-columns: minmax(0, 1fr);
  }

  .queue-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 14px;
  }

  .topbar {
    align-items: flex-start;
    min-height: 84px;
    padding: 12px 16px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .topbar-meta {
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
  }

  .topbar-meta span {
    max-width: 42vw;
  }

  .page {
    width: min(100% - 24px, 1180px);
    margin-top: 18px;
  }

  .upload-workbench,
  .job-detail {
    padding: 18px;
  }

  .workbench-head,
  .detail-head {
    display: grid;
  }

  h1 {
    font-size: 25px;
  }

  .drop-zone {
    grid-template-columns: 40px minmax(0, 1fr);
    min-height: 126px;
    padding: 18px;
  }

  .drop-icon {
    width: 40px;
    height: 40px;
  }

  .controls-row {
    grid-template-columns: 1fr;
  }

  .queue-item {
    padding: 13px;
  }

  .metrics dd {
    white-space: normal;
  }
}
