:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-alt: #eef3f1;
  --ink: #17202a;
  --muted: #64707d;
  --line: #d9e0e7;
  --blue: #2563eb;
  --green: #0f766e;
  --amber: #b45309;
  --red: #b91c1c;
  --filled-bg: #e7efec;
  --filled-line: #9bbeb7;
  --shadow: 0 10px 24px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

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

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

button.danger {
  border-color: #fecaca;
  color: var(--red);
}

button.danger:hover {
  background: #fef2f2;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

input,
select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 7px 10px;
  color: var(--ink);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

input.is-filled,
select.is-filled,
textarea.is-filled {
  background: var(--filled-bg);
  border-color: var(--filled-line);
  box-shadow: inset 3px 0 0 rgba(15, 118, 110, 0.34);
}

input.is-filled:focus,
select.is-filled:focus,
textarea.is-filled:focus {
  border-color: var(--green);
  outline: 2px solid rgba(15, 118, 110, 0.16);
}

input[readonly].is-filled {
  background: #dfe9e6;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

label input,
label select {
  color: var(--ink);
}

.shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #17202a;
  color: #edf2f7;
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 16px;
}

.brand {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding-bottom: 8px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #0f766e;
  color: #fff;
  font-weight: 700;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.brand p {
  margin: 4px 0 0;
  color: #aab6c3;
  font-size: 12px;
}

.panel {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.panel-title {
  margin-bottom: 10px;
  color: #dbe5ee;
  font-size: 13px;
  font-weight: 700;
}

.step-progress {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.step-progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  font-size: 12px;
}

#stepProgressLabel {
  min-width: 0;
  color: #eef4f7;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#stepProgressValue {
  color: #aab6c3;
  font-variant-numeric: tabular-nums;
}

.step-progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #263443;
}

.step-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #2dd4bf;
  transition: width 0.25s ease, background 0.15s ease;
}

.step-progress[data-status="running"] .step-progress-bar {
  background: #60a5fa;
}

.step-progress[data-status="failed"] .step-progress-bar {
  background: #f87171;
}

.wide {
  width: 100%;
}

.draft-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  max-height: 240px;
  overflow: auto;
}

.draft-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px;
  gap: 6px;
  align-items: stretch;
}

.draft-item {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 48px;
  padding: 8px;
  text-align: left;
  background: rgba(255, 255, 255, 0.05);
  color: #edf2f7;
}

.draft-item small {
  color: #aab6c3;
}

.draft-delete {
  min-height: 48px;
  padding: 0 8px;
  background: rgba(255, 255, 255, 0.05);
  border-color: #4f2d35;
  color: #fecaca;
  font-size: 12px;
}

.draft-delete:hover {
  background: #3b1d25;
  border-color: #fca5a5;
}

.draft-empty {
  padding: 10px 8px;
  color: #aab6c3;
  font-size: 12px;
}

.steps {
  display: grid;
  gap: 8px;
}

.steps button {
  position: relative;
  width: 100%;
  text-align: left;
  padding: 0 10px 0 32px;
  background: #202c39;
  color: #eef4f7;
  border-color: #314253;
}

.steps button::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 11px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #516375;
  transform: translateY(-50%);
  transition: background 0.15s, box-shadow 0.15s;
}

.steps button:hover {
  background: #263443;
}

.steps button:disabled {
  opacity: 0.78;
}

.steps button.is-current {
  border-color: #6ba6d9;
  background: #223247;
}

.steps button.is-running {
  opacity: 1;
  border-color: #93c5fd;
}

.steps button.is-running::before {
  background: #60a5fa;
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.18);
}

.steps button.is-done {
  border-color: rgba(45, 212, 191, 0.54);
}

.steps button.is-done::before {
  background: #2dd4bf;
}

.steps button.is-failed {
  border-color: rgba(248, 113, 113, 0.72);
}

.steps button.is-failed::before {
  background: #f87171;
}

.workspace {
  min-width: 0;
}

.demo-banner {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin: 16px 18px 0;
  padding: 12px 14px;
  border: 1px solid #f2c96d;
  border-radius: 8px;
  background: #fff8df;
  color: #5f4300;
}

.demo-banner[hidden] {
  display: none;
}

.demo-banner-signal {
  width: 10px;
  height: 34px;
  border-radius: 3px;
  background: repeating-linear-gradient(
    135deg,
    #f2a900 0,
    #f2a900 5px,
    #17202a 5px,
    #17202a 10px
  );
}

.demo-banner strong,
.demo-banner p {
  margin: 0;
}

.demo-banner p {
  margin-top: 2px;
  color: #765b16;
  font-size: 13px;
}

.demo-banner > span {
  padding: 5px 8px;
  border: 1px solid #d7ad4e;
  border-radius: 999px;
  background: #fffdf5;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px 20px;
  background: rgba(244, 246, 248, 0.95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: end;
  flex-wrap: wrap;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  padding: 18px 20px 28px;
}

.sheet-form,
.status-pane {
  display: grid;
  gap: 16px;
  align-content: start;
  min-width: 0;
}

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

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

.section-head h2 {
  margin: 0;
  font-size: 16px;
}

.section-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.section-head span {
  color: var(--muted);
  font-size: 12px;
}

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

.span-2 {
  grid-column: span 2;
}

.field-with-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 8px;
}

