:root {
  --green: #83b735;
  --green-soft: #e8f1d2;
  --text: #242424;
  --muted: #666;
  --line: #e8e8e8;
  --page: #f7f7f7;
  --white: #fff;
  --red: #ff3f32;
  --blue: #3b82ff;
  --yellow: #f2b42b;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--page);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

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

button {
  cursor: pointer;
}

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

textarea {
  resize: vertical;
}

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

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

.brand-lockup,
.admin-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #1f1f1f;
  font-weight: 900;
  text-decoration: none;
}

.brand-lockup {
  margin-bottom: 28px;
}

.brand-lockup img,
.admin-brand img {
  width: 34px;
  height: 34px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--white);
}

.brand-lockup strong,
.brand-lockup span {
  display: block;
}

.brand-lockup span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  min-height: 58px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
}

.header-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.header-stats span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
}

.header-actions,
.modal-actions,
.detail-actions,
.image-actions,
.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.workspace {
  display: grid;
  grid-template-columns: 260px minmax(360px, 1fr) minmax(380px, 520px);
  gap: 18px;
  width: min(1540px, calc(100% - 36px));
  margin: 18px auto;
  align-items: start;
}

.series-panel,
.product-panel,
.detail-panel {
  min-height: calc(100vh - 94px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}

.series-panel,
.detail-panel {
  position: sticky;
  top: 76px;
}

.series-panel {
  padding: 16px;
}

.product-panel {
  padding: 16px;
}

.detail-panel {
  max-height: calc(100vh - 94px);
  overflow: auto;
  padding: 18px;
}

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

.eyebrow {
  display: block;
  margin-bottom: 3px;
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2 {
  font-size: 20px;
  line-height: 1.16;
  letter-spacing: 0;
}

h3 {
  font-size: 14px;
  line-height: 1.3;
}

.field,
.search-box {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field span {
  color: #3b3b3b;
  font-size: 12px;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: #fff;
  outline: none;
}

input,
select {
  height: 40px;
  padding: 0 12px;
}

textarea {
  padding: 10px 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(131, 183, 53, 0.65);
  box-shadow: 0 0 0 3px rgba(131, 183, 53, 0.14);
}

.search-box input {
  padding-left: 14px;
  background: #f8f8f8;
}

.primary-button,
.preview-button,
.dark-button,
.ghost-button,
.danger-button,
.icon-button,
.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  font-weight: 900;
  white-space: nowrap;
}

.primary-button {
  width: 100%;
  padding: 0 18px;
  color: #fff;
  background: var(--green);
}

.preview-button {
  width: auto;
  padding: 0 18px;
  color: #271c03;
  background: var(--yellow);
}

.modal-actions .primary-button,
.detail-actions .primary-button,
.header-actions .primary-button {
  width: auto;
}

.primary-button.compact,
.preview-button.compact,
.dark-button,
.ghost-button,
.danger-button {
  width: auto;
  min-height: 34px;
  padding: 0 14px;
  font-size: 12px;
}

.dark-button {
  color: #fff;
  background: #0d0d0d;
}

.ghost-button {
  border: 1px solid var(--line);
  color: #2c2c2c;
  background: #fff;
}

.danger-button {
  color: #fff;
  background: var(--red);
}

.icon-button {
  width: 34px;
  height: 34px;
  min-height: 34px;
  color: #111;
  background: var(--green-soft);
  font-size: 20px;
  line-height: 1;
}

.mini-button {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  color: #2c2c2c;
  background: #fff;
  font-size: 11px;
}

.mini-button.is-danger {
  color: var(--red);
}

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

.series-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.series-item.is-active {
  border-color: rgba(131, 183, 53, 0.65);
  background: linear-gradient(180deg, #fff 0%, #f7fbef 100%);
}

.series-main {
  min-width: 0;
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.series-main strong,
.product-card strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.series-main span,
.product-card span,
.image-meta,
.form-message,
.muted-text {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.series-tools {
  display: flex;
  gap: 4px;
}

.tool-dot {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #2c2c2c;
  background: #fff;
  font-weight: 900;
}

.tool-dot.is-danger {
  color: var(--red);
}

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

.product-card {
  display: grid;
  gap: 9px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  text-align: left;
}

.product-card.is-active {
  border-color: rgba(131, 183, 53, 0.7);
  box-shadow: 0 10px 24px rgba(131, 183, 53, 0.12);
}

.product-thumb {
  display: grid;
  height: 120px;
  place-items: center;
  overflow: hidden;
  border-radius: var(--radius);
  background: #f5f5f5;
}

.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.product-thumb.is-empty {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.product-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #f2f2f2;
  color: #505050;
  font-size: 11px;
  font-weight: 900;
}

.pill.is-warn {
  color: #a15b00;
  background: #fff3d7;
}

.pill.is-green {
  color: #3f7115;
  background: var(--green-soft);
}

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

.detail-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.detail-title-row strong {
  display: block;
  font-size: 22px;
  font-weight: 900;
  line-height: 1.1;
}

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

.detail-actions {
  flex-wrap: wrap;
  justify-content: flex-start;
  margin-top: -2px;
  padding-bottom: 2px;
}

.inline-progress {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfbfb;
}

.inline-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #3b3b3b;
  font-size: 12px;
  font-weight: 900;
}

.inline-progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #ececec;
}

.inline-progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 0.18s ease;
}

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

.spec-row {
  display: grid;
  grid-template-columns: 34px minmax(90px, 0.78fr) minmax(140px, 1.35fr) auto auto;
  gap: 8px;
  align-items: start;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.spec-row.is-dragging {
  opacity: 0.48;
}

.spec-drag-handle {
  display: grid;
  width: 34px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: #7c7c7c;
  background: #fff;
  cursor: grab;
}

.spec-drag-handle:active {
  cursor: grabbing;
}

.spec-drag-handle span {
  width: 14px;
  height: 18px;
  background-image: radial-gradient(currentColor 1.6px, transparent 1.8px);
  background-position: 0 0;
  background-size: 7px 7px;
}

.spec-row textarea {
  min-height: 40px;
  max-height: 180px;
  overflow-y: auto;
  line-height: 1.45;
  white-space: pre-wrap;
}

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

.upload-button {
  position: relative;
  display: grid;
  min-height: 96px;
  place-items: center;
  align-content: center;
  gap: 5px;
  border: 1px dashed rgba(131, 183, 53, 0.7);
  border-radius: var(--radius);
  background: #fbfdf7;
  color: #3f7115;
  font-weight: 900;
  text-align: center;
  overflow: hidden;
}

.upload-button strong,
.upload-button span {
  pointer-events: none;
}

.upload-button strong {
  color: #2e5510;
  font-size: 14px;
}

.upload-button span {
  max-width: 12em;
  color: #5b7d35;
  font-size: 11px;
  line-height: 1.35;
}

.upload-zone.is-dragover {
  border-color: var(--green);
  background: #eef8dc;
  box-shadow: inset 0 0 0 2px rgba(131, 183, 53, 0.2);
}

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

.image-manager-head {
  align-items: start;
}

.image-manager-head > div {
  display: grid;
  gap: 3px;
}

.batch-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px solid #f0d7d2;
  border-radius: var(--radius);
  background: #fff8f7;
}

.batch-toolbar span {
  margin-right: auto;
  color: #6d332d;
  font-size: 12px;
  font-weight: 900;
}

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

.image-card {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.image-card.is-selecting {
  padding-top: 38px;
}

.image-card.is-selected {
  border-color: rgba(255, 63, 50, 0.52);
  background: #fff9f8;
}

.image-check {
  position: absolute;
  top: 8px;
  left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: #303030;
  font-size: 11px;
  font-weight: 900;
  z-index: 1;
}

.image-check input {
  width: 14px;
  height: 14px;
  min-width: 14px;
  padding: 0;
  accent-color: var(--red);
}

.image-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 6px;
  background: #f6f6f6;
}

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

.empty-state {
  display: grid;
  min-height: 260px;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--text);
  font-size: 18px;
}

.orphan-box {
  margin-top: 14px;
  padding: 10px;
  border: 1px dashed #d8bd72;
  border-radius: var(--radius);
  color: #705000;
  background: #fff8df;
  font-size: 12px;
  font-weight: 800;
}

.modal {
  width: min(500px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(4px);
}

.modal-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

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

.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 40;
  display: grid;
  gap: 6px;
  width: max-content;
  max-width: min(520px, calc(100% - 36px));
  padding: 14px 16px;
  border-radius: var(--radius);
  color: #fff;
  background: #111;
  box-shadow: var(--shadow);
  font-weight: 800;
  text-align: left;
  transform: translate(-50%, -50%);
}

.toast-title {
  font-size: 16px;
  font-weight: 900;
  line-height: 1.25;
}

.toast-body,
.toast-advice,
.toast-detail {
  color: rgba(255, 255, 255, 0.86);
  font-size: 12px;
  line-height: 1.45;
}

.toast-code {
  display: inline-flex;
  width: fit-content;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  color: #111;
  background: var(--yellow);
  font-size: 12px;
  font-weight: 900;
}

.toast-detail {
  max-width: 100%;
  color: rgba(255, 255, 255, 0.62);
  word-break: break-word;
}

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

  .detail-panel {
    position: static;
    grid-column: 1 / -1;
    max-height: none;
    min-height: 360px;
  }
}

@media (max-width: 760px) {
  .admin-header {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px 16px;
  }

  .header-actions {
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .workspace {
    grid-template-columns: 1fr;
    width: min(100% - 20px, 620px);
  }

  .series-panel {
    position: static;
    min-height: auto;
  }

  .product-panel,
  .detail-panel {
    min-height: auto;
  }

  .form-grid,
  .upload-row,
  .spec-row {
    grid-template-columns: 1fr;
  }

  .spec-drag-handle {
    width: 100%;
  }
}
