:root {
  color-scheme: light;
  --ink: #18211e;
  --muted: #66716d;
  --line: #d9dfdc;
  --soft-line: #e9edeb;
  --paper: #ffffff;
  --canvas: #f3f5f4;
  --green: #1f5745;
  --green-soft: #e7f0ec;
  --amber: #9a5b22;
  --amber-soft: #f7eee4;
  --red: #a13c36;
  --red-soft: #f8e9e7;
  --shadow: 0 12px 34px rgba(24, 33, 30, 0.08);
}

* { box-sizing: border-box; }
.live-panel { grid-column: 1 / -1; background: #fff; padding: 22px; border: 1px solid var(--line); border-radius: 6px; }
.live-panel h2 { margin: 0 0 12px; font-size: 16px; }
.live-panel details { border-top: 1px solid var(--line); padding: 12px 0; margin-top: 12px; }
.live-panel summary { cursor: pointer; font-weight: 600; }
.live-panel .muted { color: var(--muted); font-size: 12px; }
.live-counters { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; }
.live-row { padding: 8px 0; border-bottom: 1px solid var(--soft-line); overflow-wrap: anywhere; }
.stage-item.active .stage-index { background: var(--amber); color: white; }
.progress-wrap { min-width: 230px; }
#progressText { width: auto; min-width: 100px; white-space: nowrap; }
.progress-track.indeterminate span { width: 35% !important; animation: working 2s ease-in-out infinite alternate; }
@keyframes working { from { transform: translateX(0); } to { transform: translateX(170%); } }
@media (prefers-reduced-motion: reduce) { .progress-track.indeterminate span { animation: none; } }
[hidden] { display: none !important; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: #fff;
  font-family: SimHei, sans-serif;
  font-size: 18px;
  border-radius: 5px;
}
.brand div { display: grid; gap: 2px; }
.brand strong { font-size: 15px; font-weight: 700; }
.brand span:last-child { color: var(--muted); font-size: 11px; }

.environment {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.environment.ready .status-dot { background: var(--green); }
.environment.warning .status-dot { background: var(--amber); }

.shell { min-height: calc(100vh - 68px); display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.case-rail {
  background: var(--paper);
  border-right: 1px solid var(--line);
  padding: 22px 14px;
}
.rail-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 14px; }
.rail-heading h2, .stage-panel h2, .timeline-panel h2 { margin: 0; font-size: 14px; }
.icon-button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 5px;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}
.icon-button:hover { border-color: var(--green); color: var(--green); }

.case-list { display: grid; gap: 4px; }
.case-item {
  width: 100%;
  display: grid;
  gap: 7px;
  padding: 11px 10px;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  text-align: left;
  cursor: pointer;
  border-radius: 0 5px 5px 0;
}
.case-item:hover { background: #f6f8f7; }
.case-item.active { background: var(--green-soft); border-left-color: var(--green); }
.case-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.45;
  font-weight: 600;
}
.case-item-meta { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; }
.empty-list { color: var(--muted); padding: 16px 10px; line-height: 1.7; }

.workspace { padding: 34px 46px 60px; min-width: 0; }
.new-case-view, .case-view { width: min(1060px, 100%); margin: 0 auto; }
.page-heading { margin-bottom: 24px; }
.eyebrow { margin: 0 0 7px; color: var(--green); font-size: 12px; font-weight: 700; }
h1 { margin: 0; font-family: "Microsoft YaHei", "Segoe UI", sans-serif; font-size: 27px; line-height: 1.35; overflow-wrap: anywhere; }
h2 { letter-spacing: 0; }

.upload-form {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.drop-zone {
  min-height: 236px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 9px;
  border: 1px dashed #aeb8b3;
  background: #fafbfa;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}
.drop-zone.dragging, .drop-zone:hover { border-color: var(--green); background: var(--green-soft); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop-symbol { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--green); color: white; font-size: 22px; }
.drop-zone strong { font-size: 17px; }
.drop-zone > span:last-child { color: var(--muted); font-size: 12px; }

.mode-fieldset { margin: 24px 0 0; padding: 0; border: 0; }
.mode-fieldset legend, .notes-field > span { display: block; margin-bottom: 9px; font-weight: 700; font-size: 13px; }
.segmented-control { display: inline-grid; grid-template-columns: 1fr 1fr; padding: 3px; background: #eef1ef; border-radius: 6px; }
.segmented-control label { cursor: pointer; }
.segmented-control input { position: absolute; opacity: 0; }
.segmented-control span { min-width: 112px; height: 34px; display: grid; place-items: center; color: var(--muted); border-radius: 4px; }
.segmented-control input:checked + span { background: var(--paper); color: var(--ink); box-shadow: 0 1px 5px rgba(24, 33, 30, 0.12); font-weight: 700; }
.field-status { margin-left: 12px; color: var(--muted); font-size: 12px; }
.field-status.warning { color: var(--amber); }

.notes-field { display: block; margin-top: 24px; }
textarea { width: 100%; resize: vertical; min-height: 96px; border: 1px solid var(--line); border-radius: 5px; padding: 12px 13px; color: var(--ink); background: var(--paper); line-height: 1.65; outline: none; }
textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.notes-field input { width:100%; min-height:44px; padding:10px 12px; border:1px solid var(--line); border-radius:5px; background:white; }
.notes-field input:focus { outline:2px solid var(--green); outline-offset:2px; }
.login-page .new-case-view { max-width:520px; margin-top:7vh; }
.form-actions { margin-top: 22px; min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.form-error { color: var(--red); line-height: 1.5; }

.primary-button, .secondary-button, .back-button {
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none;
}
.primary-button { min-height: 40px; padding: 0 19px; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: var(--green); font-weight: 700; }
.primary-button:hover { background: #174637; }
.primary-button:disabled { opacity: 0.55; cursor: wait; }
.secondary-button { min-height: 38px; padding: 0 15px; background: var(--paper); color: var(--ink); border: 1px solid var(--line); }
.secondary-button:hover { border-color: var(--green); color: var(--green); }
.secondary-button.danger:hover { border-color: var(--red); color: var(--red); }
.back-button { padding: 0; margin-bottom: 18px; background: transparent; color: var(--muted); font-size: 12px; }
.back-button:hover { color: var(--green); }

.case-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.case-header > div:first-child { min-width: 0; }
.case-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding-top: 36px; flex: 0 0 auto; }
.status-band { display: flex; align-items: center; justify-content: space-between; gap: 32px; padding: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.status-copy { display: flex; align-items: center; gap: 14px; min-width: 0; }
.status-copy p { margin: 0; color: var(--muted); line-height: 1.5; }
.status-label { flex: 0 0 auto; padding: 5px 9px; background: var(--amber-soft); color: var(--amber); border-radius: 4px; font-size: 12px; font-weight: 700; }
.status-label.completed { background: var(--green-soft); color: var(--green); }
.status-label.failed, .status-label.cancelled { background: var(--red-soft); color: var(--red); }
.progress-wrap { width: 260px; display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.progress-wrap > span { width: 34px; color: var(--muted); font-size: 11px; text-align: right; }
.progress-track { height: 6px; background: #dfe4e1; border-radius: 3px; flex: 1; overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 0; background: var(--green); transition: width 260ms ease; }

.case-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.75fr); gap: 34px; padding: 30px 0; }
.stage-panel { min-width: 0; }
.stage-list { list-style: none; margin: 18px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.stage-item { min-height: 58px; display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; padding: 11px 0; border-bottom: 1px solid var(--soft-line); }
.stage-index { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: #edf0ee; color: var(--muted); font-size: 11px; font-weight: 700; }
.stage-item.complete .stage-index { background: var(--green); color: white; }
.stage-item.running .stage-index { background: var(--amber); color: white; }
.stage-copy { display: grid; gap: 3px; }
.stage-copy strong { font-size: 13px; line-height: 1.35; }
.stage-copy span { color: var(--muted); font-size: 11px; line-height: 1.45; }

.paper-panel { padding-left: 28px; border-left: 1px solid var(--line); }
.paper-preview { aspect-ratio: 0.72; position: relative; overflow: hidden; background: #e7eae8; box-shadow: 0 9px 24px rgba(24, 33, 30, 0.12); }
.paper-preview img { width: 100%; height: 100%; object-fit: contain; background: white; display: none; }
.preview-placeholder { position: absolute; inset: 0; display: grid; place-items: center; font-family: Georgia, serif; font-size: 32px; color: #8b9490; }
.paper-meta { margin: 18px 0 0; display: grid; grid-template-columns: 86px 1fr; gap: 8px 12px; line-height: 1.45; }
.paper-meta dt { color: var(--muted); }
.paper-meta dd { margin: 0; overflow-wrap: anywhere; }

.result-panel { padding: 26px 0; border-top: 1px solid var(--line); }
.result-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.result-heading h2 { margin: 0; font-size: 19px; }
.count-label { color: var(--muted); font-size: 12px; }
.result-conclusion { max-width: 820px; margin: 16px 0 0; font-size: 15px; line-height: 1.85; }
.hash-row { margin-top: 18px; display: grid; grid-template-columns: 130px 1fr; gap: 12px; color: var(--muted); font-size: 11px; }
.hash-row code { color: var(--ink); overflow-wrap: anywhere; }

.timeline-panel { padding-top: 26px; border-top: 1px solid var(--line); }
.timeline { margin-top: 16px; display: grid; }
.timeline-item { display: grid; grid-template-columns: 128px 1fr; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--soft-line); }
.timeline-time { color: var(--muted); font-size: 11px; }
.timeline-message { line-height: 1.55; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .case-rail { border-right: 0; border-bottom: 1px solid var(--line); padding: 14px 18px; }
  .case-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace { padding: 26px 22px 48px; }
  .case-grid { grid-template-columns: 1fr; }
  .paper-panel { padding-left: 0; border-left: 0; display: grid; grid-template-columns: 210px 1fr; gap: 24px; }
}

@media (max-width: 620px) {
  .topbar { padding: 0 15px; }
  .environment span:last-child { display: none; }
  .case-list { grid-template-columns: 1fr; }
  .workspace { padding: 22px 16px 42px; }
  .upload-form { padding: 18px; }
  .drop-zone { min-height: 190px; }
  .field-status { display: block; margin: 9px 0 0; }
  .form-actions, .case-header, .status-band { align-items: stretch; flex-direction: column; }
  .primary-button { width: 100%; }
  .case-actions { padding-top: 0; justify-content: stretch; }
  .case-actions > * { flex: 1; }
  .progress-wrap { width: 100%; }
  .stage-list { grid-template-columns: 1fr; }
  .paper-panel { grid-template-columns: 1fr; }
  .paper-preview { width: min(250px, 100%); }
  .timeline-item { grid-template-columns: 1fr; gap: 3px; }
}
