:root {
  --bg: #FAF9F6;
  --surface: #FFFFFF;
  --surface-2: #F3F1EA;
  --border: #E5E2D8;
  --text: #2B2823;
  --text-muted: #756F63;
  --accent: #C2582B;
  --accent-hover: #A84A22;
  --accent-soft: #F3E3D9;
  --danger: #B3261E;
  --danger-soft: #FBE9E7;
  --success: #2F6F4E;
  --success-soft: #E7F3EC;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(43, 40, 35, 0.06), 0 1px 8px rgba(43, 40, 35, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1E1D1A;
    --surface: #262420;
    --surface-2: #2E2C27;
    --border: #3B3833;
    --text: #F1EEE6;
    --text-muted: #A9A398;
    --accent: #E08A5F;
    --accent-hover: #EAA07C;
    --accent-soft: #3A2A22;
    --danger: #E5867E;
    --danger-soft: #3A2422;
    --success: #7FC29B;
    --success-soft: #21322A;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 1px 8px rgba(0, 0, 0, 0.2);
  }
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 {
  font-family: Georgia, "Songti SC", "Noto Serif SC", serif;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.5em;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Top bar */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  padding: 14px 32px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  font-family: Georgia, "Songti SC", "Noto Serif SC", serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.brand:hover {
  text-decoration: none;
  color: var(--accent);
}

.nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav-link {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 14px;
}

.nav-link:hover {
  background: var(--surface-2);
  text-decoration: none;
  color: var(--text);
}

.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.user-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.logout-form {
  display: inline;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.link-btn:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Page layout */

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* The dashboard needs the full viewport width so a wide screen isn't
   squeezed into the same reading-width column as the login/form pages. */
.dashboard-page .page {
  max-width: none;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}

.page-subtitle {
  color: var(--text-muted);
  margin: -8px 0 20px;
  font-size: 14px;
}

/* Cards */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.card + .card {
  margin-top: 20px;
}

/* Forms */

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

input[type="text"],
input[type="password"],
input[type="date"],
input[type="search"],
select {
  font-family: inherit;
  font-size: 14px;
  padding: 8px 2px;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
}

input:focus,
select:focus {
  outline: none;
  border-bottom-color: var(--accent);
}

.help-text {
  font-size: 12px;
  color: var(--text-muted);
}

.form-error, .errorlist {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  list-style: none;
  margin: 0;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  text-decoration: none;
  color: #fff;
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
}

.btn-ghost:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.btn-block {
  width: 100%;
}

/* Auth page */

.auth-page .page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px;
}

.auth-title {
  text-align: center;
  font-size: 22px;
}

.auth-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 24px;
}

/* Messages */

.messages {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
}

.message-success {
  background: var(--success-soft);
  color: var(--success);
}

.message-error {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Dashboard layout (source sidebar + data area) */

.dashboard-layout {
  display: flex;
  align-items: flex-start;
  gap: 32px;
}

.source-sidebar {
  flex: 0 0 160px;
  position: sticky;
  top: 24px;
}

.sidebar-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 12px;
  margin-bottom: 10px;
}

.source-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.source-item {
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 14px;
}

.source-item:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.source-item.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 600;
}

.dashboard-main {
  flex: 1;
  min-width: 0;
}

/* Filter bar */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 14px;
  margin-bottom: 20px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-field label {
  font-size: 12px;
  color: var(--text-muted);
}

.filter-field-grow {
  flex: 1;
  min-width: 180px;
}

.filter-field-grow input {
  width: 100%;
}

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

/* Summary */

.summary-bar {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 14px;
}

.summary-bar strong {
  color: var(--text);
}

/* Table */

.table-scroll {
  overflow-x: auto;
  border-radius: var(--radius);
}

.table-scroll table {
  border-collapse: collapse;
  width: 100%;
  min-width: 1400px;
  font-size: 13px;
}

.table-scroll thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  text-align: left;
  padding: 10px 12px;
  white-space: nowrap;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.table-scroll tbody td {
  padding: 9px 12px;
  white-space: nowrap;
}

.table-scroll tbody tr:nth-child(even) {
  background: var(--surface-2);
}

.table-scroll tbody tr:hover {
  background: var(--accent-soft);
}

.empty-state {
  padding: 48px 12px;
  text-align: center;
  color: var(--text-muted);
}

/* Pagination */

.pagination {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: center;
  margin-top: 20px;
  font-size: 13px;
}

.page-info {
  color: var(--text-muted);
}

/* Simple data table (users) */

.simple-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.simple-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.simple-table td {
  padding: 10px 12px;
  text-align: left;
}

