:root {
  color-scheme: light;
  --canvas: #f5f7f8;
  --surface: #ffffff;
  --surface-muted: #eef2f3;
  --ink: #172328;
  --ink-soft: #52636a;
  --line: #d8e0e3;
  --line-strong: #bdcace;
  --teal: #087d75;
  --teal-dark: #05645e;
  --teal-soft: #e5f4f1;
  --blue: #315f9a;
  --blue-soft: #eaf0f8;
  --amber: #a65f0b;
  --amber-soft: #fff3df;
  --red: #b33a3a;
  --red-soft: #fcecec;
  --green: #157448;
  --green-soft: #e7f5ed;
  --shadow: 0 7px 24px rgba(23, 35, 40, 0.07);
  --radius: 8px;
  --focus: 0 0 0 3px rgba(8, 125, 117, 0.2);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(49, 95, 154, 0.025) 1px, transparent 1px) 0 0 / 32px 32px,
    var(--canvas);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button,
.button,
.dropzone {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.shell {
  width: min(100% - 40px, 1240px);
  margin-inline: auto;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 68px;
  border-bottom: 1px solid rgba(189, 202, 206, 0.8);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.header-inner {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  text-decoration: none;
}

.brand:focus-visible,
.button:focus-visible,
button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 7px;
  color: #fff;
  background: var(--teal);
}

.brand-mark svg {
  width: 23px;
  height: 23px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
  line-height: 1.2;
}

.brand small {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 650;
  line-height: 1.2;
  text-transform: uppercase;
}

.system-state {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 12px;
  white-space: nowrap;
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #96a4aa;
  box-shadow: 0 0 0 3px rgba(150, 164, 170, 0.15);
}

.health-dot.is-online {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(21, 116, 72, 0.13);
}

.health-dot.is-offline {
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(179, 58, 58, 0.12);
}

.mode-badge,
.version,
.format-label,
.job-count {
  border: 1px solid var(--line);
  color: var(--ink-soft);
  background: var(--surface-muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 22px;
}

.mode-badge {
  min-height: 24px;
  padding: 0 9px;
  border-color: #b9ddd7;
  border-radius: 999px;
  color: var(--teal-dark);
  background: var(--teal-soft);
}

.version {
  min-height: 22px;
  padding-inline: 7px;
  border-radius: 4px;
}

.workspace {
  padding-block: 32px 52px;
}

.page-heading,
.panel-heading,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-heading {
  min-height: 52px;
  margin-bottom: 20px;
}

.eyebrow,
.section-index {
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 2px;
}

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

h1,
h2 {
  margin: 0;
  line-height: 1.25;
}

h1 {
  font-size: 24px;
  font-weight: 760;
}

h2 {
  font-size: 16px;
  font-weight: 750;
}

.icon-button,
.clear-file {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink-soft);
  background: var(--surface);
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.icon-button:hover,
.clear-file:hover {
  border-color: var(--line-strong);
  color: var(--teal-dark);
  background: var(--teal-soft);
}

.icon-button.is-loading svg {
  animation: spin 800ms linear infinite;
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  gap: 18px;
  align-items: stretch;
}

.panel {
  min-width: 0;
  min-height: 392px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-heading {
  min-height: 34px;
  margin-bottom: 20px;
}

.panel-heading > div,
.section-heading > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-index {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 5px;
  background: var(--teal-soft);
}

.format-label,
.job-count {
  min-height: 26px;
  padding-inline: 9px;
  border-radius: 4px;
  line-height: 24px;
}

.dropzone {
  min-height: 204px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 11px;
  padding: 24px;
  border: 1.5px dashed #9eb8bd;
  border-radius: 7px;
  text-align: center;
  background: #f8fbfb;
  transition: border-color 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.dropzone.is-dragging {
  border-color: var(--teal);
  background: var(--teal-soft);
  box-shadow: inset 0 0 0 1px var(--teal);
}

.upload-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid #b9ddd7;
  border-radius: 7px;
  color: var(--teal-dark);
  background: var(--teal-soft);
}

.upload-icon svg {
  width: 23px;
  height: 23px;
}

.dropzone-copy strong,
.dropzone-copy span {
  display: block;
}

.dropzone-copy strong {
  font-size: 16px;
}

.dropzone-copy span {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 13px;
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 720;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.button-primary {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
}

.button-primary:hover {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
}

.button-secondary {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line-strong);
}

.button-secondary:hover {
  color: var(--teal-dark);
  border-color: #8ebbb5;
  background: var(--teal-soft);
}

.button[disabled],
button[disabled] {
  cursor: not-allowed;
  opacity: 0.52;
}

.submit-button {
  width: 100%;
  margin-top: 14px;
}

.selected-file {
  min-height: 54px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  margin-top: 12px;
  padding: 6px 6px 6px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
}

.selected-file > svg {
  color: var(--blue);
}

.selected-file strong,
.selected-file small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-file strong {
  font-size: 13px;
}

.selected-file small {
  color: var(--ink-soft);
  font-size: 11px;
}

.clear-file {
  border-color: transparent;
  background: transparent;
}

.form-error {
  margin: 10px 0 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 650;
}

.status-badge {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding-inline: 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.status-idle {
  color: var(--ink-soft);
  background: var(--surface-muted);
}

.status-pending {
  border-color: #eed3a9;
  color: var(--amber);
  background: var(--amber-soft);
}

.status-processing {
  border-color: #bfd0e7;
  color: var(--blue);
  background: var(--blue-soft);
}

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

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

.empty-current {
  min-height: 290px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  color: var(--ink-soft);
  text-align: center;
}

.empty-current svg {
  width: 38px;
  height: 38px;
  color: #8da0a7;
}

.empty-current p {
  max-width: 260px;
  margin: 0;
  font-size: 13px;
}

.current-job {
  min-height: 290px;
}

.job-fileline {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.file-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 6px;
  color: #fff;
  background: var(--blue);
  font-size: 10px;
  font-weight: 800;
}

.job-fileline > div {
  min-width: 0;
}

.job-fileline > div strong,
.job-fileline > div span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-fileline > div strong {
  font-size: 14px;
}

.job-fileline > div span {
  margin-top: 2px;
  color: var(--ink-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}

.progress-track {
  position: relative;
  height: 6px;
  margin-top: 26px;
  overflow: hidden;
  border-radius: 4px;
  background: #e3e9eb;
}

.progress-track > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
  transition: width 240ms ease;
}

.progress-track.is-indeterminate > span {
  width: 35%;
  animation: progress-slide 1.25s ease-in-out infinite;
}

.progress-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 0;
  margin: 12px 0 0;
  list-style: none;
}

.progress-steps li {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--ink-soft);
  font-size: 10px;
  white-space: nowrap;
}

.progress-steps li:nth-child(2) {
  justify-content: center;
}

.progress-steps li:last-child {
  justify-content: flex-end;
}

.progress-steps li > span {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #c5d0d3;
}

.progress-steps li.is-active {
  color: var(--ink);
  font-weight: 700;
}

.progress-steps li.is-active > span {
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 125, 117, 0.14);
}

.progress-steps li.is-done > span {
  background: var(--green);
}

.job-message {
  min-height: 24px;
  margin: 20px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.job-message.is-error {
  color: var(--red);
}

.summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.summary-item {
  min-height: 29px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink-soft);
  background: var(--surface-muted);
  font-size: 11px;
}

.summary-item strong {
  color: var(--ink);
  font-size: 13px;
}

.job-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 9px;
  margin-top: 18px;
}

