:root {
  color-scheme: light;
  --ink: #172321;
  --muted: #667085;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: rgba(15, 118, 110, 0.1);
  --warning: #b45309;
  --danger: #b42318;
  --line: rgba(23, 35, 33, 0.11);
  --panel: rgba(255, 255, 255, 0.9);
  --surface: #f8faf9;
  --shadow: 0 14px 34px rgba(15, 23, 42, 0.07);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  scrollbar-gutter: stable;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: #f2eee7;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

body.detail-open { overflow: hidden; }

button,
input,
select { font: inherit; }

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

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.48);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

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

.page-shell {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 22px 18px 34px;
}

.public-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  border: 1px solid rgba(255, 255, 255, 0.88);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

.brand-row img {
  flex: 0 0 auto;
  border-radius: 12px;
  box-shadow: 0 7px 18px rgba(15, 118, 110, 0.16);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1,
h2 { margin: 0; }

h1 {
  font-size: clamp(23px, 3vw, 31px);
  line-height: 1.1;
}

.snapshot-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.snapshot-meta span:first-child {
  color: var(--ink);
  font-weight: 750;
}

.control-panel {
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) minmax(170px, 210px) auto;
  gap: 9px;
  margin-top: 13px;
  padding: 11px;
  border: 1px solid rgba(255, 255, 255, 0.88);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 9px 24px rgba(15, 23, 42, 0.05);
}

.view-tabs {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(248, 250, 249, 0.94);
}

.view-tab {
  height: 36px;
  padding: 0 15px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.view-tab.is-active {
  color: var(--accent-strong);
  background: #fff;
  box-shadow: 0 3px 11px rgba(15, 23, 42, 0.08);
}

.search-field,
.sort-field { min-width: 0; }

.control-panel input,
.control-panel select,
.reset-button {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.97);
  font-size: 13px;
}

.control-panel input,
.control-panel select { padding: 0 12px; }

.control-panel input:focus,
.control-panel select:focus {
  border-color: rgba(15, 118, 110, 0.42);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.07);
  outline: none;
}

.reset-button {
  width: auto;
  padding: 0 15px;
  color: var(--accent-strong);
  font-weight: 750;
  cursor: pointer;
}

.tag-chips {
  display: flex;
  gap: 7px;
  margin-top: 10px;
  padding: 2px 1px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tag-chips::-webkit-scrollbar { display: none; }

.tag-chip {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid rgba(23, 35, 33, 0.1);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.76);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
  cursor: pointer;
}

.tag-chip.is-active {
  border-color: rgba(15, 118, 110, 0.18);
  color: var(--accent-strong);
  background: #fff;
  box-shadow: 0 5px 14px rgba(15, 118, 110, 0.09);
}

.status-message {
  margin-top: 12px;
  padding: 34px 16px;
  border: 1px dashed var(--line);
  border-radius: 17px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.58);
  text-align: center;
  font-size: 13px;
}

.status-message.is-error { color: var(--danger); }

.product-list-wrap {
  overflow-x: auto;
  margin-top: 12px;
  border: 1px solid rgba(23, 35, 33, 0.09);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 9px 24px rgba(15, 23, 42, 0.05);
}

.product-table {
  width: 100%;
  min-width: 1060px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

.product-table th,
.product-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(23, 35, 33, 0.07);
  text-align: left;
  vertical-align: middle;
}

.product-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #f8faf9;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.product-table th:nth-child(1) { width: 31%; }
.product-table th:nth-child(2) { width: 13%; }
.product-table th:nth-child(3) { width: 14%; }
.product-table th:nth-child(4) { width: 10%; }
.product-table th:nth-child(5) { width: 12%; }
.product-table th:nth-child(6) { width: 13%; }
.product-table th:nth-child(7) { width: 7%; }

.shop-table { min-width: 820px; }
.shop-table th:nth-child(1) { width: 31%; }
.shop-table th:nth-child(2) { width: 14%; }
.shop-table th:nth-child(3) { width: 14%; }
.shop-table th:nth-child(4) { width: 13%; }
.shop-table th:nth-child(5) { width: 18%; }
.shop-table th:nth-child(6) { width: 10%; }

.product-table tbody tr:last-child td { border-bottom: 0; }
.product-table tbody tr:hover { background: rgba(15, 118, 110, 0.035); }

.is-clickable { cursor: pointer; }

.tag-list {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 5px;
}