.simple-table tbody tr:nth-child(even) {
  background: var(--surface-2);
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--accent-soft);
  color: var(--accent-hover);
}

/* eBay token status */

.badge-valid {
  background: var(--success-soft);
  color: var(--success);
}

.badge-access_expired {
  background: var(--surface-2);
  color: var(--text-muted);
}

.badge-unauthorized,
.badge-refresh_expired {
  background: var(--danger-soft);
  color: var(--danger);
}

.card h2 {
  font-size: 17px;
  margin-top: 0;
}

.card ul.help-text {
  margin: 4px 0 0;
  padding-left: 20px;
}

code {
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  word-break: break-all;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  white-space: nowrap;
}

.row-actions .sep {
  color: var(--border);
}

/* eBay 流量看板 */

/* 易仓那张表有 26 列，所以 .table-scroll table 强制了 1400px；流量的表窄得多，
   撑到 1400px 会出现莫名其妙的空白。 */
.table-scroll.auto-width table {
  min-width: 0;
}

.simple-table th.num,
.simple-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.simple-table th.num a {
  color: inherit;
}

.simple-table th.num a:hover {
  color: var(--accent);
}

.simple-table td.cell-title {
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.muted {
  color: var(--text-muted);
}

.footnote {
  margin-top: 16px;
  max-width: 900px;
  line-height: 1.7;
}

/* 回补进行中的提示条。用左边框而不是整块底色，免得和页面上的卡片抢注意力。 */
.notice {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-left: 3px solid var(--accent);
  background: var(--surface-alt, rgba(194, 88, 43, 0.06));
  border-radius: 0 6px 6px 0;
  line-height: 1.7;
  max-width: 900px;
}

.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.breadcrumb .sep {
  margin: 0 6px;
  color: var(--border);
}

.listing-title {
  font-size: 20px;
  line-height: 1.4;
  margin: 0;
}

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.tag-off {
  background: var(--surface-2);
}

.filter-check {
  align-self: end;
  padding-bottom: 6px;
}

.filter-check label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

/* ── eBay 店铺卡片（流量看板首页）────────────────────────────────
   一个店铺一个模块。卡片内部固定四段：抬头 / 六个指标 / 迷你走势 / 页脚。
   图表容器的高度必须是确定值（ECharts 初始化时要量尺寸），模板里还写了一份
   inline height 兜底。 */

.store-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  align-items: start;
}

.store-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px 14px;
  color: var(--text);
}

.store-card:hover {
  text-decoration: none;
  border-color: var(--accent);
  color: var(--text);
}

.store-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.store-card-title {
  min-width: 0;
}

.store-card-name {
  font-family: Georgia, "Songti SC", "Noto Serif SC", serif;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.store-card-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.store-card-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px 10px;
}

.store-metric {
  min-width: 0;
}

.store-metric-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.2;
}

.store-metric-value {
  display: block;
  margin-top: 3px;
  font-size: 17px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.store-spark {
  margin: 12px 0 4px;
}

.store-spark-empty {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  margin: 12px 0 4px;
}

.store-card-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.store-card-peak {
  white-space: nowrap;
}

/* ── 指标列 + 折线图（店铺详情 / 商品详情）──────────────────────
   左边一列竖排指标，右边折线图。指标行是 <button>，点一下换纵轴，
   所以要把浏览器给按钮的默认样式抹掉。 */

.chart-row {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  /* stretch（默认值）而不是 start：让图表面板长到和左边指标列一样高。
     两列高度必须由布局保证相等，不能靠「指标条数 × 行高 恰好等于图表高度」这种巧合
     ——指标从 7 个加到 9 个时下沿就差了 136px。图表画布负责吸收差额，见 .chart-canvas。 */
  align-items: stretch;
  margin-bottom: 24px;
}

@media (max-width: 900px) {
  .chart-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

.metric-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.metric-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-family: inherit;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.metric-item:hover {
  border-color: var(--accent);
}

.metric-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.metric-item .metric-label {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

.metric-item .metric-value {
  font-family: Georgia, "Songti SC", "Noto Serif SC", serif;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.metric-item.active .metric-label,
.metric-item.active .metric-value {
  color: var(--accent-hover);
}

.chart-panel {
  padding: 14px 16px 10px;
  min-width: 0;
  /* 竖向 flex，好让画布 flex-grow 去填满标题和脚注之外的空间 */
  display: flex;
  flex-direction: column;
}

.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.chart-title {
  font-size: 15px;
  margin: 0;
}

.chart-ranges {
  display: flex;
  gap: 2px;
}

.chart-ranges button {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
}

.chart-ranges button:hover {
  background: var(--surface-2);
  color: var(--text);
}

.chart-ranges button.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

/* ECharts 需要一个有确定高度的容器。
   flex-basis 是 0，所以主轴高度由 flex-grow 分配而不是取 height——模板里那句
   inline style="height:300px" 在 flex 布局下不参与计算，它只是样式表没加载出来时的兜底
   （那种情况下也没有 flex 可言）。min-height 保证再挤也不会低于 300px，
   于是「初始化前容器就有确定高度」这条依然成立。 */
.chart-canvas {
  width: 100%;
  flex: 1 1 0;
  min-height: 300px;
}

.chart-note {
  font-size: 12px;
  line-height: 1.6;
  margin: 6px 0 0;
}

/* ── 区间合计面板（partials/traffic_totals.html）───────────────────────── */

.totals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 22px;
}

.totals-group h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.totals-list {
  margin: 0;
  display: flex;
  flex-direction: column;
}

.totals-list > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--border);
}

.totals-list dt {
  font-size: 13px;
  color: var(--text-muted);
}

.totals-list dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* 商品曝光是「搜索 + 店铺」的派生口径，和上面几项不是并列关系，弱化一档 */
.totals-sub dt,
.totals-sub dd {
  opacity: 0.65;
}

.totals-share {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-muted);
}

