* { box-sizing: border-box; }

body {
  margin: 0;
  color: #0f172a;
  background: #f8fafc;
  font: 14px/1.45 "IBM Plex Sans", "Microsoft YaHei", system-ui, sans-serif;
}

a { color: #0f766e; text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: "IBM Plex Mono", Consolas, monospace; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid #d8e1ea;
  background: #fff;
}

.brand { font-weight: 800; color: #0f172a; }
.caption { color: #475569; }
.toplink { margin-left: auto; font-weight: 700; }
.page { width: min(1440px, calc(100vw - 32px)); margin: 24px auto; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

h1 { margin: 0; font-size: 24px; }
.search { display: flex; gap: 8px; }
.search label { align-self: center; color: #475569; font-size: 12px; font-weight: 700; }

input,
button {
  min-height: 36px;
  border: 1px solid #d8e1ea;
  border-radius: 6px;
  padding: 0 10px;
  font: inherit;
}

button {
  background: #0f766e;
  color: #fff;
  border-color: #0f766e;
  font-weight: 700;
}

.panel {
  overflow: auto;
  border: 1px solid #d8e1ea;
  background: #fff;
}

table { width: 100%; border-collapse: collapse; }

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid #d8e1ea;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
}

.empty {
  color: #475569;
  text-align: center;
  padding: 48px 12px;
}

.crumb { margin-bottom: 12px; color: #475569; }

.summary {
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid #d8e1ea;
  background: #fff;
}

.summary dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0 0;
}

.summary dt { color: #475569; font-size: 12px; }
.summary dd { margin: 3px 0 0; font-weight: 700; }

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 42vw);
  gap: 16px;
}

.detail-main {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.detail-section { padding: 16px; }
.detail-section h2, .raw-panel h2 { margin: 0 0 12px; font-size: 16px; }

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.media-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid #d8e1ea;
}

.raw-panel {
  position: sticky;
  top: 16px;
  align-self: start;
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 16px;
  border: 1px solid #d8e1ea;
  background: #0f172a;
  color: #f8fafc;
}

.raw-panel pre {
  overflow: auto;
  padding: 12px;
  background: rgba(255, 255, 255, 0.06);
  white-space: pre-wrap;
}

@media (max-width: 900px) {
  .toolbar,
  .summary dl,
  .detail-grid {
    display: block;
  }

  .search { margin-top: 12px; }
  .raw-panel { position: static; margin-top: 16px; }
}

.draft-panel {
  margin-bottom: 16px;
  padding: 16px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 0 0 4px;
  font-size: 16px;
}

.section-heading p {
  margin: 0;
  color: #475569;
  font-size: 12px;
}

.draft-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.draft-form label {
  display: grid;
  gap: 6px;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.draft-form input,
.draft-form textarea {
  width: 100%;
  min-width: 0;
  color: #0f172a;
  background: #fff;
}

.draft-form textarea {
  min-height: 96px;
  padding: 10px;
  resize: vertical;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
}

.draft-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.ai-status {
  margin-top: 4px;
  color: #b45309;
}

.products-table {
  table-layout: fixed;
}

.product-title-cell {
  width: 30%;
}

.price-cell {
  color: #475569;
}

.action-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.action-cell form {
  margin: 0;
}

.small-button {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid #0f766e;
  border-radius: 6px;
  background: #0f766e;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.small-button.secondary {
  background: #fff;
  color: #0f766e;
}

.small-button.upload-mini {
  background: #b45309;
  border-color: #b45309;
}

.noon-status {
  margin-top: 4px !important;
  color: #0f766e !important;
}

.upload-button {
  background: #b45309;
  border-color: #b45309;
}

.pricing-panel {
  margin-bottom: 16px;
  padding: 16px;
}

.offer-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.offer-form label {
  display: grid;
  gap: 6px;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.offer-form input {
  width: 100%;
  min-width: 0;
}

.pricing-table {
  overflow: auto;
}

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

.settings-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.settings-panel h2 {
  margin: 0;
  font-size: 16px;
}

.setting-status {
  margin: 0;
  color: #0f766e;
  font-size: 12px;
  font-weight: 700;
}

.settings-panel label {
  display: grid;
  gap: 6px;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.settings-panel input,
.settings-panel textarea {
  width: 100%;
  min-width: 0;
  color: #0f172a;
}

.settings-panel textarea {
  padding: 10px;
  resize: vertical;
}

@media (max-width: 900px) {
  .section-heading,
  .draft-form,
  .offer-form,
  .settings-form {
    display: block;
  }

  .draft-actions {
    justify-content: flex-start;
    margin-top: 12px;
  }

  .draft-form label {
    margin-top: 12px;
  }

  .offer-form label {
    margin-top: 12px;
  }
}
