:root {
  color-scheme: light;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: #f6f7f9;
  color: #171b22;
  --bg: #f6f7f9;
  --surface: #fff;
  --surface-soft: #f9fafb;
  --line: #d9dee7;
  --line-soft: #e8ebf0;
  --text: #171b22;
  --muted: #687386;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --danger: #dc2626;
  --shadow: 0 12px 30px rgba(25, 35, 55, .08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 13px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 650;
  line-height: 1.2;
}

button:hover:not(:disabled) {
  background: var(--primary-strong);
}

button.secondary {
  background: #fff;
  color: #273244;
  border-color: var(--line);
}

button.secondary:hover:not(:disabled) {
  background: #f3f6fb;
}

button.danger {
  background: var(--danger);
}

button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

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

a:hover {
  text-decoration: underline;
}

.button-link {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 13px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
}

.button-link.secondary {
  background: #fff;
  color: #273244;
  border-color: var(--line);
}

.button-link:hover {
  text-decoration: none;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-panel h1,
.page-title h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.muted {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.page-title {
  display: grid;
  gap: 3px;
}

.layout {
  display: grid;
  grid-template-columns: 212px 1fr;
  min-height: 0;
}

.tabs {
  padding: 16px 10px;
  background: #eef2f7;
  border-right: 1px solid var(--line);
}

.tab {
  display: block;
  width: 100%;
  min-height: 38px;
  text-align: left;
  margin-bottom: 6px;
  background: transparent;
  color: #344054;
  border-color: transparent;
  border-radius: 6px;
}

.tab:hover:not(:disabled) {
  background: #e3e9f2;
}

.tab.active {
  background: #fff;
  color: var(--primary);
  border-color: var(--line);
  box-shadow: 0 1px 2px rgba(25, 35, 55, .04);
}

.content {
  min-width: 0;
  padding: 20px 24px 28px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(25, 35, 55, .03);
}

.batch-upload-panel {
  padding: 0;
  overflow: hidden;
}

.batch-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.batch-header .section-title {
  margin-bottom: 4px;
}

.batch-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.batch-submit {
  background: #0f766e;
}

.batch-submit:hover:not(:disabled) {
  background: #0b5f59;
}

.batch-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 18px;
  background: #fff;
}

.batch-metric {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #f9fafb;
}

.batch-metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.batch-metric strong {
  color: #111827;
  font-size: 24px;
  line-height: 1;
}

.batch-metric.danger strong {
  color: var(--danger);
}

.batch-alert {
  margin: 0 18px 14px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #991b1b;
  font-size: 13px;
}

.batch-preview-grid {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 14px;
  padding: 0 18px 18px;
}

.batch-task-list,
.batch-json-card,
.batch-response {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.batch-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: #f8fafc;
}

.batch-subhead h3 {
  margin: 0;
}

.batch-subhead span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.batch-task-card {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.batch-task-card:last-child {
  border-bottom: 0;
}

.batch-task-card div {
  display: grid;
  gap: 3px;
}

.batch-task-card b {
  color: #1f2937;
  font-size: 13px;
}

.batch-task-card span {
  color: var(--muted);
  font-size: 12px;
}

.batch-task-card em {
  color: var(--danger);
  font-size: 12px;
  font-style: normal;
}

.batch-task-card.blocked {
  background: #fff7f7;
}

.batch-json-card pre,
.batch-response pre {
  max-height: 520px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.batch-response {
  margin: 0 18px 18px;
}

.batch-response.success {
  border-color: #bbf7d0;
}

.batch-response.success .batch-subhead {
  background: #f0fdf4;
}

.batch-response.danger {
  border-color: #fecaca;
}

.batch-response.danger .batch-subhead {
  background: #fff1f2;
}

@media (max-width: 960px) {
  .batch-header {
    display: grid;
  }

  .batch-actions {
    justify-content: flex-start;
  }

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

  .batch-preview-grid {
    grid-template-columns: 1fr;
  }
}

.prompt-form {
  background: var(--surface-soft);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 16px;
  margin-top: 14px;
  box-shadow: none;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.toolbar input,
.toolbar select {
  width: auto;
  min-width: 150px;
}

.toolbar input[type="search"] {
  min-width: min(360px, 100%);
  flex: 1;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field label {
  font-size: 12px;
  font-weight: 700;
  color: #344054;
}

.field input,
.field select,
.field textarea,
.toolbar input,
.toolbar select {
  width: 100%;
  border: 1px solid #cfd6e2;
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.toolbar input:focus,
.toolbar select:focus {
  border-color: #8fb4ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.toolbar input,
.toolbar select {
  width: auto;
}

.toolbar input[type="search"] {
  flex: 1;
}

.inline-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.inline-tab-wrap {
  display: inline-flex;
  align-items: stretch;
  margin-bottom: -1px;
}

.inline-tab-wrap .inline-tab {
  border-radius: 6px 0 0 0;
  margin-bottom: 0;
}

.inline-tab {
  min-height: 36px;
  margin-bottom: -1px;
  border-color: transparent;
  border-bottom-color: transparent;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: #344054;
}

.inline-tab:hover:not(:disabled) {
  background: #eef3fb;
}

.inline-tab.active {
  background: #fff;
  color: var(--primary);
  border-color: var(--line);
  border-bottom-color: #fff;
}

.inline-tab-close {
  width: 34px;
  min-height: 36px;
  padding: 0;
  margin-bottom: 0;
  border-color: var(--line);
  border-left: 0;
  border-bottom-color: #fff;
  border-radius: 0 6px 0 0;
  background: #fff;
  color: var(--muted);
  font-weight: 750;
}

.inline-tab-close:hover:not(:disabled) {
  background: #f3f6fb;
  color: var(--danger);
}

.field textarea {
  min-height: 260px;
  resize: vertical;
  line-height: 1.55;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

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

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

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

table {
  width: 100%;
  min-width: 1120px;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
}

th,
td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
  font-size: 12px;
  line-height: 1.45;
}

.select-col {
  width: 38px;
  text-align: center;
}

.select-col input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--primary);
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #344054;
  font-weight: 750;
  white-space: nowrap;
}

tbody tr:hover {
  background: #fbfdff;
}

td:last-child {
  white-space: nowrap;
}

td:last-child button {
  margin: 0 6px 6px 0;
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 70px;
  border-radius: 999px;
  padding: 4px 8px;
  font-weight: 750;
  font-size: 11px;
}

.status.pending {
  background: #fff7db;
  color: #8a5a00;
}

.status.processing {
  background: #e7f0ff;
  color: #174f9a;
}

.status.success {
  background: #e6f6ed;
  color: #1f7a47;
}

.status.failed {
  background: #fee8e7;
  color: #a12a25;
}

.status.cancelled {
  background: #edf0f4;
  color: #536070;
}

.thumb-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.thumb-button {
  display: block;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: zoom-in;
}

.thumb-button:hover,
.thumb-button:focus-visible {
  background: transparent;
  outline: none;
}

.thumb {
  width: 52px;
  height: 70px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #f3f5f8;
  display: block;
}

.thumb:hover {
  border-color: #8fb4ff;
}

.output-thumb {
  width: 64px;
  height: 86px;
}

.image-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  align-items: center;
  padding: 28px;
  background: rgba(15, 23, 42, .72);
  cursor: zoom-out;
}

.image-preview-dialog {
  display: grid;
  gap: 10px;
  max-width: min(94vw, 1120px);
  max-height: 94vh;
  color: #fff;
}

.image-preview-dialog img {
  max-width: min(94vw, 1120px);
  max-height: calc(94vh - 40px);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .36);
  background: #111827;
}

.image-preview-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 12px;
  color: rgba(255, 255, 255, .78);
}

.image-preview-meta a {
  color: #fff;
}

.image-preview-nav {
  width: 44px;
  height: 64px;
  justify-self: center;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .26);
  background: rgba(15, 23, 42, .42);
  color: #fff;
  font-size: 40px;
  line-height: 1;
  cursor: pointer;
}

.image-preview-nav:hover {
  background: rgba(15, 23, 42, .64);
}

.image-preview-nav:disabled {
  opacity: .26;
  cursor: default;
}

.image-preview-nav:disabled:hover {
  background: rgba(15, 23, 42, .42);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.message {
  min-height: 22px;
  color: var(--primary);
  margin: 10px 0 0;
  font-size: 13px;
}

.message.error {
  color: var(--danger);
}

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

.upload-content {
  display: grid;
  gap: 16px;
  padding: 22px;
}

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

.progress-bar span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  animation: progress-slide 1.1s ease-in-out infinite alternate;
}

@keyframes progress-slide {
  from {
    transform: translateX(-45%);
  }
  to {
    transform: translateX(145%);
  }
}

.task-detail {
  display: grid;
  gap: 14px;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.detail-header .section-title {
  margin-bottom: 0;
}

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

.meta-item {
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.meta-item b {
  color: #344054;
  font-size: 12px;
}

.metric {
  display: grid;
  gap: 7px;
  padding: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.metric b {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  font-size: 28px;
  line-height: 1;
  color: var(--text);
}

.section-title {
  margin: 0 0 12px;
  font-size: 17px;
  letter-spacing: 0;
}

h3 {
  margin: 18px 0 10px;
  font-size: 14px;
  color: #344054;
}

.setting-form {
  display: grid;
  gap: 14px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}

.setting-form:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.seller-section {
  margin-top: 14px;
}

.seller-section:first-of-type {
  margin-top: 0;
}

.seller-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.seller-form-row {
  display: grid;
  grid-template-columns: minmax(190px, 280px) minmax(0, 1fr);
  border-bottom: 1px solid var(--line-soft);
}

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

.seller-form-label {
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 12px 14px;
  background: #f8fafc;
  border-right: 1px solid var(--line-soft);
  color: #344054;
  font-size: 12px;
  font-weight: 750;
}

.seller-form-label b {
  color: var(--danger);
  font-size: 14px;
  line-height: 1;
}

.seller-form-label small {
  color: var(--muted);
  font-weight: 500;
  line-height: 1.35;
}

.seller-form-value {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
  padding: 10px 12px;
}

.seller-input {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid #cfd6e2;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.seller-input.select::after {
  content: "select";
  margin-left: auto;
  padding-left: 12px;
  color: var(--muted);
  font-size: 11px;
}

.seller-input.empty {
  color: #98a2b3;
  background: #f9fafb;
  border-style: dashed;
}

.seller-regenerate {
  min-height: 38px;
  white-space: nowrap;
}

.seller-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 12px;
}

.seller-image-tile {
  min-height: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #344054;
  text-align: left;
}

.seller-image-tile:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #8fb4ff;
}

.seller-image-tile img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
  border-radius: 6px;
  background: #f3f5f8;
}

.seller-image-tile span {
  display: block;
  margin-top: 7px;
  font-size: 12px;
  font-weight: 700;
}

.rich-preview-board {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
}

.rich-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: #344054;
  font-size: 12px;
  font-weight: 750;
}

.rich-preview-toolbar span:last-child {
  color: var(--muted);
  font-weight: 600;
}

.rich-preview-canvas {
  display: grid;
  gap: 14px;
  max-width: 780px;
  margin: 0 auto;
  padding: 16px;
}

.rich-preview-block {
  display: grid;
  gap: 8px;
  min-height: 0;
  padding: 10px;
  border: 1px dashed #c7d2e4;
  border-radius: 8px;
  background: #fff;
  color: #344054;
}

.rich-preview-block:hover:not(:disabled) {
  background: #fbfdff;
  border-color: #8fb4ff;
}

.rich-preview-block span {
  font-size: 12px;
  font-weight: 750;
  text-align: left;
}

.rich-preview-block img {
  width: 100%;
  max-height: 820px;
  object-fit: contain;
  display: block;
  border-radius: 6px;
  background: #eef2f7;
}

.json-preview {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-soft);
}

.rich-content-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-soft);
}

.rich-content-form h3 {
  margin-top: 0;
}

.rich-content-form textarea {
  min-height: 260px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
}

.json-preview summary {
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 650;
  color: #344054;
}

.json-preview pre {
  max-height: 420px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.log-list {
  max-height: 280px;
  overflow: auto;
  padding: 0;
  margin: 0;
  list-style: none;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.log-list li {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
  line-height: 1.5;
}

.log-list li:last-child {
  border-bottom: 0;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .tabs {
    display: flex;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .tab {
    width: auto;
    white-space: nowrap;
  }

  .grid-2,
  .grid-3,
  .detail-meta,
  .seller-form-row {
    grid-template-columns: 1fr;
  }

  .seller-form-label {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .seller-form-value {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 16px;
  }
}