/* ── 环比变化列 ───────────────────────────────────────────────────────── */

.delta {
  font-variant-numeric: tabular-nums;
}

.delta-up { color: var(--success); }
.delta-down { color: var(--danger); }
.delta-flat { color: var(--text-muted); }

/* ── 每日明细的「详细」展开行 ─────────────────────────────────────────── */

/* 每个数据行后面跟着一个默认隐藏的展开行，于是数据行在 DOM 里永远是奇数位，
   nth-child 斑马纹会整个错位（条纹全落到隐藏行上）。这里关掉条纹改用分隔线。

   两处在用：商品页的每日数据（.daily-table）和商品预警（.expandable-table）。
   必须排在 .table-scroll / .simple-table 那两条条纹规则**后面**——三条的特异性
   完全相同（1 类 + 1 伪类 + 2 元素），靠源码顺序取胜。 */
.daily-table tbody tr:nth-child(even),
.expandable-table tbody tr:nth-child(even) {
  background: none;
}

.daily-table tbody > tr > td,
.expandable-table tbody > tr > td {
  border-bottom: 1px solid var(--border);
}

.daily-table tbody tr.row-detail > td,
.expandable-table tbody tr.row-detail > td {
  border-bottom: 0;
  padding: 0;
  /* **必须放开 nowrap。** `.table-scroll tbody td` 给所有单元格加了
     `white-space: nowrap`，而面板里那段说明是一整段中文——不换行的话表格必须长到
     那一整段的长度（用户 2026-09-22 报的"横向长度被拉长"，主因就是这一条）。
     写在这条选择器上是因为特异性：`.table-scroll tbody td` 是 (0,1,2)，
     短写法 `.row-detail > td` 只有 (0,1,1)，**赢不了**，改了看着像没生效。 */
  white-space: normal;
}

/* ── 展开面板不能把外层表格撑宽（用户 2026-09-22 报的）────────────────────
 *
 * 两条独立的原因，两条都得治：
 *
 * 1. `.table-scroll tbody td` 给**所有**单元格加了 `white-space: nowrap`，而面板里
 *    那段说明是一整段中文——不换行的话表格必须长到那一整段的长度。这是主因。
 * 2. 面板里那张分店铺小表本身也要宽度。
 *
 * 第 2 条靠 `.detail-scroll` 兜底：`width: 0` 让它对表格的宽度诉求归零（百分比
 * min-width 不参与固有宽度计算，所以 `min-width: 100%` 只在排版时把它撑回整行宽），
 * 真放不下时由它自己横向滚动，**外层表格一列都不动**。 */


.detail-scroll {
  width: 0;
  min-width: 100%;
  overflow-x: auto;
  /* 竖向必须 hidden：下面那个 0fr 的网格行靠它把内容裁掉 */
  overflow-y: hidden;
}

/* 展开 / 收起的高度动画。`grid-template-rows: 0fr -> 1fr` 是少数能动画到 auto 高度的
 * 写法（max-height 得先知道高度）。**没有这层包装的页面没有过渡**——商品页的每日数据
 * 就没有，行为和以前一样是瞬间显示，traffic_rows.js 据此分流。 */
.detail-reveal {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 200ms ease;
}

