:root {
  color-scheme: light;
  --bg: #f4f7fa;
  --panel: #ffffff;
  --ink: #172433;
  --muted: #6a7887;
  --line: #d9e2eb;
  --line-strong: #b8c7d6;
  --blue: #005bac;
  --blue-dark: #003f7a;
  --blue-soft: #e9f3ff;
  --green: #1f7a4d;
  --green-soft: #eaf7f0;
  --red: #a62b2b;
  --red-soft: #fff0f0;
  --amber: #8a5d00;
  --amber-soft: #fff7e6;
  --shadow: 0 12px 30px rgba(20, 36, 56, .08);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, "Microsoft JhengHei", "PingFang TC", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

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

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

a:hover {
  text-decoration: underline;
}

.site-header {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand img {
  width: 150px;
  height: auto;
  display: block;
}

.brand strong {
  display: block;
  color: var(--blue-dark);
  font-size: 17px;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quiet-link {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 11px;
  border-radius: 6px;
  color: #34495f;
  font-weight: 700;
}

.quiet-link.active,
.quiet-link:hover {
  background: var(--blue-soft);
  color: var(--blue-dark);
  text-decoration: none;
}

body[data-page="staff"] .quiet-link {
  display: none;
}

.page {
  width: min(1120px, calc(100vw - 40px));
  margin: 28px auto 48px;
}

.staff-layout,
.debug-layout {
  display: grid;
  gap: 18px;
}

.upload-panel,
.jobs-panel,
.debug-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.upload-panel {
  padding: 24px;
}

.panel-title {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.25;
}

h2 {
  font-size: 18px;
  line-height: 1.35;
}

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

.upload-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 14px;
  align-items: stretch;
}

.upload-form.is-running {
  grid-template-columns: minmax(0, 1fr) 170px 170px;
}

.drop-zone {
  min-height: 132px;
  display: grid;
  place-items: center;
  gap: 8px;
  border: 2px dashed #9dbfe0;
  border-radius: 8px;
  background: linear-gradient(180deg, #f4f9ff, #ffffff);
  color: var(--blue-dark);
  text-align: center;
  cursor: pointer;
}

.drop-zone:hover {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(0, 91, 172, .1);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-main {
  display: block;
  font-size: 20px;
  font-weight: 800;
}

.drop-hint {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.primary-button,
.secondary-button,
.download-button,
.stop-button,
.logout-button {
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  min-height: 42px;
  padding: 0 14px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  height: 132px;
  background: var(--blue);
  border-color: #07569b;
  color: #fff;
  font-size: 18px;
}

.stop-button {
  background: var(--red);
  border-color: #8f2020;
  color: #fff;
}

.stop-button:hover {
  background: #7f1f1f;
}

.stop-button.large {
  height: 132px;
  font-size: 17px;
}

.primary-button:hover,
.download-button:hover {
  background: var(--blue-dark);
  text-decoration: none;
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: .62;
}

.secondary-button {
  background: #fff;
  color: var(--ink);
}

.secondary-button:hover {
  border-color: var(--blue);
}

.logout-button {
  background: #fff;
  color: #34495f;
}

.logout-button:hover {
  border-color: var(--blue);
  color: var(--blue-dark);
}

.queue-message {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #bad3ec;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-weight: 800;
}

.jobs-panel {
  padding: 18px;
}

.section-head,
.debug-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.debug-head {
  margin-bottom: 0;
  padding: 20px 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.staff-job {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(250px, .9fr) 140px;
  gap: 12px;
  align-items: center;
  min-height: 78px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.staff-job.processing {
  border-color: #b9d6f3;
  background: #fbfdff;
}

.staff-job.review {
  border-color: #ead29a;
  background: #fffdf8;
}

.staff-job.fail {
  border-color: #efc4c4;
  background: #fffafa;
}

.staff-job.canceled {
  border-color: #ead29a;
  background: #fffdf8;
}

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

.job-main strong {
  overflow-wrap: anywhere;
}

.job-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.progress-block {
  width: 100%;
  display: grid;
  gap: 6px;
  min-width: 0;
}

.progress-line,
.progress-detail {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.progress-line span:first-child {
  color: var(--ink);
  font-weight: 800;
}

.progress-line span,
.progress-detail span {
  overflow-wrap: anywhere;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfeaf4;
}

.progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), #2f8ac7);
  transition: width .35s ease;
}

.progress-detail {
  color: var(--muted);
  font-size: 12px;
}

.job-download {
  justify-self: end;
}

.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--blue);
  border-color: #07569b;
  color: #fff;
}

.plain-note {
  color: var(--muted);
  font-size: 13px;
}

.danger,
.plain-note.danger {
  color: var(--red);
}

.empty-state {
  display: grid;
  gap: 6px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #fbfdff;
}

.empty-state strong {
  color: var(--ink);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f7fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-badge.ok {
  color: var(--green);
  background: var(--green-soft);
  border-color: #badfc9;
}

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

.status-badge.review {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: #ead29a;
}

.status-badge.fail {
  color: var(--red);
  background: var(--red-soft);
  border-color: #efc4c4;
}

.status-badge.canceled {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: #ead29a;
}

.status-badge.neutral {
  color: var(--muted);
}

.review-note {
  color: var(--amber);
  font-weight: 800;
}

.debug-layout {
  width: min(1360px, calc(100vw - 40px));
  margin-left: 50%;
  transform: translateX(-50%);
}

.debug-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.debug-card {
  padding: 18px;
  overflow: hidden;
}

.debug-card h2 {
  margin-bottom: 12px;
}

.kv-list {
  display: grid;
  gap: 8px;
}

.kv-list div {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdff;
}

.kv-list span {
  color: var(--muted);
  font-size: 13px;
}

.kv-list strong {
  overflow-wrap: anywhere;
}

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

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  table-layout: fixed;
}

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

th {
  background: #f3f7fb;
  color: #263542;
  font-size: 12px;
  font-weight: 800;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.debug-error {
  margin-top: 6px;
  color: var(--red);
  font-size: 12px;
}

.debug-links,
.debug-gates {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.debug-links a,
.debug-gates span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #f8fbfe;
  font-size: 12px;
  font-weight: 700;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: var(--bg);
}

.login-shell {
  width: min(420px, 100%);
}

.login-panel {
  display: grid;
  gap: 16px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel img {
  width: 170px;
  height: auto;
}

.login-panel h1 {
  font-size: 24px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 800;
}

.login-form input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
}

.login-submit {
  height: 48px;
  font-size: 16px;
}

.login-message {
  color: var(--red);
  font-weight: 800;
}

@media (max-width: 860px) {
  .site-header,
  .section-head,
  .debug-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .page,
  .debug-layout {
    width: min(100vw - 24px, 1120px);
    margin-top: 18px;
  }

  .upload-form,
  .staff-job,
  .debug-grid {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .stop-button.large {
    height: 54px;
  }

  .job-download {
    justify-self: stretch;
  }

  .download-button {
    width: 100%;
  }
}

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

  .brand img {
    width: 136px;
  }

  .header-actions {
    flex-wrap: wrap;
  }

  h1 {
    font-size: 23px;
  }

  .upload-panel,
  .jobs-panel,
  .debug-card {
    padding: 14px;
  }
}
