:root {
  color-scheme: light;
  --ink: #171a1f;
  --muted: #6b7280;
  --line: #e2e5e9;
  --panel: #ffffff;
  --soft: #f7f8fa;
  --brand: #1f2937;
  --brand-dark: #111827;
  --brand-soft: #f1f3f5;
  --accent: #6f5b3e;
  --danger: #b42318;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #ffffff 0, #fafafa 320px, var(--soft) 100%);
  color: var(--ink);
}

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

.shell {
  width: min(1200px, calc(100vw - 40px));
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  font-size: 20px;
  white-space: nowrap;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #1f2937;
  color: white;
  box-shadow: 0 10px 22px rgba(17, 24, 39, 0.16);
}

.nav {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
}

.nav a,
.ghost,
.primary,
.danger {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 14px;
  text-decoration: none;
  color: var(--ink);
  background: white;
  cursor: pointer;
  font-weight: 700;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.nav a:hover,
.ghost:hover {
  border-color: #b9c7cf;
  background: #f8faf9;
}

.primary:active,
.ghost:active,
.danger:active {
  transform: translateY(1px);
}

.primary {
  color: white;
  background: var(--brand);
  border-color: var(--brand);
  box-shadow: none;
}

.primary:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.danger {
  color: white;
  background: var(--danger);
  border-color: var(--danger);
}

.hero {
  padding: 42px 0 26px;
}

.hero h1 {
  max-width: 760px;
  margin: 0 0 12px;
  font-size: clamp(34px, 6vw, 62px);
  line-height: 1.02;
  letter-spacing: 0;
}

.hero p {
  max-width: 700px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
  margin: 0;
}

.storefront {
  padding-bottom: 64px;
}

.hero-panel-foot {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.hero-panel-foot span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: #334155;
  background: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  font-weight: 900;
}

.catalog-head {
  position: sticky;
  top: 76px;
  z-index: 8;
  margin: 22px 0 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
  box-shadow: 0 12px 28px rgba(17, 24, 39, 0.04);
}

.store-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0;
}

.store-toolbar h2 {
  margin: 0;
  font-size: 24px;
}

.store-toolbar p {
  margin: 5px 0 0;
  color: var(--muted);
}

.search-box {
  width: min(420px, 100%);
}

.search-box input {
  min-height: 48px;
  background: #f8faf9;
}

.category-bar {
  margin: 14px 0 0;
}

.page {
  padding-bottom: 46px;
}

