:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-soft: #eef2f6;
  --surface-strong: #101820;
  --ink: #17202a;
  --muted: #687384;
  --line: #dce2ea;
  --green: #169d68;
  --green-soft: #e4f7ee;
  --red: #d94a4a;
  --red-soft: #fde8e8;
  --amber: #d58a11;
  --amber-soft: #fff3d8;
  --blue: #2878d8;
  --blue-soft: #e6f0ff;
  --shadow: 0 18px 46px rgba(24, 34, 48, 0.08);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(16, 24, 32, 0.04), transparent 260px),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(230px, 0.8fr) minmax(280px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px clamp(16px, 3vw, 32px);
  color: #f8fbff;
  background: rgba(16, 24, 32, 0.96);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

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

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  color: #101820;
  background: linear-gradient(135deg, #32b67a, #f3b23a);
  border-radius: var(--radius);
  font-weight: 850;
}

.brand-title,
.brand-subtitle {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-title {
  font-size: 1rem;
  font-weight: 780;
}

.brand-subtitle {
  margin-top: 2px;
  color: rgba(248, 251, 255, 0.68);
  font-size: 0.78rem;
}

.search-box {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: rgba(248, 251, 255, 0.74);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
}

.search-box input {
  width: 100%;
  min-width: 0;
  color: #ffffff;
  background: transparent;
  border: 0;
  outline: 0;
}

.search-box input::placeholder {
  color: rgba(248, 251, 255, 0.52);
}

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

.status-pill,
.mode-pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  color: rgba(248, 251, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  white-space: nowrap;
}

.mode-pill {
  background: rgba(255, 255, 255, 0.08);
}

.layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr) 310px;
  gap: 16px;
  align-items: start;
  padding: 18px clamp(16px, 3vw, 32px) 30px;
}

.rail {
  position: sticky;
  top: 86px;
  display: grid;
  gap: 14px;
  min-width: 0;
}

.workspace {
  display: grid;
  gap: 14px;
  min-width: 0;
}

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

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

.count-badge {
  padding: 2px 7px;
  color: var(--muted);
  background: var(--surface-soft);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.drop-zone {
  display: grid;
  gap: 8px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
  background: #fbfcfe;
  border: 1px dashed #b8c5d6;
  border-radius: var(--radius);
  transition:
    border-color 140ms ease,
    background 140ms ease;
}

.drop-zone.is-over {
  background: var(--blue-soft);
  border-color: rgba(40, 120, 216, 0.55);
}

.upload-title {
  color: var(--ink);
  font-weight: 820;
}

.upload-copy {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.file-input {
  width: 100%;
}

.form-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
}

.field select,
.field input[type="text"] {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  color: var(--ink);
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: 0;
}

.check-row {
  display: grid;
  gap: 9px;
}

.check-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 690;
}

.command-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.command-button,
.mini-button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-weight: 760;
}

.command-button.primary {
  color: #ffffff;
  background: var(--blue);
  border-color: var(--blue);
}

.command-button:disabled,
.mini-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.mini-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.82rem;
}

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

.summary-item {
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.summary-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 720;
}

.summary-value {
  margin-top: 6px;
  overflow-wrap: anywhere;
  font-weight: 780;
}

.hero-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.instrument-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 9px;
  margin: 0;
  font-size: clamp(1.34rem, 2vw, 1.9rem);
  line-height: 1.2;
}

.instrument-title small {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 640;
}

.instrument-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 9px;
}

.metric-chip,
.tag {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.tag.good {
  color: #0f5132;
  background: var(--green-soft);
  border-color: rgba(22, 157, 104, 0.16);
}

.tag.warn {
  color: #6d4b0c;
  background: var(--amber-soft);
  border-color: rgba(213, 138, 17, 0.28);
}

.tag.bad {
  color: #7a2020;
  background: var(--red-soft);
  border-color: rgba(217, 74, 74, 0.26);
}

.progress-card {
  display: grid;
  min-width: 168px;
  padding: 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.progress-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 730;
}

.progress-value {
  margin-top: 4px;
  font-size: 1.72rem;
  line-height: 1;
  font-weight: 820;
}

.progress-copy {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.78rem;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  background: var(--surface-soft);
  border-radius: 999px;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--green), var(--blue));
  border-radius: inherit;
  transition: width 180ms ease;
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs button {
  min-height: 36px;
  padding: 0 13px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.86rem;
  font-weight: 760;
  white-space: nowrap;
}

.tabs button.is-active {
  color: #ffffff;
  background: var(--surface-strong);
  border-color: var(--surface-strong);
}

.preview-box {
  max-height: 560px;
  min-height: 420px;
  margin: 0;
  overflow: auto;
  padding: 14px;
  color: #17202a;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font:
    0.88rem/1.62 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.line-table {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.line-row {
  display: grid;
  grid-template-columns: 64px 70px minmax(0, 1fr) 92px;
  gap: 8px;
  align-items: start;
  padding: 9px 10px;
  background: #fbfcfe;
  border-bottom: 1px solid var(--line);
  font-size: 0.84rem;
}

.line-row:last-child {
  border-bottom: 0;
}

.line-row.is-head {
  color: var(--muted);
  background: var(--surface-soft);
  font-weight: 790;
}

.line-text {
  overflow-wrap: anywhere;
}

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

.job-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 11px;
  text-align: left;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.job-row:hover,
.job-row.is-active {
  border-color: rgba(40, 120, 216, 0.45);
  box-shadow: 0 10px 28px rgba(40, 120, 216, 0.09);
}

.job-name {
  overflow: hidden;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.empty-state {
  padding: 20px;
  color: var(--muted);
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

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

.hint-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hint-list li {
  padding: 10px;
  color: var(--muted);
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.86rem;
  line-height: 1.5;
}

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

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .rail.right {
    position: static;
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
  }

  .top-actions {
    justify-content: space-between;
  }

  .layout {
    display: block;
    padding: 12px;
  }

  .rail {
    position: static;
    margin-bottom: 12px;
  }

  .rail.right {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .workspace {
    margin-bottom: 12px;
  }

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

  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  :root {
    font-size: 14px;
  }

  .summary-strip,
  .export-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .line-row {
    grid-template-columns: 46px 50px minmax(0, 1fr);
  }

  .line-row span:nth-child(4) {
    display: none;
  }
}
