:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #697386;
  --line: #dce3ec;
  --paper: #f6f8fb;
  --panel: #ffffff;
  --blue: #1d4ed8;
  --green: #0f8f69;
  --red: #c2410c;
  --gold: #a16207;
  --shadow: 0 16px 40px rgba(18, 31, 52, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(100%, 460px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 2px 16px;
}

.title-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  min-width: 0;
}

.account-badge {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  margin-bottom: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #e8f0ff;
  color: var(--blue);
  font-weight: 900;
  box-shadow: 0 8px 20px rgba(18, 31, 52, 0.08);
}

.account-badge img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.account-name {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  letter-spacing: 0;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--blue);
  box-shadow: 0 8px 20px rgba(18, 31, 52, 0.08);
}

.filter-panel,
.period-panel {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.filter-panel {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.date-filter-panel {
  position: relative;
  margin-bottom: 10px;
}

.top-filter-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: flex-end;
}

.date-filter-half {
  flex: 1 1 62%;
  min-width: 0;
}

.date-filter-half .date-filter-toggle {
  width: 100%;
}

.store-category-field {
  flex: 1 1 38%;
  min-width: 0;
  display: grid;
  gap: 5px;
}

.store-category-field select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
  padding: 0 10px;
  box-shadow: var(--shadow);
}

.store-category-field select:disabled {
  background: #eef2f7;
  color: var(--muted);
}

.date-filter-toggle {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
  box-shadow: var(--shadow);
}

.date-filter-toggle b {
  color: var(--blue);
  font-size: 14px;
}

.date-filter-popover {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 0.82fr) 52px;
  column-gap: 14px;
  row-gap: 5px;
  align-items: end;
  margin-top: 6px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.date-filter-popover label {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.date-filter-popover span {
  color: var(--muted);
  font-size: 10px;
}

.date-filter-popover input {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  height: 34px;
  min-height: 34px;
  line-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f9fbfd;
  color: var(--ink);
  font-size: 12px;
  padding: 0 8px;
}

.date-filter-popover button {
  grid-column: auto;
  justify-self: stretch;
  height: 34px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f9fbfd;
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
  padding: 0 3px;
  white-space: nowrap;
}

.filter-panel label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.retail-filters {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: flex-end;
}

.retail-filters label {
  flex: 1 1 0;
}

.filter-panel span {
  color: var(--muted);
  font-size: 10px;
}

.mval {
  display: none;
}

/* 手机端门店卡完整店名显示层（仅移动端媒体块内 display:block），桌面隐藏 */
.store-mval {
  display: none;
}


.filter-panel select:disabled,
.filter-panel input:disabled,
.store-select-button:disabled {
  color: #94a3b8;
  background: #eef2f7;
  cursor: not-allowed;
}

.filter-panel select,
.filter-panel input {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f9fbfd;
  color: var(--ink);
  font-size: 12px;
  box-sizing: border-box;
}

.store-filter-field {
  position: relative;
}

.store-filter-control {
  position: relative;
  min-width: 0;
}

.store-filter-control select {
  display: none;
}

.store-select-button {
  width: 100%;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f9fbfd;
  color: var(--ink);
  font-size: 12px;
  text-align: left;
}

.store-select-button span {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.store-select-button b {
  color: var(--blue);
  font-size: 13px;
}

.store-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  width: 100%;
  min-width: min(260px, calc(100vw - 28px));
  max-width: calc(100vw - 28px);
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 38px rgba(18, 31, 52, 0.18);
}

.store-dropdown input {
  height: 28px;
  min-height: 28px;
  margin-bottom: 5px;
  padding: 0 7px;
  font-size: 16px;
}

.store-options {
  max-height: 310px;
  overflow-y: auto;
}

.store-option {
  width: 100%;
  min-height: 30px;
  display: block;
  padding: 0 7px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  line-height: 30px;
  text-align: left;
}

.store-option:hover,
.store-option.active {
  background: #eef4ff;
  color: var(--blue);
  font-weight: 700;
}

.multi-select {
  position: relative;
  min-width: 0;
}

.multi-select-button {
  width: 100%;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f9fbfd;
  color: var(--ink);
  font-size: 12px;
  text-align: left;
}

.multi-select-button span {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-select-button b {
  color: var(--blue);
  font-size: 13px;
}

.multi-select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 28;
  width: 100%;
  min-width: min(220px, calc(100vw - 28px));
  max-width: calc(100vw - 28px);
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 38px rgba(18, 31, 52, 0.18);
}

.multi-select-option {
  width: 100%;
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 7px;
  border-radius: 5px;
  color: var(--ink);
  font-size: 12px;
  line-height: 30px;
  white-space: nowrap;
}

.multi-select-option:hover {
  background: #eef4ff;
}

.multi-select-option input {
  flex: 0 0 14px;
  width: 14px;
  min-width: 14px;
  height: 14px;
  min-height: 14px;
  margin: 0;
  accent-color: var(--blue);
}

.multi-select-menu .multi-select-option {
  display: flex !important;
  grid-template-columns: none !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start;
  white-space: nowrap;
}

.multi-select-menu .multi-select-option input {
  appearance: auto;
  -webkit-appearance: checkbox;
  flex: 0 0 14px !important;
  width: 14px !important;
  min-width: 14px !important;
  height: 14px !important;
  min-height: 14px !important;
}

.multi-select-menu .multi-select-option span {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.supplier-filter-field {
  position: relative;
  min-width: 0;
}

.supplier-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  width: min(360px, calc(100vw - 28px));
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 38px rgba(18, 31, 52, 0.18);
}

.supplier-option {
  width: 100%;
  min-height: 30px;
  display: block;
  padding: 0 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  line-height: 30px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.supplier-option:hover,
.supplier-option.active {
  background: #eef4ff;
  color: var(--blue);
  font-weight: 700;
}

@media (max-width: 699px) {
  .staff-chart {
    grid-template-columns: repeat(auto-fit, minmax(54px, 1fr));
    align-items: end;
    gap: 10px;
    min-height: 220px;
    padding: 14px 10px;
    overflow-x: auto;
  }

  .staff-bar {
    grid-template-columns: 1fr;
    grid-template-rows: 18px 28px 136px 34px;
    justify-items: center;
    gap: 5px;
    min-width: 54px;
    min-height: 0;
  }

  .staff-rank {
    font-size: 10px;
  }

  .staff-bar strong {
    width: 100%;
    font-size: 12px;
    text-align: center;
  }

  .staff-bar-track {
    width: 22px;
    height: 132px;
    display: flex;
    align-items: flex-end;
    border-radius: 7px;
  }

  .staff-bar-track i {
    width: 100%;
    height: var(--staff-pct);
    background: linear-gradient(180deg, #48a4ff, #1d7cff);
  }

  .staff-bar em {
    max-width: 64px;
    overflow-wrap: anywhere;
    font-size: 11px;
    line-height: 1.15;
    text-align: center;
    white-space: normal;
  }

  #stockView .purchase-filters {
    display: block;
  }
  #stockView .stock-filter-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 8px;
  }

  .store-dropdown {
    left: auto;
    right: 0;
    width: min(260px, calc(100vw - 28px));
  }

  .multi-select-menu {
    left: 0;
    right: auto;
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    max-height: 190px;
  }

  #retailProductCategoryFilter {
    min-height: 34px;
    padding: 0 9px;
    font-size: 12px;
    line-height: 34px;
  }

  .supplier-dropdown {
    width: 100%;
    max-width: 100%;
    max-height: 190px;
  }

  #stockView .stock-filter-row label:last-child {
    grid-column: auto;
  }
}

/* 电脑端：每日零售业绩标题上移 */
@media (orientation: landscape) and (min-width: 900px), (min-width: 1120px) {
  body.day-period #overviewView .section-title:first-child {
    margin-top: -6px;
  }
}