.page-title {
  min-height: 148px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.page-title h1 {
  margin: 4px 0 0;
  font-size: clamp(34px, 5vw, 54px);
  line-height: 1.05;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--brand);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.chip {
  white-space: nowrap;
  border: 1px solid var(--line);
  background: #f8faf9;
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 800;
}

.chip.active {
  color: white;
  border-color: var(--brand);
  background: var(--brand);
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding-bottom: 44px;
}

.product-row {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) 180px;
  gap: 18px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 132px;
  box-shadow: 0 10px 26px rgba(17, 24, 39, 0.04);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.product-row:hover {
  border-color: #cfd5dc;
  box-shadow: 0 16px 34px rgba(17, 24, 39, 0.07);
}

.product-media,
.product-media .product-thumb,
.product-media .icon {
  width: 96px;
  height: 96px;
}

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

.product-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.icon {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #eef3f4;
  color: var(--brand);
  font-size: 25px;
  font-weight: 900;
}

.product-thumb {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
}

.admin-thumb {
  width: 46px;
  height: 46px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
}

.badge {
  align-self: flex-start;
  border: 1px solid #e4dccf;
  background: #fbf8f2;
  color: var(--accent);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 900;
}

.muted-badge {
  border-color: var(--line);
  background: #f8faf9;
  color: var(--muted);
}

.category-pill {
  display: block;
  color: #4b5563;
  font-size: 12px;
  font-weight: 900;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  background: #f8fafc;
}

.product-row h3 {
  margin: 0;
  max-width: 760px;
  font-size: 20px;
  line-height: 1.35;
  letter-spacing: 0;
}

.price-line {
  margin-top: 2px;
  color: #111827;
  font-size: 27px;
  line-height: 1;
  font-weight: 900;
}

.price-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.meta,
.desc {
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
}

.desc {
  max-width: 760px;
  margin-top: 8px;
  min-height: 0;
}

.product-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.product-action {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.product-action .primary {
  width: 132px;
  min-height: 42px;
}

.empty-products {
  grid-column: 1 / -1;
  min-height: 180px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 30;
}

.modal.show {
  display: flex;
}

.dialog {
  width: min(520px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  background: white;
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.26);
}

.buy-dialog {
  width: min(860px, calc(100vw - 24px));
  padding: 24px;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.dialog h2,
.panel h2 {
  margin: 0 0 14px;
}

.icon-button {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #4b5563;
  background: #fff;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  font-weight: 500;
}

.icon-button:hover {
  border-color: #c8ced6;
  background: #f8fafc;
}

.buy-scroll {
  max-height: calc(100vh - 150px);
  overflow: auto;
  padding: 4px 2px 2px;
}

.buy-product-card {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 22px;
  align-items: center;
  margin-top: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.buy-product-media {
  min-width: 0;
}

.buy-product-image,
.buy-product-icon {
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
}

.buy-product-image {
  display: block;
  object-fit: cover;
}

.buy-product-icon {
  display: grid;
  place-items: center;
  color: var(--brand);
  font-size: 54px;
  font-weight: 900;
}

.buy-product-main {
  min-width: 0;
}

.buy-product-main h3 {
  margin: 0;
  font-size: 25px;
  line-height: 1.35;
  letter-spacing: 0;
}

.buy-product-tags {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.stock-tag,
.sold-tag {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 5px 12px;
  font-weight: 900;
}

.stock-tag {
  background: #dcfce7;
  color: #166534;
}

.sold-tag {
  background: #fef0d0;
  color: #8a3f22;
}

.buy-description {
  padding: 20px 0;
  color: #334155;
  font-size: 17px;
  line-height: 1.9;
  border-bottom: 1px solid var(--line);
  white-space: normal;
  word-break: break-word;
}

.buy-description a {
  color: #2563eb;
}

.buy-pay-method {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.buy-pay-method span {
  color: var(--muted);
  font-weight: 800;
}

.buy-pay-method strong {
  color: var(--ink);
  font-size: 17px;
}

.pay-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.alipay-logo {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: #1677ff;
  color: #fff;
  font-style: normal;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.buy-price-box {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.buy-price-box div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.buy-price-box span {
  color: var(--muted);
  font-weight: 800;
}

.buy-price-box strong {
  font-size: 24px;
  line-height: 1;
}

.buy-form {
  gap: 14px;
}

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

.field-label {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 14px;
}

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

.quantity-control input {
  width: 120px;
  text-align: center;
  font-weight: 900;
}

.qty-button {
  width: 42px;
  height: 42px;
  border: 1px solid #d1d8df;
  border-radius: 8px;
  background: #eef3f4;
  color: var(--brand);
  cursor: pointer;
  font-size: 22px;
  font-weight: 900;
}

.buy-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 6px -2px 0;
  padding: 14px 0 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), #fff 34%);
}

.buy-actions .primary,
.buy-actions .ghost {
  min-width: 112px;
}

.form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: white;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(15, 118, 110, 0.14);
  border-color: var(--brand);
}

input[type="checkbox"] {
  width: auto;
  min-height: auto;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.delivery-input {
  width: 100%;
  min-width: 0;
  min-height: 58px;
  margin-bottom: 0;
}

.delivery-button {
  width: 100%;
  min-height: 36px;
  padding: 6px 10px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
}

.panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin: 18px 0;
  box-shadow: 0 18px 45px rgba(23, 32, 38, 0.05);
}

.admin-shell {
  width: min(1320px, calc(100vw - 40px));
  padding-top: 14px;
}

.admin-tabs {
  position: sticky;
  top: 76px;
  z-index: 8;
  display: flex;
  gap: 8px;
  margin: 0 0 12px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
}

.compact-panel summary {
  cursor: pointer;
  font-size: 17px;
  font-weight: 900;
}

.compact-panel form {
  margin-top: 16px;
}

.analytics-panel {
  padding: 14px;
}

.compact-select {
  width: 132px;
  gap: 4px;
  font-size: 12px;
  font-weight: 800;
}

.compact-select select {
  min-height: 36px;
  padding: 7px 10px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.metric-card strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
  line-height: 1;
}

.partner-link-box {
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
  color: #111827;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.chart-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.chart-legend {
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  padding: 10px 12px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.legend-view,
.chart-dot-view {
  background: #1f2937;
  fill: #1f2937;
}

.legend-click,
.chart-dot-click {
  background: #a16207;
  fill: #a16207;
}

.traffic-chart {
  width: 100%;
  min-height: 260px;
  overflow-x: auto;
  padding: 0 8px 8px;
}

.traffic-chart svg {
  display: block;
  width: 100%;
  min-width: 760px;
  height: auto;
}

.chart-grid {
  stroke: #eef1f4;
  stroke-width: 1;
}

.chart-baseline {
  stroke: #d8dde3;
  stroke-width: 1;
}

.chart-axis {
  fill: #7b8491;
  font-size: 11px;
  font-weight: 700;
}

.chart-line-view,
.chart-line-click {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.chart-line-view {
  stroke: #1f2937;
}

.chart-line-click {
  stroke: #a16207;
}

.admin-order-table {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-order-head,
.admin-order-row {
  min-width: 1120px;
  display: grid;
  grid-template-columns: 280px 230px 100px 150px minmax(280px, 1fr) 92px;
  gap: 12px;
  align-items: center;
}

.admin-order-head {
  padding: 10px 12px;
  color: var(--muted);
  background: #f8fafc;
  font-size: 13px;
  font-weight: 900;
}

.admin-order-row {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.order-cell {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.order-cell strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-cell small {
  color: var(--muted);
  font-weight: 700;
}

.money-cell {
  font-weight: 900;
}

.action-cell {
  justify-items: stretch;
}

.query-board {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.query-form,
.result-panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(23, 32, 38, 0.06);
}

.query-form {
  position: sticky;
  top: 88px;
  display: grid;
  gap: 16px;
  padding: 18px;
}

.result-panel {
  min-width: 0;
  padding: 18px;
}

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

.section-head h2 {
  margin: 0;
  font-size: 20px;
}

.section-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.query-fields {
  display: grid;
  gap: 12px;
}

.wide {
  width: 100%;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 20px 0;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 13px;
  background: #fbfcfa;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.order-no {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
  background: #eef2f7;
  color: #475569;
}

.status.pending {
  background: #fff7ed;
  color: #b45309;
}

.status.paid {
  background: #ecfdf5;
  color: #047857;
}

.status.awaiting_delivery {
  background: #fff7ed;
  color: #b45309;
}

.status.shipped {
  background: #ecfdf5;
  color: #047857;
}

.status.fulfilled {
  background: #e7f4f1;
  color: var(--brand-dark);
}

.status.cancelled {
  background: #fef2f2;
  color: var(--danger);
}

.delivery-waiting {
  color: #8a5a1f;
  font-weight: 800;
}

.delivery-content {
  max-width: 360px;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
  color: var(--ink);
  font-family: inherit;
}

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

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

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

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

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(360px, calc(100vw - 32px));
  background: #172026;
  color: white;
  border-radius: 8px;
  padding: 12px 14px;
  display: none;
  z-index: 40;
}

.toast.show {
  display: block;
}

@media (max-width: 720px) {
  .topbar-inner {
    min-height: 64px;
  }

  .toolbar,
  .page-title,
  .store-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand {
    font-size: 17px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .nav a,
  .ghost,
  .primary,
  .danger {
    min-height: 36px;
    padding: 7px 11px;
  }

  .toolbar,
  .page-title,
  .store-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .catalog-head {
    position: static;
    padding: 14px;
  }

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

  .product-row {
    grid-template-columns: 80px minmax(0, 1fr);
    align-items: start;
    gap: 12px;
  }

  .product-media,
  .product-media .product-thumb,
  .product-media .icon {
    width: 80px;
    height: 80px;
  }

  .product-row h3 {
    font-size: 18px;
  }

  .product-action {
    grid-column: 1 / -1;
    justify-items: stretch;
  }

  .product-action .primary {
    width: 100%;
  }

  .buy-dialog {
    width: calc(100vw - 18px);
    padding: 18px;
  }

  .buy-scroll {
    max-height: calc(100vh - 120px);
  }

  .buy-product-card,
  .buy-fields,
  .buy-price-box {
    grid-template-columns: 1fr;
  }

  .buy-product-main h3 {
    font-size: 20px;
  }

  .buy-description {
    font-size: 15px;
    line-height: 1.8;
  }

  .buy-actions {
    justify-content: stretch;
  }

  .buy-actions .primary,
  .buy-actions .ghost {
    flex: 1;
  }

  .query-board {
    grid-template-columns: 1fr;
  }

  .query-form {
    position: static;
  }

  .metric-row {
    grid-template-columns: 1fr;
  }

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