.jobs-section {
  margin-top: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-heading {
  min-height: 34px;
  margin-bottom: 17px;
}

.jobs-header,
.job-row {
  display: grid;
  grid-template-columns: minmax(240px, 1.7fr) minmax(112px, 0.65fr) minmax(160px, 0.85fr) minmax(200px, 1fr);
  gap: 16px;
  align-items: center;
}

.jobs-header {
  min-height: 36px;
  padding: 0 14px;
  border-block: 1px solid var(--line);
  color: var(--ink-soft);
  background: var(--surface-muted);
  font-size: 11px;
  font-weight: 750;
}

.jobs-list {
  padding: 0;
  margin: 0;
  list-style: none;
}

.job-row {
  min-height: 72px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  transition: background-color 180ms ease;
}

.job-row:hover {
  background: #f8fafa;
}

.job-cell {
  min-width: 0;
}

.job-cell-file {
  display: flex;
  align-items: center;
  gap: 10px;
}

.job-cell-file .file-mark {
  width: 36px;
  height: 36px;
}

.job-cell-file > div {
  min-width: 0;
}

.job-cell-file strong,
.job-cell-file small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-cell-file strong {
  font-size: 13px;
}

.job-cell-file small {
  color: var(--ink-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}

.job-date {
  color: var(--ink-soft);
  font-size: 12px;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.row-action {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink-soft);
  background: var(--surface);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: color 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.row-action:hover {
  color: var(--teal-dark);
  border-color: #8ebbb5;
  background: var(--teal-soft);
}

.row-action svg {
  width: 16px;
  height: 16px;
}

.row-message {
  color: var(--ink-soft);
  font-size: 12px;
}

.row-message.is-error {
  color: var(--red);
}

.jobs-empty,
.jobs-loading {
  min-height: 150px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 13px;
}

.jobs-empty svg {
  width: 34px;
  height: 34px;
  color: #8da0a7;
}

.jobs-empty p {
  margin: 0;
}

.jobs-loading {
  grid-auto-flow: column;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #c7d3d6;
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 750ms linear infinite;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  max-width: min(380px, calc(100vw - 40px));
  padding: 11px 14px;
  border: 1px solid #b9ddd7;
  border-radius: 6px;
  color: var(--teal-dark);
  background: var(--teal-soft);
  box-shadow: 0 10px 30px rgba(23, 35, 40, 0.15);
  font-size: 13px;
  font-weight: 650;
}

.toast.is-error {
  border-color: #efc0c0;
  color: var(--red);
  background: var(--red-soft);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes progress-slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(310%); }
}

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

  .panel {
    min-height: auto;
  }

  .jobs-header {
    display: none;
  }

  .job-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 9px 14px;
    padding-block: 14px;
  }

  .job-cell-file {
    grid-column: 1;
    grid-row: 1;
  }

  .job-cell-status {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
  }

  .job-cell-date {
    grid-column: 1;
    grid-row: 2;
    padding-left: 46px;
  }

  .job-cell-actions {
    grid-column: 1 / -1;
    grid-row: 3;
    padding-left: 46px;
  }

  .row-actions {
    justify-content: flex-start;
  }
}

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

  .shell {
    width: min(100% - 28px, 1240px);
  }

  .app-header,
  .header-inner {
    min-height: 62px;
  }

  .brand small,
  .version,
  .system-state > #healthText {
    display: none;
  }

  .brand strong {
    font-size: 14px;
  }

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

  .system-state {
    gap: 7px;
  }

  .workspace {
    padding-block: 22px 36px;
  }

  .page-heading {
    margin-bottom: 15px;
  }

  h1 {
    font-size: 21px;
  }

  .panel,
  .jobs-section {
    padding: 17px;
  }

  .panel-heading {
    margin-bottom: 16px;
  }

  .dropzone {
    min-height: 220px;
    padding: 20px 14px;
  }

  .dropzone-copy span {
    font-size: 12px;
  }

  .job-actions {
    grid-template-columns: 1fr;
  }

  .progress-steps li {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    white-space: normal;
    line-height: 1.25;
  }

  .progress-steps li:nth-child(2) {
    align-items: center;
  }

  .progress-steps li:last-child {
    align-items: flex-end;
    text-align: right;
  }

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

  .job-cell-file,
  .job-cell-status,
  .job-cell-date,
  .job-cell-actions {
    grid-column: 1;
    grid-row: auto;
    padding-left: 0;
  }

  .job-cell-status {
    position: absolute;
    right: 17px;
  }

  .job-row {
    position: relative;
  }

  .job-cell-file {
    padding-right: 96px;
  }

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

  .row-action {
    width: 100%;
  }

  .toast {
    right: 14px;
    bottom: 14px;
    max-width: calc(100vw - 28px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