.property-panel {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.property-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.property-panel-head strong {
  font-size: 13px;
}

.property-panel-head span {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.property-panel-head span[data-status="ok"] {
  color: var(--green);
}

.property-panel-head span[data-status="warning"] {
  color: var(--amber);
}

.property-panel-head span[data-status="loading"] {
  color: var(--blue);
}

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

.property-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  min-width: 0;
}

.property-field-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-select {
  position: relative;
  min-width: 0;
}

.multi-select-trigger {
  position: relative;
  display: block;
  width: 100%;
  min-height: 36px;
  padding: 7px 34px 7px 10px;
  border-color: var(--line);
  border-radius: 6px;
  color: var(--ink);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background:
    linear-gradient(45deg, transparent 50%, #384656 50%) right 14px center / 6px 6px no-repeat,
    linear-gradient(135deg, #384656 50%, transparent 50%) right 9px center / 6px 6px no-repeat,
    #fff;
}

.multi-select-trigger.is-filled {
  border-color: var(--filled-line);
  box-shadow: inset 3px 0 0 rgba(15, 118, 110, 0.34);
  background:
    linear-gradient(45deg, transparent 50%, #384656 50%) right 14px center / 6px 6px no-repeat,
    linear-gradient(135deg, #384656 50%, transparent 50%) right 9px center / 6px 6px no-repeat,
    var(--filled-bg);
}

.multi-select-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  display: none;
  max-height: 188px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 12px 24px rgba(23, 32, 42, 0.14);
  padding: 4px;
}

.multi-select.is-open .multi-select-menu {
  display: grid;
  gap: 1px;
}

.property-grid .multi-select .multi-select-option {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 5px 7px;
  border-radius: 4px;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
}

.property-grid .multi-select .multi-select-option:hover {
  background: #eef3f1;
}

.property-grid .multi-select .multi-select-option input[type="checkbox"] {
  width: 14px;
  height: 14px;
  min-height: 14px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  accent-color: var(--green);
}

.multi-select-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.property-empty {
  grid-column: 1 / -1;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfd;
  font-size: 12px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-alt);
  color: #384656;
  font-size: 12px;
}

.sku-bulk-row th {
  background: #fff;
  border-bottom-color: #cfd8e3;
}

.sku-bulk-row th:first-child {
  background: #fbfcfd;
}

.sku-bulk-input {
  min-width: 120px;
  min-height: 34px;
  background: #fbfcfd;
}

.sku-bulk-input:focus {
  border-color: var(--green);
  outline: 2px solid rgba(15, 118, 110, 0.16);
}

.sku-bulk-apply {
  width: 100%;
  min-width: 72px;
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.sku-bulk-apply:hover {
  background: #115e59;
  border-color: #115e59;
}

td input {
  min-width: 120px;
}

.sku-image-cell {
  display: grid;
  grid-template-columns: 52px minmax(150px, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 230px;
}

.sku-image-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 56px;
  gap: 6px;
}

.inline-thumb {
  position: relative;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 11px;
}

.inline-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
}

.asset-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 10px 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
  min-height: 150px;
}

.asset-box:nth-child(2) {
  grid-row: span 2;
}

.asset-box strong {
  display: block;
  margin-bottom: 4px;
}

.asset-box p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.asset-actions {
  display: grid;
  gap: 6px;
}

.asset-actions button {
  width: 100%;
}

.asset-preview {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
  min-height: 72px;
}

.asset-preview.single {
  grid-template-columns: minmax(72px, 112px);
}

.asset-thumb {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.asset-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.asset-file-badge {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  background: #eef3f1;
  color: #384656;
  font-size: 12px;
  font-weight: 700;
}

.asset-thumb span {
  display: block;
  padding: 6px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thumb-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 22px;
  min-height: 22px;
  height: 22px;
  padding: 0;
  border-color: rgba(185, 28, 28, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--red);
  font-size: 16px;
  line-height: 1;
}

.thumb-delete:hover {
  background: #fef2f2;
  border-color: rgba(185, 28, 28, 0.55);
}

.asset-empty {
  display: grid;
  place-items: center;
  min-height: 72px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
}

#resultLog {
  min-height: 520px;
  max-height: calc(100vh - 170px);
  overflow: auto;
  margin: 0;
  border-radius: 8px;
  background: #101820;
  color: #d9f0e8;
  padding: 14px;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

#draftBadge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--green);
  background: #ecfdf5;
}

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

  .content-grid {
    grid-template-columns: 1fr;
  }

  .status-pane {
    order: -1;
  }
}

@media (max-width: 820px) {
  .demo-banner {
    grid-template-columns: 10px minmax(0, 1fr);
  }

  .demo-banner > span {
    grid-column: 2;
    justify-self: start;
  }

  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .toolbar,
  .form-grid,
  .property-grid,
  .asset-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }
}
