:root {
  --ink: #172026;
  --ink-soft: #334249;
  --muted: #68757b;
  --line: #d9d7cf;
  --paper: #f4f1e9;
  --surface: #fffdf8;
  --surface-strong: #fff;
  --accent: #d85c2b;
  --accent-dark: #ae431d;
  --teal: #135f5c;
  --yellow: #f2c14e;
  --danger: #a62f29;
  --shadow: 0 18px 45px rgba(23, 32, 38, 0.11);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(rgba(23, 32, 38, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 32, 38, 0.025) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

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

h1 {
  margin-bottom: 0;
  font-family: "STKaiti", "KaiTi", "Microsoft YaHei", serif;
  font-size: clamp(27px, 3vw, 40px);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 24px;
}

h3 {
  margin-bottom: 12px;
  font-size: 16px;
}

.brand-mark {
  display: grid;
  width: 62px;
  height: 62px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  color: var(--yellow);
  background: var(--ink);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 32px;
  font-weight: 700;
}

.brand-mark.compact {
  width: 46px;
  height: 46px;
  font-size: 25px;
}

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

.login-panel {
  display: grid;
  width: min(440px, 100%);
  gap: 20px;
  padding: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-copy p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.65;
}

.field {
  display: grid;
  gap: 7px;
}

.field > span {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
}

.field b {
  color: var(--danger);
}

input,
textarea {
  width: 100%;
  border: 1px solid #c9c8c1;
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface-strong);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input {
  height: 44px;
  padding: 0 12px;
}

textarea {
  padding: 11px 12px;
  line-height: 1.55;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(19, 95, 92, 0.13);
}

.primary-button,
.quiet-button,
.danger-button,
.upload-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 700;
  text-decoration: none;
}

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

.primary-button:hover {
  background: var(--accent-dark);
}

.quiet-button,
.upload-button {
  border-color: var(--line);
  color: var(--ink-soft);
  background: var(--surface);
}

.quiet-button:hover,
.upload-button:hover {
  border-color: var(--teal);
  color: var(--teal);
}

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

.primary-button:disabled,
.quiet-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.back-link,
.text-link {
  color: var(--teal);
  font-size: 13px;
  text-align: center;
  text-decoration: none;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px max(24px, calc((100% - 1320px) / 2));
  color: #fff;
  background: var(--ink);
}

.admin-brand,
.admin-actions,
.list-toolbar,
.toolbar-actions,
.section-heading,
.editor-footer,
.pagination,
.confirm-actions {
  display: flex;
  align-items: center;
}

.admin-brand {
  gap: 15px;
}

.admin-brand .eyebrow {
  color: var(--yellow);
}

.admin-actions {
  gap: 18px;
}

.admin-actions .text-link {
  color: rgba(255, 255, 255, 0.75);
}

.admin-actions .quiet-button {
  border-color: rgba(255, 255, 255, 0.24);
  color: #fff;
  background: transparent;
}

.admin-main {
  width: min(1320px, calc(100% - 48px));
  margin: 28px auto 60px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 170px)) 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.summary-strip > div {
  display: grid;
  gap: 3px;
  padding: 18px 22px;
}

.summary-strip > div + div {
  border-left: 1px solid var(--line);
}

.summary-strip strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 23px;
}

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

.summary-time {
  justify-items: end;
  text-align: right;
}

.summary-time strong {
  font-family: inherit;
  font-size: 14px;
}