/* 每日业绩柱状图：电脑端横向排列，铺满屏幕宽度 */
.day-chart {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 4px;
  min-height: 220px;
  padding: 10px 4px 4px;
}
.day-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 4px;
}
.day-value {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--day-pct, 3%) + 3px);
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  pointer-events: none;
}
.day-bar-track {
  position: relative;
  width: 100%;
  height: 220px;
  display: flex;
  align-items: flex-end;
  border-radius: 4px 4px 0 0;
  background: transparent;
  overflow: visible;
}
.day-bar-fill {
  width: 100%;
  height: var(--day-pct, 3%);
  background: linear-gradient(180deg, #3b82f6, #1e40af);
  border-radius: 4px 4px 0 0;
}
.day-label {
  font-size: 11px;
  color: var(--ink);
  white-space: nowrap;
}
.day-col.day-clickable {
  cursor: pointer;
}
.day-col.day-clickable:hover .day-bar-track {
  background: transparent;
}
.day-col.day-clickable:hover .day-label {
  color: var(--blue);
  font-weight: 700;
}
.day-col.weekend .day-bar-fill {
  background: linear-gradient(180deg, #1e3a8a, #172554);
}
.day-col.selected .day-bar-fill {
  background: linear-gradient(180deg, #f59e0b, #b45309);
}
.day-col.selected .day-label {
  color: #b45309;
  font-weight: 900;
}
.day-col.selected .day-value {
  color: #b45309;
  font-weight: 700;
}

.day-chart-total {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* 手机端：每日柱状图竖向排列 */
@media (max-width: 720px) {
  .day-chart {
    flex-direction: column;
    align-items: stretch;
    min-height: 0;
    gap: 8px;
  }
  .day-col {
    flex: 0 0 auto;
    min-width: 0;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    height: auto;
  }
  .day-label {
    flex: 0 0 34px;
    text-align: right;
    order: 1;
  }
  .day-value {
    position: static;
    transform: none;
    bottom: auto;
    order: 3;
    font-size: 12px;
    pointer-events: auto;
  }
  .day-bar-track {
    flex: 1 1 auto;
    max-width: none;
    height: 18px;
    order: 2;
    border-radius: 4px;
    background: transparent;
  }
  .day-bar-fill {
    height: 100%;
    width: var(--day-pct, 3%);
    border-radius: 4px;
    background: linear-gradient(90deg, #3b82f6, #1e40af);
  }
  .day-col.weekend .day-bar-fill {
    background: linear-gradient(90deg, #1e3a8a, #172554);
  }
  .day-col.selected .day-bar-fill {
    background: linear-gradient(90deg, #f59e0b, #b45309);
  }
  .day-value {
    flex: 0 0 auto;
    order: 3;
    font-size: 12px;
  }
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: #eef2f7;
}

.retail-rank-switch {
  margin: 0 0 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 699px) {
  .retail-rank-switch {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.segment,
.tab {
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.segment.active,
.tab.active {
  background: var(--ink);
  color: white;
}

.date-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.date-line strong {
  color: var(--ink);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.metric-card {
  min-height: 116px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric-card.primary {
  grid-column: 1 / -1;
  background: #17355f;
  color: white;
}

.metric-card span,
.metric-card em {
  display: block;
  color: inherit;
  opacity: 0.72;
  font-size: 12px;
  font-style: normal;
}

.metric-card strong {
  display: block;
  margin: 10px 0 8px;
  font-size: 25px;
  letter-spacing: 0;
}

.metric-card.primary strong {
  font-size: 34px;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin: 14px 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(246, 248, 251, 0.92);
  backdrop-filter: blur(12px);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 10px;
}

.section-title h2 {
  font-size: 17px;
}

.section-title span {
  color: var(--muted);
  font-size: 12px;
}

.bars {
  display: grid;
  gap: 9px;
}

.bar-row {
  display: grid;
  grid-template-columns: 50px minmax(0, 63%) 92px;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  color: var(--muted);
  font-size: 12px;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 6px;
  background: #e7edf4;
}

.compare-bars {
  display: grid;
  gap: 4px;
}

.bar-row.compare {
  grid-template-columns: 44px 1fr 92px;
}

.bar-track.previous {
  background: #e9eef6;
}

.bar-track.current {
  background: #e6f4ee;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.bar-fill.previous {
  background: #8aa1c1;
}

.bar-fill.current {
  background: var(--green);
}

.bar-value {
  color: var(--ink);
  font-weight: 800;
  text-align: left;
  white-space: nowrap;
}

.trend-legend {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.trend-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.trend-legend i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.legend-previous {
  background: #8aa1c1;
}

.legend-current {
  background: var(--green);
}

.store-list,
.stock-list {
  display: grid;
  gap: 10px;
}

.store-item,
.fund-balance-item,
.stock-item {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.fund-balance-item {
  cursor: default;
}

.store-item.fund-balance-item {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}

.store-item.fund-balance-item .store-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.store-item.fund-balance-item .store-main strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.store-item.fund-balance-item .store-main span {
  flex: 0 0 auto;
  color: var(--blue);
  font-weight: 900;
}

.staff-chart {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.staff-bar {
  display: grid;
  grid-template-columns: 54px minmax(72px, 130px) minmax(0, 1fr) 88px;
  align-items: center;
  gap: 10px;
  min-height: 34px;
}

.staff-rank {
  color: #0b3b78;
  font-size: 12px;
  font-weight: 800;
}

.staff-bar strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.staff-identity { min-width: 0; }
.staff-identity strong { display: block; }
.staff-identity small { display: block; margin-top: 4px; color: var(--muted, #64748b); font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
#retailStaffList .store-meta span { overflow-wrap: anywhere; }
@media (max-width: 699px) {
  .staff-bar .staff-identity { width: 100%; align-self: start; text-align: center; }
  .staff-bar:has(.staff-identity) { grid-template-rows: 18px minmax(66px, auto) 136px 34px; }
}

.staff-bar-track {
  height: 18px;
  overflow: hidden;
  border-radius: 6px;
  background: #e7eef7;
}

.staff-bar-track i {
  display: block;
  width: var(--staff-pct);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1d7cff, #48a4ff);
}

.staff-bar em {
  color: #1267ff;
  font-size: 13px;
  font-style: normal;
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

@media (max-width: 699px) {
  .staff-chart {
    grid-template-columns: repeat(auto-fit, minmax(54px, 1fr));
    align-items: end;
    gap: 10px;
    min-height: 220px;
    padding: 14px 10px;
    overflow-x: auto;
  }

  .staff-bar {
    grid-template-columns: 1fr;
    grid-template-rows: 18px 28px 136px 34px;
    justify-items: center;
    gap: 5px;
    min-width: 54px;
    min-height: 0;
  }

  .staff-rank {
    font-size: 10px;
  }

  .staff-bar strong {
    width: 100%;
    font-size: 12px;
    text-align: center;
  }

  .staff-bar-track {
    width: 22px;
    height: 132px;
    display: flex;
    align-items: flex-end;
    border-radius: 7px;
  }

  .staff-bar-track i {
    width: 100%;
    height: var(--staff-pct);
    background: linear-gradient(180deg, #48a4ff, #1d7cff);
  }

  .staff-bar em {
    max-width: 64px;
    overflow-wrap: anywhere;
    font-size: 11px;
    line-height: 1.15;
    text-align: center;
    white-space: normal;
  }
}

.stock-item {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: start;
}

.stock-item.expanded {
  gap: 8px;
}

.stock-expand-toggle {
  margin-top: 6px;
  width: 100%;
  min-height: 28px;
  border: 0;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 700;
}

.stock-expand-toggle.compact {
  margin-top: 4px;
  font-size: 13px;
}

.stock-size-detail {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}

.stock-color-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.stock-size-color {
  display: none;
}

.stock-size-color.active {
  display: block;
}

.stock-color-pill {
  min-height: 28px;
  padding: 3px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: #52657f;
  font-size: 13px;
  font-weight: 700;
}

.stock-color-pill.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

.stock-size-grid {
  display: flex;
  flex-wrap: nowrap;
  gap: 7px 18px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.stock-size-cell {
  flex: 0 0 auto;
  min-width: 30px;
  min-height: 30px;
  display: grid;
  gap: 3px;
  align-content: start;
}

.stock-size-cell span {
  color: var(--ink);
  font-size: 12.5px;
}

.stock-size-cell strong {
  color: var(--blue);
  font-size: 11.5px;
}

.stock-detail-empty {
  padding: 10px 0;
  color: var(--muted);
}

.store-item.with-image,
.stock-item.with-image {
  display: grid;
  grid-template-columns: 66px 1fr;
  gap: 10px;
  align-items: start;
}

.store-item.with-image.with-rank {
  grid-template-columns: 38px 66px 1fr;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: 34px;
  height: 22px;
  color: #17355f;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}

.rank-badge em {
  color: #0f5ea8;
  font-size: 13px;
  font-style: normal;
  font-weight: 900;
}

.retail-product-item {
  border-color: #b8c7e6;
  background: #f8fbff;
  box-shadow: 0 8px 18px rgba(23, 53, 95, 0.08);
}

.retail-product-item .store-main span {
  font-size: 19px;
  color: #0f5ea8;
}

.retail-product-item .store-meta span {
  color: #475569;
  font-weight: 700;
}

.item-body {
  min-width: 0;
}

.product-thumb {
  width: 66px;
  height: 66px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2f7;
  object-fit: cover;
}

.product-thumb.missing {
  display: none;
}

.store-item.with-image:has(.product-thumb.missing),
.stock-item.with-image:has(.product-thumb.missing) {
  grid-template-columns: 1fr;
}

.store-item.with-image.with-rank:has(.product-thumb.missing) {
  grid-template-columns: 38px 1fr;
}

.store-main,
.stock-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.store-main strong,
.stock-main strong {
  font-size: 16px;
}

.store-main span,
.stock-main span {
  color: var(--blue);
  font-weight: 800;
}

.store-main .main-ratio {
  display: block;
  margin-top: 4px;
  color: var(--blue);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
  line-height: 1.1;
  text-align: right;
}

.store-meta,
.stock-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

.stock-note {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.stock-meta span {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}

.stock-meta small {
  color: #8a97a8;
  font-size: 11px;
  font-weight: 500;
}

.store-meta .payment-meta {
  color: var(--blue);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.25;
}

.search-row {
  margin-bottom: 10px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.search-box span {
  color: var(--muted);
  font-size: 18px;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.stock-summary,
.purchase-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.stock-summary {
  grid-template-columns: repeat(2, 1fr);
}

.purchase-summary-net {
  grid-column: span 2;
}

.purchase-flow-card {
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.purchase-flow-card:hover {
  border-color: rgba(29, 78, 216, 0.35);
  transform: translateY(-1px);
}

.purchase-flow-card.active {
  border-color: rgba(15, 143, 105, 0.58) !important;
  background: #ecfdf5 !important;
  box-shadow: 0 16px 34px rgba(15, 143, 105, 0.16) !important;
}

.purchase-flow-card.active span,
.purchase-flow-card.active strong {
  color: #047857;
}

.stock-summary div,
.purchase-summary div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.stock-summary span,
.purchase-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stock-summary strong,
.purchase-summary strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.note,
.detail-note {
  margin: -2px 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}


#trendCategoryFilterRow {
  margin: 6px 0 8px;
}

#trendCategoryFilterRow label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
}

#trendCategoryFilterRow span {
  color: var(--ink);
  font-size: 15px;
}

#trendCategoryFilter {
  min-width: 92px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  padding: 0 8px;
}

.purchase-filters {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.stock-filters {
  display: block;
}
.stock-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.stock-filter-row:last-child {
  margin-bottom: 0;
}
.stock-filter-row > label {
  flex: 1;
  min-width: 120px;
}

.purchase-filters label {
  flex: 1 1 0;
  min-width: 0;
}

.retail-filters {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.retail-filters label {
  flex: 1 1 0;
  display: grid;
  gap: 5px;
  min-width: 0;
}

.retail-filters span {
  color: var(--muted);
  font-size: 10px;
}

.purchase-filters label {
  display: grid;
  gap: 5px;
}

.purchase-filters span {
  color: var(--muted);
  font-size: 10px;
}

.purchase-filters select,
.purchase-filters .filter-input {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f9fbfd;
  color: var(--ink);
  font-size: 13px;
  padding: 0 9px;
}

.drill-title {
  position: sticky;
  top: 58px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 0 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

/* 会员板块：顶部「会员 / 返回」页头不固定，随页面滚走 */
#vipView .drill-title {
  position: static;
}

.text-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--blue);
  font-weight: 700;
}

.hidden {
  display: none !important;
}

.analysis-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 16px;
  margin: 2px 0 12px;
  padding: 0 8px 10px;
  border-bottom: 2px solid var(--line);
}

#analysisView {
  width: 100%;
  box-sizing: border-box;
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 22px 28px;
  background: #fff;
  color: #202124;
}

.analysis-page-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(132px, 1fr));
  gap: 4px;
  margin: 0 0 14px;
  padding: 4px;
  border: 1px solid #d8e1ef;
  border-radius: 8px;
  background: #f5f7fb;
}

.analysis-page-tab {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #56667a;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.analysis-page-tab.active {
  background: #1677ff;
  color: #fff;
  box-shadow: 0 6px 16px rgba(22, 119, 255, 0.22);
}

.analysis-subview {
  display: none;
}

.analysis-subview.active {
  display: block;
  width: 100%;
  min-width: 0;
}

.profit-view {
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  overflow: hidden;
  min-height: var(--analysis-profit-min-height, 620px);
  border-top: 2px solid var(--line);
  background: #fff;
}

.profit-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 16px;
}

.profit-summary article {
  min-height: 66px;
  display: grid;
  place-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
}

.profit-summary article.clickable {
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease, transform .16s ease;
}

.profit-summary article.clickable:hover,
.profit-summary article.clickable.active {
  border-color: #1d4ed8;
  background: #f5f9ff;
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

.profit-summary article.clickable:active {
  transform: translateY(1px);
}

.profit-summary article.profit-summary-status.profit-good {
  border-color: #047857;
  background: #e8f8ef;
}

.profit-summary article.profit-summary-status.profit-even {
  border-color: #1d4ed8;
  background: #eaf2ff;
}

.profit-summary article.profit-summary-status.profit-risk {
  border-color: #b91c1c;
  background: #feecec;
}

.profit-summary strong {
  color: #2b2f35;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
}

.profit-summary span {
  color: #56667a;
  font-size: 11px;
}

.profit-section-title {
  margin-top: 8px;
}

.profit-title-status {
  display: inline-grid;
  place-items: center;
  min-width: 62px;
  margin-left: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  line-height: 1;
  vertical-align: middle;
}

.profit-title-status.profit-good {
  background: #e8f8ef;
  color: #047857;
}

.profit-title-status.profit-even {
  background: #eaf2ff;
  color: #1d4ed8;
}

.profit-title-status.profit-risk {
  background: #feecec;
  color: #b91c1c;
}

.profit-list {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.profit-table {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #d8e1ef;
  border-radius: 8px;
}

.profit-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.35fr) repeat(3, minmax(112px, 1fr)) 96px minmax(182px, 1.32fr);
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-top: 1px solid #e7edf6;
  background: #fff;
}

.profit-row:first-child {
  border-top: 0;
}

.profit-row.profit-header {
  min-height: 38px;
  padding-top: 9px;
  padding-bottom: 9px;
  background: #f5f7fb;
  color: #56667a;
  font-size: 12px;
  font-weight: 700;
}

.profit-head-status {
  text-align: center;
}

.profit-name strong {
  display: block;
  overflow: hidden;
  color: #2b2f35;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profit-name span,
.profit-cell span {
  display: block;
  color: #718096;
  font-size: 11px;
}

.profit-cell strong {
  display: block;
  color: #2b2f35;
  font-size: 15px;
}

.profit-status {
  width: 96px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.profit-status > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  max-width: 100%;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  text-align: center;
}

.profit-status.profit-good {
  color: #047857;
}

.profit-status.profit-good > span {
  background: #e8f8ef;
}

.profit-status.profit-even {
  color: #1d4ed8;
}

.profit-status.profit-even > span {
  background: #eaf2ff;
}

.profit-status.profit-risk {
  color: #b91c1c;
}

.profit-status.profit-risk > span {
  background: #feecec;
}

.profit-progress {
  display: grid;
  gap: 5px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.profit-track {
  position: relative;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf5;
  contain: paint;
}

.profit-track i {
  display: block;
  width: var(--profit-progress, 0%);
  width: min(100%, max(0%, var(--profit-progress, 0%)));
  max-width: 100%;
  height: 100%;
  border-radius: inherit;
  background: #b91c1c;
}

.profit-row.profit-even .profit-track i {
  background: #1d4ed8;
}

.profit-row.profit-good .profit-track i {
  background: #047857;
}

.profit-progress small {
  min-width: 0;
  max-width: 100%;
  color: #56667a;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.profit-empty {
  min-height: 220px;
  display: grid;
  place-items: center;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: #718096;
  font-size: 14px;
}

@media (max-width: 1180px) {
  .profit-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .profit-table {
    display: grid;
    gap: 8px;
    border: 0;
    border-radius: 0;
  }

  .profit-row.profit-header {
    display: none;
  }

  .profit-row {
    min-width: 0;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px 10px;
    padding: 10px;
    border: 1px solid #d8e1ef;
    border-radius: 8px;
  }

  .profit-name,
  .profit-progress {
    min-width: 0;
    grid-column: 1 / -1;
  }

  .profit-cell,
  .profit-status {
    min-width: 0;
  }

  .profit-status {
    width: 100%;
    grid-column: 1 / -1;
  }

  .profit-name strong,
  .profit-cell strong,
  .profit-progress small {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.analysis-head h2 {
  margin: 0;
  color: #2b2f35;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 0;
  text-align: center;
}

.analysis-head span {
  color: #2b2f35;
  font-size: 16px;
  font-weight: 700;
}

.analysis-title-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 0;
}

.analysis-print-btn {
  padding: 3px 14px;
  border: 1px solid #b8c7e6;
  border-radius: 999px;
  background: #fff;
  color: #0f5ea8;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s ease, box-shadow .16s ease;
}

.analysis-print-btn:hover {
  background: #f5f9ff;
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}

.analysis-kpis {
  display: grid;
  /* ①年业绩 ②本年业绩(长标签加宽) ③主营商品销售数(宽) ④毛利金额 ⑤毛利率 ⑥客单价(收窄) */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1.35fr) minmax(0, 1fr) minmax(0, 0.85fr) minmax(0, 0.7fr);
  gap: 8px;
  margin: 8px 0 18px;
}

.analysis-kpis article,
.analysis-member-kpis article {
  min-height: 66px;
  display: grid;
  place-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
}

.analysis-kpis article[data-analysis-kpi] {
  cursor: pointer;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.analysis-kpis article[data-analysis-kpi]:hover,
.analysis-kpis article[data-analysis-kpi].active {
  border-color: #1d4ed8;
  background: #f5f9ff;
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.14);
}

.analysis-kpis strong,
.analysis-member-kpis strong {
  color: #2b2f35;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.1;
}

.analysis-kpis strong.analysis-kpi-compare {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  font-size: clamp(14px, 1.1vw, 18px);
}

.analysis-kpi-compare span {
  min-width: 0;
  display: grid;
  gap: 3px;
  justify-items: center;
}

.analysis-kpi-compare em {
  color: #56667a;
  font-size: 10px;
  font-style: normal;
  font-weight: 500;
}

.analysis-kpi-compare b {
  max-width: 100%;
  overflow: hidden;
  color: #2b2f35;
  font-size: clamp(15px, 1.3vw, 20px);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analysis-kpis span,
.analysis-member-kpis span {
  color: #56667a;
  font-size: 11px;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-areas:
    "trend trend trend trend trend trend trend trend"
    "weekday weekday weekday hour hour hour size size"
    "catRetail catRetail category category member member visit visit"
    "vipStructure vipStructure vipStructure vipStructure vipStructure vipStructure vipStructure vipStructure"
    "vipMonth vipMonth vipMonth vipMonth vipMonth vipMonth vipMonth vipMonth";
  gap: 14px 18px;
  align-items: start;
}

.analysis-panel {
  min-height: 210px;
  padding: 12px 12px 12px;
  border-top: 2px solid var(--line);
  background: #fff;
}

.analysis-panel.wide {
  grid-column: span 2;
}

.analysis-grid .analysis-panel:first-child {
  grid-area: trend;
  min-height: 330px;
}

.analysis-panel.full {
  grid-area: vipMonth;
}

.analysis-weekday-panel {
  grid-area: weekday;
}

.analysis-hour-panel {
  grid-area: hour;
}

.analysis-size-panel {
  grid-area: size;
}

.analysis-category-panel {
  grid-area: category;
}

.analysis-cat-retail-panel {
  grid-area: catRetail;
}

.analysis-member-panel {
  grid-area: member;
}

.analysis-visit-panel {
  grid-area: visit;
}

/* 会员/VIP 环图面板收窄后：环图缩小，给图例留空间 */
.analysis-member-panel .analysis-donut-wrap,
.analysis-visit-panel .analysis-donut-wrap {
  grid-template-columns: minmax(0, 104px) minmax(0, 1fr);
  gap: 10px;
}

.analysis-member-panel .analysis-donut,
.analysis-visit-panel .analysis-donut {
  width: 96px;
  height: 96px;
}

.analysis-member-panel .analysis-donut::after,
.analysis-visit-panel .analysis-donut::after {
  width: 54px;
  height: 54px;
}

.analysis-member-panel .analysis-donut strong,
.analysis-visit-panel .analysis-donut strong {
  font-size: 14px;
}

.analysis-vip-structure-panel {
  grid-area: vipStructure;
  min-height: 0;
}

.analysis-panel h3 {
  margin: 0 0 10px;
  color: #2b2f35;
  font-size: 14px;
  font-weight: 600;
}

.analysis-bars {
  height: 166px;
  display: flex;
  align-items: end;
  gap: 8px;
  padding: 18px 4px 2px;
  border-left: 1px solid #e1e7ef;
  border-bottom: 1px solid #e1e7ef;
  background: repeating-linear-gradient(to top, transparent 0, transparent 39px, rgba(92, 106, 122, 0.35) 40px);
  overflow-x: auto;
}

.analysis-month-trend {
  height: 280px;
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 2px;
  padding: 18px 8px 8px;
  overflow: hidden;
}

.analysis-month-bars,
.analysis-month-axis,
.analysis-year-axis {
  display: grid;
  min-width: 0;
}

.analysis-month-bars {
  height: 100%;
  min-height: 0;
  align-items: end;
  gap: 4px;
}

.analysis-month-bar {
  position: relative;
  min-width: 0;
  height: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.analysis-month-bar span {
  position: absolute;
  bottom: calc(var(--bar-height) + 4px);
  left: 50%;
  transform: translateX(-50%);
  min-height: 14px;
  color: #42526a;
  font-size: 9px;
  white-space: nowrap;
}

.analysis-month-bar i {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(26px, 72%);
  height: var(--bar-height);
  min-height: 4px;
  display: block;
  background: linear-gradient(180deg, #3b82f6, #1e40af);
}

.analysis-month-bar:hover i,
.analysis-month-bar.active i {
  background: linear-gradient(180deg, #f59e0b, #b45309);
}

.analysis-month-bar.active span {
  color: #b45309;
  font-weight: 700;
}

.analysis-month-axis {
  gap: 4px;
}

.analysis-month-axis b,
.analysis-year-axis em {
  min-width: 0;
  color: #42526a;
  font-size: 10px;
  font-style: normal;
  font-weight: 500;
  text-align: center;
}

.analysis-year-axis em {
  padding-top: 3px;
  border-left: 1px dashed #9fb0c6;
  border-right: 1px dashed #9fb0c6;
  border-bottom: 1px dashed #9fb0c6;
}

.analysis-panel.wide .analysis-bars {
  height: 220px;
}

.analysis-panel.wide .analysis-month-trend {
  height: 280px;
}

.analysis-bars.compact {
  height: 140px;
}

.analysis-vbar {
  min-width: 30px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: end;
  align-items: center;
  gap: 4px;
}

.analysis-vbar span {
  min-height: 14px;
  color: #42526a;
  font-size: 9px;
}

.analysis-vbar i {
  width: 25px;
  min-height: 4px;
  display: block;
  background: linear-gradient(180deg, #3b82f6, #1e40af);
}

.analysis-vbar b {
  color: #42526a;
  font-size: 10px;
  font-weight: 500;
}

.analysis-hbars {
  display: grid;
  gap: 9px;
}

.analysis-hbar {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 56px;
  align-items: center;
  gap: 8px;
  color: #42526a;
  font-size: 11px;
}

.analysis-hbar b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.analysis-hbar span {
  height: 18px;
  display: block;
  background: #e8f0ff;
}

.analysis-hbar i {
  height: 100%;
  display: block;
  background: linear-gradient(180deg, #3b82f6, #1e40af);
}

.analysis-hbar em {
  font-style: normal;
  text-align: right;
}

.analysis-donut-wrap {
  min-height: 158px;
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.analysis-vip-structure-panel .analysis-hbar {
  grid-template-columns: 82px minmax(0, 1fr) 62px;
}

.analysis-vip-structure-panel .analysis-hbars {
  gap: 8px;
}

.analysis-donut {
  width: 120px;
  height: 120px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  position: relative;
}

.analysis-donut::after {
  content: "";
  position: absolute;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: #fff;
}

.analysis-donut strong {
  position: relative;
  z-index: 1;
  color: #2b2f35;
  font-size: 18px;
}

.analysis-legend {
  display: grid;
  gap: 7px;
  color: #42526a;
  font-size: 11px;
}

.analysis-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.analysis-legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.analysis-member-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 240px));
  justify-content: start;
  gap: 8px;
  margin-bottom: 12px;
}


.load-more-button {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef4ff;
  color: var(--blue);
  font-weight: 800;
}

.empty-state {
  padding: 18px 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

@media (min-width: 700px) {
  .app-shell {
    padding-top: 28px;
  }
}


.auth-locked .app-shell {
  display: none;
}

.session-restoring .auth-locked .app-shell {
  display: block;
}

.session-restoring .auth-locked .login-screen {
  display: none;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top left, rgba(29, 78, 216, 0.14), transparent 34%), var(--paper);
}

.auth-ready .login-screen {
  display: none;
}

.login-card {
  width: min(100%, 390px);
  display: grid;
  gap: 14px;
  padding: 26px 22px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-brand {
  display: grid;
  gap: 6px;
  margin-bottom: 4px;
}

.login-brand span {
  width: fit-content;
  padding: 4px 8px;
  border-radius: 6px;
  background: #e8f0ff;
  color: var(--blue);
  font-weight: 700;
  font-size: 12px;
}

.login-brand h1 {
  font-size: 22px;
}

.login-brand p,
.login-card label span {
  color: var(--muted);
  font-size: 13px;
}

.login-card label {
  display: grid;
  gap: 7px;
}

.login-card input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  background: #f9fbfd;
  color: var(--ink);
}

.login-card input:focus {
  outline: 2px solid rgba(29, 78, 216, 0.18);
  border-color: var(--blue);
}

.login-error {
  min-height: 18px;
  color: var(--red);
  font-size: 13px;
}

.login-button {
  min-height: 44px;
  border: 0;
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
}

.logout-button {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--muted);
  box-shadow: 0 8px 20px rgba(18, 31, 52, 0.08);
}


.metric-action {
  cursor: pointer;
}

.metric-action:focus {
  outline: 2px solid rgba(29, 78, 216, 0.22);
  outline-offset: 2px;
}

.member-detail {
  display: grid;
  gap: 12px;
}


.member-bars {
  gap: 12px;
}

.member-bar-row {
  grid-template-columns: minmax(64px, 92px) minmax(110px, 0.66fr) minmax(132px, 168px);
  min-height: 52px;
}

.member-bar-row strong {
  display: grid;
  gap: 2px;
  justify-items: start;
  color: var(--ink);
  font-size: 12px;
}

.member-bar-row strong em {
  color: var(--muted);
  font-style: normal;
  font-size: 10px;
}


.member-page .filter-panel,
.member-page .period-panel,
.member-page .metric-grid,
.member-page .tabs {
  display: none;
}

.analysis-page .metric-grid {
  display: none;
}

.vip-page .metric-grid {
  display: none;
}

.member-bar-row .bar-track {
  height: 20px;
  border-radius: 9px;
  background: #dbeafe;
}

.member-bar-row .bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #1d4ed8);
}


.metric-card strong:empty::after,
.store-main span:empty::after {
  content: "";
}


.style-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--blue);
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.54);
}

.image-dialog {
  width: min(92vw, 520px);
  max-height: 88vh;
  overflow: hidden;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.image-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.image-head button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

#imagePreview {
  display: block;
  width: 100%;
  max-height: calc(88vh - 60px);
  object-fit: contain;
  background: #f8fafc;
}

.image-empty {
  padding: 54px 20px;
  color: var(--muted);
  text-align: center;
}


.purchase-product-drill {
  cursor: pointer;
}

.purchase-product-drill:hover,
.purchase-product-drill:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 8px 24px rgba(30, 117, 255, 0.14);
  outline: none;
}

.purchase-store-dialog {
  width: min(94vw, 760px);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.purchase-store-dialog .image-head > div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.purchase-store-dialog .image-head span {
  color: var(--muted);
  font-size: 12px;
}

.purchase-history {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding: 6px 14px 10px;
  max-height: 96px;
  overflow-y: auto;
  flex-shrink: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.purchase-history-item {
  white-space: nowrap;
}

.purchase-store-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fbff;
}

.purchase-store-summary div {
  min-width: 0;
  padding: 10px;
  border: 1px solid #dce8f8;
  border-radius: 9px;
  background: #fff;
}

.purchase-store-summary span,
.purchase-store-summary strong {
  display: block;
}

.purchase-store-summary span {
  color: var(--muted);
  font-size: 12px;
}

.purchase-store-summary strong {
  margin-top: 4px;
  color: var(--text);
  font-size: 18px;
}

.purchase-store-list {
  min-height: 120px;
  overflow-y: auto;
  padding: 6px 14px 14px;
}

.purchase-store-list.loading-state,
.purchase-store-list.empty-state {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.purchase-store-row {
  display: grid;
  grid-template-columns: 30px minmax(160px, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}

.purchase-store-index {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.purchase-store-row > div:nth-child(2) {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.purchase-store-row > div:nth-child(2) strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchase-store-row > div:nth-child(2) span,
.purchase-store-metrics span {
  color: var(--muted);
  font-size: 12px;
}

.purchase-store-metrics {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  white-space: nowrap;
}

.purchase-store-metrics strong {
  color: var(--primary);
}

@media (max-width: 640px) {
  .purchase-store-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .purchase-store-row {
    grid-template-columns: 26px minmax(0, 1fr);
  }

  .purchase-store-metrics {
    grid-column: 2;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px 12px;
  }
}

/* compact topbar */
.topbar {
  gap: 8px;
  padding: 6px 2px 14px;
}
.title-wrap {
  flex: 1 1 auto;
  min-width: 0;
  gap: 8px;
}
.title-wrap > div:last-child {
  min-width: 0;
}
.title-wrap h1 {
  font-size: 18px;
  line-height: 1.18;
  max-width: 11.5em;
}
.account-badge {
  width: 38px;
  height: 38px;
  flex-basis: 38px;
}
.eyebrow,
.account-name {
  font-size: 11px;
  line-height: 1.25;
}
.icon-button,
.logout-button {
  width: 38px;
  height: 38px;
  min-height: 38px;
  flex: 0 0 38px;
  padding: 0;
  font-size: 15px;
}
.logout-button {
  font-size: 14px;
  line-height: 1.1;
}
@media (max-width: 380px) {
  .title-wrap h1 { font-size: 17px; max-width: 10.6em; }
  .account-badge { width: 36px; height: 36px; flex-basis: 36px; }
  .icon-button, .logout-button { width: 36px; height: 36px; min-height: 36px; flex-basis: 36px; }
  .date-filter-popover { grid-template-columns: minmax(0, 0.8fr) minmax(0, 0.8fr) 48px; column-gap: 10px; padding: 7px 8px; }
  .date-filter-popover button { grid-column: auto; height: 34px; min-height: 34px; font-size: 10px; padding: 0 2px; }
  .date-filter-popover input { height: 34px; min-height: 34px; line-height: 34px; font-size: 11px; }
}

.photo-search-tab {
  display: grid;
  place-items: center;
}

.magnifier-icon {
  width: 18px;
  height: 18px;
  display: block;
  position: relative;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.magnifier-icon::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 2px;
  right: -7px;
  bottom: -4px;
  border-radius: 999px;
  background: currentColor;
  transform: rotate(45deg);
  transform-origin: left center;
}

/* UI refresh v2.1 2026-08-26: lighter blue and mobile filter parity */
:root {
  --blue: #1677ff;
}

.metric-card.primary {
  background: linear-gradient(135deg, #2386ff 0%, #1677ff 52%, #4aa3ff 100%) !important;
  border-color: rgba(22, 119, 255, 0.42) !important;
  box-shadow: 0 18px 38px rgba(22, 119, 255, 0.18) !important;
}

.segment.active,
.tab.active {
  background: #1677ff !important;
  color: #ffffff !important;
  box-shadow: 0 10px 22px rgba(22, 119, 255, 0.22) !important;
}

.metric-card.primary span,
.metric-card.primary strong,
.metric-card.primary em {
  color: #ffffff !important;
}

.bar-value,
.store-main span,
.stock-main span,
.stock-summary strong,
.purchase-summary strong,
.style-link,
.date-filter-toggle b,
.multi-select-button b,
.store-select-button b {
  color: #1677ff !important;
}

@media (orientation: landscape) and (min-width: 900px), (min-width: 1120px) {
  .tabs {
    background: linear-gradient(180deg, #eaf5ff 0%, #e4f0f9 100%) !important;
  }

  .tab.active {
    background: #1677ff !important;
  }
}

@media (max-width: 899px) {
  .filter-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
    padding: 12px !important;
    border-radius: 10px !important;
    background: rgba(255, 255, 255, 0.94) !important;
  }

  .filter-panel label {
    gap: 6px !important;
  }

  .filter-panel span {
    font-size: 11px !important;
    font-weight: 700 !important;
  }

  .filter-panel select,
  .store-select-button,
  .multi-select-button {
    min-height: 42px !important;
    border-radius: 8px !important;
    background: #fbfdff !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    padding: 0 10px !important;
  }

  .date-filter-toggle,
  .period-panel,
  .tabs {
    border-radius: 10px !important;
  }

  .segment.active {
    background: #1677ff !important;
  }
}

/* UI refresh v2 final overrides: keep this block last */
@media (orientation: landscape) and (min-width: 900px), (min-width: 1120px) {
  body {
    padding: 20px 0 !important;
    background: #cbdde8 !important;
  }

  .app-shell {
    width: min(calc(100% - 48px), 1360px) !important;
    min-height: calc(100vh - 40px);
    display: grid !important;
    grid-template-columns: 210px minmax(0, 1fr) !important;
    grid-template-rows: auto auto auto auto auto 1fr !important;
    gap: 16px 22px !important;
    margin: 0 auto !important;
    padding: 28px 28px 34px !important;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 36px !important;
    background: #f4f8fc !important;
    box-shadow: 0 22px 70px rgba(39, 61, 84, 0.16);
    overflow: clip;
  }

  .topbar {
    position: static !important;
    grid-column: 1 / -1 !important;
    grid-row: 1 !important;
    min-height: 66px !important;
    margin: -8px -8px 2px !important;
    padding: 8px 18px 16px !important;
    border: 0 !important;
    border-bottom: 1px solid rgba(207, 223, 237, 0.72) !important;
    border-radius: 26px 26px 0 0 !important;
    background: rgba(255, 255, 255, 0.92) !important;
    box-shadow: none !important;
  }

  .tabs {
    position: sticky !important;
    top: 20px !important;
    grid-column: 1 !important;
    grid-row: 2 / span 5 !important;
    align-self: start !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 9px !important;
    min-height: 520px !important;
    margin: 0 !important;
    padding: 20px 14px !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: #eaf3fb !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
  }

  .tab {
    width: 100% !important;
    min-height: 44px !important;
    padding: 0 18px !important;
    border-radius: 8px !important;
    color: #6e7f91 !important;
    font-size: 14px !important;
    text-align: left !important;
  }

  .tab.active {
    background: #1677ff !important;
    color: #ffffff !important;
    box-shadow: 0 12px 26px rgba(22, 119, 255, 0.28) !important;
  }

  .filter-panel,
  .date-filter-panel,
  .period-panel,
  .metric-grid,
  .view {
    grid-column: 2 !important;
  }

  .filter-panel {
    grid-row: 2 !important;
    margin: 0 !important;
  }

  .date-filter-panel {
    grid-row: 3 !important;
    margin: 0 !important;
  }

  .period-panel {
    grid-row: 4 !important;
    margin: 0 !important;
  }

  .metric-grid {
    grid-row: 5 !important;
    margin: 0 !important;
  }

  .view {
    grid-row: 6 !important;
    min-width: 0;
  }

  #overviewView.active {
    display: grid !important;
    grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.1fr) !important;
    column-gap: 22px !important;
  }
  body.day-period #overviewView.active {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

/* UI refresh v2 2026-08-26: D2C soft admin style */
:root {
  --ink: #101828;
  --muted: #7a8798;
  --line: #dce7f1;
  --paper: #cbdde8;
  --panel: #ffffff;
  --blue: #1677ff;
  --green: #10a37f;
  --red: #b42318;
  --gold: #b7791f;
  --nav: #eaf3fb;
  --workbench: #f4f8fc;
  --shadow: 0 12px 34px rgba(39, 61, 84, 0.08);
  --shadow-soft: 0 1px 1px rgba(39, 61, 84, 0.03), 0 18px 42px rgba(39, 61, 84, 0.08);
  --focus: 0 0 0 3px rgba(22, 119, 255, 0.18);
}

body {
  background: var(--paper);
}

.app-shell {
  background: transparent;
}

.account-badge,
.icon-button,
.logout-button,
.filter-panel,
.period-panel,
.date-filter-toggle,
.metric-card,
.tabs,
.store-item,
.stock-item,
.search-box,
.stock-summary div,
.purchase-summary div,
.purchase-filters,
.retail-filters,
.drill-title,
.login-card {
  border-color: rgba(176, 193, 211, 0.48);
  box-shadow: var(--shadow-soft);
}

.topbar,
.filter-panel,
.date-filter-toggle,
.period-panel,
.metric-card,
.tabs,
.store-item,
.stock-item,
.purchase-filters,
.retail-filters,
.search-box,
.stock-summary div,
.purchase-summary div,
.drill-title {
  background: rgba(255, 255, 255, 0.94);
}

.account-badge {
  background: linear-gradient(180deg, #f7fbff, #e8f2ff);
  color: #0f64d8;
  border-color: #bed5f5;
}

h1,
.section-title h2,
.store-main strong,
.stock-main strong {
  color: #101828;
  font-weight: 900;
}

.eyebrow {
  color: #56687c;
  font-size: 11px;
  font-weight: 800;
}

.account-name {
  color: #6b7b8f;
}

.filter-panel span,
.purchase-filters span,
.retail-filters span,
.metric-card span,
.metric-card em,
.section-title span,
.date-line,
.note,
.detail-note,
.stock-note,
.store-meta,
.stock-meta {
  color: var(--muted);
}

.filter-panel select,
.filter-panel input,
.purchase-filters select,
.purchase-filters .filter-input,
.retail-filters select,
.store-select-button,
.multi-select-button,
.date-filter-popover input,
#trendCategoryFilter {
  min-height: 40px;
  border-color: #cfdfed;
  border-radius: 8px;
  background: #fbfdff;
}

.date-filter-toggle,
.search-box {
  min-height: 44px;
}

.metric-card {
  min-height: 112px;
  border-radius: 10px;
}

.metric-card.primary {
  background: linear-gradient(135deg, #1253a5 0%, #173b69 100%);
  border-color: rgba(18, 83, 165, 0.55);
  box-shadow: 0 22px 48px rgba(18, 83, 165, 0.22);
}

.metric-card strong {
  color: #061225;
  font-weight: 950;
}

.bar-track {
  height: 11px;
  background: #deebf4;
}

.bar-fill {
  background: linear-gradient(90deg, #14a37f, #07916f);
}

.bar-value,
.store-main span,
.stock-main span,
.stock-summary strong,
.purchase-summary strong {
  color: #0b63f6;
}

.store-item,
.stock-item {
  border-radius: 10px;
}

.product-thumb {
  border-radius: 8px;
  background: #f2f6fa;
}

.store-dropdown,
.multi-select-menu,
.supplier-dropdown,
.date-filter-popover {
  border-color: rgba(176, 193, 211, 0.58);
  border-radius: 10px;
}

.store-option:hover,
.store-option.active,
.supplier-option:hover,
.supplier-option.active,
.multi-select-option:hover {
  background: #eaf3ff;
  color: #0b63f6;
}

@media (orientation: landscape) and (min-width: 900px), (min-width: 1120px) {
  body {
    padding: 20px 0;
    background: var(--paper);
  }

  .app-shell {
    width: min(calc(100% - 48px), 1360px);
    min-height: calc(100vh - 40px);
    display: grid;
    grid-template-columns: 210px minmax(0, 1fr);
    grid-template-rows: auto auto auto auto auto 1fr;
    gap: 16px 22px;
    margin: 0 auto;
    padding: 28px 28px 34px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 36px;
    background: var(--workbench);
    box-shadow: 0 22px 70px rgba(39, 61, 84, 0.16);
    overflow: clip;
  }

  .topbar {
    position: static;
    grid-column: 1 / -1;
    grid-row: 1;
    min-height: 66px;
    margin: -8px -8px 2px;
    padding: 8px 18px 16px;
    border: 0;
    border-bottom: 1px solid rgba(207, 223, 237, 0.72);
    border-radius: 26px 26px 0 0;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: none;
  }

  .title-wrap {
    align-items: center;
  }

  .title-wrap h1 {
    font-size: 24px;
  }

  .account-badge {
    width: 46px;
    height: 46px;
    flex-basis: 46px;
    border-radius: 12px;
    font-size: 15px;
  }

  .icon-button,
  .logout-button {
    width: 46px;
    height: 46px;
    min-height: 46px;
    border-radius: 10px;
  }

  .logout-button {
    width: auto;
    min-width: 54px;
    padding: 0 14px;
  }

  .tabs {
    position: sticky;
    top: 20px;
    grid-column: 1;
    grid-row: 2 / span 5;
    align-self: start;
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
    min-height: 520px;
    margin: 0;
    padding: 20px 14px;
    border: 0;
    border-radius: 0;
    background: var(--nav);
    box-shadow: none;
  }

  .tab {
    justify-content: flex-start;
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 8px;
    color: #6e7f91;
    font-size: 14px;
    text-align: left;
    box-shadow: none;
  }

  .tab.active {
    background: #1677ff;
    color: #ffffff;
    box-shadow: 0 12px 26px rgba(22, 119, 255, 0.28);
  }

  .tab:hover:not(.active) {
    background: rgba(255, 255, 255, 0.82);
    color: #1677ff;
  }

  .filter-panel,
  .date-filter-panel,
  .period-panel,
  .metric-grid,
  .view {
    grid-column: 2;
  }

  .filter-panel {
    grid-row: 2;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    margin: 0;
    padding: 14px;
    border-radius: 12px;
  }

  .date-filter-panel {
    grid-row: 3;
    margin: 0;
  }

  .date-filter-toggle {
    border-radius: 12px;
  }

  .period-panel {
    grid-row: 4;
    grid-template-columns: 190px minmax(220px, 1fr);
    margin: 0;
    padding: 12px 14px;
    border-radius: 12px;
  }

  .segmented {
    border-radius: 10px;
    background: #edf4fb;
  }

  .segment.active {
    background: #101b31;
  }

  .metric-grid {
    grid-row: 5;
    grid-template-columns: minmax(245px, 1.35fr) repeat(4, minmax(130px, 1fr));
    margin: 0;
  }

  .metric-card {
    padding: 16px;
    border-radius: 12px;
  }

  .metric-card strong {
    font-size: 25px;
  }

  .metric-card.primary strong {
    font-size: 34px;
  }

  .view {
    grid-row: 6;
    min-width: 0;
  }

  .view.active {
    display: block;
  }

  #overviewView.active {
    display: grid;
    grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.1fr);
    column-gap: 22px;
  }

  .purchase-filters,
  .retail-filters,
  .stock-summary div,
  .purchase-summary div,
  .drill-title,
  .search-box {
    border-radius: 12px;
  }

  .store-item,
  .stock-item {
    border-radius: 12px;
  }
}

@media (max-width: 899px) {
  body {
    background: #edf4f8;
  }

  .app-shell {
    padding: 22px 14px 30px;
  }

  .topbar,
  .filter-panel,
  .date-filter-toggle,
  .period-panel,
  .metric-card,
  .tabs,
  .store-item,
  .stock-item,
  .purchase-filters,
  .retail-filters,
  .stock-summary div,
  .purchase-summary div,
  .search-box {
    border-radius: 9px;
  }

  .metric-card.primary {
    border-radius: 10px;
  }
  .purchase-summary strong {
    font-size: 16px;
  }
  .purchase-summary span {
    font-size: 10px;
  }
  .purchase-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .purchase-summary-net {
    grid-column: span 1;
  }
}

/* UI refresh 2026-08-26: compact premium dashboard polish */
:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #d8e0eb;
  --paper: #eef3f8;
  --panel: #ffffff;
  --blue: #1d4ed8;
  --green: #0f8f69;
  --red: #b42318;
  --gold: #b7791f;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 1px 2px rgba(15, 23, 42, 0.04), 0 14px 34px rgba(15, 23, 42, 0.07);
  --focus: 0 0 0 3px rgba(29, 78, 216, 0.16);
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

button,
select,
input {
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

button {
  cursor: pointer;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
.metric-action:focus-visible {
  outline: 0;
  border-color: rgba(29, 78, 216, 0.62);
  box-shadow: var(--focus);
}

.app-shell {
  padding-top: 16px;
}

.topbar {
  color: var(--ink);
}

.account-badge,
.icon-button,
.logout-button,
.filter-panel,
.period-panel,
.date-filter-toggle,
.metric-card,
.tabs,
.store-item,
.stock-item,
.search-box,
.stock-summary div,
.purchase-summary div,
.purchase-filters,
.retail-filters,
.drill-title,
.login-card {
  border-color: rgba(148, 163, 184, 0.32);
  box-shadow: var(--shadow);
}

.account-badge {
  background: #eaf1ff;
  color: #1e40af;
  border-radius: 10px;
}

.eyebrow {
  color: #475569;
  font-weight: 700;
}

h1 {
  color: #0b1220;
  font-weight: 900;
}

.account-name,
.section-title span,
.date-line,
.metric-card span,
.metric-card em,
.store-meta,
.stock-meta,
.note,
.detail-note,
.stock-note,
.purchase-filters span,
.retail-filters span,
.filter-panel span {
  color: var(--muted);
}

.icon-button,
.logout-button,
.text-button,
.load-more-button {
  background: #ffffff;
  color: #1e40af;
}

.icon-button:hover,
.logout-button:hover,
.text-button:hover,
.load-more-button:hover {
  border-color: rgba(29, 78, 216, 0.34);
  background: #f7faff;
  color: #173c9f;
}

.filter-panel,
.period-panel,
.purchase-filters,
.retail-filters {
  background: rgba(255, 255, 255, 0.92);
}

.filter-panel select,
.filter-panel input,
.purchase-filters select,
.purchase-filters .filter-input,
.retail-filters select,
.store-select-button,
.multi-select-button,
.date-filter-popover input,
#trendCategoryFilter {
  min-height: 38px;
  border-color: #d7deea;
  background: #fbfdff;
  color: #172033;
  font-weight: 600;
}

.filter-panel select:hover,
.filter-panel input:hover,
.purchase-filters select:hover,
.purchase-filters .filter-input:hover,
.retail-filters select:hover,
.store-select-button:hover,
.multi-select-button:hover,
.date-filter-toggle:hover,
.search-box:hover {
  border-color: rgba(29, 78, 216, 0.34);
}

.store-dropdown,
.multi-select-menu,
.supplier-dropdown,
.date-filter-popover {
  border-color: rgba(148, 163, 184, 0.34);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.14);
}

.store-option,
.supplier-option,
.multi-select-option {
  border-radius: 7px;
}

.store-option:hover,
.store-option.active,
.supplier-option:hover,
.supplier-option.active,
.multi-select-option:hover {
  background: #edf4ff;
  color: #1d4ed8;
}

.segmented {
  gap: 3px;
  padding: 4px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: #edf2f8;
}

.segment,
.tab {
  border-radius: 7px;
  font-weight: 900;
}

.segment.active,
.tab.active {
  background: #111c31;
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.16);
}

.segment:hover:not(.active),
.tab:hover:not(.active) {
  background: #ffffff;
  color: #1e40af;
}

.metric-grid {
  gap: 12px;
}

.metric-card {
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.metric-card:hover,
.store-item:hover,
.stock-item:hover {
  border-color: rgba(29, 78, 216, 0.26);
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.1);
  transform: translateY(-1px);
}

.metric-card.primary {
  background: #173b69;
  border-color: rgba(23, 59, 105, 0.88);
  box-shadow: 0 18px 42px rgba(23, 59, 105, 0.24);
}

.metric-card strong {
  color: #07111f;
  font-weight: 950;
  line-height: 1.05;
}

.metric-card.primary strong,
.metric-card.primary span,
.metric-card.primary em {
  color: #ffffff;
}

.metric-card.primary span,
.metric-card.primary em {
  opacity: 0.82;
}

.tabs {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
}

.section-title {
  margin-top: 10px;
}

.section-title h2 {
  color: #07111f;
  font-weight: 950;
}

.bar-track {
  background: #dde6f0;
}

.bar-fill {
  background: #0f8f69;
}

.bar-fill.previous {
  background: #94a3b8;
}

.bar-value,
.store-main span,
.stock-main span,
.stock-summary strong,
.purchase-summary strong {
  color: #1d4ed8;
  font-weight: 950;
}

.store-item,
.stock-item,
.stock-summary div,
.purchase-summary div {
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.store-main strong,
.stock-main strong {
  color: #0b1220;
  font-weight: 950;
}

.store-meta span,
.stock-meta span {
  color: #5f6f85;
}

.product-thumb {
  border-color: #e0e7f0;
  background: #f4f7fb;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.search-box {
  background: #ffffff;
}

.search-box input::placeholder,
.filter-input::placeholder {
  color: #94a3b8;
}

.empty-state,
.empty {
  color: #718096;
}

@media (orientation: landscape) and (min-width: 700px), (min-width: 900px) {
  body {
    background: #e9eff6;
  }

  .topbar {
    border-bottom-color: rgba(148, 163, 184, 0.28);
    background: rgba(233, 239, 246, 0.88);
    box-shadow: 0 8px 26px rgba(15, 23, 42, 0.05);
  }

  .metric-grid {
    gap: 14px;
  }

  .rank-list,
  .store-list,
  .stock-list {
    gap: 14px;
  }
}

@media (orientation: landscape) and (min-width: 700px), (min-width: 900px) {
  body {
    background: #edf2f7;
  }

  .app-shell {
    width: min(100%, 1180px);
    padding: 18px 22px 30px;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 6;
    min-height: 64px;
    margin: -18px -22px 14px;
    padding: 12px 22px;
    border-bottom: 1px solid var(--line);
    background: rgba(237, 242, 247, 0.94);
    backdrop-filter: blur(12px);
  }

  .title-wrap h1 {
    max-width: none;
    font-size: 21px;
  }

  #vipListHead,
  #vipBillHead,
  #vipItemHead {
    position: sticky;
    top: 36px;
    z-index: 4;
    background: var(--paper);
  }

  .account-badge {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }

  .icon-button,
  .logout-button {
    width: 42px;
    height: 42px;
    min-height: 42px;
    flex-basis: 42px;
  }

  .filter-panel {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
    padding: 10px 12px;
  }

  .date-filter-panel {
    margin-bottom: 12px;
  }

  .date-filter-popover {
    grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) 76px;
    width: min(100%, 560px);
  }

  .period-panel {
    display: grid;
    grid-template-columns: 180px minmax(220px, 1fr);
    align-items: center;
    gap: 16px;
    padding: 10px 12px;
  }

  .period-panel .date-line {
    padding-top: 0;
  }

  .metric-grid {
    grid-template-columns: minmax(240px, 1.35fr) repeat(4, minmax(132px, 1fr));
    gap: 12px;
    margin-top: 12px;
  }

  .metric-card {
    min-height: 104px;
    padding: 13px 14px;
  }

  .metric-card.primary {
    grid-column: auto;
  }

  .metric-card strong {
    margin: 8px 0 6px;
    font-size: 24px;
  }

  .metric-card.primary strong {
    font-size: 32px;
  }

  .tabs {
    top: 64px;
    grid-template-columns: repeat(auto-fit, minmax(94px, 1fr));
    margin: 12px 0 14px;
  }

  .tab,
  .segment {
    min-height: 36px;
  }

  .section-title {
    margin: 8px 0 10px;
  }

  .section-title h2 {
    font-size: 18px;
  }

  #overviewView.active {
    display: grid;
    grid-template-columns: minmax(330px, 0.9fr) minmax(420px, 1.1fr);
    column-gap: 18px;
    row-gap: 10px;
    align-items: start;
    /* app-shell 把 .view(row6, 1fr) 拉伸到占满视口余高；选店后内容变矮时
       默认 align-content:stretch 会把 auto 行均分拉高 → 标题行被撑出大空白、
       两个标题错位。锁 start 让行高恢复自然、内容靠上（2026-09-22 小伟反馈）。 */
    align-content: start;
  }

  /* 「经营模式」标题显式落位到右列第 1 行：原来靠 .section-title:nth-of-type(2)
     匹配，但 #trendBars 也是 div 占掉了 nth-of-type(2) 序号，规则从未生效过，
     全靠 auto-placement 碰巧放对；行高被拉伸时它与左列标题错位 48px。 */
  #overviewView .section-title:nth-of-type(2),
  #overviewView .section-title.mode-section,
  #overviewView #modeList {
    grid-column: 2;
  }

  #overviewView .section-title:first-child,
  #overviewView #trendBars {
    grid-column: 1;
  }

  #overviewView .section-title:first-child,
  #overviewView .section-title:nth-of-type(2),
  #overviewView .section-title.mode-section {
    grid-row: 1;
    align-self: end;
  }

  #overviewView #trendBars,
  #overviewView #modeList {
    grid-row: 2;
    align-self: start;
  }

  .bars {
    gap: 8px;
  }

  .bar-row {
    grid-template-columns: minmax(58px, 82px) minmax(120px, 1fr) minmax(92px, 120px);
  }

  .rank-list,
  .store-list,
  .stock-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .member-detail .rank-list,
  #trendDetailList,
  #purchaseProductList,
  #stockList {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .store-item,
  .stock-item {
    min-height: 92px;
    padding: 12px;
  }

  .store-item.with-image,
  .stock-item.with-image {
    grid-template-columns: 72px 1fr;
  }

  .store-item.with-image.with-rank {
    grid-template-columns: 38px 72px 1fr;
  }

  .product-thumb {
    width: 72px;
    height: 72px;
  }

  .store-main strong,
  .stock-main strong {
    font-size: 15px;
  }

  .store-meta,
  .stock-meta {
    gap: 7px 10px;
    font-size: 12px;
  }

  .purchase-filters {
    flex-wrap: nowrap;
    padding: 10px 12px;
  }

  #modeView .purchase-filters,
  #purchaseView .purchase-filters {
    flex-wrap: nowrap;
  }

  .search-row {
    max-width: 520px;
  }

  .stock-summary {
    grid-template-columns: repeat(2, minmax(180px, 260px));
  }

  .drill-title {
    top: 122px;
  }

  .member-bar-row {
    grid-template-columns: minmax(84px, 120px) minmax(220px, 1fr) minmax(150px, 190px);
  }
}

@media (orientation: landscape) and (min-width: 700px) and (max-height: 520px) {
  .app-shell {
    width: min(100%, 1100px);
    padding: 12px 18px 24px;
  }

  .topbar {
    min-height: 54px;
    margin: -12px -18px 10px;
    padding: 8px 18px;
  }

  .eyebrow,
  .account-name {
    font-size: 10px;
  }

  .title-wrap h1 {
    font-size: 18px;
  }

  .filter-panel,
  .period-panel,
  .purchase-filters {
    padding: 8px 10px;
  }

  .metric-grid {
    gap: 9px;
  }

  .metric-card {
    min-height: 88px;
    padding: 10px 12px;
  }

  .metric-card strong {
    font-size: 21px;
  }

  .metric-card.primary strong {
    font-size: 28px;
  }

  .tabs {
    top: 54px;
    margin: 10px 0 12px;
  }

  .drill-title {
    top: 104px;
  }
}
.product-title-right {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 44px;
}

.photo-search-title {
  width: 42px;
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
}

.magnifier-icon {
  width: 18px;
  height: 18px;
  display: block;
  position: relative;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.magnifier-icon::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 2px;
  right: -7px;
  bottom: -4px;
  border-radius: 999px;
  background: currentColor;
  transform: rotate(45deg);
  transform-origin: left center;
}

/* UI refresh v2.2 final: mobile top filters stay in one row */
@media (max-width: 899px) {
  .filter-panel {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 7px !important;
    padding: 10px !important;
  }

  .filter-panel label {
    gap: 5px !important;
    min-width: 0 !important;
  }

  .filter-panel span {
    overflow: hidden;
    font-size: 10px !important;
    font-weight: 700 !important;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .filter-panel select,
  .store-select-button {
    min-height: 40px !important;
    padding: 0 6px !important;
    border-radius: 8px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
  }

  .store-select-button {
    gap: 4px !important;
  }

  .store-select-button span {
    font-size: 12px !important;
  }

  .store-select-button b {
    flex: 0 0 auto;
    font-size: 12px !important;
  }
}

/* UI refresh v2.3 final: equal mobile controls and searchable store field */
.store-search-input {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cfdfed;
  border-radius: 8px;
  background: #fbfdff;
  color: #101828;
  font-size: 13px;
  font-weight: 700;
  padding: 0 10px;
}

.store-search-input::placeholder {
  color: #5f6f85;
}

.store-search-input::-webkit-search-cancel-button {
  cursor: pointer;
}

.store-filter-control .store-dropdown {
  width: min(360px, calc(100vw - 28px));
}

@media (max-width: 899px) {
  .filter-panel select,
  .filter-panel input,
  .multi-select-button,
  .store-search-input,
  .retail-filters select {
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    line-height: 40px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border-radius: 8px !important;
    font-size: 12px !important;
    font-weight: 700 !important;
  }

  .multi-select-button,
  .store-search-input {
    padding-left: 6px !important;
    padding-right: 6px !important;
  }

  .multi-select-button span {
    font-size: 12px !important;
  }

  .filter-panel .store-dropdown {
    width: min(300px, calc(100vw - 28px)) !important;
    max-height: 230px !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%);
  }
}

/* Boss agent page */
.agent-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 42;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(135deg, #2386ff, #1677ff);
  color: #fff;
  font-size: 16px;
  font-weight: 950;
  box-shadow: 0 18px 42px rgba(22, 119, 255, 0.28);
}

.agent-fab:hover,
.agent-fab.active {
  transform: translateY(-2px);
  box-shadow: 0 22px 52px rgba(22, 119, 255, 0.34);
}

.agent-panel {
  position: fixed;
  inset: 0;
  z-index: 60;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  display: none;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #f5f9fd;
  box-shadow: none;
}

body.agent-page .filter-panel,
body.agent-page .date-filter-panel,
body.agent-page .period-panel,
body.agent-page .metric-grid,
body.agent-page .tabs {
  display: none;
}

body.agent-page .agent-fab {
  display: none;
}

.view.agent-panel.active {
  display: grid;
}

.agent-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 12px;
  border-bottom: 1px solid #e3edf6;
  background: linear-gradient(180deg, #f8fbff, #ffffff);
}

.agent-head div {
  display: grid;
  gap: 3px;
}

.agent-head strong {
  color: #101828;
  font-size: 16px;
  font-weight: 950;
}

.agent-head span {
  color: #7a8798;
  font-size: 12px;
  font-weight: 700;
}

.agent-head button {
  width: auto;
  min-width: 54px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid #dce7f1;
  border-radius: 10px;
  background: #fff;
  color: #667085;
  font-size: 13px;
  font-weight: 900;
}

.agent-quick {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  border-bottom: 1px solid #edf3f8;
}

.agent-quick button {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #dce7f1;
  border-radius: 999px;
  background: #f7fbff;
  color: #375f8d;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.agent-quick button:hover {
  border-color: rgba(22, 119, 255, 0.42);
  color: #1677ff;
}

.agent-messages {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  background: #f5f9fd;
}

.agent-message {
  width: fit-content;
  max-width: min(760px, 88%);
  padding: 10px 12px;
  border-radius: 10px;
  color: #26364a;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
  box-shadow: 0 6px 16px rgba(39, 61, 84, 0.06);
}

.agent-message.user {
  justify-self: end;
  background: #1677ff;
  color: #fff;
  border-bottom-right-radius: 5px;
}

.agent-message.assistant {
  justify-self: start;
  background: #fff;
  border: 1px solid #e3edf6;
  border-bottom-left-radius: 5px;
}

.agent-message.loading {
  color: #667085;
}

.agent-message small {
  display: block;
  margin-top: 7px;
  color: #8a98aa;
  font-size: 11px;
}

.agent-products {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.agent-product-card {
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 5px;
  min-width: 0;
  padding: 7px;
  border: 1px solid #e3edf6;
  border-radius: 8px;
  background: #f8fbff;
  color: #26364a;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.agent-product-card img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 6px;
  background: #eef4fb;
}

.agent-product-card img.missing {
  display: none;
}

.agent-product-main,
.agent-product-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-product-main {
  font-size: 12px;
  font-weight: 800;
}

.agent-product-meta {
  color: #667085;
  font-size: 11px;
}

.agent-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 10px;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #e3edf6;
  background: #fff;
}

.agent-form textarea {
  width: 100%;
  min-height: 44px;
  height: 44px;
  max-height: 44px;
  resize: none;
  border: 1px solid #dce7f1;
  border-radius: 10px;
  background: #fbfdff;
  color: #101828;
  font: inherit;
  font-size: 13px;
  line-height: 1.45;
  padding: 10px 12px;
}

.agent-form button {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: #1677ff;
  color: #fff;
  font-weight: 900;
}

.agent-form button:disabled {
  opacity: 0.58;
  cursor: wait;
}

@media (max-width: 899px) {
  .agent-fab {
    right: 16px;
    bottom: 16px;
    width: 54px;
    height: 54px;
    border-radius: 16px;
  }

  .agent-panel {
    height: 100vh;
    min-height: 100vh;
    border-radius: 0;
  }

  .agent-messages {
    min-height: 0;
  }
}

@media (max-width: 900px) {
  .analysis-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analysis-grid {
    grid-template-columns: 1fr;
    grid-template-areas: none;
    width: 100%;
    max-width: 100%;
  }

  .analysis-panel,
  .analysis-panel.wide,
  .analysis-panel.full,
  .analysis-grid .analysis-panel:first-child {
    grid-area: auto;
    grid-column: auto;
    min-width: 0;
    max-width: 100%;
  }

  .analysis-grid .analysis-panel:first-child {
    min-height: 0;
  }

  .analysis-head {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .analysis-head h2 {
    font-size: 24px;
  }

  .analysis-donut-wrap {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .analysis-member-kpis {
    grid-template-columns: 1fr;
  }

  .profit-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .profit-table {
    display: grid;
    gap: 8px;
    border: 0;
    border-radius: 0;
  }

  .profit-row.profit-header {
    display: none;
  }

  .profit-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px 10px;
    padding: 10px;
    border: 1px solid #d8e1ef;
    border-radius: 8px;
  }

  .profit-name,
  .profit-progress {
    grid-column: 1 / -1;
  }

  .profit-name strong,
  .profit-cell strong,
  .profit-progress small {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .profit-status {
    justify-self: center;
  }
}

@media (max-width: 600px) {
  #analysisView {
    width: 100%;
    max-width: 100%;
    padding: 12px 10px 20px;
    overflow: hidden;
  }

  .analysis-head {
    gap: 6px;
    margin-bottom: 10px;
    padding: 0 0 8px;
  }

  .analysis-title-wrap {
    justify-content: space-between;
    gap: 8px;
  }

  .analysis-head h2 {
    min-width: 0;
    overflow: hidden;
    font-size: 20px;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .analysis-head span {
    font-size: 13px;
    text-align: left;
  }

  .analysis-print-btn {
    flex: 0 0 auto;
    padding: 4px 10px;
    font-size: 11px;
  }

  #analysisView .section-title {
    align-items: flex-start;
    gap: 3px;
  }

  #analysisView .section-title h2 {
    font-size: 15px;
  }

  #analysisView .section-title span {
    max-width: 100%;
    font-size: 11px;
    line-height: 1.35;
  }

  .analysis-kpis {
    gap: 7px;
    margin: 6px 0 12px;
  }

  .analysis-page-tabs {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .profit-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin: 10px 0 12px;
  }

  .profit-summary article {
    min-height: 58px;
    padding: 7px 6px;
  }

  .profit-summary strong {
    font-size: 18px;
  }

  .profit-table {
    display: grid;
    gap: 8px;
    border: 0;
    border-radius: 0;
  }

  .profit-row.profit-header {
    display: none;
  }

  .profit-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
    border: 1px solid #d8e1ef;
    border-radius: 8px;
  }

  .profit-name,
  .profit-progress {
    grid-column: 1 / -1;
  }

  .profit-status {
    justify-self: center;
  }

  .analysis-kpis article,
  .analysis-member-kpis article {
    min-height: 58px;
    padding: 7px 6px;
    border-radius: 7px;
  }

  .analysis-kpis strong,
  .analysis-member-kpis strong {
    max-width: 100%;
    overflow: hidden;
    font-size: 20px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .analysis-kpis strong.analysis-kpi-compare {
    grid-template-columns: 1fr;
    gap: 2px;
    font-size: 13px;
  }

  .analysis-kpi-compare span {
    grid-template-columns: auto minmax(0, 1fr);
    justify-items: stretch;
    align-items: baseline;
    gap: 4px;
  }

  .analysis-kpi-compare em {
    font-size: 9px;
    white-space: nowrap;
  }

  .analysis-kpi-compare b {
    font-size: 13px;
    text-align: right;
  }

  .analysis-kpis span,
  .analysis-member-kpis span {
    font-size: 10px;
    text-align: center;
  }

  .analysis-grid {
    gap: 10px;
  }

  .analysis-panel,
  .analysis-grid .analysis-panel:first-child {
    min-height: 0;
    padding: 10px 8px;
  }

  .analysis-panel h3 {
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.35;
  }

  .analysis-month-trend {
    height: 210px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 12px 4px 6px;
    scrollbar-width: thin;
  }

  .analysis-month-bars,
  .analysis-month-axis,
  .analysis-year-axis {
    min-width: 640px;
  }

  .analysis-month-bar span {
    font-size: 8px;
  }

  .analysis-month-axis b,
  .analysis-year-axis em {
    font-size: 9px;
  }

  .analysis-hbar {
    grid-template-columns: minmax(58px, 0.9fr) minmax(86px, 1.5fr) minmax(44px, auto);
    gap: 6px;
    font-size: 10px;
  }

  .analysis-vip-structure-panel .analysis-hbar {
    grid-template-columns: minmax(68px, 1fr) minmax(80px, 1.4fr) minmax(46px, auto);
  }

  .analysis-hbar span {
    height: 14px;
  }

  .analysis-donut-wrap {
    min-height: 0;
    gap: 8px;
  }

  .analysis-donut {
    width: 96px;
    height: 96px;
  }

  .analysis-donut::after {
    width: 54px;
    height: 54px;
  }

  .analysis-donut strong {
    font-size: 13px;
  }

  .analysis-legend {
    width: 100%;
    gap: 5px;
    font-size: 11px;
  }

  .analysis-member-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analysis-bars.compact {
    height: 124px;
    overflow-x: auto;
    padding-top: 12px;
  }

  .analysis-bars.compact .analysis-vbar {
    min-width: 36px;
  }

  .analysis-bars.compact .analysis-vbar b {
    font-size: 9px;
    letter-spacing: -0.3px;
    white-space: nowrap;
  }
}

@media (max-width: 380px) {
  .analysis-kpis {
    grid-template-columns: 1fr;
  }

  .analysis-member-kpis {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   版面优化 2026-09-18（仅显示层，不涉及任何数据取数/计算逻辑）
   ============================================================ */

/* 1) 手机端主导航：一行横向滑动，最后一个页签不再孤行折行 */
@media (max-width: 699px) {
  .tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tabs .tab {
    flex: 1 0 auto;
    min-width: 68px;
    white-space: nowrap;
  }
}

/* 2) 销售页汇总卡片：手机/窄屏两列展示，金额不再被挤成竖排换行
      （卡片容器带内联 4 列样式，需 !important 覆盖） */
@media (max-width: 899px) {
  #salesStoreSummary {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  #salesStoreSummary > div {
    min-width: 0;
  }

  #salesStoreSummary strong,
  #salesProductSection .purchase-summary strong {
    white-space: nowrap;
  }
}

/* ===== 会员板块 2.0「会员管理」：页头 / 工具栏面板 / KPI 卡 / 明细面板（1:1 设计稿复刻） ===== */
.vip-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 2px 0 12px;
}
.vip-hero-text h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--color-text-primary, #0f172a);
}
.vip-hero-text p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--color-text-secondary, #64748b);
}
.vip-hero-meta { font-size: 12px; color: var(--color-text-tertiary, #94a3b8); white-space: nowrap; }

/* 通用白卡面板 */
.vip-panel {
  background: var(--color-background-primary, #fff);
  border: 0.5px solid var(--color-border-tertiary, rgba(15, 23, 42, 0.12));
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  padding: 14px 16px;
}

/* ── 工具栏面板：页签 + 搜索 + 店仓 + 会员类型 + 导出 ── */
.vip-toolbar-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.vip-page-tabs {
  display: flex;
  gap: 8px;
  margin-right: 8px;
}
.vip-page-tab {
  border: 1px solid var(--color-border-tertiary, rgba(15, 23, 42, 0.14));
  background: var(--color-background-secondary, #f1f5f9);
  color: var(--color-text-secondary, #475569);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.vip-page-tab:hover { border-color: rgba(15, 23, 42, 0.32); }
.vip-page-tab.active {
  background: #1d2b50;
  border-color: #1d2b50;
  color: #fff;
}
.vip-search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 1 240px;
  min-width: 180px;
  border: 1px solid var(--color-border-secondary, rgba(15, 23, 42, 0.18));
  border-radius: 999px;
  padding: 7px 14px;
  background: var(--color-background-primary, #fff);
}
.vip-search-box span { color: var(--color-text-tertiary, #94a3b8); font-size: 14px; }
.vip-search-box input {
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 13px;
  width: 100%;
  min-width: 0;
}
/* 字段：小标签在上一行，控件在下 */
.vip-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 0 1 190px;
  min-width: 150px;
}
.vip-field > span {
  font-size: 12px;
  color: var(--color-text-secondary, #64748b);
  white-space: nowrap;
}
.vip-field .store-filter-control { width: 100%; }
.vip-field .store-search-input { font-weight: 500; }
.vip-field .store-search-input:disabled {
  background: var(--color-background-secondary, #f1f5f9);
  color: #64748b;
  cursor: not-allowed;
}
.vip-field .store-dropdown { width: min(300px, calc(100vw - 28px)); }
.vip-field .store-option { text-align: left; cursor: pointer; }
.vip-field .store-option.active { color: #185fa5; font-weight: 600; }
.vip-select {
  width: 100%;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-primary, #0f172a);
  border: 1px solid var(--color-border-secondary, rgba(15, 23, 42, 0.18));
  border-radius: 9px;
  padding: 7px 10px;
  background: var(--color-background-primary, #fff);
  outline: none;
  cursor: pointer;
}
.vip-select:focus { border-color: var(--color-border-info, #378add); }
.vip-export-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: #1d2b50;
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
}
.vip-export-btn:hover { background: #2a3c6b; }
.vip-export-btn:disabled { opacity: 0.6; cursor: default; }
.vip-export-btn i { font-style: normal; font-size: 12px; }

/* 生日月份行（生日页签专属筛选） */
.vip-bd-months-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border-top: 0.5px dashed var(--color-border-tertiary, rgba(15, 23, 42, 0.14));
  margin-top: 12px;
  padding-top: 12px;
}
.vip-bd-months-row > span {
  font-size: 12px;
  color: var(--color-text-secondary, #64748b);
  white-space: nowrap;
}
.vip-bd-months {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  flex: 1;
}
.vip-bd-month-chip { justify-content: center; }
.vip-bd-month-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0.5px solid var(--color-border-tertiary, rgba(15, 23, 42, 0.15));
  background: var(--color-background-primary, #fff);
  border-radius: 999px;
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  color: var(--color-text-secondary, #64748b);
  cursor: pointer;
  white-space: nowrap; /* iPad 定宽格里「1月 15,406」不许换行（2026-09-22） */
}
.vip-bd-month-chip i {
  font-style: normal;
  font-size: 11px;
  color: var(--color-text-tertiary, #94a3b8);
}
.vip-bd-month-chip:hover:not(:disabled) { border-color: var(--color-border-secondary, rgba(15, 23, 42, 0.3)); }
.vip-bd-month-chip.active {
  border-color: #1d2b50;
  background: #1d2b50;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(29, 43, 80, 0.32);
}
.vip-bd-month-chip.active i { color: rgba(255, 255, 255, 0.78); }
.vip-bd-month-chip.active:hover:not(:disabled) { border-color: #1d2b50; }
.vip-bd-month-chip:disabled { opacity: 0.55; cursor: not-allowed; }

/* ── KPI 区：休眠分布 + 12月以上 / 无消费 侧卡 ── */
.vip-kpis {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.vip-kpi-card {
  background: var(--color-background-primary, #fff);
  border: 0.5px solid var(--color-border-tertiary, rgba(15, 23, 42, 0.12));
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  padding: 14px 16px;
  min-width: 0;
}
.vip-kpi-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.vip-kpi-card > header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text-primary, #0f172a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vip-kpi-card > header > span { font-size: 12px; color: var(--color-text-tertiary, #94a3b8); white-space: nowrap; }
.vip-kpi-ico { font-style: normal; font-size: 11px; color: #e1404a; letter-spacing: 1px; }

/* 休眠分布柱图 */
.vip-tier-bars {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 6px;
  padding: 14px 4px 0;
}
.vip-dist-bar {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 4px 2px 6px;
  cursor: pointer;
  font: inherit;
}
.vip-dist-bar strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary, #0f172a);
}
.vip-dist-col {
  display: flex;
  align-items: flex-end;
  height: 118px;
  width: 100%;
  max-width: 58px;
  justify-content: center;
}
.vip-dist-col i {
  display: block;
  width: 100%;
  border-radius: 7px;
  background: #a9c8ee;
  transition: background .15s;
}
.vip-dist-bar.is-max .vip-dist-col i { background: #2563c4; }
.vip-dist-bar.is-warm .vip-dist-col i { background: #e8a558; }
.vip-dist-bar em {
  font-style: normal;
  font-size: 12px;
  color: var(--color-text-secondary, #64748b);
  white-space: nowrap;
}
.vip-dist-bar:hover { border-color: rgba(15, 23, 42, 0.18); }
.vip-dist-bar.active {
  border-color: var(--color-border-info, #378add);
  background: var(--color-background-info, #e6f1fb);
}

/* 12月以上 / 无消费 侧卡：大数字 + 红色面积图 */
.vip-kpi-side {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.vip-kpi-side strong {
  display: block;
  margin-top: 14px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--color-text-primary, #0f172a);
  position: relative;
  z-index: 1;
}
.vip-kpi-side .vip-kpi-area {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 58px;
  pointer-events: none;
}
.vip-kpi-side:hover { border-color: rgba(15, 23, 42, 0.28); }
.vip-kpi-side.active {
  border-color: var(--color-border-info, #378add);
  box-shadow: inset 0 0 0 1px var(--color-border-info, #378add);
}

/* ── 明细面板：标题行 + 数字分页 + 表格 ── */
.vip-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.vip-detail-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.vip-detail-title h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text-primary, #0f172a);
  white-space: nowrap;
}
.vip-detail-title span { font-size: 12px; color: var(--color-text-tertiary, #94a3b8); }
/* 下钻页（消费记录/商品明细）：返回胶囊按钮 + 分隔线大标题（设计稿样式） */
.vip-back-btn:not([hidden]) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(15, 23, 42, 0.16);
  background: var(--color-background-primary, #fff);
  color: var(--color-text-primary, #0f172a);
  border-radius: 10px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.vip-back-btn::before { content: "\2190"; font-size: 14px; line-height: 1; }
.vip-back-btn:hover { border-color: rgba(15, 23, 42, 0.36); background: var(--color-background-secondary, #f8fafc); }
.vip-detail-title.is-drill { align-items: center; gap: 12px; }
/* 标题旁会员信息胶囊：姓名 / 电话 / 会员类型 */
.vip-member-meta { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.vip-member-meta[hidden] { display: none; }
.vip-meta-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  background: #f5f7fa;
  border: 0.5px solid rgba(15, 23, 42, 0.08);
  border-radius: 8px;
  padding: 4px 10px;
  font-style: normal;
  white-space: nowrap;
}
.vip-meta-chip small { font-size: 12px; color: #94a3b8; }
.vip-meta-chip b { font-size: 13px; font-weight: 600; color: var(--color-text-primary, #0f172a); }
.vip-detail-title.is-drill h3 {
  font-size: 19px;
  border-left: 1px solid rgba(15, 23, 42, 0.12);
  padding-left: 12px;
  margin-left: auto;
  order: 10;
}
/* 下钻统计卡：图标色块 + 标签/数值 */
.vip-drill-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 2px 0 14px;
}
.vip-stat-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--color-background-primary, #fff);
  border: 0.5px solid rgba(15, 23, 42, 0.1);
  border-radius: 12px;
  padding: 12px 14px;
  min-width: 0;
}
.vip-stat-ico {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.vip-stat-ico svg { width: 20px; height: 20px; }
.vip-stat-ico.c-blue { background: #e8f1fd; color: #2f6fed; }
.vip-stat-ico.c-green { background: #e5f6ee; color: #17a34a; }
.vip-stat-ico.c-purple { background: #efeafd; color: #7a5af5; }
.vip-stat-ico.c-orange { background: #fff2df; color: #ef8e1b; }
.vip-stat-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.vip-stat-meta small { font-size: 12px; color: #94a3b8; white-space: nowrap; }
.vip-stat-meta strong { font-size: 18px; font-weight: 700; color: var(--color-text-primary, #0f172a); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vip-pager-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.vip-total-label { font-size: 12px; color: var(--color-text-tertiary, #94a3b8); white-space: nowrap; }
.vip-pager {
  display: flex;
  align-items: center;
  gap: 5px;
}
.vip-page-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--color-border-secondary, rgba(15, 23, 42, 0.18));
  background: var(--color-background-primary, #fff);
  color: var(--color-text-secondary, #475569);
  font: inherit;
  font-size: 12.5px;
  border-radius: 8px;
  cursor: pointer;
}
.vip-page-btn:hover:not(:disabled):not(.active) { border-color: rgba(15, 23, 42, 0.34); }
.vip-page-btn.active {
  background: #1d2b50;
  border-color: #1d2b50;
  color: #fff;
  font-weight: 700;
}
.vip-page-btn:disabled { opacity: 0.45; cursor: default; }
.vip-page-ellipsis { font-size: 12px; color: var(--color-text-tertiary, #94a3b8); padding: 0 2px; }
.vip-pagesize { width: auto; font-size: 12px; padding: 5px 8px; }

/* 表格表头 / 行（休眠 13 列 + 操作）；列宽 minmax(0,fr) 弹性比例，窄屏按比例缩不出屏 */
.vip-table-head {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 0.95fr) minmax(0, 0.55fr) minmax(0, 0.68fr) minmax(0, 1.05fr) minmax(0, 0.45fr) minmax(0, 0.45fr) minmax(0, 0.85fr) minmax(0, 0.6fr) minmax(0, 0.95fr) minmax(0, 0.55fr);
  gap: 8px;
  padding: 4px 14px 8px;
  font-size: 12px;
  color: var(--color-text-secondary, #64748b);
}
.vip-tbody { display: block; }
.vip-tbody .empty-state { border-top: 0.5px solid var(--color-border-tertiary, rgba(15, 23, 42, 0.08)); }

/* 销售门店下钻：品类筛选 chips（主营商品 + 其他品类），复用 vip-page-tab 胶囊样式 */
.sales-drill-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2px 0 12px;
}
.sales-drill-cats .vip-page-tab { padding: 6px 14px; font-size: 12.5px; }
.sales-drill-cats[hidden] { display: none; }
/* 生日明细表头：必须与 .vip-bd-row 同为 8 列 + 同 gap + 同左右内边距（否则表头与卡片错位）。
   选择器提权为 .vip-table-head.vip-bd-head（(0,2,0) > 断点里的 .vip-table-head (0,1,0)），
   使 901~1239 / 1240~1399 断点里的休眠表头列模板(10/13 列)、gap、padding 不再覆盖本表头。
   iPad 实测：修前横屏表头 10/13 列 vs 卡片 8 列，最大错位 125~268px（2026-09-22）。 */
.vip-table-head.vip-bd-head {
  grid-template-columns: minmax(0, 0.75fr) minmax(0, 0.65fr) minmax(0, 0.95fr) minmax(0, 0.7fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 0.95fr) minmax(0, 1fr);
  gap: 8px;
  padding: 4px 14px 8px;
}
.vip-table-head.vip-bd-head span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 会员类型徽章（休眠时段列） */
.vip-badge {
  display: inline-block;
  font-style: normal;
  font-size: 11px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
}
.vip-badge-0 { background: #e3edfb; color: #2f6fc2; }
.vip-badge-1 { background: #e0f5f1; color: #0f9d8a; }
.vip-badge-2 { background: #e7ecfd; color: #4c5fd6; }
.vip-badge-3 { background: #f1e9fb; color: #8a4fd3; }
.vip-badge-4 { background: #fdeeda; color: #c77a1d; }
.vip-badge-5 { background: #fde3e3; color: #c0392b; }
.vip-badge-6 { background: #eef1f5; color: #64748b; }
.vip-detail-btn {
  border: none;
  background: transparent;
  color: #185fa5;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
}
.vip-detail-btn:hover { text-decoration: underline; }
.vip-list { display: flex; flex-direction: column; gap: 6px; }
.vip-member-row,
.vip-bill-row,
.vip-item-row,
.vip-bd-row {
  display: grid;
  align-items: center;
  gap: 8px;
  background: var(--color-background-primary, #fff);
  font-size: 13px;
}
/* 休眠明细行：13 列 + 操作（设计稿为细分隔线表格风，非卡片）；列宽与表头一致 */
.vip-member-row {
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 0.95fr) minmax(0, 0.55fr) minmax(0, 0.68fr) minmax(0, 1.05fr) minmax(0, 0.45fr) minmax(0, 0.45fr) minmax(0, 0.85fr) minmax(0, 0.6fr) minmax(0, 0.95fr) minmax(0, 0.55fr);
  padding: 10px 14px;
  border-bottom: 0.5px solid rgba(15, 23, 42, 0.07);
  cursor: pointer;
}
.vip-member-row:hover { background: var(--color-background-secondary, #f8fafc); }
.vip-member-row .v-stats,
.vip-member-row .v-shops { display: contents; }
/* 生日明细行：会员类型 / 生日月日 / 出生日期 / 姓名 / 手机 / 最近消费门店 / 最近消费日期 / 累计消费金额 */
.vip-bd-row {
  grid-template-columns: minmax(0, 0.75fr) minmax(0, 0.65fr) minmax(0, 0.95fr) minmax(0, 0.7fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 0.95fr) minmax(0, 1fr);
  padding: 10px 14px;
  border-bottom: 0.5px solid rgba(15, 23, 42, 0.07);
}
.vip-bd-row:hover { background: var(--color-background-secondary, #f8fafc); }
/* 下钻行（消费记录 / 商品明细）：细分隔线表格风（设计稿） */
.vip-bill-row,
.vip-item-row {
  padding: 11px 14px;
  border-bottom: 0.5px solid rgba(15, 23, 42, 0.07);
}
.vip-bill-row:hover,
.vip-item-row:hover { background: var(--color-background-secondary, #f8fafc); }
/* 下钻列表去掉卡片间距，呈现连续表格 */
.vip-drill-list { gap: 0; }
.vip-member-row .v-type,
.vip-bd-row .v-type { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vip-member-row .v-store,
.vip-member-row .v-laststore,
.vip-member-row .v-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vip-member-row .v-name, .vip-member-row .v-amt, .vip-bill-row .v-amt, .vip-item-row .v-amt { text-align: left; }
.vip-member-row .v-last { white-space: nowrap; }
.vip-member-row .v-amt { font-weight: 600; }
.vip-bd-row .v-md,
.vip-bd-row .v-birth,
.vip-bd-row .v-phone { white-space: nowrap; }
.vip-bd-row .v-md b { color: #a32d2d; font-weight: 700; }
.vip-bd-row .v-name,
.vip-bd-row .v-laststore { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vip-bd-row .v-lastdate { color: #475569; white-space: nowrap; font-variant-numeric: tabular-nums; }
.vip-bd-row .v-amt { color: #a32d2d; font-weight: 600; white-space: nowrap; }
.vip-phone-btn {
  border: none;
  background: transparent;
  color: #185fa5;
  font: inherit;
  cursor: pointer;
  padding: 0;
  text-align: left;
}
.vip-phone-btn:hover { text-decoration: underline; }
.vip-list-head {
  display: grid;
  grid-template-columns: minmax(68px, 1.25fr) minmax(64px, 1.2fr) minmax(54px, 0.7fr) minmax(34px, 0.55fr) minmax(44px, 0.8fr) minmax(86px, 1.1fr) minmax(28px, 0.5fr) minmax(28px, 0.5fr) minmax(56px, 0.85fr) minmax(38px, 0.6fr) minmax(80px, 0.9fr);
  gap: 6px;
  padding: 2px 10px 6px;
  font-size: 12px;
  color: var(--color-text-secondary, #64748b);
}
/* ── 下钻列表表头：账单（消费记录） / 商品明细，列宽与对应行 grid 一致 ── */
.vip-bill-head {
  grid-template-columns: minmax(110px, 1.1fr) minmax(130px, 1.25fr) minmax(64px, 0.6fr) minmax(96px, 0.9fr) minmax(96px, 0.85fr);
  margin-top: 2px;
  background: #edf3fb;
  border-radius: 8px;
  padding: 9px 14px;
  color: #33415c;
  font-weight: 500;
}
.vip-item-head {
  grid-template-columns: 52px minmax(0, 1.05fr) minmax(0, 0.95fr) minmax(52px, 0.55fr) 76px 56px 96px 64px;
  margin-top: 2px;
  background: #edf3fb;
  border-radius: 8px;
  padding: 9px 14px;
  color: #33415c;
  font-weight: 500;
}
.vip-item-head span:nth-child(7) { text-align: left; }
.vip-bill-head span:last-child { text-align: right; }
/* ── 可排序表头：累计金额 / 最近购物日 ── */
.vip-sort-btn {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 3px;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  font: inherit;
  font-size: 12px;
  color: inherit;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  user-select: none;
}
.vip-sort-btn:hover { color: #185fa5; }
.vip-sort-btn::after {
  content: "↕";
  font-size: 10px;
  line-height: 1;
  color: #cbd5e1;
}
.vip-sort-btn:hover::after { color: #94a3b8; }
.vip-sort-btn[data-dir="desc"]::after { content: "↓"; color: #185fa5; }
.vip-sort-btn[data-dir="asc"]::after { content: "↑"; color: #185fa5; }
.vip-sort-btn.active {
  color: #185fa5;
  font-weight: 600;
}
/* 手机端排序条（表头在窄屏隐藏，用胶囊按钮代替） */
.vip-sort-bar { display: none; }
.vip-sort-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0.5px solid var(--color-border-tertiary, rgba(15, 23, 42, 0.15));
  background: var(--color-background-primary, #fff);
  border-radius: 999px;
  padding: 5px 10px;
  font: inherit;
  font-size: 12px;
  color: var(--color-text-secondary, #64748b);
  cursor: pointer;
}
.vip-sort-chip::after {
  content: "↕";
  font-size: 10px;
  line-height: 1;
  color: #cbd5e1;
}
.vip-sort-chip[data-dir="desc"]::after { content: "↓"; color: #185fa5; }
.vip-sort-chip[data-dir="asc"]::after { content: "↑"; color: #185fa5; }
.vip-sort-chip.active {
  border-color: var(--color-border-info, #378add);
  background: var(--color-background-info, #e6f1fb);
  color: #185fa5;
  font-weight: 600;
}
.vip-bill-row { grid-template-columns: minmax(110px, 1.1fr) minmax(130px, 1.25fr) minmax(64px, 0.6fr) minmax(96px, 0.9fr) minmax(96px, 0.85fr); cursor: pointer; }
.vip-bill-row .v-bstore { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vip-bill-row .v-date { white-space: nowrap; }
.vip-bill-row .v-amt { font-weight: 500; white-space: nowrap; }
.vip-bill-row .v-more {
  justify-self: end;
  background: #e8f1fd;
  color: #185fa5;
  font-size: 12px;
  font-weight: 500;
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}
.vip-item-row {
  grid-template-columns: 44px minmax(0, 1.05fr) minmax(0, 0.95fr) minmax(52px, 0.55fr) 76px 56px 96px 64px;
}
/* 颜色/尺码/零售价：桌面端 display:contents 直接当独立列（手机端媒体块里改成并排一行） */
.vip-item-row .v-itemmeta { display: contents; }
.vip-item-row .v-color,
.vip-item-row .v-size {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #33415c;
}
.vip-item-row .v-price { white-space: nowrap; color: #33415c; font-variant-numeric: tabular-nums; }
/* 图片缺失不能 display:none：会移除网格子项导致后面四列整体左移错位，改为隐藏但保留占位 */
.vip-item-row .product-thumb.missing {
  display: block;
  visibility: hidden;
}
.vip-item-row .product-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  border: 0.5px solid var(--color-border-tertiary, rgba(15, 23, 42, 0.15));
}
.vip-item-row .v-qty.is-return {
  color: #d92d20;
  font-weight: 600;
}
.vip-item-row .style-link {
  border: none;
  background: transparent;
  color: #185fa5;
  font: inherit;
  cursor: pointer;
  padding: 0;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#vipPhoneMenu {
  position: fixed;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--color-background-primary, #fff);
  border: 0.5px solid var(--color-border-secondary, rgba(15, 23, 42, 0.3));
  border-radius: var(--border-radius-md, 8px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  padding: 6px;
  min-width: 180px;
}
#vipPhoneMenu .vip-phone-action {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--color-text-primary, #0f172a);
  text-decoration: none;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
}
#vipPhoneMenu .vip-phone-action.call { color: #0f6e56; }
#vipPhoneMenu .vip-phone-action:hover { background: var(--color-background-secondary, #f1f5f9); }
.vip-list .vip-member-row:first-child,
.vip-list .vip-bill-row:first-child { margin-top: 2px; }

/* iPad 宽度：月份 chips 从固定 7 列改为自适应列（min 88px），格子永不挤压换行 */
@media (min-width: 901px) and (max-width: 1399px) {
  .vip-bd-months { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
}

/* ============================================================
   iPad / 中屏适配 2026-09-21：休眠 13 列明细不再出屏、不跳行
   - 基础模板列宽从 px 下限改为 minmax(0, fr) 弹性比例，任何宽度按比例缩放
   - 全部单元格 nowrap + ellipsis：数据永不折行，超出省略
   - 901~1239（iPad 横屏主力区）：隐藏「开卡店仓 / 折扣 / 操作」→ 10 列紧凑
   - 1240~1399：13 列全显，压缩间距（1366 iPad Pro 12.9 横屏可用）
   - ≤900 仍走手机卡片布局（不变）
   ============================================================ */
.vip-member-row .v-days,
.vip-member-row .v-phone,
.vip-member-row .v-bills,
.vip-member-row .v-qty,
.vip-member-row .v-amt,
.vip-member-row .v-disc { white-space: nowrap; }
/* 表头格不折行：窄列超出省略 */
.vip-table-head > span,
.vip-table-head > .vip-sort-btn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vip-member-row .v-days,
.vip-member-row .v-bills,
.vip-member-row .v-qty,
.vip-member-row .v-amt,
.vip-member-row .v-last,
.vip-member-row .v-phone .vip-phone-btn { font-variant-numeric: tabular-nums; }

@media (min-width: 901px) and (max-width: 1239px) {
  /* 隐藏次要列：表头第 2/11/13 格（开卡店仓 / 折扣 / 操作）+ 行内对应单元格 */
  #vipListHead span:nth-child(2),
  #vipListHead span:nth-child(11),
  #vipListHead span:nth-child(13) { display: none; }
  .vip-member-row .v-store,
  .vip-member-row .v-disc,
  .vip-member-row .v-act { display: none; }
  .vip-table-head {
    grid-template-columns: minmax(0, 0.84fr) minmax(0, 1fr) minmax(0, 0.86fr) minmax(0, 0.64fr) minmax(0, 0.58fr) minmax(0, 1.12fr) minmax(0, 0.4fr) minmax(0, 0.4fr) minmax(0, 0.84fr) minmax(0, 1.04fr);
    gap: 4px;
    padding: 4px 10px 6px;
    font-size: 11px;
  }
  .vip-member-row {
    grid-template-columns: minmax(0, 0.84fr) minmax(0, 1fr) minmax(0, 0.86fr) minmax(0, 0.64fr) minmax(0, 0.58fr) minmax(0, 1.12fr) minmax(0, 0.4fr) minmax(0, 0.4fr) minmax(0, 0.84fr) minmax(0, 1.04fr);
    gap: 4px;
    padding: 9px 10px;
    font-size: 12px;
  }
  .vip-table-head .vip-sort-btn { font-size: 11px; }
  .vip-badge { font-size: 10.5px; padding: 3px 5px; }
  .vip-member-row .v-phone .vip-phone-btn { font-size: 12px; letter-spacing: -0.2px; }
}
@media (min-width: 1240px) and (max-width: 1399px) {
  .vip-table-head {
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 0.95fr) minmax(0, 0.55fr) minmax(0, 0.68fr) minmax(0, 1.05fr) minmax(0, 0.45fr) minmax(0, 0.45fr) minmax(0, 0.85fr) minmax(0, 0.6fr) minmax(0, 0.95fr) minmax(0, 0.55fr);
    gap: 5px;
    padding: 4px 10px 8px;
    font-size: 11.5px;
  }
  .vip-member-row {
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 0.95fr) minmax(0, 0.55fr) minmax(0, 0.68fr) minmax(0, 1.05fr) minmax(0, 0.45fr) minmax(0, 0.45fr) minmax(0, 0.85fr) minmax(0, 0.6fr) minmax(0, 0.95fr) minmax(0, 0.55fr);
    gap: 5px;
    padding: 10px;
    font-size: 12.5px;
  }
  .vip-table-head .vip-sort-btn { font-size: 11.5px; }
}

@media (max-width: 900px) {
  /* ── 页头与工具栏面板 ── */
  .vip-hero-text h2 { font-size: 20px; }
  .vip-hero-text p { font-size: 12px; }
  .vip-panel { padding: 12px; border-radius: 12px; }
  .vip-page-tab { font-size: 15px; padding: 8px 18px; }
  .vip-search-box { flex: 1 1 100%; min-width: 0; }
  .vip-field { flex: 1 1 100%; min-width: 0; }
  /* 手机端输入框字号必须 ≥16px：小于 16px 时浏览器会在聚焦时自动放大整个页面 */
  #vipPhoneSearch,
  .vip-search-box input,
  .vip-field .store-search-input,
  .vip-select { font-size: 16px !important; }
  .vip-field .store-dropdown {
    left: 0;
    right: auto;
    width: 100%;
    min-width: min(260px, calc(100vw - 28px));
    max-width: calc(100vw - 28px);
  }
  .vip-field .store-option {
    font-size: 15px;
    min-height: 40px;
    line-height: 40px;
  }
  .vip-export-btn { flex: 1 1 100%; justify-content: center; }
  .vip-bd-months { display: flex; flex-wrap: wrap; }
  .vip-bd-month-chip { font-size: 14px; min-height: 32px; padding: 4px 12px; }

  /* ── KPI：分布柱图整行横向滚动，两张侧卡并排 ── */
  .vip-kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .vip-kpi-dist { grid-column: 1 / -1; }
  .vip-kpi-side strong { font-size: 24px; }
  .vip-tier-bars {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    padding: 12px 2px 0;
  }
  .vip-dist-bar { flex: 0 0 64px; scroll-snap-align: start; }
  .vip-dist-col { height: 84px; max-width: 44px; }
  .vip-dist-bar strong { font-size: 13px; font-weight: 600; }

  /* ── 会员明细：表头隐藏，行改为带标签的卡片 ── */
  .vip-table-head, .vip-list-head { display: none; }
  .vip-tbody { display: flex; flex-direction: column; gap: 10px; }
  /* 窄屏：表头隐藏，改用排序胶囊（右上角标跟随当前排序） */
  .vip-sort-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 2px 0 8px;
  }
  .vip-sort-bar-label { font-size: 12px; color: #94a3b8; }
  .vip-member-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "name  tier"
      "phone days"
      "type  type"
      "shops shops"
      "stats stats"
      "last  last";
    row-gap: 8px;
    padding: 13px 14px 12px;
    font-size: 13px;
    border: 0.5px solid rgba(15, 23, 42, 0.1);
    border-radius: 12px;
    border-bottom: 0.5px solid rgba(15, 23, 42, 0.1);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  }
  .vip-member-row .v-act { display: none; }
  .vip-member-row:active { background: var(--color-background-secondary, #f8fafc); }
  .vip-member-row .v-col { min-width: 0; }
  .vip-member-row .v-name {
    grid-area: name;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
  }
  .vip-member-row .v-tier {
    grid-area: tier;
    justify-self: end;
    align-self: start;
    max-width: 100%;
    overflow: hidden;
  }
  .vip-member-row .v-phone {
    grid-area: phone;
    display: block;
    font-size: 15px;
  }
  .vip-member-row .v-phone .vip-phone-btn { color: #1677ff; font-weight: 600; }
  .vip-member-row .v-days {
    grid-area: days;
    justify-self: end;
    font-size: 12px;
    color: #64748b;
  }
  .vip-member-row .v-days::before { content: "休眠 "; color: #94a3b8; }
  .vip-member-row .v-type {
    grid-area: type;
    font-size: 12px;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .vip-member-row .v-type::before { content: "会员类型  "; color: #94a3b8; font-weight: 400; }
  /* 开卡 / 消费：蓝色图标 + 灰标签在上，门店在下 */
  .vip-member-row .v-shops {
    grid-area: shops;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .vip-member-row .v-store,
  .vip-member-row .v-laststore {
    display: block;
    font-size: 12.5px;
    font-weight: 500;
    color: #334155;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .vip-member-row .v-store::before,
  .vip-member-row .v-laststore::before {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: #94a3b8;
    margin-bottom: 2px;
    padding-left: 18px;
    background-repeat: no-repeat;
    background-size: 13px 13px;
    background-position: left center;
  }
  .vip-member-row .v-store::before {
    content: "开卡";
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231677ff' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M4.5 9.5L6 4h12l1.5 5.5M4.5 9.5V20h15V9.5'/%3E%3Cpath d='M9.5 20v-5.5h5V20'/%3E%3C/svg%3E");
  }
  .vip-member-row .v-laststore::before {
    content: "消费";
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231677ff' stroke-width='2'%3E%3Crect x='2.5' y='5' width='19' height='14' rx='2'/%3E%3Cpath d='M2.5 10h19'/%3E%3C/svg%3E");
  }
  /* 笔数/件数/累计金额/折扣：灰色圆角统计带 */
  .vip-member-row .v-stats {
    grid-area: stats;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    background: #f6f8fa;
    border-radius: 10px;
    padding: 9px 12px;
  }
  .vip-member-row .v-bills,
  .vip-member-row .v-qty,
  .vip-member-row .v-amt,
  .vip-member-row .v-disc { display: block; min-width: 0; }
  .vip-member-row .v-bills::before,
  .vip-member-row .v-qty::before,
  .vip-member-row .v-amt::before,
  .vip-member-row .v-disc::before {
    display: block;
    font-size: 10.5px;
    font-weight: 400;
    color: #94a3b8;
    margin-bottom: 2px;
    white-space: nowrap;
  }
  .vip-member-row .v-bills::before { content: "笔数"; }
  .vip-member-row .v-qty::before { content: "件数"; }
  .vip-member-row .v-amt::before { content: "累计金额"; }
  .vip-member-row .v-disc::before { content: "折扣"; }
  .vip-member-row .v-bills,
  .vip-member-row .v-qty,
  .vip-member-row .v-disc { font-weight: 600; color: #0f172a; }
  .vip-member-row .v-amt { font-weight: 700; color: #1677ff; }
  /* 最近购物日：时钟图标 + 灰字 */
  .vip-member-row .v-last {
    grid-area: last;
    font-size: 12px;
    color: #64748b;
    display: block;
    padding-left: 18px;
    background-repeat: no-repeat;
    background-size: 13px 13px;
    background-position: left center;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E");
  }
  .vip-member-row .v-last::before { content: "最近购物日  "; color: #94a3b8; }
  .vip-member-row .v-amt,
  .vip-bill-row .v-amt,
  .vip-item-row .v-amt { text-align: left; }

  /* ── 消费记录：门店/日期/金额重排，避免挤压 ── */
  .vip-bill-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "bstore bstore"
      "date   amt"
      "count  more";
    row-gap: 5px;
    padding: 10px 12px 11px;
    border: 0.5px solid var(--color-border-tertiary, rgba(15, 23, 42, 0.15));
    border-radius: var(--border-radius-md, 8px);
  }
  .vip-bill-row:active { background: var(--color-background-secondary, #f8fafc); }
  .vip-bill-row .v-bstore {
    grid-area: bstore;
    font-size: 12px;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .vip-bill-row .v-bstore::before { content: "消费门店  "; color: #94a3b8; }
  .vip-bill-row .v-date { grid-area: date; font-size: 15px; font-weight: 600; color: var(--color-text-primary, #0f172a); }
  .vip-bill-row .v-billcount { grid-area: count; font-size: 12px; color: #64748b; }
  .vip-bill-row .v-amt { grid-area: amt; font-weight: 600; font-size: 14px; white-space: nowrap; }
  .vip-bill-row .v-more { grid-area: more; text-align: right; font-size: 12px; align-self: center; }

  /* ── 商品明细：缩略图 + 款号，颜色/尺码/零售价并入款号下方一行，金额/折扣右列 ── */
  .vip-item-row {
    grid-template-columns: 48px minmax(0, 1fr) auto;
    grid-template-areas:
      "thumb style amt"
      "thumb meta disc";
    row-gap: 4px;
    gap: 8px;
    padding: 9px 12px;
    border: 0.5px solid var(--color-border-tertiary, rgba(15, 23, 42, 0.15));
    border-radius: var(--border-radius-md, 8px);
  }
  .vip-item-row .product-thumb { grid-area: thumb; width: 48px; height: 48px; }
  .vip-item-row .style-link { grid-area: style; }
  .vip-item-row .v-itemmeta {
    grid-area: meta;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 12px;
    font-size: 12px;
    color: #64748b;
  }
  .vip-item-row .v-itemmeta .v-color,
  .vip-item-row .v-itemmeta .v-size,
  .vip-item-row .v-itemmeta .v-price { color: #64748b; white-space: nowrap; }
  .vip-item-row .v-itemmeta .v-color::before { content: "颜色 "; color: #94a3b8; }
  .vip-item-row .v-itemmeta .v-size::before { content: "尺码 "; color: #94a3b8; }
  .vip-item-row .v-itemmeta .v-price::before { content: "零售价 "; color: #94a3b8; }
  .vip-item-row .v-amt { grid-area: amt; font-weight: 600; white-space: nowrap; }
  .vip-item-row .v-disc { grid-area: disc; align-self: center; justify-self: end; font-size: 12px; color: #64748b; white-space: nowrap; }
  /* 手机端是卡片布局（件数隐藏），缺图缩略图必须移除才能对齐 */
  .vip-item-row .product-thumb.missing { display: none; }
  .vip-item-row .v-qty { display: none; }

  /* ── 生日明细手机端：与休眠会员同款独立圆角卡片（2026-09-22） ── */
  .vip-bd-head { display: none; }
  .vip-bd-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "name      name"
      "phone     md"
      "type      birth"
      "laststore lastdate"
      "amt       amt";
    row-gap: 8px;
    padding: 13px 14px 12px;
    font-size: 13px;
    border: 0.5px solid rgba(15, 23, 42, 0.1);
    border-radius: 12px;
    border-bottom: 0.5px solid rgba(15, 23, 42, 0.1);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  }
  .vip-bd-row:active { background: var(--color-background-secondary, #f8fafc); }
  .vip-bd-row .v-col { min-width: 0; }
  /* 第一行：姓名大字加粗（同休眠卡片的姓名行） */
  .vip-bd-row .v-name {
    grid-area: name;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
  }
  /* 第二行：手机号蓝色可点（左） + 生日月日红色高亮（右） */
  .vip-bd-row .v-phone {
    grid-area: phone;
    display: block;
    font-size: 15px;
  }
  .vip-bd-row .v-phone .vip-phone-btn { color: #1677ff; font-weight: 600; }
  .vip-bd-row .v-md {
    grid-area: md;
    justify-self: end;
    align-self: center;
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
  }
  .vip-bd-row .v-md::before { content: "生日  "; color: #94a3b8; font-weight: 400; }
  .vip-bd-row .v-md b { font-size: 13px; }
  /* 第三行：会员类型（左） + 出生日期（右，同休眠卡片的休眠天数位） */
  .vip-bd-row .v-type {
    grid-area: type;
    font-size: 12px;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .vip-bd-row .v-type::before { content: "会员类型  "; color: #94a3b8; font-weight: 400; }
  .vip-bd-row .v-birth {
    grid-area: birth;
    justify-self: end;
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
  }
  .vip-bd-row .v-birth::before { content: "出生  "; color: #94a3b8; font-weight: 400; }
  /* 第四行：消费门店 + 消费日期双列，蓝色图标 + 灰标签在上（同休眠卡片的开卡/消费行） */
  .vip-bd-row .v-laststore {
    grid-area: laststore;
    display: block;
    font-size: 12.5px;
    font-weight: 500;
    color: #334155;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-left: 18px;
    background-repeat: no-repeat;
    background-size: 13px 13px;
    background-position: left center;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231677ff' stroke-width='2'%3E%3Crect x='2.5' y='5' width='19' height='14' rx='2'/%3E%3Cpath d='M2.5 10h19'/%3E%3C/svg%3E");
  }
  .vip-bd-row .v-laststore::before {
    content: "消费";
    display: block;
    margin-bottom: 2px;
    font-size: 11px;
    font-weight: 400;
    color: #94a3b8;
  }
  .vip-bd-row .v-lastdate {
    grid-area: lastdate;
    display: block;
    font-size: 12.5px;
    font-weight: 500;
    color: #334155;
    white-space: nowrap;
    padding-left: 18px;
    background-repeat: no-repeat;
    background-size: 13px 13px;
    background-position: left center;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E");
  }
  .vip-bd-row .v-lastdate::before {
    content: "消费日期";
    display: block;
    margin-bottom: 2px;
    font-size: 11px;
    font-weight: 400;
    color: #94a3b8;
  }
  /* 第五行：累计金额灰底圆角统计带（同休眠卡片的统计带风格） */
  .vip-bd-row .v-amt {
    grid-area: amt;
    display: block;
    background: #f6f8fa;
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 15px;
    font-weight: 700;
    color: #a32d2d;
  }
  .vip-bd-row .v-amt::before {
    content: "累计金额";
    display: block;
    margin-bottom: 2px;
    font-size: 10.5px;
    font-weight: 400;
    color: #94a3b8;
  }

  /* ── 分页器：标题与分页上下两行 ── */
  .vip-detail-head { flex-direction: column; align-items: flex-start; }
  .vip-pager-bar { width: 100%; justify-content: space-between; }

  /* ── 下钻页：统计卡 2x2 + 返回胶囊紧凑 ── */
  .vip-drill-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 2px 0 10px; }
  .vip-stat-card { padding: 10px 12px; border-radius: 10px; }
  .vip-stat-ico { width: 32px; height: 32px; border-radius: 8px; }
  .vip-stat-meta strong { font-size: 16px; }
  .vip-detail-title.is-drill h3 { font-size: 17px; padding-left: 10px; margin-left: 0; order: 0; }
  .vip-detail-title.is-drill { flex-wrap: wrap; row-gap: 8px; }
  .vip-member-meta { width: 100%; order: 9; }
  .vip-back-btn:not([hidden]) { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }
  .vip-bill-head { padding: 8px 12px; }
  .vip-bill-row .v-more { padding: 3px 10px; }

  #vipPhoneMenu { left: 12px !important; right: 12px; min-width: 0; }
}

/* ============================================================
   侧边导航图标化 2026-09-21（设计稿：图标上/文字下，选中浅蓝底蓝字）
   ============================================================ */
.tab {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
}
/* 权限隐藏：.tab 的 !important display 会盖过 .hidden，必须用更高优先级压制 */
.tab.hidden,
.tabs .tab.hidden {
  display: none !important;
}
.tab svg {
  width: 15px;
  height: 15px;
  flex: none;
}

@media (orientation: landscape) and (min-width: 900px), (min-width: 1120px) {
  .tabs .tab {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    min-height: 46px !important;
    padding: 0 14px !important;
    border-radius: 10px !important;
    text-align: left !important;
    font-size: 14px !important;
    font-weight: 600 !important;
  }
  .tabs .tab svg { width: 20px; height: 20px; }
  .tabs .tab.active {
    background: #1677ff !important;
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(22, 119, 255, 0.35) !important;
    font-weight: 800 !important;
  }
  .tabs .tab.active:hover:not(.active) { background: #1677ff !important; }
  .tabs .tab:hover:not(.active) {
    background: rgba(255, 255, 255, 0.88) !important;
    color: #1677ff !important;
  }
}

@media (max-width: 699px) {
  .tabs .tab { min-height: 38px !important; }
  .tabs .tab svg { width: 15px; height: 15px; }
}

/* ── 识款板块：3333 内独立页面（shikuan.html）── */
body.photo-search-page .filter-panel,
body.photo-search-page .date-filter-panel,
body.photo-search-page .period-panel,
body.photo-search-page .metric-grid {
  display: none !important;
}

body.secret-page .filter-panel,
body.secret-page .date-filter-panel,
body.secret-page .period-panel,
body.secret-page .metric-grid {
  display: none !important;
}

.miji-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 0;
}

.miji-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.miji-kicker {
  display: block;
  margin-bottom: 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

.miji-hero h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.miji-hero p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.miji-clear {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.miji-cats {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.miji-cats-loading {
  color: var(--muted);
  font-size: 12px;
}

.miji-cat {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.miji-cat.active {
  border-color: #1d4ed8;
  background: #1d4ed8;
  color: #ffffff;
}

.miji-cat-panel {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid #dbe6ff;
  border-radius: 8px;
  background: #f7faff;
}

.miji-cat-panel.hidden {
  display: none;
}

.miji-cat-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}

.miji-cat-head strong {
  font-size: 14px;
}

.miji-cat-head span {
  color: var(--muted);
  font-size: 12px;
}

.miji-cat-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.miji-cat-q {
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid #cfe0ff;
  border-radius: 8px;
  background: #ffffff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  line-height: 1.4;
}

.miji-cat-q:hover {
  background: #eef5ff;
}

.miji-related {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #dbe6ff;
}

.miji-related-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.miji-related button {
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid #cfe0ff;
  border-radius: 999px;
  background: #ffffff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  text-align: left;
}

.miji-related button:hover {
  background: #eef5ff;
}

.miji-quick {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.miji-quick button {
  flex: 0 0 auto;
  height: 36px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #cfe0ff;
  border-radius: 8px;
  background: #eef5ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.miji-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  max-height: 54dvh;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.miji-message {
  width: fit-content;
  max-width: 92%;
  padding: 11px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.65;
  white-space: normal;
  overflow-wrap: anywhere;
}

.miji-message.assistant {
  align-self: flex-start;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #1e293b;
}

.miji-message.user {
  align-self: flex-end;
  background: #1d4ed8;
  color: #ffffff;
}

.miji-message.loading {
  color: #64748b;
}

.miji-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.miji-sources span {
  max-width: 100%;
  padding: 3px 7px;
  border: 1px solid #dbeafe;
  border-radius: 7px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 800;
}

.miji-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.miji-image-card {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 7px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #ffffff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  cursor: zoom-in;
}

.miji-image-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: top center;
  border-radius: 6px;
  background: #eef2f7;
}

.miji-image-card span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.miji-image-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(15, 23, 42, 0.58);
}

.miji-image-modal.hidden {
  display: none;
}

.miji-image-dialog {
  width: min(1120px, 96vw);
  max-height: 94dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.32);
}

.miji-image-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
}

.miji-image-head strong {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.miji-image-head span {
  flex: 0 0 auto;
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
}

.miji-image-close {
  position: relative;
  width: 34px;
  height: 34px;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  background: #f8fafc;
  color: #0f172a;
}

.miji-image-close::before,
.miji-image-close::after {
  content: "";
  position: absolute;
  left: 9px;
  top: 16px;
  width: 14px;
  height: 2px;
  border-radius: 2px;
  background: #0f172a;
}

.miji-image-close::before {
  transform: rotate(45deg);
}

.miji-image-close::after {
  transform: rotate(-45deg);
}

.miji-image-stage {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  background: #f8fafc;
}

.miji-image-stage img {
  display: block;
  width: 100%;
  max-height: calc(94dvh - 56px);
  object-fit: contain;
  background: #f8fafc;
}

.miji-image-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 46px;
  height: 70px;
  transform: translateY(-50%);
  border: 1px solid rgba(148, 163, 184, 0.5);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  color: #0f172a;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
}

.miji-image-nav::before {
  content: "";
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  border-top: 4px solid currentColor;
  border-right: 4px solid currentColor;
  border-radius: 2px;
}

.miji-image-nav.prev::before {
  left: 17px;
  transform: translateY(-50%) rotate(-135deg);
}

.miji-image-nav.next::before {
  right: 17px;
  transform: translateY(-50%) rotate(45deg);
}

.miji-image-nav.prev {
  left: 14px;
}

.miji-image-nav.next {
  right: 14px;
}

.miji-image-nav:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}

@media (max-width: 699px) {
  .miji-image-modal {
    padding: 10px;
  }
  .miji-image-nav {
    width: 38px;
    height: 58px;
    font-size: 34px;
  }
  .miji-image-nav.prev {
    left: 8px;
  }
  .miji-image-nav.next {
    right: 8px;
  }
}

.miji-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 68px;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.miji-form textarea {
  width: 100%;
  min-height: 42px;
  max-height: 120px;
  resize: vertical;
  padding: 10px 11px;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

.miji-form button {
  height: 42px;
  border: 0;
  border-radius: 8px;
  background: #1d4ed8;
  color: #ffffff;
  font-size: 14px;
  font-weight: 900;
}

.miji-form button:disabled {
  opacity: 0.55;
}

@media (orientation: landscape) and (min-width: 900px), (min-width: 1120px) {
  .miji-panel {
    min-height: 0;
  }
  .miji-messages {
    max-height: 58dvh;
  }
}

@media (max-width: 699px) {
  .miji-panel {
    min-height: 0;
  }
  .miji-hero {
    padding: 14px;
  }
  .miji-hero h2 {
    font-size: 20px;
  }
  .miji-message {
    max-width: 96%;
    font-size: 13px;
  }
}

body.ecommerce-page .topbar,
body.ecommerce-page .filter-panel,
body.ecommerce-page .date-filter-panel,
body.ecommerce-page .period-panel,
body.ecommerce-page .metric-grid {
  display: none !important;
}

.photo-search-frame {
  display: block;
  width: 100%;
  height: calc(100dvh - 120px);
  min-height: 560px;
  border: 1px solid var(--line, #dbe4ef);
  border-radius: 12px;
  background: #fff;
}

/* ── 电商板块：3333 内独立页面（douyin.html，自带 1303# 那套米金主题样式）── */
.ecommerce-frame {
  display: block;
  width: 100%;
  height: calc(100dvh - 96px);
  min-height: 620px;
  border: 1px solid var(--line, #dbe4ef);
  border-radius: 12px;
  background: #f6f8fb;
}

@media (max-width: 699px) {
  .ecommerce-frame {
    height: calc(100dvh - 100px - env(safe-area-inset-bottom, 0px));
    min-height: 420px;
    border-radius: 10px;
  }
}

@media (max-width: 699px) {
  .photo-search-frame {
    height: calc(100dvh - 100px);
    min-height: 480px;
    border-radius: 10px;
  }
}

/* ── 秘籍板块双页签：左「销售秘籍」右「销售百问」（同经营板块样式）── */
.secret-page-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(132px, 1fr));
  gap: 4px;
  margin: 0 0 14px;
  padding: 4px;
  border: 1px solid #d8e1ef;
  border-radius: 8px;
  background: #f5f7fb;
}

.secret-page-tab {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #56667a;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.secret-page-tab.active {
  background: #1677ff;
  color: #fff;
  box-shadow: 0 6px 16px rgba(22, 119, 255, 0.22);
}

.secret-subview {
  display: none;
}

.secret-subview.active {
  display: block;
  width: 100%;
}

/* ── 销售百问：秘籍板块内 iframe（baiwen.html，1303#销售百问 100 问）── */
.baiwen-frame {
  display: block;
  width: 100%;
  height: calc(100dvh - 150px);
  min-height: 560px;
  border: 1px solid var(--line, #dbe4ef);
  border-radius: 12px;
  background: #f6f8fb;
}

@media (max-width: 699px) {
  .secret-page-tabs {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .baiwen-frame {
    height: calc(100dvh - 140px);
    min-height: 480px;
    border-radius: 10px;
  }
}

.multi-select-photo-entry span {
  color: #1677ff;
  font-weight: 700;
}


/* ═══ 库存结构页（stockView 第二页签） ═══ */
.stock-section-title { flex-wrap: wrap; }
.stock-page-switch { flex: none; }
.stock-structure { margin-top: 4px; }
.stock-structure-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 2px 0 10px; }
.stock-structure-head h2 { margin: 0; font-size: 19px; font-weight: 900; color: #1e3a8a; letter-spacing: 0.03em; }
.structure-title-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; min-width: 0; }
.structure-dimensions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.structure-dimensions label { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; color: #42526a; font-size: 13px; cursor: pointer; }
.structure-dimensions input { width: 16px; height: 16px; margin: 0; accent-color: #1677ff; cursor: pointer; }
.structure-dimensions input:focus-visible { outline: 2px solid #1677ff; outline-offset: 3px; }
@media print { .structure-dimensions { display: none !important; } }
.stock-structure-head .analysis-print-btn { flex: none; }
.stock-structure-scroll { overflow-x: auto; border: 1px solid #e3eaf5; border-radius: 12px; background: #ffffff; box-shadow: var(--shadow-soft); }
.stock-structure-table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 13px; color: #1f2937; }
.stock-structure-table th,
.stock-structure-table td { border: 1px solid #e3eaf5; padding: 7px 10px; text-align: center; white-space: nowrap; }
.stock-structure-table thead th { position: sticky; top: 0; background: #1e40af; color: #ffffff; font-weight: 900; font-size: 12.5px; letter-spacing: 0.02em; z-index: 1; }
.stock-structure-table td.st-cat { font-weight: 900; background: #eff6ff; color: #1e3a8a; vertical-align: middle; min-width: 72px; }
.stock-structure-table td.st-mode { font-weight: 800; background: #f8fafc; color: #334155; vertical-align: middle; }
.stock-structure-table td.st-year { color: #475569; }
.stock-structure-table td.st-num { text-align: center; font-variant-numeric: tabular-nums; min-width: 64px; }
.stock-structure-table td.st-total { font-weight: 800; color: #1e3a8a; background: #f8fafc; }
.stock-structure-table td.st-num.st-neg { color: #dc2626; }
.stock-structure-table tr.st-mode-subtotal td.st-neg { color: #b91c1c; }
.stock-structure-table tr.st-grand-total td.st-neg { color: #fecaca; }
.stock-structure-table tr.st-mode-subtotal td { background: #f1f5f9; font-weight: 800; color: #334155; text-align: left; }
.stock-structure-table tr.st-mode-subtotal td.st-num { text-align: center; }
.stock-structure-table tr.st-cat-summary td { background: #dbeafe; font-weight: 900; color: #1e3a8a; text-align: left; }
.stock-structure-table tr.st-cat-summary td.st-num { text-align: center; }
.stock-structure-table tr.st-grand-total td { background: #1d4ed8; color: #ffffff; font-weight: 900; text-align: left; }
.stock-structure-table tr.st-grand-total td.st-num { text-align: center; color: #ffffff; }
.stock-structure-table .st-abbr { display: none; }
@media (max-width: 720px) {
  .stock-structure-table { font-size: 10.5px; min-width: 0; width: 100%; }
  .stock-structure-table .st-full { display: none; }
  .stock-structure-table .st-abbr { display: inline; }
  .stock-structure-table th,
  .stock-structure-table td { padding: 3px 3px; white-space: nowrap; }
  .stock-structure-table thead th { font-size: 10px; padding: 4px 2px; }
  .stock-structure-table td.st-cat { min-width: 0; padding: 3px 2px; }
  .stock-structure-table td.st-mode { font-size: 10px; padding: 3px 2px; }
  .stock-structure-table td.st-num { min-width: 0; }
  .stock-structure-scroll { overflow-x: auto; }
}


/* ═══ 库存结构页顶部 KPI 卡片行 ═══ */
.stock-structure-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 0 0 12px; }
.st-kpi { background: #ffffff; border: 1px solid #e3eaf5; border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow-soft, 0 1px 3px rgba(15, 23, 42, 0.06)); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.st-kpi .st-kpi-label { font-size: 12px; font-weight: 700; color: #64748b; white-space: nowrap; }
.st-kpi strong { font-size: 20px; font-weight: 900; color: #1e3a8a; font-variant-numeric: tabular-nums; line-height: 1.2; }
.st-kpi strong.st-neg { color: #dc2626; }
.st-kpi.st-kpi-main { background: linear-gradient(135deg, #eff6ff, #dbeafe); border-color: #bfdbfe; }
.st-kpi.st-kpi-main strong { font-size: 24px; color: #1d4ed8; }
.st-kpi.st-kpi-main .st-kpi-label { color: #1e40af; }
@media (max-width: 720px) {
  .stock-structure-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
  .st-kpi { padding: 9px 11px; border-radius: 10px; }
  .st-kpi .st-kpi-label { font-size: 11px; }
  .st-kpi strong { font-size: 16px; }
  .st-kpi.st-kpi-main { grid-column: span 2; }
  .st-kpi.st-kpi-main strong { font-size: 19px; }
}


/* ═══ 会员明细（休眠/生日）桌面端内容居中；≤900 手机卡片布局保持原样 ═══ */
@media (min-width: 901px) {
  .vip-table-head > span,
  .vip-table-head > .vip-sort-btn,
  .vip-list-head > span,
  .vip-list-head > .vip-sort-btn { text-align: center; }
  .vip-member-row .v-col,
  .vip-bd-row .v-col { text-align: center; justify-content: center; }
  .vip-member-row .v-amt, .vip-bd-row .v-amt { text-align: center; }
}

/* iPad member drill pages: final override after desktop centering rules. */
@media (min-width: 901px) and (max-width: 1239px) {
  #vipView .vip-detail-head {
    align-items: flex-start;
  }

  #vipView .vip-detail-title.is-drill {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "back title"
      "meta meta"
      "hint hint";
    align-items: center;
    gap: 8px 12px;
    width: 100%;
    min-width: 0;
  }

  #vipView .vip-detail-title.is-drill .vip-back-btn {
    grid-area: back;
  }

  #vipView .vip-detail-title.is-drill h3 {
    grid-area: title;
    order: 0;
    margin-left: 0;
    padding-left: 12px;
    border-left: 1px solid rgba(15, 23, 42, 0.12);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #vipView .vip-detail-title.is-drill #vipListHint {
    grid-area: hint;
    min-width: 0;
  }

  #vipView .vip-detail-title.is-drill .vip-member-meta {
    grid-area: meta;
    width: 100%;
    min-width: 0;
    gap: 6px;
  }

  #vipView .vip-detail-title.is-drill .vip-meta-chip {
    min-width: 0;
    max-width: 100%;
  }

  #vipView .vip-detail-title.is-drill .vip-meta-chip b {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #vipView .vip-drill-kpis {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  #vipView .vip-stat-card {
    padding: 10px;
    gap: 8px;
  }

  #vipView .vip-stat-ico {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }

  #vipView .vip-stat-meta strong {
    font-size: 15px;
  }

  #vipView .vip-bill-head,
  #vipView .vip-bill-row,
  #vipView .vip-item-head,
  #vipView .vip-item-row {
    width: 100%;
    box-sizing: border-box;
  }

  #vipView .vip-bill-head,
  #vipView .vip-bill-row {
    grid-template-columns: minmax(120px, 1.15fr) minmax(112px, 1fr) minmax(54px, 0.5fr) minmax(88px, 0.78fr) minmax(92px, 0.8fr);
    gap: 6px;
    padding-left: 12px;
    padding-right: 12px;
  }

  #vipView .vip-bill-head > *,
  #vipView .vip-bill-row > * {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #vipView .vip-bill-head > :nth-child(1),
  #vipView .vip-bill-row .v-bstore,
  #vipView .vip-bill-head > :nth-child(2),
  #vipView .vip-bill-row .v-date {
    text-align: left;
    justify-self: stretch;
  }

  #vipView .vip-bill-head > :nth-child(3),
  #vipView .vip-bill-row .v-billcount {
    text-align: center;
    justify-self: stretch;
  }

  #vipView .vip-bill-head > :nth-child(4),
  #vipView .vip-bill-row .v-amt {
    text-align: right;
    justify-self: stretch;
  }

  #vipView .vip-bill-head > :nth-child(5),
  #vipView .vip-bill-row .v-more {
    text-align: right;
    justify-self: end;
  }

  #vipView .vip-bill-row .v-more {
    padding-left: 9px;
    padding-right: 9px;
  }

  #vipView .vip-item-head,
  #vipView .vip-item-row {
    grid-template-columns: 40px minmax(96px, 1.1fr) minmax(64px, 0.78fr) minmax(42px, 0.48fr) minmax(64px, 0.62fr) minmax(38px, 0.38fr) minmax(76px, 0.72fr) minmax(46px, 0.45fr);
    gap: 5px;
    padding-left: 10px;
    padding-right: 10px;
  }

  #vipView .vip-item-head {
    font-size: 11px;
  }

  #vipView .vip-item-row {
    font-size: 12px;
  }

  #vipView .vip-item-head > *,
  #vipView .vip-item-row > *,
  #vipView .vip-item-row .v-itemmeta > * {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #vipView .vip-item-row .product-thumb {
    width: 36px;
    height: 36px;
  }

  #vipView .vip-item-row .v-itemmeta {
    display: contents;
  }

  #vipView .vip-item-head > :nth-child(1) { text-align: center; }
  #vipView .vip-item-head > :nth-child(2),
  #vipView .vip-item-row .style-link,
  #vipView .vip-item-head > :nth-child(3),
  #vipView .vip-item-row .v-color {
    text-align: left;
    justify-self: stretch;
  }

  #vipView .vip-item-head > :nth-child(4),
  #vipView .vip-item-row .v-size,
  #vipView .vip-item-head > :nth-child(6),
  #vipView .vip-item-row .v-qty,
  #vipView .vip-item-head > :nth-child(8),
  #vipView .vip-item-row .v-disc {
    text-align: center;
    justify-self: stretch;
  }

  #vipView .vip-item-head > :nth-child(5),
  #vipView .vip-item-row .v-price,
  #vipView .vip-item-head > :nth-child(7),
  #vipView .vip-item-row .v-amt {
    text-align: right;
    justify-self: stretch;
  }
}

/* Mobile A sample: compact refined phone dashboard. Desktop rules stay untouched. */
@media (max-width: 699px) {
  body {
    background: #edf3f8 !important;
  }

  .app-shell {
    width: 100% !important;
    max-width: 430px !important;
    padding: 12px 14px calc(94px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .topbar {
    min-height: 54px !important;
    margin: 6px 0 10px !important;
    padding: 8px 10px !important;
    border: 1px solid #dce7f1 !important;
    border-radius: 12px !important;
    background: rgba(255, 255, 255, 0.96) !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) !important;
    gap: 8px !important;
  }

  .title-wrap {
    align-items: center !important;
    gap: 8px !important;
  }

  .account-badge {
    width: 34px !important;
    height: 34px !important;
    flex-basis: 34px !important;
    margin: 0 !important;
    border-radius: 10px !important;
    box-shadow: none !important;
  }

  .eyebrow {
    display: none !important;
  }

  .title-wrap h1 {
    max-width: none !important;
    overflow: hidden !important;
    color: #08111f !important;
    font-size: 16px !important;
    line-height: 1.15 !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .account-name {
    margin-top: 3px !important;
    color: #64748b !important;
    font-size: 11px !important;
    line-height: 1.1 !important;
  }

  .icon-button,
  .logout-button {
    width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
    flex: 0 0 32px !important;
    border-radius: 9px !important;
    box-shadow: none !important;
  }

  .logout-button {
    overflow: hidden !important;
    color: transparent !important;
    font-size: 0 !important;
  }

  .logout-button::after {
    content: "退" !important;
    color: #64748b !important;
    font-size: 12px !important;
    font-weight: 800 !important;
  }

  .filter-panel {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 6px !important;
    margin: 0 0 8px !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  .filter-panel label,
  .store-category-field,
  .date-filter-popover label {
    gap: 0 !important;
  }

  .filter-panel label > span,
  .store-category-field > span {
    display: none !important;
  }

  .filter-panel select,
  .filter-panel input,
  .store-select-button,
  .multi-select-button,
  .store-category-field select,
  .date-filter-toggle {
    min-height: 30px !important;
    height: 30px !important;
    padding: 0 8px !important;
    border-color: #d7e4f2 !important;
    border-radius: 7px !important;
    background: rgba(255, 255, 255, 0.88) !important;
    color: #29405f !important;
    box-shadow: none !important;
    font-size: 11px !important;
    font-weight: 800 !important;
    line-height: 30px !important;
  }

  .multi-select-button,
  .date-filter-toggle {
    justify-content: center !important;
    gap: 5px !important;
  }

  .store-search-input {
    text-align: center !important;
  }

  .store-search-input::placeholder {
    color: #29405f !important;
    opacity: 1 !important;
  }

  .date-filter-panel {
    margin: 0 0 8px !important;
  }

  .top-filter-row {
    display: grid !important;
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.35fr) !important;
    gap: 6px !important;
    align-items: stretch !important;
  }

  .date-filter-toggle {
    justify-content: space-between !important;
    padding: 0 10px !important;
  }

  .date-filter-popover {
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    top: 34px !important;
    z-index: 12 !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 54px !important;
    margin-top: 0 !important;
    padding: 8px !important;
    border-radius: 10px !important;
  }

  .date-filter-popover span {
    font-size: 10px !important;
  }

  .date-filter-popover input,
  .date-filter-popover button {
    height: 32px !important;
    min-height: 32px !important;
    border-radius: 7px !important;
    font-size: 11px !important;
  }

  .period-panel {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    margin: 0 !important;
    padding: 8px !important;
    border-radius: 10px !important;
    box-shadow: none !important;
  }

  .period-panel .segmented {
    flex: 0 0 126px !important;
    gap: 4px !important;
    padding: 3px !important;
  }

  .period-panel .segment {
    min-height: 28px !important;
    padding: 0 !important;
    border-radius: 7px !important;
    font-size: 11px !important;
  }

  .date-line {
    min-width: 0 !important;
    display: grid !important;
    gap: 2px !important;
    justify-items: end !important;
    font-size: 10px !important;
    line-height: 1.15 !important;
    text-align: right !important;
  }

  .date-line strong {
    max-width: 178px !important;
    overflow: hidden !important;
    color: #29405f !important;
    font-size: 11px !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    margin-top: 8px !important;
  }

  .metric-card {
    min-height: 62px !important;
    padding: 10px 12px !important;
    border-radius: 8px !important;
    box-shadow: none !important;
  }

  .metric-card.primary {
    min-height: 112px !important;
    grid-column: 1 / -1 !important;
    padding: 16px 18px !important;
    border-radius: 10px !important;
  }

  .metric-card span,
  .metric-card em {
    font-size: 10.5px !important;
    line-height: 1.25 !important;
  }

  .metric-card strong {
    margin: 7px 0 5px !important;
    font-size: 18px !important;
    line-height: 1.08 !important;
  }

  .metric-card.primary strong {
    margin: 12px 0 8px !important;
    font-size: 32px !important;
  }

  .tabs {
    position: fixed !important;
    left: 50% !important;
    right: auto !important;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    top: auto !important;
    z-index: 25 !important;
    width: min(calc(100vw - 28px), 402px) !important;
    display: flex !important;
    gap: 4px !important;
    margin: 0 !important;
    padding: 8px !important;
    overflow-x: auto !important;
    border: 1px solid #dce7f1 !important;
    border-radius: 14px !important;
    background: rgba(255, 255, 255, 0.96) !important;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.12) !important;
    transform: translateX(-50%) !important;
    scroll-snap-type: x proximity !important;
    scrollbar-width: none !important;
  }

  .tabs::-webkit-scrollbar {
    display: none !important;
  }

  .tabs .tab {
    flex: 0 0 64px !important;
    min-width: 64px !important;
    min-height: 46px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    padding: 4px 2px !important;
    border: 0 !important;
    border-radius: 10px !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #64748b !important;
    font-size: 10.5px !important;
    font-weight: 800 !important;
    scroll-snap-align: start !important;
  }

  .tabs .tab.active {
    background: #eaf3ff !important;
    color: #1677ff !important;
    box-shadow: none !important;
  }

  .tabs .tab svg {
    width: 15px !important;
    height: 15px !important;
  }

  .section-title {
    margin: 18px 2px 8px !important;
  }

  .section-title h2 {
    font-size: 17px !important;
    line-height: 1.2 !important;
  }

  .section-title span {
    font-size: 11px !important;
  }

  .bars,
  .rank-list,
  .purchase-filters,
  .retail-filters,
  .search-box,
  .drill-title,
  .stock-filter-panel,
  .stock-filter-row,
  .stock-summary div,
  .purchase-summary div,
  .analysis-panel,
  .miji-panel {
    border-radius: 10px !important;
    box-shadow: none !important;
  }

  .bar-row {
    min-height: 28px !important;
    gap: 8px !important;
    padding: 4px 0 !important;
  }

  .bar-row > span {
    font-size: 12px !important;
    font-weight: 850 !important;
  }

  .bar-track {
    height: 7px !important;
  }

  .bar-value {
    font-size: 11px !important;
  }

  .store-item,
  .stock-item {
    padding: 11px 12px !important;
    border-radius: 10px !important;
    box-shadow: none !important;
  }

  .store-main strong,
  .stock-main strong {
    font-size: 13px !important;
  }

  .store-main span,
  .stock-main span,
  .store-meta,
  .stock-meta {
    font-size: 11px !important;
  }

  body.member-page .tabs {
    display: none !important;
  }
}

/* Mobile compact polish v3: restore period switch and add KPI icons, UI only. */
@media (max-width: 699px) {
  body:has(#overviewView.active) .date-filter-panel {
    display: none !important;
  }

  body:has(#overviewView.active) .period-panel {
    display: flex !important;
    min-height: 38px !important;
    margin: -2px 0 9px !important;
    padding: 4px 6px !important;
    border: 0 !important;
    border-radius: 10px !important;
    background: rgba(255, 255, 255, 0.72) !important;
    box-shadow: inset 0 0 0 1px rgba(220, 231, 241, 0.72) !important;
  }

  body:has(#overviewView.active) .period-panel .segmented {
    flex: 0 0 124px !important;
    min-height: 30px !important;
    padding: 3px !important;
    border-radius: 9px !important;
    background: #eef3f8 !important;
  }

  body:has(#overviewView.active) .period-panel .segment {
    min-height: 24px !important;
    border-radius: 7px !important;
    font-size: 11px !important;
    font-weight: 850 !important;
  }

  body:has(#overviewView.active) .period-panel .date-line {
    display: grid !important;
    flex: 1 1 auto !important;
    gap: 1px !important;
    justify-items: end !important;
    font-size: 9.5px !important;
  }

  body:has(#overviewView.active) .period-panel .date-line strong {
    max-width: 174px !important;
    font-size: 10.5px !important;
  }

  .metric-card:not(.primary)::before {
    background-repeat: no-repeat, no-repeat !important;
    background-position: center, center !important;
    background-size: 22px 22px, 100% 100% !important;
  }

  .metric-card:nth-child(2)::before {
    background-image:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231677ff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 13 13 20a2 2 0 0 1-2.8 0L3 12.8V4h8.8L20 12.2a2 2 0 0 1 0 2.8Z'/%3E%3Cpath d='M7.5 7.5h.01'/%3E%3C/svg%3E"),
      linear-gradient(135deg, #eef6ff, #dcecff) !important;
  }

  .metric-card:nth-child(3)::before {
    background-image:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2327b96f' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 19v-1.5a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4V19'/%3E%3Ccircle cx='9.5' cy='7' r='3.5'/%3E%3Cpath d='M21 19v-1.3a3.2 3.2 0 0 0-2.8-3.2'/%3E%3Cpath d='M16.5 3.8a3.3 3.3 0 0 1 0 6.4'/%3E%3C/svg%3E"),
      linear-gradient(135deg, #e9fbef, #d8f5e1) !important;
  }

  .metric-card:nth-child(4)::before {
    background-image:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f59e0b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cellipse cx='12' cy='5.5' rx='6.5' ry='3'/%3E%3Cpath d='M5.5 5.5v5c0 1.7 2.9 3 6.5 3s6.5-1.3 6.5-3v-5'/%3E%3Cpath d='M5.5 10.5v5c0 1.7 2.9 3 6.5 3s6.5-1.3 6.5-3v-5'/%3E%3Cpath d='M15.5 16.2l1.4 1.4 2.6-3'/%3E%3C/svg%3E"),
      linear-gradient(135deg, #fff6e8, #ffecd0) !important;
  }

  .metric-card:nth-child(5)::before {
    background-image:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b5cf6' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v9h9'/%3E%3Cpath d='M20.5 15.5A9 9 0 1 1 8.5 3.8'/%3E%3Cpath d='M15 3.5A9 9 0 0 1 20.5 9H15Z'/%3E%3C/svg%3E"),
      linear-gradient(135deg, #f2eaff, #eadcff) !important;
  }
}

/* Mobile A visual refinement based on the approved phone mockup direction. */
@media (max-width: 699px) {
  body {
    background: linear-gradient(180deg, #ffffff 0%, #f3f7fb 38%, #eef4f9 100%) !important;
  }

  .app-shell {
    max-width: 430px !important;
    padding: 18px 14px calc(100px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .topbar {
    margin: 0 0 18px !important;
    padding: 4px 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  .account-badge {
    width: 44px !important;
    height: 44px !important;
    flex-basis: 44px !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: #eef5ff !important;
  }

  .title-wrap {
    gap: 10px !important;
  }

  .title-wrap h1 {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    color: #07111f !important;
    font-size: 19px !important;
    font-weight: 950 !important;
    letter-spacing: 0 !important;
  }

  .title-wrap h1::after {
    content: none;
  }

  .account-name {
    color: #8a94a3 !important;
    font-size: 13px !important;
    font-weight: 700 !important;
  }

  .icon-button,
  .logout-button {
    width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
    border: 0 !important;
    background: transparent !important;
    color: #07111f !important;
    font-size: 22px !important;
  }

  .logout-button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    height: 28px !important;
    min-height: 28px !important;
    flex: 0 0 auto !important;
    padding: 0 11px !important;
    border: 0 !important;
    border-radius: 999px !important;
    background: #eef2f7 !important;
    box-shadow: none !important;
    color: #64748b !important;
    font-size: 11.5px !important;
    font-weight: 800 !important;
    line-height: 1 !important;
    letter-spacing: 0.5px !important;
    overflow: visible !important;
  }

  .logout-button::after {
    content: none !important;
  }

  .filter-panel {
    position: relative !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 10px !important;
    margin-bottom: 16px !important;
  }

  .filter-panel label:nth-child(4) {
    display: none !important;
  }

  .filter-panel::after {
    content: "筛选";
    min-height: 46px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: #f1f5f9;
    color: #3b4656;
    font-size: 15px;
    font-weight: 850;
    box-shadow: inset 0 0 0 1px rgba(226, 232, 240, 0.72);
  }

  .filter-panel select,
  .filter-panel input,
  .store-select-button,
  .multi-select-button {
    min-height: 46px !important;
    height: 46px !important;
    border: 0 !important;
    border-radius: 10px !important;
    background: #f1f5f9 !important;
    color: #07111f !important;
    box-shadow: none !important;
    font-size: 15px !important;
    font-weight: 900 !important;
    text-align: center !important;
  }

  .filter-panel select {
    text-align-last: center !important;
  }

  body:has(#overviewView.active) .date-filter-panel,
  body:has(#overviewView.active) .period-panel {
    display: none !important;
  }

  .metric-grid {
    gap: 10px !important;
    margin-top: 0 !important;
  }

  .metric-card {
    position: relative !important;
    min-height: 112px !important;
    display: grid !important;
    grid-template-columns: 54px minmax(0, 1fr) !important;
    grid-template-rows: auto auto auto !important;
    align-content: center !important;
    column-gap: 10px !important;
    padding: 16px 22px 16px 14px !important;
    border: 1px solid #e0e7ef !important;
    border-radius: 11px !important;
    background: rgba(255, 255, 255, 0.96) !important;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06) !important;
  }

  .metric-card::before {
    content: "";
    grid-row: 1 / 4;
    width: 50px;
    height: 50px;
    align-self: center;
    border-radius: 14px;
    background: linear-gradient(135deg, #eef6ff, #dcecff);
  }

  .metric-card::after {
    content: "›";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #8a94a3;
    font-size: 26px;
    font-weight: 300;
  }

  .metric-card:nth-child(3)::before {
    background: linear-gradient(135deg, #e9fbef, #d8f5e1);
  }

  .metric-card:nth-child(4)::before {
    background: linear-gradient(135deg, #fff6e8, #ffecd0);
  }

  .metric-card:nth-child(5)::before {
    background: linear-gradient(135deg, #f2eaff, #eadcff);
  }

  .metric-card span,
  .metric-card strong,
  .metric-card em {
    grid-column: 2 !important;
    min-width: 0 !important;
  }

  .metric-card span {
    color: #4b5565 !important;
    overflow: hidden !important;
    font-size: 12.5px !important;
    font-weight: 800 !important;
    opacity: 1 !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .metric-card strong {
    margin: 6px 0 4px !important;
    color: #07111f !important;
    overflow: hidden !important;
    font-size: 20px !important;
    font-weight: 950 !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .metric-card em {
    color: #7b8798 !important;
    font-size: 11.5px !important;
    font-style: normal !important;
    opacity: 1 !important;
  }

  .metric-card.primary {
    min-height: 174px !important;
    display: block !important;
    padding: 24px 26px !important;
    overflow: hidden !important;
    border: 0 !important;
    border-radius: 13px !important;
    background: linear-gradient(135deg, #2f8cff 0%, #1677ff 58%, #0570f8 100%) !important;
    box-shadow: 0 16px 32px rgba(22, 119, 255, 0.24) !important;
  }

  .metric-card.primary::before {
    content: "";
    position: absolute;
    right: 24px;
    top: 72px;
    width: 142px;
    height: 54px;
    border-radius: 0;
    background:
      linear-gradient(to top, rgba(255,255,255,.24) 0 34%, transparent 34% 100%) 0 28px / 12px 26px no-repeat,
      linear-gradient(to top, rgba(255,255,255,.28) 0 62%, transparent 62% 100%) 20px 12px / 10px 42px no-repeat,
      linear-gradient(to top, rgba(255,255,255,.22) 0 48%, transparent 48% 100%) 38px 20px / 10px 34px no-repeat,
      linear-gradient(to top, rgba(255,255,255,.26) 0 54%, transparent 54% 100%) 56px 17px / 10px 37px no-repeat,
      linear-gradient(to top, rgba(255,255,255,.30) 0 72%, transparent 72% 100%) 74px 4px / 10px 50px no-repeat,
      linear-gradient(to top, rgba(255,255,255,.35) 0 82%, transparent 82% 100%) 92px 0 / 10px 54px no-repeat,
      linear-gradient(to top, rgba(255,255,255,.24) 0 64%, transparent 64% 100%) 110px 10px / 10px 44px no-repeat,
      linear-gradient(to top, rgba(255,255,255,.20) 0 46%, transparent 46% 100%) 128px 22px / 10px 32px no-repeat;
    opacity: .9;
  }

  .metric-card.primary::after {
    content: none;
  }

  .metric-card.primary .date-line {
    position: absolute !important;
    right: 18px !important;
    top: 18px !important;
    display: grid !important;
    gap: 3px !important;
    justify-items: end !important;
    margin: 0 !important;
    z-index: 2;
  }

  .metric-card.primary .date-line span {
    margin: 0 !important;
    color: rgba(255, 255, 255, 0.82) !important;
    font-size: 9.5px !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
  }

  .metric-card.primary .date-line strong {
    max-width: 168px !important;
    margin: 0 !important;
    color: #fff !important;
    font-size: 11px !important;
    font-weight: 800 !important;
    line-height: 1.3 !important;
    text-align: right !important;
    white-space: normal !important;
  }

  .metric-card.primary span {
    color: #eaf4ff !important;
    font-size: 18px !important;
    font-weight: 900 !important;
  }

  .metric-card.primary strong {
    margin: 22px 0 20px !important;
    color: #fff !important;
    font-size: 44px !important;
    line-height: .95 !important;
    letter-spacing: 0 !important;
  }

  .metric-card.primary em {
    display: block !important;
    padding-top: 13px !important;
    border-top: 1px solid rgba(255,255,255,.22) !important;
    color: #eaf4ff !important;
    font-size: 14px !important;
    font-weight: 800 !important;
  }

  #overviewView .section-title {
    margin: 26px 2px 10px !important;
  }

  #overviewView .section-title h2 {
    font-size: 21px !important;
    font-weight: 950 !important;
  }

  #overviewView .section-title span {
    color: #7b8798 !important;
    font-size: 14px !important;
  }

  #overviewView .bars,
  #overviewView #modeList {
    padding: 20px 18px !important;
    border: 1px solid #e0e7ef !important;
    border-radius: 12px !important;
    background: rgba(255, 255, 255, 0.96) !important;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.055) !important;
  }

  #overviewView .bar-row {
    grid-template-columns: 70px minmax(0, 1fr) 96px !important;
    min-height: 33px !important;
    padding: 3px 0 !important;
    gap: 10px !important;
  }

  #overviewView .bar-row > span {
    color: #334155 !important;
    font-size: 14px !important;
    font-weight: 850 !important;
  }

  #overviewView .bar-track {
    height: 13px !important;
    border-radius: 4px !important;
    background: linear-gradient(90deg, #edf2f7, #f5f7fa) !important;
  }

  #overviewView .bar-fill {
    background: linear-gradient(90deg, #2890ff, #1677ff) !important;
  }

  #overviewView .bar-value {
    color: #1677ff !important;
    font-size: 14px !important;
    font-weight: 900 !important;
    text-align: right !important;
  }

  #overviewView #modeList {
    counter-reset: mobile-store-rank;
    display: grid !important;
    gap: 0 !important;
    pointer-events: none !important;
  }

  #overviewView #modeList::before {
    content: "#    门店                         实际成交额";
    display: block;
    margin: -2px 0 8px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #f5f7fa;
    color: #64748b;
    font-size: 12px;
    font-weight: 850;
    white-space: pre;
  }

  #overviewView .mobile-store-rank {
    counter-increment: mobile-store-rank;
    min-height: 48px !important;
    display: grid !important;
    grid-template-columns: 34px minmax(0, 1fr) auto !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 9px 10px !important;
    border: 0 !important;
    border-bottom: 1px solid #eef2f7 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  #overviewView .mobile-store-rank:last-child {
    border-bottom: 0 !important;
  }

  #overviewView .mobile-store-rank .rank-badge {
    width: 24px !important;
    height: 24px !important;
    display: grid !important;
    place-items: center !important;
    color: transparent !important;
    font-size: 0 !important;
  }

  #overviewView .mobile-store-rank .rank-badge::before {
    content: counter(mobile-store-rank);
    color: #07111f;
    font-size: 14px;
    font-weight: 900;
  }

  #overviewView .mobile-store-rank:nth-child(1) .rank-badge::before,
  #overviewView .mobile-store-rank:nth-child(2) .rank-badge::before,
  #overviewView .mobile-store-rank:nth-child(3) .rank-badge::before {
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #f6ad1b;
    color: #fff;
  }

  #overviewView .mobile-store-rank:nth-child(2) .rank-badge::before {
    background: #98a2b3;
  }

  #overviewView .mobile-store-rank:nth-child(3) .rank-badge::before {
    background: #c8874a;
  }

  #overviewView .mobile-store-rank .item-body {
    display: contents !important;
  }

  #overviewView .mobile-store-rank .store-main {
    display: contents !important;
  }

  #overviewView .mobile-store-rank .store-main strong {
    grid-column: 2 !important;
    overflow: hidden !important;
    color: #07111f !important;
    font-size: 14px !important;
    font-weight: 850 !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  #overviewView .mobile-store-rank .store-main span {
    grid-column: 3 !important;
    color: #07111f !important;
    font-size: 14px !important;
    font-weight: 900 !important;
    white-space: nowrap !important;
  }

  #overviewView .mobile-store-rank .main-ratio,
  #overviewView .mobile-store-rank .store-meta {
    display: none !important;
  }

  .tabs {
    width: 100vw !important;
    bottom: 0 !important;
    padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    border-width: 1px 0 0 !important;
    border-radius: 0 !important;
    box-shadow: 0 -10px 28px rgba(15, 23, 42, 0.08) !important;
  }

  .tabs .tab {
    display: none !important;
  }

  .tabs .tab[data-view="overview"],
  .tabs .tab[data-view="mode"],
  .tabs .tab[data-view="retail"],
  .tabs .tab[data-view="stock"],
  .tabs .tab[data-view="secret"] {
    display: flex !important;
  }

  .tabs .tab[data-view="secret"] span {
    font-size: 0 !important;
  }

  .tabs .tab[data-view="secret"] span::after {
    content: "更多";
    font-size: 12px;
  }

  .tabs .tab[data-view="secret"] svg {
    display: none !important;
  }

  .tabs .tab[data-view="secret"]::before {
    content: "•••";
    color: currentColor;
    font-size: 18px;
    line-height: 1;
  }

  .tabs .tab {
    flex: 1 1 0 !important;
    min-width: 58px !important;
    min-height: 58px !important;
    font-size: 12px !important;
  }
}

/* Mobile A final polish: make the real page closer to the approved compact mockup. */
@media (max-width: 699px) {
  .app-shell {
    padding-top: 12px !important;
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  .topbar {
    margin-bottom: 10px !important;
  }

  .account-badge {
    width: 38px !important;
    height: 38px !important;
    flex-basis: 38px !important;
  }

  .title-wrap h1 {
    font-size: 16.5px !important;
    max-width: calc(100vw - 134px) !important;
  }

  .title-wrap h1::after {
    padding: 2px 7px !important;
    font-size: 10.5px !important;
  }

  .account-name {
    font-size: 11.5px !important;
  }

  .icon-button {
    width: 34px !important;
    height: 34px !important;
    min-height: 34px !important;
  }

  .filter-panel {
    gap: 7px !important;
    margin-bottom: 10px !important;
  }

  .filter-panel::after,
  .filter-panel select,
  .filter-panel input,
  .store-select-button,
  .multi-select-button {
    min-height: 38px !important;
    height: 38px !important;
    border-radius: 9px !important;
    font-size: 12.5px !important;
  }

  .metric-grid {
    gap: 9px !important;
  }

  .metric-card.primary {
    min-height: 146px !important;
    padding: 19px 22px !important;
    border-radius: 12px !important;
  }

  .metric-card.primary span {
    font-size: 15.5px !important;
  }

  .metric-card.primary strong {
    margin: 18px 0 14px !important;
    font-size: 36px !important;
  }

  .metric-card.primary em {
    padding-top: 10px !important;
    font-size: 12px !important;
  }

  .metric-card.primary::before {
    right: 20px !important;
    top: 58px !important;
    transform: scale(.86) !important;
    transform-origin: right top !important;
  }

  .metric-card.primary .date-line {
    right: 16px !important;
    top: 16px !important;
  }

  .metric-card.primary .date-line strong {
    max-width: 150px !important;
    font-size: 10.5px !important;
    white-space: normal !important;
    text-align: right !important;
  }

  .metric-card:not(.primary) {
    min-height: 88px !important;
    grid-template-columns: 42px minmax(0, 1fr) !important;
    column-gap: 9px !important;
    padding: 11px 18px 11px 12px !important;
    border-radius: 10px !important;
  }

  .metric-card:not(.primary)::before {
    width: 40px !important;
    height: 40px !important;
    border-radius: 11px !important;
  }

  .metric-card:not(.primary)::after {
    right: 7px !important;
    font-size: 22px !important;
  }

  .metric-card:not(.primary) span {
    font-size: 11.5px !important;
  }

  .metric-card:not(.primary) strong {
    margin: 4px 0 2px !important;
    font-size: 16.5px !important;
    max-width: 100% !important;
  }

  .metric-card:not(.primary) em {
    max-height: 25px !important;
    overflow: hidden !important;
    font-size: 10px !important;
    line-height: 1.25 !important;
  }

  #overviewView .section-title {
    margin: 18px 2px 8px !important;
  }

  #overviewView .section-title h2 {
    font-size: 18px !important;
  }

  #overviewView .section-title span {
    font-size: 12px !important;
  }

  #overviewView .bars,
  #overviewView #modeList {
    padding: 14px 15px !important;
    border-radius: 11px !important;
  }

  #overviewView .bar-row {
    grid-template-columns: 58px minmax(0, 1fr) 88px !important;
    min-height: 27px !important;
    gap: 8px !important;
  }

  #overviewView .bar-row > span,
  #overviewView .bar-value {
    font-size: 12px !important;
  }

  #overviewView #trendBars .bar-row:nth-child(n+6) {
    display: none !important;
  }

  #overviewView .bar-track {
    height: 9px !important;
  }

  #overviewView #modeList::before {
    margin-bottom: 6px !important;
    padding: 8px 10px !important;
    font-size: 11px !important;
  }

  #overviewView .mobile-store-rank {
    min-height: 40px !important;
    grid-template-columns: 30px minmax(0, 1fr) auto !important;
    padding: 7px 8px !important;
  }

  #overviewView .mobile-store-rank .rank-badge {
    width: 22px !important;
    height: 22px !important;
  }

  #overviewView .mobile-store-rank .rank-badge::before {
    font-size: 12px !important;
  }

  #overviewView .mobile-store-rank .store-main strong,
  #overviewView .mobile-store-rank .store-main span {
    font-size: 12px !important;
  }

  .tabs {
    padding-top: 7px !important;
  }

  .tabs .tab {
    min-height: 50px !important;
    font-size: 10.5px !important;
  }
}

/* Mobile compact polish v2: smaller typography and more refined density, UI only. */
@media (max-width: 699px) {
  body {
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  .app-shell {
    padding-top: 10px !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
    padding-bottom: calc(86px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .topbar {
    margin-bottom: 8px !important;
  }

  .account-badge {
    width: 34px !important;
    height: 34px !important;
    flex-basis: 34px !important;
  }

  .title-wrap {
    gap: 8px !important;
  }

  .title-wrap h1 {
    max-width: calc(100vw - 124px) !important;
    font-size: 15px !important;
    line-height: 1.12 !important;
  }

  .title-wrap h1::after {
    padding: 2px 6px !important;
    font-size: 9.5px !important;
  }

  .account-name {
    margin-top: 2px !important;
    font-size: 10.5px !important;
    line-height: 1.1 !important;
  }

  .icon-button {
    width: 30px !important;
    height: 30px !important;
    min-height: 30px !important;
    font-size: 18px !important;
  }

  .filter-panel {
    gap: 6px !important;
    margin-bottom: 9px !important;
  }

  .filter-panel::after,
  .filter-panel select,
  .filter-panel input,
  .store-select-button,
  .multi-select-button {
    min-height: 34px !important;
    height: 34px !important;
    border-radius: 8px !important;
    font-size: 11.5px !important;
    font-weight: 850 !important;
  }

  .metric-grid {
    gap: 8px !important;
  }

  .metric-card.primary {
    min-height: 132px !important;
    padding: 17px 20px !important;
    border-radius: 11px !important;
  }

  .metric-card.primary span {
    font-size: 14px !important;
  }

  .metric-card.primary strong {
    margin: 15px 0 12px !important;
    font-size: 32px !important;
  }

  .metric-card.primary em {
    padding-top: 9px !important;
    font-size: 10.8px !important;
  }

  .metric-card.primary::before {
    right: 16px !important;
    top: 50px !important;
    transform: scale(.74) !important;
    transform-origin: right top !important;
    opacity: .78 !important;
  }

  .metric-card.primary .date-line {
    right: 14px !important;
    top: 14px !important;
  }

  .metric-card.primary .date-line strong {
    max-width: 132px !important;
    font-size: 10px !important;
    white-space: normal !important;
    text-align: right !important;
  }

  .metric-card:not(.primary) {
    min-height: 78px !important;
    grid-template-columns: 36px minmax(0, 1fr) !important;
    column-gap: 8px !important;
    padding: 10px 16px 10px 11px !important;
    border-radius: 9px !important;
  }

  .metric-card:not(.primary)::before {
    width: 34px !important;
    height: 34px !important;
    border-radius: 10px !important;
  }

  .metric-card:not(.primary)::after {
    right: 6px !important;
    font-size: 20px !important;
  }

  .metric-card:not(.primary) span {
    font-size: 10.5px !important;
  }

  .metric-card:not(.primary) strong {
    margin: 3px 0 1px !important;
    font-size: 15px !important;
  }

  .metric-card:not(.primary) em {
    max-height: 24px !important;
    font-size: 9.5px !important;
    line-height: 1.22 !important;
  }

  #overviewView .section-title {
    margin: 16px 2px 7px !important;
  }

  #overviewView .section-title h2 {
    font-size: 16.5px !important;
  }

  #overviewView .section-title span {
    font-size: 11px !important;
  }

  #overviewView .bars,
  #overviewView #modeList {
    padding: 12px 13px !important;
    border-radius: 10px !important;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.045) !important;
  }

  #overviewView .bar-row {
    grid-template-columns: 52px minmax(0, 1fr) 80px !important;
    min-height: 25px !important;
    gap: 7px !important;
    padding: 1px 0 !important;
  }

  #overviewView .bar-row > span,
  #overviewView .bar-value {
    font-size: 11px !important;
  }

  #overviewView .bar-track {
    height: 8px !important;
  }

  #overviewView #trendBars .bar-row:nth-child(n+6) {
    display: none !important;
  }

  #overviewView #modeList {
    gap: 7px !important;
  }

  #overviewView #modeList::before {
    display: none !important;
  }

  #overviewView #modeList .store-item {
    min-height: 58px !important;
    padding: 10px 11px !important;
    border: 1px solid #edf2f7 !important;
    border-radius: 9px !important;
    background: #fff !important;
  }

  #overviewView #modeList .store-main strong,
  #overviewView #modeList .store-main span {
    font-size: 12px !important;
  }

  #overviewView #modeList .store-meta span {
    font-size: 9.5px !important;
  }

  .tabs {
    padding: 6px 12px calc(8px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .tabs .tab {
    min-height: 46px !important;
    font-size: 10px !important;
    gap: 3px !important;
  }

  .tabs .tab svg {
    width: 14px !important;
    height: 14px !important;
  }
}

/* Keep the original year/month/day period switch visible on mobile overview. */
@media (max-width: 699px) {
  body:has(#overviewView.active) .period-panel {
    display: flex !important;
    min-height: 36px !important;
    margin: -2px 0 9px !important;
    padding: 4px 6px !important;
    border: 0 !important;
    border-radius: 9px !important;
    background: rgba(255, 255, 255, 0.74) !important;
    box-shadow: inset 0 0 0 1px rgba(220, 231, 241, 0.72) !important;
  }

  body:has(#overviewView.active) .period-panel .segmented {
    flex: 0 0 122px !important;
    min-height: 28px !important;
    padding: 3px !important;
    border-radius: 8px !important;
    background: #eef3f8 !important;
  }

  body:has(#overviewView.active) .period-panel .segment {
    min-height: 22px !important;
    border-radius: 6px !important;
    font-size: 10.5px !important;
    font-weight: 850 !important;
  }

  body:has(#overviewView.active) .period-panel .date-line {
    display: grid !important;
    flex: 1 1 auto !important;
    gap: 1px !important;
    justify-items: end !important;
    font-size: 9px !important;
    line-height: 1.1 !important;
  }

  body:has(#overviewView.active) .period-panel .date-line strong {
    max-width: 172px !important;
    font-size: 10px !important;
  }
}

@media (max-width: 899px) {
  body:has(#overviewView.active) .filter-panel {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    gap: 10px !important;
    margin-bottom: 12px !important;
    padding: 2px 0 10px !important;
  }

  body:has(#overviewView.active) .filter-panel::after {
    display: none !important;
    content: none !important;
  }

  body:has(#overviewView.active) .filter-panel > label,
  body:has(#overviewView.active) .filter-panel > label:nth-child(4) {
    position: relative !important;
    flex: 1 1 0 !important;
    min-width: 0 !important;
    min-height: 44px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: center !important;
    gap: 3px !important;
    padding: 6px 22px 6px 11px !important;
    border-radius: 12px !important;
    background: #f1f5f9 !important;
    box-shadow: inset 0 0 0 1px rgba(226, 232, 240, 0.72) !important;
  }

  body:has(#overviewView.active) .filter-panel > label::after {
    content: "⌄" !important;
    position: absolute !important;
    right: 9px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    color: #94a3b8 !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
  }

  body:has(#overviewView.active) .filter-panel > label > span,
  body:has(#overviewView.active) .filter-panel > .store-filter-field > span {
    flex: 0 0 auto !important;
    min-width: max-content !important;
    display: inline !important;
    color: #6b7280 !important;
    font-size: 9.5px !important;
    font-weight: 650 !important;
    line-height: 1.3 !important;
    white-space: nowrap !important;
  }

  body:has(#overviewView.active) .filter-panel > label:nth-child(4) > span:first-child {
    font-size: 0 !important;
  }

  body:has(#overviewView.active) .filter-panel > label:nth-child(4) > span:first-child::before {
    content: "状态" !important;
    font-size: 9.5px !important;
  }

  body:has(#overviewView.active) .filter-panel > label:nth-child(5) > span:first-child {
    font-size: 0 !important;
  }

  body:has(#overviewView.active) .filter-panel > label:nth-child(5) > span:first-child::before {
    content: "类别" !important;
    font-size: 9.5px !important;
  }

  body:has(#overviewView.active) .filter-panel > label.store-filter-field {
    flex: 1 1 0 !important;
    width: auto !important;
    min-width: 0 !important;
  }

  body:has(#overviewView.active) .filter-panel select,
  body:has(#overviewView.active) .filter-panel input,
  body:has(#overviewView.active) .store-select-button,
  body:has(#overviewView.active) .multi-select-button {
    flex: 0 0 auto !important;
    min-width: 0 !important;
    max-width: none !important;
    min-height: 0 !important;
    height: auto !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    color: #07111f !important;
    font-size: 11.5px !important;
    font-weight: 800 !important;
    line-height: 1.1 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    text-align: left !important;
    text-align-last: left !important;
  }

  body:has(#overviewView.active) .filter-panel > label > select {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    opacity: 0 !important;
    z-index: 3 !important;
    cursor: pointer !important;
  }

  body:has(#overviewView.active) .filter-panel .mval {
    display: inline !important;
    flex: 0 0 auto !important;
    color: #07111f !important;
    font-size: 11.5px !important;
    font-weight: 800 !important;
    line-height: 1.1 !important;
    white-space: nowrap !important;
  }

  body:has(#overviewView.active) .filter-panel .multi-select {
    flex: 1 1 auto !important;
    align-self: stretch !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    min-width: 0 !important;
    width: 100% !important;
  }

  body:has(#overviewView.active) .filter-panel .multi-select-button {
    flex: 1 1 auto !important;
    width: 100% !important;
    height: auto !important;
  }

  body:has(#overviewView.active) .filter-panel .multi-select-button b {
    display: none !important;
  }

  body:has(#overviewView.active) .store-filter-control {
    align-self: center !important;
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  body:has(#overviewView.active) .multi-select-button b {
    color: #94a3b8 !important;
  }

  body:has(#overviewView.active) .filter-panel > label:nth-child(4) select {
    font-size: 12px !important;
  }

  body:has(#overviewView.active) .multi-select-button {
    justify-content: flex-start !important;
    gap: 3px !important;
  }

  body:has(#overviewView.active) .store-filter-control {
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }

  body:has(#overviewView.active) .store-filter-control {
    position: relative !important;
  }

  body:has(#overviewView.active) .store-mval {
    display: block !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    color: #07111f !important;
    font-size: 11.5px !important;
    font-weight: 800 !important;
    line-height: 1.25 !important;
    white-space: normal !important;
  }

  body:has(#overviewView.active) .store-search-input {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    flex: 1 1 auto !important;
    opacity: 0 !important;
    z-index: 2 !important;
    font-size: 14px !important;
  }

  body:has(#overviewView.active) .store-search-input:focus {
    opacity: 1 !important;
    z-index: 5 !important;
    padding: 2px 8px !important;
    border-radius: 8px !important;
    background: #ffffff !important;
    box-shadow: 0 4px 14px rgba(15, 42, 80, 0.14) !important;
  }

  body:has(#overviewView.active) .filter-panel .multi-select-menu {
    left: 0 !important;
    right: auto !important;
    width: min(220px, calc(100vw - 28px)) !important;
    min-width: 0 !important;
    max-width: calc(100vw - 28px) !important;
  }

  body:has(#overviewView.active) .filter-panel .multi-select-menu .multi-select-option {
    position: static !important;
    flex: 0 0 auto !important;
    min-width: 0 !important;
    min-height: 32px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 0 8px !important;
    border-radius: 7px !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible !important;
  }

  body:has(#overviewView.active) .filter-panel .multi-select-menu .multi-select-option input {
    appearance: auto !important;
    -webkit-appearance: checkbox !important;
    flex: 0 0 15px !important;
    width: 15px !important;
    min-width: 15px !important;
    height: 15px !important;
    min-height: 15px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 3px !important;
    background: transparent !important;
    box-shadow: none !important;
    accent-color: #0b63f6 !important;
  }

  body:has(#overviewView.active) .filter-panel .multi-select-menu .multi-select-option span {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    color: #1f2a3d !important;
    font-size: 13px !important;
    font-weight: 550 !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  body:has(#overviewView.active) .filter-panel > label.store-filter-field .store-filter-control {
    position: static !important;
  }

  body:has(#overviewView.active) .filter-panel .store-dropdown {
    top: calc(100% + 6px) !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    width: min(260px, calc(100vw - 32px)) !important;
    min-width: 0 !important;
    max-width: calc(100vw - 32px) !important;
    max-height: calc(100dvh - 180px) !important;
    overflow-y: auto !important;
  }

  body:has(#overviewView.active) .filter-panel .store-options {
    max-height: min(310px, calc(100dvh - 266px)) !important;
  }

  body:has(#overviewView.active) .filter-panel .store-option {
    color: #1f2a3d !important;
    font-size: 13px !important;
    line-height: 34px !important;
  }

  body:has(#overviewView.active) .store-search-input::placeholder {
    color: #07111f !important;
    opacity: 1 !important;
  }
}

/* Mobile fixes: keep original interactions, readable month menu, scrollable tab rail. */
@media (max-width: 699px) {
  body:has(#overviewView.active) .filter-panel {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    gap: 10px !important;
    margin-bottom: 12px !important;
    padding: 2px 0 10px !important;
  }

  body:has(#overviewView.active) .filter-panel::after {
    display: none !important;
    content: none !important;
  }

  body:has(#overviewView.active) .filter-panel > label,
  body:has(#overviewView.active) .filter-panel > label:nth-child(4) {
    position: relative !important;
    flex: 1 1 0 !important;
    min-width: 0 !important;
    min-height: 44px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: center !important;
    gap: 3px !important;
    padding: 6px 22px 6px 11px !important;
    border-radius: 12px !important;
    background: #f1f5f9 !important;
    box-shadow: inset 0 0 0 1px rgba(226, 232, 240, 0.72) !important;
  }

  body:has(#overviewView.active) .filter-panel > label::after {
    content: "⌄" !important;
    position: absolute !important;
    right: 9px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    color: #94a3b8 !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
  }

  body:has(#overviewView.active) .filter-panel > label > span,
  body:has(#overviewView.active) .filter-panel > .store-filter-field > span {
    flex: 0 0 auto !important;
    min-width: max-content !important;
    display: inline !important;
    color: #6b7280 !important;
    font-size: 9.5px !important;
    font-weight: 650 !important;
    line-height: 1.3 !important;
    white-space: nowrap !important;
  }

  body:has(#overviewView.active) .filter-panel > label:nth-child(4) > span:first-child {
    font-size: 0 !important;
  }

  body:has(#overviewView.active) .filter-panel > label:nth-child(4) > span:first-child::before {
    content: "状态" !important;
    font-size: 9.5px !important;
  }

  body:has(#overviewView.active) .filter-panel > label:nth-child(5) > span:first-child {
    font-size: 0 !important;
  }

  body:has(#overviewView.active) .filter-panel > label:nth-child(5) > span:first-child::before {
    content: "类别" !important;
    font-size: 9.5px !important;
  }

  body:has(#overviewView.active) .filter-panel > label.store-filter-field {
    flex: 1 1 0 !important;
    width: auto !important;
    min-width: 0 !important;
  }

  body:has(#overviewView.active) .filter-panel select,
  body:has(#overviewView.active) .filter-panel input,
  body:has(#overviewView.active) .store-select-button,
  body:has(#overviewView.active) .multi-select-button {
    flex: 0 0 auto !important;
    min-width: 0 !important;
    max-width: none !important;
    min-height: 0 !important;
    height: auto !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    color: #07111f !important;
    font-size: 11.5px !important;
    font-weight: 800 !important;
    line-height: 1.1 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    text-align: left !important;
    text-align-last: left !important;
  }

  body:has(#overviewView.active) .filter-panel > label > select {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    opacity: 0 !important;
    z-index: 3 !important;
    cursor: pointer !important;
  }

  body:has(#overviewView.active) .filter-panel .mval {
    display: inline !important;
    flex: 0 0 auto !important;
    color: #07111f !important;
    font-size: 11.5px !important;
    font-weight: 800 !important;
    line-height: 1.1 !important;
    white-space: nowrap !important;
  }

  body:has(#overviewView.active) .filter-panel .multi-select {
    flex: 1 1 auto !important;
    align-self: stretch !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    min-width: 0 !important;
    width: 100% !important;
  }

  body:has(#overviewView.active) .filter-panel .multi-select-button {
    flex: 1 1 auto !important;
    width: 100% !important;
    height: auto !important;
  }

  body:has(#overviewView.active) .filter-panel .multi-select-button b {
    display: none !important;
  }

  body:has(#overviewView.active) .store-filter-control {
    align-self: center !important;
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  body:has(#overviewView.active) .multi-select-button b {
    color: #94a3b8 !important;
  }

  body:has(#overviewView.active) .filter-panel > label:nth-child(4) select {
    font-size: 12px !important;
  }

  body:has(#overviewView.active) .multi-select-button {
    justify-content: flex-start !important;
    gap: 3px !important;
  }

  body:has(#overviewView.active) .store-filter-control {
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }

  body:has(#overviewView.active) .store-filter-control {
    position: relative !important;
  }

  body:has(#overviewView.active) .store-mval {
    display: block !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    color: #07111f !important;
    font-size: 11.5px !important;
    font-weight: 800 !important;
    line-height: 1.25 !important;
    white-space: normal !important;
  }

  body:has(#overviewView.active) .store-search-input {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    flex: 1 1 auto !important;
    opacity: 0 !important;
    z-index: 2 !important;
    font-size: 14px !important;
  }

  body:has(#overviewView.active) .store-search-input:focus {
    opacity: 1 !important;
    z-index: 5 !important;
    padding: 2px 8px !important;
    border-radius: 8px !important;
    background: #ffffff !important;
    box-shadow: 0 4px 14px rgba(15, 42, 80, 0.14) !important;
  }

  body:has(#overviewView.active) .filter-panel .multi-select-menu {
    left: 0 !important;
    right: auto !important;
    width: min(220px, calc(100vw - 28px)) !important;
    min-width: 0 !important;
    max-width: calc(100vw - 28px) !important;
  }

  body:has(#overviewView.active) .filter-panel .multi-select-menu .multi-select-option {
    position: static !important;
    flex: 0 0 auto !important;
    min-width: 0 !important;
    min-height: 32px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 0 8px !important;
    border-radius: 7px !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible !important;
  }

  body:has(#overviewView.active) .filter-panel .multi-select-menu .multi-select-option input {
    appearance: auto !important;
    -webkit-appearance: checkbox !important;
    flex: 0 0 15px !important;
    width: 15px !important;
    min-width: 15px !important;
    height: 15px !important;
    min-height: 15px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 3px !important;
    background: transparent !important;
    box-shadow: none !important;
    accent-color: #0b63f6 !important;
  }

  body:has(#overviewView.active) .filter-panel .multi-select-menu .multi-select-option span {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    color: #1f2a3d !important;
    font-size: 13px !important;
    font-weight: 550 !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  body:has(#overviewView.active) .filter-panel > label.store-filter-field .store-filter-control {
    position: static !important;
  }

  body:has(#overviewView.active) .filter-panel .store-dropdown {
    top: calc(100% + 6px) !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    width: min(260px, calc(100vw - 32px)) !important;
    min-width: 0 !important;
    max-width: calc(100vw - 32px) !important;
    max-height: calc(100dvh - 180px) !important;
    overflow-y: auto !important;
  }

  body:has(#overviewView.active) .filter-panel .store-options {
    max-height: min(310px, calc(100dvh - 266px)) !important;
  }

  body:has(#overviewView.active) .filter-panel .store-option {
    color: #1f2a3d !important;
    font-size: 13px !important;
    line-height: 34px !important;
  }

  body:has(#overviewView.active) .store-search-input::placeholder {
    color: #07111f !important;
    opacity: 1 !important;
  }

  body:has(#overviewView.active) .period-panel .store-category-field {
    position: relative !important;
    flex: 0 0 auto !important;
    display: flex !important;
    align-items: center !important;
    gap: 2px !important;
    min-height: 28px !important;
    margin: 0 !important;
    padding: 0 8px !important;
    border: 0 !important;
    border-radius: 999px !important;
    background: #f1f5f9 !important;
    box-shadow: inset 0 0 0 1px rgba(226, 232, 240, 0.72) !important;
  }

  body:has(#overviewView.active) .period-panel .store-category-field > span:first-child {
    display: inline !important;
    color: #6b7280 !important;
    font-size: 10.5px !important;
    font-weight: 650 !important;
    line-height: 1 !important;
    white-space: nowrap !important;
  }

  body:has(#overviewView.active) .period-panel .store-category-field .mval {
    display: inline !important;
    color: #07111f !important;
    font-size: 12px !important;
    font-weight: 900 !important;
    line-height: 1 !important;
    white-space: nowrap !important;
  }

  body:has(#overviewView.active) .period-panel .store-category-field::after {
    content: "⌄" !important;
    flex: 0 0 auto !important;
    color: #94a3b8 !important;
    font-size: 9px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
  }

  body:has(#overviewView.active) .period-panel .store-category-field select {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    opacity: 0 !important;
    z-index: 3 !important;
    cursor: pointer !important;
  }

  body:has(#overviewView.active) .period-panel .date-line {
    min-width: 0 !important;
  }

  body:has(#overviewView.active) .period-panel .date-line strong {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  #overviewView #modeList {
    pointer-events: auto !important;
    gap: 5px !important;
    margin-bottom: 20px !important;
  }

  #overviewView #modeList .store-item {
    min-height: 46px !important;
    padding: 8px 10px !important;
    cursor: pointer !important;
    position: relative !important;
    z-index: 1 !important;
  }

  #overviewView #trendBars .bar-row:nth-child(n+6) {
    display: grid !important;
  }

  #overviewView #modeList .store-main strong,
  #overviewView #modeList .store-main span {
    font-size: 11.5px !important;
  }

  #overviewView #modeList .store-meta {
    gap: 4px 8px !important;
    margin-top: 4px !important;
  }

  #overviewView #modeList .store-meta span {
    display: inline !important;
    font-size: 9px !important;
  }

  .filter-panel .multi-select-menu span,
  .filter-panel .multi-select-menu label span,
  .multi-select-menu span,
  .multi-select-menu label span {
    display: inline !important;
    color: #1f2a3d !important;
    font-size: 13px !important;
    font-weight: 750 !important;
    line-height: 1.2 !important;
  }

  .multi-select-menu label,
  .multi-select-menu .multi-select-option,
  .multi-select-menu button {
    min-height: 34px !important;
    color: #1f2a3d !important;
    font-size: 13px !important;
  }

  .multi-select-menu input[type="checkbox"] {
    width: 16px !important;
    height: 16px !important;
    min-height: 0 !important;
    margin: 0 8px 0 0 !important;
  }

  .tabs {
    width: 100vw !important;
    left: 0 !important;
    right: auto !important;
    bottom: 0 !important;
    display: flex !important;
    gap: 4px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 6px 12px calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    border-width: 1px 0 0 !important;
    border-radius: 0 !important;
    box-shadow: 0 -10px 28px rgba(15, 23, 42, 0.08) !important;
    transform: none !important;
    scroll-snap-type: x proximity !important;
    scrollbar-width: none !important;
  }

  .tabs::-webkit-scrollbar {
    display: none !important;
  }

  .tabs .tab,
  .tabs .tab[data-view="overview"],
  .tabs .tab[data-view="mode"],
  .tabs .tab[data-view="photoSearch"],
  .tabs .tab[data-view="retail"],
  .tabs .tab[data-view="purchase"],
  .tabs .tab[data-view="sales"],
  .tabs .tab[data-view="stock"],
  .tabs .tab[data-view="ecommerce"],
  .tabs .tab[data-view="analysis"],
  .tabs .tab[data-view="vip"],
  .tabs .tab[data-view="secret"] {
    flex: 0 0 58px !important;
    min-width: 58px !important;
    min-height: 48px !important;
    display: flex !important;
    font-size: 10px !important;
    scroll-snap-align: start !important;
  }

  .tabs .tab.hidden {
    display: none !important;
  }

  .tabs .tab[data-view="secret"] span {
    font-size: 10px !important;
  }

  .tabs .tab[data-view="secret"] span::after,
  .tabs .tab[data-view="secret"]::before {
    content: none !important;
  }

  .tabs .tab[data-view="secret"] svg {
    display: block !important;
  }
}

/* Ultra-narrow phones (<=374px): squeeze the overview filter row a bit more */
@media (max-width: 374px) {
  body:has(#overviewView.active) .filter-panel {
    gap: 6px !important;
  }

  body:has(#overviewView.active) .filter-panel > label {
    padding: 7px 20px 7px 9px !important;
  }

  body:has(#overviewView.active) .filter-panel > label > span,
  body:has(#overviewView.active) .filter-panel > label:nth-child(4) > span:first-child::before,
  body:has(#overviewView.active) .filter-panel > label:nth-child(5) > span:first-child::before {
    font-size: 9px !important;
    line-height: 1.3 !important;
  }

  body:has(#overviewView.active) .filter-panel .mval,
  body:has(#overviewView.active) .filter-panel select,
  body:has(#overviewView.active) .filter-panel input,
  body:has(#overviewView.active) .filter-panel .multi-select-button {
    font-size: 11px !important;
  }

  body:has(#overviewView.active) .filter-panel > label::after {
    right: 6px !important;
    font-size: 9px !important;
  }
}
/* Overview period panel (mobile): category capsule beside segmented, date line on own row */
@media (max-width: 899px) {
  body:has(#overviewView.active) .period-panel {
    flex-wrap: wrap !important;
    gap: 2px 8px !important;
    justify-content: flex-start !important;
  }

  body:has(#overviewView.active) .period-panel .date-line {
    flex: 0 0 100% !important;
    justify-content: space-between !important;
  }

  body:has(#overviewView.active) .period-panel .store-category-field {
    position: relative !important;
    flex: 0 0 auto !important;
    display: flex !important;
    align-items: center !important;
    gap: 2px !important;
    min-height: 30px !important;
    margin: 0 !important;
    padding: 0 6px !important;
    border: 0 !important;
    border-radius: 999px !important;
    background: #f1f5f9 !important;
    box-shadow: inset 0 0 0 1px rgba(226, 232, 240, 0.72) !important;
  }

  body:has(#overviewView.active) .period-panel .store-category-field > span:first-child {
    display: inline !important;
    color: #6b7280 !important;
    font-size: 10.5px !important;
    font-weight: 650 !important;
    line-height: 1 !important;
    white-space: nowrap !important;
  }

  body:has(#overviewView.active) .period-panel .store-category-field .mval {
    display: inline !important;
    color: #07111f !important;
    font-size: 11.5px !important;
    font-weight: 900 !important;
    line-height: 1 !important;
    white-space: nowrap !important;
  }

  body:has(#overviewView.active) .period-panel .store-category-field select {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    opacity: 0 !important;
    z-index: 3 !important;
    cursor: pointer !important;
    font-size: 11.5px !important;
  }

  body:has(#overviewView.active) .period-panel .store-category-field::after {
    content: "⌄" !important;
    flex: 0 0 auto !important;
    color: #94a3b8 !important;
    font-size: 9px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
  }
}

/* ─── 修改密码弹窗（顶栏 ⚙，2026-09-30）─── */
.settings-dialog {
  width: min(360px, 100%);
  padding: 22px 22px 18px !important;
  border-radius: 14px !important;
  background: #fff !important;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28) !important;
}

.settings-dialog .image-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.settings-dialog .image-head strong {
  font-size: 17px;
  font-weight: 900;
  color: #07111f;
}

.settings-dialog .image-head button {
  border: 0;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  padding: 2px 6px;
}

.settings-user {
  margin: 0 0 12px;
  color: #64748b;
  font-size: 12.5px;
}

.settings-field {
  display: block;
  margin-bottom: 12px;
}

.settings-field span {
  display: block;
  margin-bottom: 5px;
  color: #334155;
  font-size: 12.5px;
  font-weight: 700;
}

.settings-field input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid #d8e0ea;
  border-radius: 9px;
  background: #f8fafc;
  color: #07111f;
  font-size: 16px;
}

.settings-field input:focus {
  outline: none;
  border-color: #1677ff;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.14);
}

.settings-msg {
  margin: 2px 0 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fef2f2;
  color: #dc2626;
  font-size: 12.5px;
  font-weight: 700;
}

.settings-msg.ok {
  background: #ecfdf5;
  color: #059669;
}

.settings-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.settings-actions button {
  flex: 1;
  padding: 10px 0;
  border: 1px solid #d8e0ea;
  border-radius: 9px;
  background: #f1f5f9;
  color: #334155;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.settings-actions button#settingsSubmit {
  border-color: #1677ff;
  background: linear-gradient(135deg, #2f8cff, #1677ff);
  color: #fff;
}

.settings-actions button:disabled {
  opacity: 0.6;
  cursor: default;
}

@media (max-width: 699px) {
  .settings-dialog {
    width: min(340px, calc(100vw - 32px));
    padding: 18px 16px 14px !important;
  }

  .settings-field input {
    padding: 9px 11px;
    font-size: 16px;
  }
}

/* Mobile overview: keep the date picker visible as its own row. */
@media (max-width: 699px) {
  body:has(#overviewView.active) .date-filter-panel {
    display: block !important;
    width: 100% !important;
    margin: -4px 0 10px !important;
  }

  body:has(#overviewView.active) .date-filter-panel .top-filter-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 0 !important;
    align-items: stretch !important;
  }

  body:has(#overviewView.active) .date-filter-half {
    width: 100% !important;
    min-width: 0 !important;
    flex: 1 1 100% !important;
  }

  body:has(#overviewView.active) .date-filter-toggle {
    min-height: 38px !important;
    justify-content: space-between !important;
    padding: 0 12px !important;
    border-radius: 8px !important;
    background: #fff !important;
  }

  body:has(#overviewView.active) .date-filter-popover {
    left: 0 !important;
    right: 0 !important;
    top: 42px !important;
    z-index: 32 !important;
  }
}

/* Mobile shared date filter: non-overview pages only have the date control, so keep it full width. */
@media (max-width: 699px) {
  .date-filter-panel .top-filter-row {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .date-filter-panel .date-filter-half {
    width: 100% !important;
    min-width: 0 !important;
    grid-column: 1 / -1 !important;
  }

  .date-filter-panel .date-filter-toggle {
    justify-content: space-between !important;
    gap: 8px !important;
  }

  .date-filter-panel .date-filter-toggle span {
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
}

/* Mobile analysis profit view: compact KPI grid and store cards. */
@media (max-width: 600px) {
  #analysisProfitPane.active {
    margin-top: 2px !important;
  }

  #analysisProfitPane .profit-view {
    min-height: 0 !important;
    border-top: 0 !important;
    background: transparent !important;
    overflow: visible !important;
  }

  #analysisProfitPane .profit-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px !important;
    margin: 4px 0 18px !important;
  }

  #analysisProfitPane .profit-summary article {
    position: relative !important;
    min-height: 82px !important;
    display: grid !important;
    grid-template-columns: 34px minmax(0, 1fr) !important;
    grid-template-rows: 1fr auto !important;
    align-items: center !important;
    justify-items: start !important;
    gap: 2px 8px !important;
    padding: 12px 10px !important;
    border: 1px solid rgba(226, 232, 240, 0.72) !important;
    border-radius: 8px !important;
    background: rgba(255, 255, 255, 0.9) !important;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04) !important;
  }

  #analysisProfitPane .profit-summary article::before {
    content: "" !important;
    grid-row: 1 / 3 !important;
    width: 34px !important;
    height: 34px !important;
    border-radius: 999px !important;
    background-color: #fff1f2 !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-size: 19px 19px !important;
  }

  #analysisProfitPane .profit-summary article:nth-child(1)::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e11d48' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 10.5 6.5 5h11L20 10.5'/%3E%3Cpath d='M5 10.5V20h14v-9.5'/%3E%3Cpath d='M8.5 20v-5h7v5'/%3E%3Cpath d='M4 10.5c0 1.3 1 2.2 2.3 2.2s2.3-.9 2.3-2.2c0 1.3 1 2.2 2.4 2.2s2.4-.9 2.4-2.2c0 1.3 1 2.2 2.3 2.2s2.3-.9 2.3-2.2'/%3E%3C/svg%3E") !important;
  }

  #analysisProfitPane .profit-summary article:nth-child(2)::before {
    background-color: #ecfdf5 !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2316a34a' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cellipse cx='12' cy='5.5' rx='6.5' ry='3'/%3E%3Cpath d='M5.5 5.5v5c0 1.7 2.9 3 6.5 3s6.5-1.3 6.5-3v-5'/%3E%3Cpath d='M5.5 10.5v5c0 1.7 2.9 3 6.5 3s6.5-1.3 6.5-3v-5'/%3E%3C/svg%3E") !important;
  }

  #analysisProfitPane .profit-summary article:nth-child(3)::before {
    background-color: #eef2ff !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232563eb' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 19V5'/%3E%3Cpath d='M4 19h16'/%3E%3Cpath d='m7 15 4-4 3 3 5-7'/%3E%3C/svg%3E") !important;
  }

  #analysisProfitPane .profit-summary article:nth-child(4)::before {
    background-color: #fff7ed !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ea580c' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a9 9 0 1 1-9-9v9Z'/%3E%3Cpath d='M21 12a9 9 0 0 0-9-9'/%3E%3C/svg%3E") !important;
  }

  #analysisProfitPane .profit-summary article:nth-child(5)::before {
    background-color: #f5f3ff !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234f46e5' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 19V9'/%3E%3Cpath d='M12 19V5'/%3E%3Cpath d='M19 19v-7'/%3E%3C/svg%3E") !important;
  }

  #analysisProfitPane .profit-summary article:nth-child(6)::before {
    background-color: #fff7ed !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c2410c' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 3h9l3 3v15H6z'/%3E%3Cpath d='M14 3v4h4'/%3E%3Cpath d='M9 13h6'/%3E%3Cpath d='M9 17h4'/%3E%3C/svg%3E") !important;
  }

  #analysisProfitPane .profit-summary strong {
    align-self: end !important;
    color: #0f172a !important;
    font-size: 18px !important;
    font-weight: 950 !important;
    line-height: 1.05 !important;
    letter-spacing: 0 !important;
  }

  #analysisProfitPane .profit-summary span {
    align-self: start !important;
    color: #64748b !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
  }

  #analysisProfitPane .profit-summary article.clickable.active {
    border-color: rgba(22, 119, 255, 0.5) !important;
    box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.1), 0 8px 24px rgba(15, 23, 42, 0.04) !important;
  }

  #analysisProfitPane .profit-section-title {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    margin: 2px 0 12px !important;
  }

  #analysisProfitPane .profit-section-title h2 {
    color: #0f172a !important;
    font-size: 16px !important;
    font-weight: 950 !important;
    line-height: 1.25 !important;
  }

  #analysisProfitPane .profit-section-title span {
    flex: 0 1 auto !important;
    color: #64748b !important;
    font-size: 11px !important;
    font-weight: 650 !important;
    line-height: 1.25 !important;
    text-align: right !important;
  }

  #analysisProfitPane .profit-section-title span::before {
    content: "i" !important;
    display: inline-grid !important;
    place-items: center !important;
    width: 14px !important;
    height: 14px !important;
    margin-right: 4px !important;
    border: 1px solid #94a3b8 !important;
    border-radius: 50% !important;
    color: #64748b !important;
    font-size: 9px !important;
    font-weight: 900 !important;
    vertical-align: 1px !important;
  }

  #analysisProfitPane .profit-list {
    gap: 12px !important;
  }

  #analysisProfitPane .profit-table {
    display: grid !important;
    gap: 12px !important;
  }

  #analysisProfitPane .profit-row {
    position: relative !important;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    grid-template-areas:
      "name name status"
      "amount profit even"
      "progress progress progress" !important;
    gap: 12px 0 !important;
    padding: 16px 16px 14px !important;
    border: 1px solid rgba(226, 232, 240, 0.75) !important;
    border-radius: 8px !important;
    background: rgba(255, 255, 255, 0.94) !important;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05) !important;
  }

  #analysisProfitPane .profit-row::after {
    content: "›" !important;
    position: absolute !important;
    top: 14px !important;
    right: 16px !important;
    color: #64748b !important;
    font-size: 28px !important;
    font-weight: 300 !important;
    line-height: 1 !important;
  }

  #analysisProfitPane .profit-name {
    grid-area: name !important;
    padding-right: 24px !important;
  }

  #analysisProfitPane .profit-name strong {
    color: #0f172a !important;
    font-size: 15px !important;
    font-weight: 950 !important;
    line-height: 1.25 !important;
  }

  #analysisProfitPane .profit-name span {
    margin-top: 4px !important;
    color: #64748b !important;
    font-size: 12px !important;
    font-weight: 650 !important;
  }

  #analysisProfitPane .profit-cell {
    min-width: 0 !important;
    padding: 0 10px !important;
  }

  #analysisProfitPane .profit-cell:nth-of-type(2) {
    grid-area: amount !important;
    padding-left: 0 !important;
  }

  #analysisProfitPane .profit-cell:nth-of-type(3) {
    grid-area: profit !important;
    border-left: 1px solid #e2e8f0 !important;
    border-right: 1px solid #e2e8f0 !important;
  }

  #analysisProfitPane .profit-cell:nth-of-type(4) {
    grid-area: even !important;
    padding-right: 0 !important;
  }

  #analysisProfitPane .profit-cell strong {
    color: #0f172a !important;
    font-size: 15px !important;
    font-weight: 950 !important;
    line-height: 1.15 !important;
  }

  #analysisProfitPane .profit-cell span {
    margin-top: 4px !important;
    color: #64748b !important;
    font-size: 11.5px !important;
    font-weight: 650 !important;
    line-height: 1.15 !important;
  }

  #analysisProfitPane .profit-status {
    grid-area: status !important;
    width: auto !important;
    justify-self: end !important;
    align-self: start !important;
    padding-right: 20px !important;
  }

  #analysisProfitPane .profit-status > span {
    min-width: 58px !important;
    padding: 7px 12px !important;
    border-radius: 999px !important;
    font-size: 12px !important;
    font-weight: 900 !important;
  }

  #analysisProfitPane .profit-progress {
    grid-area: progress !important;
    gap: 8px !important;
  }

  #analysisProfitPane .profit-track {
    height: 9px !important;
    background: #edf1f6 !important;
  }

  #analysisProfitPane .profit-track i {
    background: linear-gradient(90deg, #f43f5e, #e11d48) !important;
  }

  #analysisProfitPane .profit-row.profit-even .profit-track i {
    background: linear-gradient(90deg, #3b82f6, #1d4ed8) !important;
  }

  #analysisProfitPane .profit-row.profit-good .profit-track i {
    background: linear-gradient(90deg, #22c55e, #16a34a) !important;
  }

  #analysisProfitPane .profit-progress small {
    color: #64748b !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    white-space: normal !important;
  }
}

@media (max-width: 374px) {
  #analysisProfitPane .profit-summary {
    gap: 6px !important;
  }

  #analysisProfitPane .profit-summary article {
    grid-template-columns: 28px minmax(0, 1fr) !important;
    min-height: 76px !important;
    padding: 10px 8px !important;
    gap: 2px 6px !important;
  }

  #analysisProfitPane .profit-summary article::before {
    width: 28px !important;
    height: 28px !important;
    background-size: 16px 16px !important;
  }

  #analysisProfitPane .profit-summary strong {
    font-size: 16px !important;
  }

  #analysisProfitPane .profit-summary span {
    font-size: 10.5px !important;
  }

  #analysisProfitPane .profit-row {
    padding: 14px 12px 13px !important;
  }

  #analysisProfitPane .profit-cell {
    padding: 0 8px !important;
  }

  #analysisProfitPane .profit-cell strong {
    font-size: 14px !important;
  }
}

.purchase-rate-filter { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; color: var(--muted); font-size: 12px; }
.purchase-rate-filter input { width: 100px; min-height: 36px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); }
.purchase-rate-filter .note { margin: 0; }

.supplier-picker { position: relative; min-width: 0; }
.supplier-picker select[hidden] { display: none; }
.supplier-options { min-width: 180px; width: max-content; max-width: min(280px, calc(100vw - 24px)); position: absolute; top: calc(100% + 5px); left: 0; right: 0; z-index: 40; max-height: 260px; overflow-y: auto; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.supplier-options button { display: block; width: 100%; min-height: 36px; border: 0; border-radius: 4px; padding: 8px; text-align: left; background: transparent; color: var(--ink); font-size: 13px; cursor: pointer; overflow-wrap: anywhere; }
.supplier-options button:hover, .supplier-options button.active { background: #eaf1ff; color: #1e40af; }
.supplier-options .supplier-empty { padding: 8px; color: var(--muted); font-size: 12px; }

/* Local trial: fixed 20-row list pages. */
.rank-pagination { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 16px; padding: 14px 8px; margin-top: 4px; color: var(--muted); font-size: 12px; }
.rank-page-buttons, .rank-page-jump { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; }
.rank-pagination button { min-height: 36px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink); cursor: pointer; font-size: 12px; }
.rank-pagination button:hover:not(:disabled) { border-color: #1677ff; color: #1677ff; background: #eef5ff; }
.rank-pagination button:disabled { opacity: .45; cursor: default; }
.rank-pagination input { width: 66px; min-height: 36px; border: 1px solid var(--line); border-radius: 7px; padding: 4px 6px; color: var(--ink); background: var(--panel); }
.rank-pagination button:focus-visible, .rank-pagination input:focus-visible { outline: 2px solid #1677ff; outline-offset: 2px; }
.rank-page-position { min-width: 90px; text-align: center; font-variant-numeric: tabular-nums; }
.rank-page-error { width: 100%; color: #b42318; text-align: center; }
.rank-page-empty { grid-column: 1 / -1; padding: 20px; text-align: center; color: var(--muted); }
@media (max-width: 600px) { .rank-pagination { padding: 12px 0; gap: 8px; } .rank-page-count { flex-basis: 100%; text-align: center; } .rank-pagination button { padding: 6px 9px; min-height: 40px; } }

/* Excel export controls */
.product-export-row { display:flex; align-items:center; flex-wrap:wrap; gap:12px; max-width:none; }
.product-export-row .search-box { flex:1 1 240px; max-width:560px; min-width:0; }
.product-export-row #productExportBtn { min-height:42px; padding:8px 16px; white-space:nowrap; border:1px solid var(--line); border-radius:8px; background:var(--panel); color:var(--blue, #1673ff); }
.product-export-row #productExportBtn:disabled { opacity:.6; cursor:wait; }
.product-export-status { color:var(--muted); font-size:12px; }
#productDataPane .product-export-row { max-width:none; }
.purchase-rate-filter .excel-export-button{min-height:38px;padding:8px 16px;white-space:nowrap;border:1px solid var(--line);border-radius:8px;background:var(--panel);color:var(--blue,#1673ff)}
.purchase-rate-filter .excel-export-button:disabled{opacity:.6;cursor:wait}

/* 商品零售结构：复用库存结构表格与打印，零售页独立五页签布局。 */
.retail-page-switch { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stock-structure-hint { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 0 0 12px; overflow-wrap: anywhere; }
@media (max-width: 699px) { .retail-page-switch { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

#purchaseRankSwitch { grid-template-columns: repeat(3, minmax(0, 1fr)); }
