:root {
  --accent: #e84b32;
  --ink: #1a1d21;
  --muted: #6e747c;
  --line: #dfe2e5;
  --surface: #f6f7f7;
  --panel: #ffffff;
  --sidebar: #191c20;
  --danger: #c7352c;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--surface);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans SC", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button, input, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }

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

.login-panel {
  width: min(400px, 100%);
  padding: 40px;
  background: white;
  border-top: 3px solid var(--accent);
}

.login-brand { margin: 0 0 40px; font: 700 17px Georgia, serif; }
.login-panel h1 { margin: 0 0 30px; font-size: 28px; }
.login-panel label { display: block; margin-bottom: 9px; font-weight: 700; }
.form-error { min-height: 20px; margin: 8px 0 12px; color: var(--danger); font-size: 13px; }

.admin-app { min-height: 100vh; }

.sidebar {
  width: 236px;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  color: white;
  background: var(--sidebar);
}

.sidebar-brand {
  height: 82px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.4);
  border-radius: 50%;
  font: 700 16px Georgia, serif;
}
.brand-mark.has-image { overflow: hidden; border-color: transparent; }
.brand-mark img { width: 100%; height: 100%; display: block; object-fit: cover; }

.sidebar-brand div { display: grid; gap: 3px; min-width: 0; }
.sidebar-brand strong { overflow: hidden; text-overflow: ellipsis; font: 700 15px Georgia, "Microsoft YaHei UI", serif; }
.sidebar-brand small { color: #9298a0; font-size: 11px; }

.sidebar nav { display: grid; gap: 4px; padding: 20px 12px; }
.nav-item {
  height: 44px;
  border: 0;
  border-left: 3px solid transparent;
  padding: 0 18px;
  color: #aeb3b9;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.nav-item:hover { color: white; background: rgba(255,255,255,.05); }
.nav-item.active { border-left-color: var(--accent); color: white; background: rgba(255,255,255,.08); }

.sidebar-foot {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding: 20px 24px 26px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.sidebar-foot a, .sidebar-foot button {
  border: 0;
  padding: 0;
  color: #aeb3b9;
  background: none;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.sidebar-foot a:hover, .sidebar-foot button:hover { color: white; }

.main-content { margin-left: 236px; }
.topbar {
  height: 82px;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 36px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.96);
}
.topbar > div { display: flex; align-items: center; gap: 14px; }
.topbar p { margin: 0; font-weight: 700; }
.save-state { color: var(--muted); font-size: 12px; }
.save-state.dirty { color: #ad6b00; }

.button {
  min-height: 40px;
  border: 1px solid transparent;
  padding: 0 17px;
  font-weight: 700;
  cursor: pointer;
}
.button:disabled { opacity: .55; cursor: not-allowed; }
.button.primary { color: white; background: var(--accent); }
.button.primary:hover:not(:disabled) { filter: brightness(.93); }
.button.secondary { border-color: #cfd3d7; color: var(--ink); background: white; }
.button.secondary:hover { border-color: #90969c; }
.button.ghost { color: var(--muted); background: transparent; }
.button.full { width: 100%; }

.content-shell { width: min(1040px, calc(100% - 72px)); margin: 0 auto; padding: 54px 0 90px; }
.editor-section { scroll-margin-top: 105px; }
.editor-section + .editor-section { margin-top: 88px; padding-top: 64px; border-top: 1px solid var(--line); }
.section-title { margin-bottom: 34px; }
.section-title.product-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.section-title.stats-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.eyebrow { margin: 0 0 7px; color: var(--accent); font-size: 11px; font-weight: 700; }
.section-title h1, .section-title h2 { margin: 0; font-size: 28px; }

.settings-form {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  padding: 30px;
  border: 1px solid var(--line);
  background: white;
}
.field { min-width: 0; }
.field.span-2 { grid-column: span 2; }
.field.span-4 { grid-column: 1 / -1; }
.field label, .product-fields label { display: block; margin-bottom: 9px; font-size: 12px; font-weight: 700; }
input, textarea {
  width: 100%;
  border: 1px solid #ccd0d4;
  border-radius: 0;
  outline: 0;
  color: var(--ink);
  background: white;
}
input { height: 42px; padding: 0 12px; }
textarea { resize: vertical; min-height: 76px; padding: 11px 12px; line-height: 1.6; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 14%, transparent); }
input::placeholder, textarea::placeholder { color: #a1a6ab; }

.color-input { height: 42px; display: flex; align-items: center; gap: 10px; border: 1px solid #ccd0d4; padding: 5px 10px 5px 5px; }
.color-input input { width: 34px; height: 30px; border: 0; padding: 0; background: none; cursor: pointer; }
.color-input span { color: var(--muted); font-family: Consolas, monospace; font-size: 12px; text-transform: uppercase; }

.logo-editor { display: flex; align-items: center; gap: 20px; padding: 18px; border: 1px solid var(--line); background: #fafafa; }
.logo-preview { width: 72px; height: 72px; display: grid; flex: 0 0 72px; place-items: center; overflow: hidden; border: 1px solid #cfd3d7; border-radius: 50%; color: var(--muted); background: white; font: 700 23px Georgia, serif; }
.logo-preview img { width: 100%; height: 100%; display: block; object-fit: cover; }
.logo-controls { min-width: 0; }
.logo-controls > div { display: flex; flex-wrap: wrap; gap: 8px; }
.logo-upload-button { display: inline-flex !important; align-items: center; justify-content: center; margin: 0 !important; }
.logo-controls p { margin: 9px 0 0; color: var(--muted); font-size: 11px; }
.logo-controls > span { min-height: 16px; display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }

.hero-media-field { padding-top: 6px; }
.hero-media-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.hero-media-heading strong { font-size: 14px; }
.hero-media-heading p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.hero-upload-button { display: inline-flex !important; align-items: center; justify-content: center; flex: 0 0 auto; margin: 0 !important; }
.hero-media-options { min-height: 54px; display: flex; align-items: center; gap: 26px; padding: 0 16px; border: 1px solid var(--line); background: #fafafa; }
.switch-field { display: flex !important; align-items: center; gap: 9px; margin: 0 !important; cursor: pointer; }
.switch-field input { width: 17px; height: 17px; padding: 0; accent-color: var(--accent); }
.switch-field span { font-size: 12px; }
.interval-field { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.interval-field label { margin: 0; font-size: 12px; }
.interval-field input { width: 70px; height: 34px; }
.interval-field span { color: var(--muted); font-size: 11px; }
.hero-upload-status { min-height: 18px; margin: 10px 0 0; color: var(--muted); font-size: 11px; }
.hero-image-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.hero-image-item { min-width: 0; border: 1px solid var(--line); background: #fafafa; }
.hero-image-item img, .hero-image-item video { width: 100%; aspect-ratio: 4 / 3; display: block; object-fit: cover; background: #17191b; }
.hero-image-actions { display: flex; align-items: center; justify-content: space-between; padding: 7px; }
.hero-image-actions span { color: var(--muted); font-size: 10px; }
.hero-image-actions div { display: flex; gap: 4px; }
.hero-image-actions button { width: 28px; height: 28px; border: 1px solid #d4d7da; padding: 0; color: var(--muted); background: white; cursor: pointer; }
.hero-image-actions button:hover:not(:disabled) { border-color: #92979c; color: var(--ink); }
.hero-image-actions button:disabled { opacity: .35; cursor: default; }
.hero-image-actions button.remove { color: var(--danger); }
.hero-images-empty { grid-column: 1 / -1; padding: 30px 12px; border: 1px dashed #ccd0d4; color: var(--muted); font-size: 12px; text-align: center; }

.product-list { border-top: 1px solid var(--line); }
.product-row {
  min-height: 112px;
  display: grid;
  grid-template-columns: 126px minmax(0, 1fr) 120px 116px;
  align-items: center;
  gap: 22px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.row-image { width: 126px; height: 82px; overflow: hidden; background: #e8eaeb; }
.row-image img { width: 100%; height: 100%; display: block; object-fit: cover; }
.row-copy { min-width: 0; }
.row-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.row-copy p { margin: 8px 0 0; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.row-category { color: var(--muted); font-size: 12px; }
.featured-badge { display: inline-block; margin-left: 8px; padding: 3px 6px; color: #236a4a; background: #e2f2e9; font-size: 10px; vertical-align: 1px; }
.row-actions { display: flex; justify-content: flex-end; gap: 8px; }
.row-actions button { height: 34px; border: 1px solid #ccd0d4; padding: 0 11px; color: var(--ink); background: white; cursor: pointer; }
.row-actions button:hover { border-color: #8d9399; }
.row-actions button.danger { color: var(--danger); }
.list-empty { padding: 70px 20px; border-block: 1px solid var(--line); color: var(--muted); text-align: center; }
.list-empty strong { display: block; margin-bottom: 12px; color: var(--ink); }
.text-button { border: 0; border-bottom: 1px solid currentColor; padding: 0 0 2px; color: var(--accent); background: none; cursor: pointer; }

.analytics-card {
  min-height: 230px;
  display: grid;
  grid-template-columns: 1fr minmax(220px, 320px);
  align-items: end;
  gap: 40px;
  padding: 32px;
  border: 1px solid var(--line);
  background: white;
}
.analytics-card span { display: block; color: var(--muted); font-size: 12px; }
.analytics-card strong { display: block; margin-top: 12px; font-size: 72px; font-weight: 500; line-height: 1; }
.analytics-card > div p { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.analytics-note { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.8; }

.password-form {
  max-width: 650px;
  display: grid;
  gap: 20px;
  padding: 30px;
  border: 1px solid var(--line);
  background: white;
}
.password-form label { display: block; margin-bottom: 9px; font-size: 12px; font-weight: 700; }
.password-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 4px; }
.password-actions p { margin: 0; color: var(--muted); font-size: 11px; }

dialog { padding: 0; }
.product-dialog { width: min(900px, calc(100% - 32px)); max-height: calc(100vh - 32px); border: 0; box-shadow: 0 24px 80px rgba(0,0,0,.3); }
.product-dialog::backdrop { background: rgba(17,19,21,.68); }
.product-dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.dialog-header { min-height: 78px; display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-size: 22px; }
.close-button { width: 38px; height: 38px; border: 0; color: var(--muted); background: transparent; font-size: 27px; cursor: pointer; }
.dialog-body { display: grid; grid-template-columns: 260px 1fr; gap: 30px; padding: 26px; overflow: auto; }
.image-preview { aspect-ratio: 4 / 3; display: grid; place-items: center; overflow: hidden; color: var(--muted); background: #eaeced; }
.image-preview img { width: 100%; height: 100%; display: block; object-fit: cover; }
.upload-button { width: 100%; display: flex; align-items: center; justify-content: center; margin-top: 10px; }
.upload-status { min-height: 18px; margin: 8px 0 0; color: var(--muted); font-size: 11px; text-align: center; }
.product-fields { display: grid; gap: 18px; }
.field-row { display: flex; align-items: flex-end; gap: 16px; }
.field-row .grow { flex: 1; }
.check-field { min-height: 42px; display: flex !important; align-items: center; gap: 9px; margin: 0 !important; cursor: pointer; }
.check-field input { width: 17px; height: 17px; accent-color: var(--accent); }
.dialog-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 15px 24px; border-top: 1px solid var(--line); background: #fafafa; }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  max-width: min(360px, calc(100% - 48px));
  padding: 13px 18px;
  color: white;
  background: #202429;
  box-shadow: 0 10px 30px rgba(0,0,0,.22);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 180ms ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

@media (max-width: 820px) {
  .sidebar { width: 100%; height: 64px; inset: 0 0 auto; flex-direction: row; align-items: center; }
  .sidebar-brand, .sidebar-foot { display: none; }
  .sidebar nav { width: 100%; display: flex; overflow-x: auto; padding: 0 6px; }
  .nav-item { min-width: 82px; flex: 1; height: 64px; border-left: 0; border-bottom: 3px solid transparent; padding: 0 9px; text-align: center; }
  .nav-item.active { border-bottom-color: var(--accent); }
  .main-content { margin: 64px 0 0; }
  .topbar { height: 68px; padding: 0 16px; }
  .content-shell { width: min(100% - 32px, 1040px); padding-top: 40px; }
  .settings-form { grid-template-columns: 1fr 1fr; padding: 20px; }
  .field.span-2, .field.span-4 { grid-column: 1 / -1; }
  .product-row { grid-template-columns: 90px minmax(0,1fr) 104px; gap: 14px; }
  .row-image { width: 90px; height: 68px; }
  .row-category { display: none; }
  .dialog-body { grid-template-columns: 210px 1fr; gap: 20px; padding: 20px; }
  .analytics-card { grid-template-columns: 1fr; gap: 28px; }
  .hero-image-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .login-panel { padding: 30px 24px; }
  .topbar > div { display: grid; gap: 2px; }
  .content-shell { width: calc(100% - 24px); }
  .section-title.product-title { align-items: flex-start; }
  .settings-form { grid-template-columns: 1fr; padding: 16px; gap: 18px; }
  .product-row { grid-template-columns: 72px minmax(0,1fr); min-height: 96px; }
  .row-image { width: 72px; height: 60px; }
  .row-actions { grid-column: 2; justify-content: flex-start; margin-top: -6px; }
  .dialog-body { grid-template-columns: 1fr; }
  .image-editor { width: min(260px, 100%); }
  .field-row { align-items: stretch; flex-direction: column; }
  .field-row .field { width: 100%; }
  .check-field { align-self: flex-start; }
  .section-title.stats-title { align-items: flex-start; }
  .analytics-card { min-height: 210px; padding: 24px 20px; }
  .analytics-card strong { font-size: 60px; }
  .password-form { padding: 22px 18px; }
  .password-actions { align-items: stretch; flex-direction: column; }
  .password-actions .button { width: 100%; }
  .hero-media-heading { align-items: flex-start; flex-direction: column; gap: 14px; }
  .hero-media-options { align-items: flex-start; flex-direction: column; gap: 14px; padding-block: 14px; }
  .interval-field { margin-left: 0; }
  .hero-image-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