.row-detail.open .detail-reveal {
  grid-template-rows: 1fr;
}

@media (prefers-reduced-motion: reduce) {
  .detail-reveal { transition: none; }
}

/* 整行就是开关（商品预警，用户 2026-09-22）。行的悬停高亮本来就有
   （`.table-scroll tbody tr:hover`），所以这里只补两件事：手型，和键盘焦点看得见
   ——`tabindex="0"` 让行可聚焦之后，没有焦点框的话键盘用户不知道自己在哪一行。 */
tr.row-toggle {
  cursor: pointer;
}

tr.row-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.toggle-caret {
  display: inline-block;
  width: 12px;
  margin-right: 2px;
  color: var(--text-muted);
  transition: transform 200ms ease;
}

/* 小三角跟的是**行**的展开状态，所以选择器挂在带 aria-expanded 的那个元素上
   （现在是 <tr>，原来是 SKU 那个 <button>）。 */
.row-toggle[aria-expanded="true"] .toggle-caret {
  transform: rotate(90deg);
}

@media (prefers-reduced-motion: reduce) {
  .toggle-caret { transition: none; }
}

/* ── 展开面板里那张分店铺小表 ─────────────────────────────────────────────
 *
 * **这张表在 `.table-scroll` 里面，所以外层给"表格"写的每一条规则都会命中它**，
 * 而那些规则的特异性大多是 (0,1,2)——`.mini-table td` 只有 (0,1,1)，赢不了。
 * 所以下面一律写成 `.table-scroll .mini-table …`（(0,2,2) 起），不靠源码顺序。
 * 三条非改不可的：
 *   padding    —— 外层是 9px 12px，八列会把面板撑宽
 *   position   —— 外层 thead th 是 sticky，小表的表头会跟着粘在容器顶上、
 *                 和外层表头叠在一起
 *   斑马纹     —— .expandable-table 那条把条纹关了（隐藏行会让它错位），
 *                 但小表里没有隐藏行，条纹该留着 */

.table-scroll .mini-table {
  font-size: 13px;
}

.table-scroll .mini-table thead th,
.table-scroll .mini-table tbody td {
  padding: 5px 10px;
  white-space: nowrap;
}

.table-scroll .mini-table thead th {
  position: static;
}

.table-scroll .mini-table tbody tr:nth-child(even) {
  background: var(--surface-2);
}

.table-scroll .mini-table tbody > tr > td {
  border-bottom: 0;
}

/* 「上一期 → 近一期」后面紧跟变化，中间留一点空。
   包一层 .cell-delta 而不是写 `.muted + .muted`：兄弟选择器会连「— → —」里的第二个
   破折号一起命中（文字节点不打断相邻关系），空隙就落在箭头两边而不是变化前面。 */
.mini-table .cell-delta {
  margin-left: 6px;
}

.btn-tiny {
  padding: 2px 10px;
  font-size: 12px;
  border-radius: 999px;
}

.detail-panel {
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 16px;
  margin-bottom: 6px;
}

