:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-muted: #f2f2f4;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #d8d8de;
  --primary: #0071e3;
  --primary-dark: #005bb5;
  --accent: #3a3a3c;
  --danger: #d70015;
  --success: #248a3d;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.07);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px clamp(16px, 4vw, 48px);
  background: rgba(251, 251, 253, 0.82);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  backdrop-filter: saturate(180%) blur(18px);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: #1d1d1f;
  color: #fff;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.brand-logo {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.25;
}

.brand strong {
  font-weight: 700;
  letter-spacing: 0;
}

.brand small {
  color: var(--muted);
  margin-top: 2px;
}

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

.topnav a,
.ghost-button,
.primary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.primary-button {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

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

.ghost-button:hover,
.topnav a:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #fff;
}

.primary-button:active,
.ghost-button:active,
.topnav a:active,
.danger-button:active {
  transform: scale(0.99);
}

.ghost-button:disabled,
.primary-button:disabled,
.danger-button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
}

.danger-button {
  border-color: #ffd6dc;
  background: #fff5f6;
  color: var(--danger);
  font-weight: 700;
}

.compact {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.form-shell {
  width: min(773px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 64px;
}

.admin-shell {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 64px;
}

.login-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-shell {
  width: min(420px, calc(100% - 32px));
}

.login-card {
  display: grid;
  justify-items: center;
  gap: 22px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-logo {
  width: 58px;
  height: 58px;
}

.login-card h1 {
  margin: 0;
  font-size: 30px;
}

.login-form {
  display: grid;
  width: 100%;
  gap: 16px;
}

.login-form label {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

.login-error {
  display: block;
  min-height: 18px;
}

.intro-band,
.admin-head {
  display: grid;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 52px 0 34px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  text-align: center;
}

.intro-band > div {
  max-width: 880px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(36px, 7vw, 64px);
  line-height: 1.08;
  letter-spacing: 0;
  font-weight: 760;
}

.intro-copy {
  max-width: 760px;
  margin-bottom: 0;
  margin-left: auto;
  margin-right: auto;
  color: var(--muted);
  line-height: 1.8;
}

.intro-status {
  width: 230px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.intro-status strong,
.intro-status span {
  display: block;
}

.intro-status span {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.6;
}

.form-stack {
  display: grid;
  gap: 18px;
  margin-top: 22px;
}

.form-section,
.submit-panel,
.data-panel,
.drawer-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.form-section {
  padding: clamp(18px, 3vw, 28px);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}

.section-head h2 {
  margin-bottom: 6px;
  font-size: 22px;
  font-weight: 720;
}

.section-head p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.7;
}

.field-grid,
.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field-label {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
  line-height: 1.45;
  text-align: left;
}

.field-title {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.field-number {
  flex: 0 0 auto;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.field-title-text {
  min-width: 0;
}

.required-star {
  flex: 0 0 auto;
  color: var(--danger);
  font-weight: 800;
  line-height: 1;
  transform: translateY(-0.08em);
}

.required-tag {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fff1f2;
  color: var(--danger);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid #c7c7cc;
  border-radius: 8px;
  background: #fbfbfd;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.14);
}

.field-note,
.muted {
  margin: -2px 0 2px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  text-align: left;
}

.range-control {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}

.range-control span {
  color: var(--muted);
}

.choice-group {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.choice-button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-height: 24px;
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  transition: color 160ms ease;
}

.choice-button input {
  appearance: auto;
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  accent-color: var(--primary);
  cursor: pointer;
}

.choice-button input:focus {
  box-shadow: none;
}

.choice-button:has(input:checked) {
  color: var(--primary);
}

.location-control {
  display: grid;
  gap: 10px;
}

.location-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.mini-field {
  display: grid;
  gap: 6px;
}

.mini-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.locate-button {
  width: fit-content;
  display: none;
}

.example-image-button {
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbfd;
  cursor: zoom-in;
  overflow: hidden;
}

.example-image-button img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  background: #f5f5f7;
}

.upload-control {
  display: grid;
  gap: 10px;
}

.upload-box {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 104px;
  padding: 16px;
  border: 1px dashed #b9b9c0;
  border-radius: 8px;
  background: var(--surface-muted);
  text-align: center;
  overflow: hidden;
  transition: border-color 160ms ease, background 160ms ease;
}

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

.upload-title {
  display: block;
  font-weight: 800;
  color: var(--primary);
}

.upload-requirement {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.file-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
}

.file-preview-wrap {
  position: relative;
  min-width: 0;
}

.file-preview {
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f5f7;
  cursor: zoom-in;
  overflow: hidden;
}

.remove-file-button {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(29, 29, 31, 0.82);
  color: #fff;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}

.file-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-status {
  margin: -2px 0 0;
  color: var(--success);
  font-size: 13px;
  font-weight: 700;
}

.field-error {
  display: none;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.field.invalid input,
.field.invalid select,
.field.invalid textarea,
.field.invalid .upload-box {
  border-color: var(--danger);
}

.field.invalid .field-error {
  display: block;
}

.product-list {
  display: grid;
  gap: 16px;
}

.product-item {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbfd;
}

.product-item-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
}

.icon-button.danger {
  color: var(--danger);
  border-color: #f0c5c5;
}

.section-actions {
  margin-top: 16px;
}

.submit-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px;
}

.submit-panel p {
  margin-bottom: 0;
  color: var(--muted);
}

.success-backdrop {
  position: fixed;
  inset: 0;
  z-index: 54;
  background: rgba(0, 0, 0, 0.38);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.success-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.success-dialog {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 55;
  display: grid;
  place-items: center;
  gap: 16px;
  min-width: min(280px, calc(100% - 48px));
  min-height: 178px;
  padding: 30px 28px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 28px 76px rgba(0, 0, 0, 0.22);
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transform: translate(-50%, -50%) scale(0.96);
  transition: opacity 180ms ease, transform 180ms ease;
}

.success-dialog.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.success-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(180deg, #34c759 0%, #1f9d46 100%);
  color: #fff;
  box-shadow: 0 12px 24px rgba(36, 138, 61, 0.24), inset 0 1px 1px rgba(255, 255, 255, 0.35);
}

.success-check-icon {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.success-title {
  color: var(--text);
  font-size: 19px;
  font-weight: 760;
  line-height: 1.25;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  max-width: min(420px, calc(100% - 48px));
  padding: 14px 16px;
  border-radius: 8px;
  background: #1d1d1f;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast[data-tone="success"] {
  background: var(--success);
}

.toast[data-tone="error"] {
  background: var(--danger);
}

.image-preview-dialog {
  width: fit-content;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.image-preview-dialog::backdrop {
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(6px);
}

.image-preview-dialog img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 80px);
  object-fit: contain;
}

.image-preview-close {
  position: static;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin: 0 0 8px auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #000;
  box-shadow: none;
  z-index: 1;
  font-size: 28px;
  font-weight: 500;
  line-height: 1;
}

.admin-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  text-align: left;
}

.admin-head h1 {
  margin-bottom: 0;
}

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

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

.stat-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.stat-card span {
  color: var(--muted);
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
  line-height: 1;
  font-weight: 760;
}

.data-panel {
  overflow: hidden;
}

.table-toolbar {
  display: grid;
  grid-template-columns: minmax(170px, 1.25fr) minmax(128px, 0.9fr) minmax(142px, 0.9fr) minmax(128px, 0.9fr) minmax(118px, 0.75fr);
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  overflow-x: hidden;
}

table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 11px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  word-break: break-word;
}

th {
  background: #f5f5f7;
  color: #6e6e73;
  font-size: 12px;
  font-weight: 700;
}

th:nth-child(1),
td:nth-child(1) {
  width: 4%;
}

th:nth-child(2),
td:nth-child(2) {
  width: 18%;
}

th:nth-child(3),
td:nth-child(3) {
  width: 7%;
}

th:nth-child(4),
td:nth-child(4) {
  width: 10%;
}

th:nth-child(5),
td:nth-child(5) {
  width: 5%;
}

th:nth-child(6),
td:nth-child(6) {
  width: 8%;
}

th:nth-child(7),
td:nth-child(7) {
  width: 8%;
}

th:nth-child(8),
td:nth-child(8) {
  width: 8%;
}

th:nth-child(9),
td:nth-child(9) {
  width: 8%;
}

th:nth-child(10),
td:nth-child(10) {
  width: 24%;
}

td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eaf6ee;
  color: #0b6b32;
  font-weight: 700;
  font-size: 13px;
}

.status-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(11, 107, 50, 0.1);
}

.status-unreviewed {
  background: #f5f5f7;
  color: #6e6e73;
}

.status-reviewed {
  background: #eaf6ee;
  color: #0b6b32;
}

.status-archived {
  background: #eef4ff;
  color: #005bb5;
}

.status-designed {
  background: #fff5e6;
  color: #9a5a00;
}

.row-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  min-width: 0;
}

.row-actions .compact {
  min-height: 28px;
  padding: 0 6px;
  font-size: 11px;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  justify-content: flex-end;
  background: rgba(0, 0, 0, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.drawer.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-card {
  width: min(840px, 100%);
  height: 100%;
  border-radius: 8px 0 0 8px;
  overflow: auto;
  transform: translateX(30px);
  transition: transform 180ms ease;
}

.drawer.open .drawer-card {
  transform: translateX(0);
}

.drawer-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(251, 251, 253, 0.86);
  backdrop-filter: saturate(180%) blur(18px);
}

.drawer-head h2 {
  margin-bottom: 0;
}

.drawer-content {
  padding: 20px;
}

.drawer-form {
  display: grid;
  gap: 22px;
}

.admin-field {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

.admin-field span {
  color: var(--muted);
  font-size: 13px;
}

.admin-field.wide {
  grid-column: 1 / -1;
}

.drawer-section {
  display: grid;
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.drawer-section h3,
.file-group h3 {
  margin-bottom: 0;
  font-size: 18px;
}

.file-group {
  display: grid;
  gap: 10px;
}

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

.file-gallery a {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbfd;
}

.file-gallery img,
.file-tile {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  object-fit: cover;
  background: #f2f2f4;
}

.file-tile {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.file-gallery small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.drawer-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 0 0;
  background: var(--surface);
}

@media (max-width: 860px) {
  .intro-band,
  .admin-head,
  .submit-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .intro-status {
    width: 100%;
  }

  .field-grid,
  .admin-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .location-grid {
    grid-template-columns: 1fr;
  }

  .product-item {
    grid-template-columns: 1fr;
  }

  .table-toolbar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .topnav,
  .topnav a,
  .admin-actions,
  .admin-actions a,
  .submit-panel .primary-button {
    width: 100%;
  }

  .range-control {
    grid-template-columns: 1fr;
  }

  .range-control span {
    display: none;
  }

  .drawer-card {
    border-radius: 0;
  }
}
