:root {
  --bg: #f4f6f4;
  --surface: #fff;
  --text: #202521;
  --muted: #69746d;
  --line: #dfe5df;
  --brand: #ff6900;
  --brand-dark: #d94f00;
  --danger: #b9372d;
  --soft: #fff3e8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

body.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
  background: linear-gradient(130deg, rgba(255, 105, 0, 0.96), rgba(166, 68, 0, 0.88));
}

a {
  color: inherit;
  text-decoration: none;
}

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

.admin-top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
  padding: 0 28px;
  background: var(--brand);
  color: #fff;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand__mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 12px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-badge {
  color: rgba(255, 255, 255, 0.86);
  font-size: 13px;
}

.admin-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 22px;
}

.sidebar {
  display: grid;
  align-content: start;
  gap: 18px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(35, 44, 38, 0.06);
}

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

.panel__head h1,
.panel__head h2 {
  margin: 0;
}

.panel__head h1 {
  font-size: 24px;
}

.panel__head h2 {
  font-size: 18px;
}

.panel__head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.search {
  display: block;
  padding: 12px 16px;
}

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

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255, 105, 0, 0.14);
}

.product-list {
  display: grid;
  gap: 8px;
  max-height: 46vh;
  overflow: auto;
  padding: 0 12px 14px;
}

.product-item {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  min-height: 68px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.product-item.is-active {
  border-color: var(--brand);
  background: var(--soft);
}

.product-item img {
  width: 54px;
  height: 54px;
  border-radius: 6px;
  object-fit: cover;
  background: #fff1e5;
}

.product-item strong,
.product-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-item small {
  margin-top: 5px;
  color: var(--muted);
}

.category-editor {
  display: grid;
  gap: 10px;
  padding: 14px 16px 16px;
}

.category-row,
.image-row {
  display: grid;
  grid-template-columns: minmax(0, 0.7fr) minmax(0, 1fr) 38px;
  gap: 8px;
  align-items: center;
}

.image-row {
  grid-template-columns: 72px minmax(180px, 1fr) auto;
  align-items: end;
}

.image-row img {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  cursor: zoom-in;
  object-fit: cover;
  background: #fff1e5;
}

.image-row img:focus-visible {
  outline: 3px solid rgba(255, 105, 0, 0.38);
  outline-offset: 2px;
}

.image-row label {
  min-width: 0;
}

.image-row label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.image-row__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.image-row__actions .secondary-button {
  min-height: 38px;
  padding: 0 12px;
}

.cover-badge {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(255, 105, 0, 0.32);
  border-radius: 8px;
  background: rgba(255, 105, 0, 0.1);
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
}

.editor {
  min-width: 0;
}

.editor__head {
  align-items: flex-start;
}

.product-form,
.site-form {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.site-form {
  gap: 12px;
  padding: 14px 16px 16px;
}

.product-form label span,
.site-form label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

.form-grid--single {
  grid-template-columns: 1fr;
  gap: 12px;
}

.image-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.image-tools h2 {
  margin: 0;
  font-size: 18px;
}

.image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.support-upload {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.support-upload img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.support-upload img[hidden] {
  display: none;
}

.image-list {
  display: grid;
  gap: 10px;
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-link,
.ghost-button,
.upload-button,
.icon-button,
.remove-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  padding: 0 18px;
  border: 0;
  background: #fff;
  color: var(--brand-dark);
}

.secondary-button,
.ghost-link,
.upload-button {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.upload-button {
  position: relative;
  overflow: hidden;
  background: var(--soft);
  border-color: rgba(255, 105, 0, 0.32);
  color: var(--brand-dark);
}

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

.ghost-link {
  border-color: rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.ghost-button {
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.login-card {
  width: min(430px, 100%);
  padding: 28px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(12, 23, 18, 0.22);
}

.login-brand {
  color: var(--text);
}

.login-brand .brand__mark {
  border-color: var(--brand);
  color: var(--brand);
}

.login-brand small {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 26px;
}

.login-form label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.hidden-tool-link {
  color: inherit;
  text-decoration: none;
}

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

.login-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.user-list {
  display: grid;
  gap: 8px;
  padding: 0 16px 16px;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.user-row strong,
.user-row small {
  display: block;
}

.user-row small {
  margin-top: 3px;
  color: var(--muted);
}

.danger-button {
  padding: 0 14px;
  border: 1px solid rgba(185, 55, 45, 0.32);
  background: #fff;
  color: var(--danger);
}

.icon-button,
.remove-button {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 20px;
}

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

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #16211b;
  color: #fff;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

.admin-image-viewer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(12, 19, 16, 0.72);
}

.admin-image-viewer__panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(980px, calc(100vw - 36px));
  height: min(760px, calc(100vh - 36px));
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.admin-image-viewer__bar,
.admin-image-viewer__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.admin-image-viewer__foot {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.admin-image-viewer__foot span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-image-viewer__foot a {
  flex: 0 0 auto;
  color: var(--brand-dark);
  font-weight: 800;
  text-decoration: none;
}

.admin-image-viewer__stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 18px 58px;
  background: #fff3e8;
}

.admin-image-viewer__stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #fff;
}

.admin-image-viewer__close,
.admin-image-viewer__nav {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.admin-image-viewer__close {
  width: 36px;
  height: 36px;
  font-size: 22px;
  line-height: 1;
}

.admin-image-viewer__nav {
  position: absolute;
  top: 50%;
  width: 42px;
  height: 52px;
  transform: translateY(-50%);
  font-size: 34px;
}

.admin-image-viewer__nav--prev {
  left: 14px;
}

.admin-image-viewer__nav--next {
  right: 14px;
}

@media (max-width: 920px) {
  .admin-shell {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .product-list {
    max-height: none;
  }
}

@media (max-width: 620px) {
  .admin-top {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions > * {
    flex: 1;
  }

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

  .image-row {
    grid-template-columns: 58px minmax(0, 1fr) 38px;
  }

  .image-row img {
    width: 58px;
    height: 58px;
  }

  .admin-image-viewer {
    padding: 10px;
  }

  .admin-image-viewer__panel {
    width: calc(100vw - 20px);
    height: calc(100vh - 20px);
  }

  .admin-image-viewer__stage {
    padding: 12px 46px;
  }

  .admin-image-viewer__nav {
    width: 34px;
    height: 44px;
  }
}