.list-panel {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.list-toolbar {
  justify-content: space-between;
  gap: 24px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.toolbar-actions {
  gap: 10px;
}

.search-box input {
  width: min(320px, 36vw);
}

.list-status {
  padding: 13px 24px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.product-list {
  display: grid;
}

.product-row {
  display: grid;
  grid-template-columns: 64px minmax(210px, 1.5fr) minmax(140px, 0.6fr) minmax(170px, 0.8fr) auto;
  gap: 18px;
  align-items: center;
  min-height: 88px;
  padding: 12px 24px;
}

.product-row + .product-row {
  border-top: 1px solid var(--line);
}

.product-row:hover {
  background: #faf7ef;
}

.row-image {
  width: 58px;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  object-fit: contain;
}

.row-main {
  min-width: 0;
}

.row-main strong {
  display: block;
  overflow: hidden;
  margin-bottom: 5px;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-main span,
.row-meta,
.row-category {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  gap: 7px;
}

.row-actions button {
  min-height: 34px;
  padding: 0 11px;
  font-size: 12px;
}

.row-actions .delete {
  color: var(--danger);
}

.empty-list {
  padding: 54px 24px;
  color: var(--muted);
  text-align: center;
}

.pagination {
  justify-content: center;
  gap: 16px;
  padding: 18px;
  border-top: 1px solid var(--line);
}

.pagination span {
  min-width: 90px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

dialog {
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
}

dialog::backdrop {
  background: rgba(23, 32, 38, 0.58);
  backdrop-filter: blur(3px);
}

.editor-dialog {
  width: min(1040px, calc(100% - 28px));
  max-height: calc(100vh - 28px);
}

.editor-shell {
  display: grid;
  max-height: calc(100vh - 28px);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.editor-header,
.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 22px;
}

.editor-header {
  border-bottom: 1px solid var(--line);
}

.editor-body {
  overflow-y: auto;
  padding: 6px 22px 24px;
}

.editor-section {
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.editor-section:last-child {
  border-bottom: 0;
}

.section-heading {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

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

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

.dialog-close {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-soft);
  background: transparent;
  font-size: 24px;
}

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

.image-item {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}

.image-item.is-main {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(216, 92, 43, 0.15);
}

.image-item img {
  display: block;
  width: 100%;
  height: 130px;
  padding: 8px;
  object-fit: contain;
}

.image-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
}

.image-tools button {
  min-height: 34px;
  padding: 4px 7px;
  border: 0;
  color: var(--ink-soft);
  background: var(--surface);
  font-size: 11px;
}

.image-tools button + button {
  border-left: 1px solid var(--line);
}

.image-tools .remove {
  color: var(--danger);
}

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

.spec-row {
  display: grid;
  grid-template-columns: minmax(140px, 0.7fr) minmax(220px, 1.3fr) 38px;
  gap: 8px;
}

.spec-row button {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--danger);
  background: var(--surface);
}

.editor-footer {
  border-top: 1px solid var(--line);
}

.editor-footer > div {
  display: flex;
  gap: 9px;
}

.confirm-dialog {
  width: min(430px, calc(100% - 28px));
}

.confirm-dialog form {
  padding: 28px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.confirm-dialog p {
  color: var(--muted);
  line-height: 1.65;
}

.confirm-actions {
  justify-content: flex-end;
  gap: 9px;
  margin-top: 24px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  padding: 12px 16px;
  border-radius: 6px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease;
}

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

@media (max-width: 900px) {
  .product-row {
    grid-template-columns: 58px minmax(0, 1fr) auto;
  }

  .row-meta,
  .row-category {
    display: none;
  }

  .summary-strip {
    grid-template-columns: repeat(3, 1fr);
  }

  .summary-time {
    display: none !important;
  }
}

@media (max-width: 680px) {
  .admin-topbar,
  .list-toolbar,
  .section-heading,
  .editor-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-topbar {
    padding: 20px;
  }

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

  .admin-main {
    width: calc(100% - 24px);
    margin-top: 14px;
  }

  .summary-strip {
    grid-template-columns: repeat(3, 1fr);
  }

  .summary-strip > div {
    padding: 14px 10px;
    text-align: center;
  }

  .toolbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box input {
    width: 100%;
  }

  .product-row {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
  }

  .row-image {
    width: 46px;
    height: 46px;
  }

  .row-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

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

  .spec-row button {
    min-height: 36px;
  }

  .editor-section {
    padding: 18px 0;
  }
}