.detail-head {
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.detail-group h4 {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.detail-note {
  display: block;
  font-size: 11px;
  font-weight: 400;
  opacity: 0.75;
}

.totals-scope {
  margin: -4px 0 16px;
  font-size: 12px;
  line-height: 1.7;
}

/* ── 商品信息卡（商品详情页）────────────────────────────────────────── */

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px 24px;
  margin: 0;
}

/* 促销可能有好几条，占满整行 */
.profile-item-wide {
  grid-column: 1 / -1;
}

.profile-item dt {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.profile-item dd {
  margin: 0;
  font-size: 15px;
}

/* 次要信息：类目上级路径、上架时长、刊登形式 */
.profile-note {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
}

/* 卡片标题后面的英文原名（Item specifics / Item description…），
   方便和 eBay 后台的叫法对上 */
.card-sub {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 8px;
}

/* 商品属性：条目多（实测十几条）且名值都短，比 profile-grid 排得密一些 */
.specifics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 24px;
  margin: 0;
}

.specifics-item dt {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.specifics-item dd {
  margin: 0;
  font-size: 14px;
  overflow-wrap: anywhere;
}

/* 卖家描述：外部 HTML，放在 sandbox iframe 里。给个固定高度让它内部滚动——
   iframe 不会自适应内容高度，而描述实测能到 86KB，铺开会把整页撑得没法看。
   白底是必须的：卖家描述基本都假设自己在白底上，深色模式下不给底色会糊成一片。 */
.desc-frame {
  width: 100%;
  height: 520px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color-scheme: light;
}

.tag-on {
  background: var(--success-soft);
  color: var(--success);
  border-color: transparent;
}

.promo-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.promo-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 13px;
}

.promo-chip strong {
  font-size: 12px;
}

.promo-end {
  font-size: 11px;
  opacity: 0.8;
}

/* ---------- 产品视角 ---------- */

/* 侧栏里第二组标题（eBay）要和上一组拉开距离 */
.sidebar-label-gap {
  margin-top: 18px;
}

/* 订单表格和产品列表里的 SKU 链接。SKU 是等宽的短字符串，
   等宽字体能让一列 SKU 在视觉上对齐，扫起来快很多。 */
.sku-link {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

/* 产品名称列可能很长，给一个上限免得把表格撑爆 */
.cell-title {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-checks {
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: flex-end;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* 汇总指标网格。auto-fill + minmax 让它在窄屏自动换行，不用写断点。 */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.metric-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 8px;
}

.metric-cell .metric-label {
  font-size: 12px;
  color: var(--text-muted);
}

.metric-cell .metric-value {
  font-size: 18px;
  font-weight: 600;
}

.product-images {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.product-images img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.product-desc {
  margin-top: 16px;
}

.product-desc h4 {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.batch-summary {
  margin-bottom: 10px;
  font-size: 14px;
}

.batch-sorts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 13px;
}

.chip {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 13px;
}

.chip:hover {
  color: var(--text);
  text-decoration: none;
}

.chip-on {
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 600;
}

/* 批次单价是这张表的重点，加粗和其他数字区分开 */
.simple-table td.strong {
  font-weight: 600;
}

.notice {
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: 8px;
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  font-size: 14px;
}

/* ── eBay 商品图片存档 ───────────────────────────────────────────────
   图片是登录后按行 id 逐张鉴权发出的（见 traffic_views.listing_image），
   不是静态文件，所以这里只管排版。一个 listing 实测平均 11.5 张、最多 24 张，
   所以用自适应网格而不是固定列数。 */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  margin: 0 0 4px;
}

.image-cell {
  margin: 0;
}

/* 商品图是白底的（eBay 要求），深色主题下直接贴上去会有一圈突兀的白，
   所以统一放在浅色底的方框里，和卖家描述那个 iframe 一个处理方式。 */
.image-cell img,
.image-placeholder {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 13px;
}

.image-failed {
  color: var(--danger);
  background: var(--danger-soft);
}

.image-cell figcaption {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ── 变化记录（字段变化 + 图片变化合成的时间线）───────────────────── */
.change-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.change-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.change-item:last-child {
  border-bottom: none;
}

.change-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.change-head time {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 13px;
}

/* profile-note 默认是 display:block（它平时挂在 dd 里独占一行），
   放进这一行里要收回成行内元素，否则每个都会把后面的挤到下一行 */
.change-head .profile-note {
  display: inline;
  margin-top: 0;
}

.change-table {
  margin: 0;
}

.change-table td {
  vertical-align: top;
  word-break: break-word;
}

.change-old {
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-color: var(--border);
}

.change-new {
  color: var(--text);
  font-weight: 500;
}

.change-images {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.change-images-label {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 28px;
}

.change-thumb {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

/* 文件过了保留期被清掉、或者还没下载。记录仍然在（这正是"日志永久保留、
   图片文件 30 天"的意思），所以位置要留着，不能当作没有过这张图。 */
.change-thumb-gone {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4px;
  font-size: 11px;
  line-height: 1.2;
  color: var(--text-muted);
  background: var(--surface-2);
}

/* 卡片里的二级标题。竞品面板里"汇总表"和"明细表"共用一张卡片，中间要有个分界。 */
.subhead {
  margin: 22px 0 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.subhead .card-sub {
  font-weight: 400;
}

/* 被排除的竞品行：留在表里（还能恢复），但要一眼看出它不算数。
   不用 display:none —— 用户排掉之后得能确认自己排的是哪一条。 */
.row-muted > td {
  opacity: 0.5;
}

/* 表格单元格里的第二行小字：挂牌价下面的单价、"份"下面的"件"。
   竞品面板同一格里要摆两个口径不同的数（$4.99 / $1.25 一件），分两行摆比
   并排摆好读，也不会把表撑宽。 */
.cell-sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.35;
}

/* 表头里的口径说明（"挂牌 / 单价"）。不写出来的话两行数字没法区分。 */
.th-sub {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

/* 高置信的标记（竞品标题里出现了我们的零件号）。和普通 .tag 区分开：
   那是"确认同一个件"，不是又一条待核对的信息。 */
.tag-strong {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