.tag-pill {
  display: inline-flex;
  min-height: 23px;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tag-pill {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.stock-pill {
  display: inline-flex;
  min-width: 74px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stock-pill.success {
  color: var(--accent-strong);
  background: rgba(15, 118, 110, 0.12);
}

.stock-pill.danger {
  color: var(--danger);
  background: rgba(180, 35, 24, 0.12);
}

.stock-pill.warn {
  color: var(--warning);
  background: rgba(180, 83, 9, 0.12);
}

.product-name {
  display: block;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.45;
  text-decoration: none;
  overflow-wrap: anywhere;
}

a.product-name:hover,
.detail-product-name:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.shop-name,
.shop-product-count,
.shop-stock-count {
  color: var(--muted);
  font-size: 11px;
}

.value-inline {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.price-value,
.shop-min-price {
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.product-checked-cell {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.product-checked-cell .is-stale,
.detail-value.is-stale { color: #9a6700; }

.empty-value {
  color: var(--muted);
  font-size: 11px;
}

.product-action-cell { text-align: right !important; }

.local-delete,
.detail-button {
  min-height: 31px;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
}

.local-delete {
  color: var(--danger);
  background: rgba(180, 35, 24, 0.08);
}

.detail-button {
  color: var(--accent-strong);
  background: rgba(15, 118, 110, 0.09);
}

.change {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  line-height: 1;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.change-arrow {
  font-size: 12px;
  line-height: 0.8;
}

.change-amount {
  font-size: 10px;
  line-height: 1;
}

.change.is-price.is-up { color: var(--danger); }
.change.is-price.is-down { color: var(--accent-strong); }
.change.is-stock.is-up { color: var(--accent-strong); }
.change.is-stock.is-down { color: var(--danger); }

.stock-pill .change.is-stock {
  font-size: 12px;
  font-weight: 700;
}

.stock-pill .change-arrow {
  font-size: 1.12em;
}

.stock-pill .change-amount {
  font-size: inherit;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  padding-top: 12px;
}

.load-more {
  min-height: 40px;
  padding: 8px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.86);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(15, 23, 42, 0.32);
  backdrop-filter: blur(2px);
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 100;
  display: flex;
  width: min(460px, 92vw);
  height: 100dvh;
  flex-direction: column;
  border-left: 1px solid rgba(23, 35, 33, 0.1);
  background: #fbfaf7;
  box-shadow: -20px 0 50px rgba(15, 23, 42, 0.16);
  animation: drawer-in 160ms ease-out;
}

@keyframes drawer-in {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
}

.detail-kicker {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.detail-head h2 {
  max-width: 360px;
  font-size: 18px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.detail-close {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.detail-content {
  overflow-y: auto;
  padding: 18px 20px calc(24px + env(safe-area-inset-bottom));
}

.detail-content > .tag-list { margin-bottom: 15px; }

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

.detail-line {
  display: flex;
  min-width: 0;
  min-height: 72px;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 11px 12px;
  border: 1px solid rgba(23, 35, 33, 0.08);
  border-radius: 12px;
  background: #fff;
}

.detail-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.detail-value {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.detail-note {
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.detail-primary-link {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
  padding: 8px 18px;
  border-radius: 10px;
  color: #fff;
  background: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.detail-product-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.detail-product-item {
  padding: 12px;
  border: 1px solid rgba(23, 35, 33, 0.08);
  border-radius: 12px;
  background: #fff;
}

.detail-product-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.detail-product-name {
  min-width: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.5;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.detail-product-price {
  flex: 0 0 auto;
  font-size: 13px;
}

@media (max-width: 900px) {
  .control-panel {
    grid-template-columns: auto minmax(220px, 1fr) minmax(150px, 190px);
  }

  .reset-button { grid-column: 3; }
}

@media (max-width: 680px) {
  html { scrollbar-gutter: auto; }

  .page-shell {
    padding: max(9px, env(safe-area-inset-top)) 9px calc(20px + env(safe-area-inset-bottom));
  }

  .public-header {
    padding: 12px 13px;
    border-radius: 16px;
  }

  .brand-row { gap: 9px; }

  .brand-row img {
    width: 33px;
    height: 33px;
    border-radius: 9px;
  }

  .eyebrow { font-size: 8px; }
  h1 { font-size: 20px; }
  .snapshot-meta { font-size: 9px; }

  .control-panel {
    grid-template-columns: 1fr auto;
    gap: 7px;
    margin-top: 9px;
    padding: 8px;
    border-radius: 14px;
  }

  .view-tabs { grid-column: 1 / -1; }
  .view-tab { flex: 1; height: 34px; }
  .search-field { min-width: 0; }
  .sort-field { grid-column: 1; }

  .control-panel input,
  .control-panel select,
  .reset-button {
    height: 39px;
    border-radius: 9px;
    font-size: 12px;
  }

  .reset-button {
    grid-column: 2;
    grid-row: 3;
    width: 64px;
    padding: 0 10px;
  }

  .tag-chips {
    margin-top: 7px;
    gap: 6px;
  }

  .tag-chip {
    min-height: 31px;
    padding: 5px 10px;
    font-size: 10px;
  }

  .product-list-wrap {
    overflow: visible;
    margin-top: 8px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .product-table,
  .product-table tbody {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .product-table thead { display: none; }

  .product-table tbody {
    display: flex;
    flex-direction: column;
    gap: 7px;
  }

  .product-row,
  .shop-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) auto;
    gap: 7px 9px;
    padding: 10px;
    border: 1px solid rgba(23, 35, 33, 0.09);
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.045);
  }

  .product-table tbody tr:hover { background: rgba(255, 255, 255, 0.94); }

  .product-table td {
    display: flex;
    min-width: 0;
    padding: 0;
    border: 0;
    flex-direction: column;
    gap: 3px;
  }

  .product-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 8px;
    font-weight: 750;
    letter-spacing: 0.04em;
  }

  .product-name-cell,
  .product-tags-cell,
  .shop-summary-name {
    grid-column: 1 / -1;
  }

  .product-name-cell::before,
  .product-tags-cell::before,
  .shop-summary-name::before { display: none; }

  .product-tags-cell { grid-row: 1; }
  .product-name-cell { grid-row: 2; }
  .product-shop-cell { grid-column: 1 / 3; grid-row: 3; }
  .product-shop-cell::before { display: none; }
  .product-shop-cell .shop-name::before { content: "店铺 · "; }

  .product-name {
    display: -webkit-box;
    font-size: 13px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

  .product-price-cell,
  .product-stock-cell {
    padding: 7px 8px !important;
    border-radius: 10px;
    background: var(--surface);
  }

  .product-price-cell { grid-column: 1; }
  .product-stock-cell { grid-column: 2; }

  .product-stock-cell .stock-pill {
    width: fit-content;
    min-width: 0;
    padding: 4px 8px;
    font-size: 11px;
  }

  .product-checked-cell {
    grid-column: 1 / 3;
    justify-content: flex-end;
    font-size: 10px;
  }

  .product-checked-cell::before { content: "检查"; }

  .product-action-cell {
    grid-column: 3;
    align-items: flex-end;
    justify-content: flex-end;
    text-align: right;
  }

  .product-action-cell::before { display: none; }

  .local-delete,
  .detail-button {
    min-width: 58px;
    min-height: 32px;
  }

  .price-value { font-size: 14px; }
  .tag-pill { min-height: 21px; padding: 2px 7px; font-size: 9px; }

  .shop-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shop-summary-name { grid-row: 1; }
  .shop-product-count,
  .shop-min-price,
  .shop-stock-count { padding: 7px 8px !important; border-radius: 9px; background: var(--surface); }
  .shop-row .product-checked-cell { grid-column: 1; }
  .shop-row .product-action-cell { grid-column: 2; }

  .detail-drawer {
    top: auto;
    bottom: 0;
    width: 100%;
    height: min(82dvh, 720px);
    border-top: 1px solid var(--line);
    border-left: 0;
    border-radius: 18px 18px 0 0;
    animation-name: drawer-up;
  }

  @keyframes drawer-up {
    from { transform: translateY(22px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }

  .detail-head { padding: 15px 14px; }
  .detail-head h2 { font-size: 16px; }
  .detail-content { padding: 14px; }
  .detail-metrics { gap: 7px; }
  .detail-line { min-height: 64px; padding: 9px 10px; }
}

@media (max-width: 390px) {
  .public-header { align-items: flex-start; }
  .snapshot-meta { padding-top: 2px; }
  .detail-metrics { grid-template-columns: 1fr 1fr; }
}

.history-panel {
  margin-top: 16px;
  padding: 13px;
  border: 1px solid rgba(23, 35, 33, 0.08);
  border-radius: 13px;
  background: #fff;
}

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

.history-title-wrap {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.history-title {
  margin: 0;
  font-size: 13px;
}

.history-source {
  color: var(--muted);
  font-size: 9px;
}

.history-window-tabs {
  display: inline-flex;
  padding: 2px;
  border-radius: 8px;
  background: var(--surface);
}

.history-window {
  min-height: 27px;
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 9px;
  font-weight: 750;
  cursor: pointer;
}

.history-window.is-active {
  color: var(--accent-strong);
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.history-loading,
.history-empty {
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface);
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
}

.history-empty.is-error { color: var(--danger); }

.history-chart-wrap {
  overflow: hidden;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(15, 118, 110, 0.055), rgba(15, 118, 110, 0.012));
}

.history-chart {
  display: block;
  width: 100%;
  height: 112px;
}

.history-grid-line {
  stroke: rgba(23, 35, 33, 0.08);
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.history-area { fill: rgba(15, 118, 110, 0.1); }

.history-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.history-dot {
  fill: #fff;
  stroke: var(--accent-strong);
  stroke-width: 2.2;
}

.history-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.history-summary .detail-line {
  min-height: 55px;
  padding: 8px 9px;
  border-radius: 9px;
  background: var(--surface);
}

.history-caption {
  margin: 9px 1px 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

@media (max-width: 680px) {
  .history-panel {
    margin-top: 13px;
    padding: 11px;
  }

  .history-head {
    align-items: flex-start;
  }

  .history-chart { height: 102px; }

  .history-summary .detail-line {
    min-height: 51px;
  }
}
