:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-muted: #eef3f8;
  --ink: #17202a;
  --muted: #607086;
  --line: #d9e1ea;
  --accent: #256f6c;
  --accent-strong: #164c4a;
  --warn: #b7791f;
  --danger: #b83232;
  --ok: #2f855a;
  --shadow: 0 18px 50px rgba(22, 37, 56, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background: var(--bg);
}

button,
input {
  font: inherit;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 247, 251, 0.94);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.45rem;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.7rem;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.05rem;
  letter-spacing: 0;
}

h4 {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  letter-spacing: 0;
}

.page-tabs {
  display: inline-flex;
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.tab-button,
.primary-action,
.secondary-action {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 800;
}

.tab-button {
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
}

.tab-button.is-active {
  color: #fff;
  background: var(--accent);
}

.primary-action,
.secondary-action {
  padding: 0 16px;
}

.primary-action {
  color: #fff;
  background: var(--accent);
}

.secondary-action {
  color: var(--accent-strong);
  border-color: #a8c8c6;
  background: #eef8f7;
}

.app-shell {
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto;
  padding: 26px 0 56px;
}

.flow-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.flow-step {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.flow-step span {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--accent-strong);
  background: #e3f2f1;
  font-weight: 900;
}

.flow-step h2 {
  margin-bottom: 4px;
  font-size: 1rem;
}

.flow-step p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.flow-step.is-active {
  border-color: rgba(37, 111, 108, 0.55);
  box-shadow: 0 16px 45px rgba(37, 111, 108, 0.12);
}

.flow-step.is-active span {
  color: #fff;
  background: var(--accent);
}

.page-panel {
  display: none;
}

.page-panel.is-active {
  display: block;
}

.panel-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.panel-actions {
  display: flex;
  align-items: end;
  gap: 12px;
}

.panel-actions label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.text-input {
  width: 190px;
  min-height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
}

.helper-text {
  max-width: 980px;
  margin-bottom: 18px;
  color: var(--muted);
  line-height: 1.75;
}

.progress-summary {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  margin-bottom: 4px;
  padding: 0 12px;
  border: 1px solid #cdd9e5;
  border-radius: 7px;
  color: var(--muted);
  background: #fbfdff;
  font-weight: 800;
}

.progress-summary.is-complete {
  color: var(--ok);
  border-color: rgba(47, 133, 90, 0.38);
  background: #eefaf3;
}

.upload-section {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-title {
  padding-top: 4px;
}

.section-title h3 {
  display: inline;
}

.progress-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  margin-left: 8px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--warn);
  background: #fff8ea;
  font-size: 0.78rem;
  font-weight: 900;
}

.progress-pill.is-complete {
  color: var(--ok);
  background: #eaf8ef;
}

.section-title p {
  color: var(--muted);
  line-height: 1.7;
}

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

.reference-column,
.upload-column {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

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

.upload-section[data-group="product"] .slot-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.upload-slot,
.reference-slot {
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.reference-slot {
  display: grid;
  grid-template-rows: 1fr auto;
}

.reference-visual {
  display: grid;
  place-items: center;
  min-height: 82px;
  background:
    linear-gradient(135deg, rgba(37, 111, 108, 0.08), rgba(183, 121, 31, 0.08)),
    #fbfdff;
}

.generated-reference {
  min-height: 104px;
  background-repeat: no-repeat;
  background-size: 300% 300%;
}

.uploaded-reference {
  min-height: 104px;
  padding: 8px;
  background: #fbfdff;
}

.uploaded-reference img {
  width: 100%;
  height: 92px;
  object-fit: cover;
  border-radius: 6px;
}

.reference-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 2px solid #8aa4b8;
  border-radius: 8px;
  color: var(--accent-strong);
  font-weight: 900;
}

.slot-label {
  padding: 8px 9px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.35;
}

.upload-slot {
  position: relative;
}

.upload-slot input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-drop {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 116px;
}

.upload-preview {
  display: grid;
  place-items: center;
  min-height: 82px;
  padding: 10px;
  background: #fbfdff;
  color: var(--muted);
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.45;
}

.upload-preview img {
  width: 100%;
  height: 82px;
  object-fit: cover;
  border-radius: 6px;
}

.upload-slot.has-file {
  border-color: rgba(47, 133, 90, 0.55);
}

.upload-slot.has-file .slot-label {
  color: var(--ok);
}

.result-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
}

.result-summary,
.model-card,
.result-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.result-summary,
.model-card {
  padding: 18px;
}

.result-summary h3 {
  font-size: 1.35rem;
}

.summary-status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  color: #fff;
  background: var(--warn);
  font-weight: 900;
}

.summary-status.ok {
  background: var(--ok);
}

.summary-status.danger {
  background: var(--danger);
}

.result-metrics {
  display: grid;
  gap: 8px;
  margin: 16px 0 0;
}

.result-metrics div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfdff;
}

.result-metrics dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.result-metrics dd {
  margin: 4px 0 0;
  font-weight: 800;
  line-height: 1.45;
}

.result-detail {
  display: grid;
  gap: 14px;
  padding: 16px;
}

code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #eef3f8;
  color: var(--accent-strong);
}

.evidence-grid {
  display: grid;
  gap: 12px;
}

.evidence-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 190px;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.evidence-image {
  display: grid;
  place-items: center;
  min-height: 128px;
  border: 1px dashed #b7c5d5;
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.evidence-meta {
  padding: 10px;
  border-left: 4px solid var(--warn);
  border-radius: 7px;
  background: #fff8ea;
}

.issue-severity {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  margin-bottom: 8px;
  padding: 0 9px;
  border-radius: 999px;
  color: #fff;
  background: var(--warn);
  font-size: 0.76rem;
  font-weight: 900;
}

.issue-severity.major {
  background: var(--danger);
}

.issue-severity.minor {
  background: var(--warn);
}

.issue-severity.review {
  background: #52667a;
}

.evidence-meta.major {
  border-left-color: var(--danger);
  background: #fff1f1;
}

.empty-state {
  padding: 34px;
  border: 1px dashed #b7c5d5;
  border-radius: 8px;
  text-align: center;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 44px));
  padding: 12px 14px;
  border: 1px solid rgba(37, 111, 108, 0.32);
  border-radius: 8px;
  color: var(--accent-strong);
  background: #eef8f7;
  box-shadow: var(--shadow);
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1120px) {
  .app-header,
  .panel-heading,
  .upload-grid,
  .upload-section,
  .result-layout,
  .evidence-card {
    grid-template-columns: 1fr;
  }

  .flow-strip {
    grid-template-columns: 1fr;
  }

  .app-header,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 24px, 1480px);
  }

  .page-tabs,
  .panel-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .slot-grid,
  .upload-section[data-group="product"] .slot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
