:root {
  --ink: #17211b;
  --muted: #69736d;
  --line: #e3e8e4;
  --soft-line: #eef1ef;
  --green: #186d4b;
  --green-dark: #10583b;
  --green-soft: #eaf5ef;
  --red: #b83f42;
  --red-soft: #fff1f1;
  --canvas: #f3f5f2;
  --surface: #ffffff;
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body {
  margin: 0;
  background:
    radial-gradient(circle at 0 0, rgba(39, 125, 88, .055), transparent 26rem),
    var(--canvas);
  color: var(--ink);
  font-family: Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, summary { font: inherit; }
button { color: inherit; }

.page-shell {
  width: min(1600px, calc(100% - 48px));
  margin: 0 auto;
  padding: 24px 0 40px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 16px;
}
.identity { display: flex; align-items: center; gap: 14px; }
.identity h1 { margin: 0 0 4px; font-size: 25px; line-height: 1.2; letter-spacing: -.02em; }
.identity p { margin: 0; color: var(--muted); font-size: 13px; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  padding: 11px 10px;
  border-radius: 12px;
  background: var(--green);
  box-shadow: 0 7px 18px rgba(24, 109, 75, .2);
}
.brand-mark i { display: block; width: 5px; border-radius: 3px 3px 1px 1px; background: #fff; }
.brand-mark i:nth-child(1) { height: 9px; opacity: .72; }
.brand-mark i:nth-child(2) { height: 16px; }
.brand-mark i:nth-child(3) { height: 12px; opacity: .85; }
.meta-chips { display: inline-flex; align-items: center; justify-content: flex-end; gap: 0; padding: 3px; border: 1px solid #dce3dd; border-radius: 10px; background: rgba(255,255,255,.76); }
.chip {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border: 1px solid #dce3dd;
  border-radius: 9px;
  background: rgba(255,255,255,.72);
  color: var(--muted);
  font-size: 12px;
}
.chip b { color: #39443e; font-weight: 600; }
.inventory-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; }
.inventory-chip { min-width: 0; min-height: 28px; justify-content: center; gap: 6px; padding: 4px 9px; border: 0; border-radius: 6px; background: transparent; font-size: 12px; }
.inventory-chip b { font-size: 12px; font-variant-numeric: tabular-nums; }
.status-divider { display: inline-flex; align-items: center; justify-content: center; margin: 0 1px; color: #9da9a0; font-size: 15px; font-weight: 600; line-height: 1; }
.inventory-chip.is-onsale { border-color: transparent; background: transparent; color: #557064; }
.inventory-chip.is-onsale::before { background: var(--green); box-shadow: 0 0 0 3px rgba(24,109,75,.09); }
.inventory-chip.is-onsale b { color: var(--green-dark); }
.inventory-chip.is-offsale { border-color: transparent; background: transparent; color: #846a6a; }
.inventory-chip.is-offsale::before { background: var(--red); box-shadow: 0 0 0 3px rgba(184,63,66,.08); }
.inventory-chip.is-offsale b { color: var(--red); }

.content-card {
  overflow: visible;
  border: 1px solid #e1e6e2;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 7px 24px rgba(25, 52, 39, .055);
}
.toolbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}
.toolbar-guide { min-width: 0; padding: 8px 12px; border-left: 3px solid #79a58e; border-radius: 0 8px 8px 0; background: #f5f8f6; }
.toolbar-guide p { margin: 0; color: #66726a; font-size: 12px; line-height: 1.5; white-space: nowrap; }
.toolbar-guide strong { color: #385947; font-weight: 700; }
.toolbar-actions { display: flex; align-items: center; gap: 10px; }
.date-selector {
  position: relative;
  height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 204px;
  padding: 0 12px;
  border: 1px solid #d9dfda;
  border-radius: 8px;
  background: #fff;
  color: #7b857e;
  font-size: 12px;
  cursor: pointer;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.date-label { color: #7b857e; }
.date-display { color: #26342b; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.calendar-symbol { position: relative; width: 14px; height: 14px; margin-left: auto; border: 1.5px solid #26342b; border-radius: 2px; }
.calendar-symbol::before { content: ""; position: absolute; top: 3px; right: -1.5px; left: -1.5px; border-top: 1.5px solid #26342b; }
.calendar-symbol::after { content: ""; position: absolute; top: -3px; left: 2px; width: 6px; height: 3px; border-right: 1.5px solid #26342b; border-left: 1.5px solid #26342b; }
.date-selector:hover { border-color: #bdc9c0; background: #fafcfb; }
.date-selector input {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  opacity: 0;
  cursor: pointer;
}
.date-selector input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: auto; height: auto; margin: 0; padding: 0; opacity: 0; cursor: pointer; }
.date-selector:focus-within {
  border-color: #a8bdb0;
  box-shadow: 0 0 0 3px rgba(24,109,75,.07);
}
.availability-filter { height: 36px; display: inline-flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid #d9dfda; border-radius: 8px; background: #f7f9f7; }
.availability-filter button { min-width: 48px; height: 28px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: #7a847e; font-size: 12px; cursor: pointer; }
.availability-filter button:hover { color: #425047; }
.availability-filter button.is-active { background: #fff; color: #34443a; box-shadow: 0 1px 4px rgba(25,52,39,.1); font-weight: 700; }
.availability-filter button.is-active[data-availability="onSale"] { background: #eaf5ef; color: var(--green-dark); }
.quiet-button,
.column-picker > summary {
  height: 36px;
  border: 1px solid #d9dfda;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
.quiet-button { padding: 0 13px; color: #566159; font-size: 12px; }
.quiet-button:hover { border-color: #bdc9c0; background: #fafcfb; }
.column-picker { position: relative; z-index: 30; }
.column-picker > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 12px;
  color: #334038;
  font-size: 13px;
  font-weight: 600;
  user-select: none;
}
.column-picker > summary::-webkit-details-marker { display: none; }
.column-picker > summary:hover,
.column-picker[open] > summary {
  border-color: #a8bdb0;
  box-shadow: 0 0 0 3px rgba(24,109,75,.07);
}
.sliders-icon { position: relative; width: 14px; height: 14px; display: inline-flex; flex-direction: column; justify-content: space-around; }
.sliders-icon i { position: relative; width: 13px; height: 1px; background: #647068; }
.sliders-icon i::after { content: ""; position: absolute; top: -2px; width: 3px; height: 3px; border: 1px solid #647068; border-radius: 50%; background: #fff; }
.sliders-icon i:nth-child(1)::after, .sliders-icon i:nth-child(3)::after { left: 2px; }
.sliders-icon i:nth-child(2)::after { right: 2px; }
.count-badge { padding: 2px 6px; border-radius: 5px; background: var(--green-soft); color: var(--green); font-size: 11px; font-weight: 700; }
.column-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 390px;
  padding: 16px;
  border: 1px solid #dfe5e0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(27, 49, 38, .15);
}
.menu-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.menu-heading strong { display: block; font-size: 14px; }
.menu-heading span { display: block; margin-top: 4px; color: #8a928d; font-size: 11px; }
.menu-heading button { padding: 2px 0; border: 0; background: transparent; color: var(--green); font-size: 12px; cursor: pointer; }
.option-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 10px; }
.option-grid label { min-height: 34px; display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 7px; color: #414c45; font-size: 12px; cursor: pointer; }
.option-grid label:hover { background: #f5f8f6; }
.option-grid input { position: absolute; opacity: 0; pointer-events: none; }
.custom-check { width: 16px; height: 16px; display: inline-grid; place-items: center; border: 1px solid #c4ccc6; border-radius: 4px; color: transparent; font-size: 11px; }
.option-grid input:checked + .custom-check { border-color: var(--green); background: var(--green); color: #fff; }
.option-grid input:focus-visible + .custom-check { outline: 3px solid rgba(24,109,75,.16); outline-offset: 1px; }

.notice { padding: 10px 20px; border-bottom: 1px solid #f0dfbd; background: #fff8e8; color: #76561d; font-size: 12px; }
.notice.is-error { border-color: #efd0d0; background: #fff1f1; color: #943a3d; }
.table-wrap {
  width: 100%;
  min-height: 450px;
  max-height: calc(100vh - 250px);
  overflow: auto;
  scrollbar-color: #bbc5bd #f2f4f2;
  scrollbar-width: thin;
}
.table-wrap::-webkit-scrollbar { width: 10px; height: 10px; }
.table-wrap::-webkit-scrollbar-track { background: #f2f4f2; }
.table-wrap::-webkit-scrollbar-thumb { border: 2px solid #f2f4f2; border-radius: 10px; background: #bbc5bd; }
table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
caption { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
th, td { height: 52px; padding: 0 16px; border-bottom: 1px solid var(--soft-line); background: #fff; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 10; height: 45px; border-bottom-color: #dde3de; background: #f7f9f7; color: #566159; font-size: 12px; font-weight: 600; text-align: left; }
td { color: #344039; font-size: 13px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f8fbf9; }
.sticky-cell { position: sticky; }
.sticky-name { left: 0; z-index: 5; width: var(--name-width); min-width: var(--name-width); max-width: var(--name-width); box-shadow: 7px 0 11px -12px rgba(26, 45, 35, .7); }
th.sticky-cell { z-index: 20; background: #f7f9f7; }
.name-column { position: sticky; }
.product-name-copy {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: #26322b;
  font-weight: 500;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: copy;
}
.product-name-copy:hover { color: var(--green); }
.product-name-copy:focus-visible { outline: 2px solid rgba(24,109,75,.24); outline-offset: 3px; border-radius: 3px; }
.product-name-content { min-width: 0; display: flex; align-items: center; gap: 8px; }
.product-name-content .product-name-copy { min-width: 0; flex: 1; }
.offline-badge { flex: 0 0 auto; padding: 2px 6px; border-radius: 999px; background: var(--red-soft); color: var(--red); font-size: 9px; font-weight: 700; }
.resize-handle { position: absolute; top: 0; right: -5px; z-index: 2; width: 10px; height: 100%; border: 0; background: transparent; cursor: col-resize; touch-action: none; }
.resize-handle::after { content: ""; position: absolute; top: 12px; bottom: 12px; left: 4px; width: 2px; border-radius: 2px; background: #cbd3cd; transition: background .15s; }
.resize-handle:hover::after, .is-resizing .resize-handle::after { background: var(--green); }
.is-resizing { cursor: col-resize !important; user-select: none !important; }
.metric-column { padding-right: 20px; padding-left: 12px; text-align: right; }
.metric-column button { width: 100%; height: 100%; display: flex; align-items: center; justify-content: flex-end; gap: 4px; padding: 0; border: 0; background: transparent; color: inherit; font-weight: inherit; cursor: pointer; }
.metric-column button:hover { color: var(--green); }
.metric-column.text-column { padding-right: 12px; padding-left: 18px; text-align: left; }
.metric-column.text-column button { justify-content: flex-start; }
.sort-icon { min-width: 10px; flex: 0 0 auto; color: #a3aca6; font-size: 13px; font-weight: 500; text-align: center; }
.metric-column.is-sorted { background: #eff7f2; color: var(--green-dark); }
.metric-column.is-sorted .sort-icon { color: var(--green); }
.numeric { padding-right: 20px; padding-left: 12px; text-align: right; font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.textual { padding-right: 12px; padding-left: 18px; text-align: left; }
td.is-sorted { background: #f5faf7; color: var(--green-dark); font-weight: 600; }
tbody tr:hover td.is-sorted { background: #eef7f2; }
.level-badge { min-height: 24px; display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; background: #edf4ef; color: #476052; font-size: 11px; font-weight: 600; }
.metric-data { position: relative; outline: none; cursor: default; }
.metric-data:hover, .metric-data:focus-visible { box-shadow: inset 0 0 0 2px rgba(24,109,75,.16); }
td.rate-high { background: var(--green-soft); color: var(--green-dark); font-weight: 700; }
td.rate-low { background: var(--red-soft); color: var(--red); font-weight: 700; }
tbody tr:hover td.rate-high { background: #def0e6; }
tbody tr:hover td.rate-low { background: #ffe5e5; }

.trend-tooltip {
  position: fixed;
  z-index: 1000;
  width: min(680px, calc(100vw - 24px));
  padding: 16px 18px 14px;
  border: 1.5px solid #c9d7cf;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 16px 42px rgba(24,44,33,.18), 0 0 0 1px rgba(24,109,75,.035);
  transform: translate(-50%, -100%);
  pointer-events: none;
}
.trend-tooltip[hidden] { display: none; }
.trend-tooltip::after { content: ""; position: absolute; left: 50%; bottom: -6px; width: 10px; height: 10px; border-right: 1.5px solid #c9d7cf; border-bottom: 1.5px solid #c9d7cf; background: #fff; transform: translateX(-50%) rotate(45deg); }
.trend-tooltip.is-below { transform: translate(-50%, 0); }
.trend-tooltip.is-below::after { top: -6px; bottom: auto; border: 0; border-top: 1.5px solid #c9d7cf; border-left: 1.5px solid #c9d7cf; }
.trend-tooltip-head { margin-bottom: 0; padding: 0 2px 4px; text-align: center; }
.trend-tooltip.is-layer .trend-tooltip-head { padding-bottom: 11px; }
.trend-tooltip-head.is-metric { padding: 0 2px 6px; }
.trend-tooltip-title { min-width: 0; }
.trend-tooltip-head strong { display: block; color: #26342c; font-size: 14px; line-height: 1.25; }
.trend-summary-strip { display: inline-flex; align-items: center; justify-content: center; gap: 9px; margin-top: 7px; padding: 5px 14px; border-radius: 999px; background: #f2f6f3; color: #748078; font-size: 11px; font-variant-numeric: tabular-nums; }
.trend-summary-strip span { white-space: nowrap; }
.trend-summary-strip i { width: 1px; height: 12px; background: #d6e0d9; }
.trend-summary-strip b { margin-left: 4px; color: #526159; font-size: 11px; font-weight: 600; }
.trend-summary-strip .trend-current-value { color: #3d4b43; font-size: 12px; font-weight: 700; }
.trend-summary-strip .trend-current-value.rate-low { color: var(--red); }
.trend-summary-strip .trend-current-value.rate-high { color: var(--green-dark); }
.trend-summary-strip .is-up b { color: var(--green-dark); }
.trend-summary-strip .is-down b { color: var(--red); }
.trend-summary-strip .is-flat b { color: #7b857f; }
.trend-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.trend-grid div { min-width: 0; padding: 8px 4px; border-radius: 7px; background: #f4f7f5; text-align: center; }
.trend-grid span { display: block; margin-bottom: 5px; color: #7d8780; font-size: 9px; font-variant-numeric: tabular-nums; }
.trend-grid strong { display: block; overflow: hidden; color: var(--green-dark); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.trend-chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart-area { fill: url(#trend-area-gradient); }
.chart-area.is-percent { opacity: .64; }
.chart-line { fill: none; stroke: #526978; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.chart-point { fill: #fff; stroke: #647985; stroke-width: 2; }
.chart-point.rate-low { stroke: var(--red); }
.chart-point.rate-high { stroke: var(--green); }
.chart-point.rate-normal { stroke: #647985; }
.chart-current-halo { fill: rgba(82,105,120,.12); }
.chart-current-halo.rate-low { fill: rgba(184,63,66,.13); }
.chart-current-halo.rate-high { fill: rgba(24,109,75,.13); }
.chart-value { fill: #526159; font-size: 10px; text-anchor: middle; opacity: .68; }
.chart-value.rate-low { fill: var(--red); }
.chart-value.rate-high { fill: var(--green-dark); }
.chart-value.is-current { font-weight: 700; opacity: 1; }
.chart-date { fill: #7d8780; font-size: 10px; text-anchor: middle; }
.chart-empty { fill: #8b948e; font-size: 12px; text-anchor: middle; }

.state-message { min-height: 450px; display: grid; place-items: center; align-content: center; gap: 10px; color: #828b85; font-size: 13px; }
.loading-dot { width: 22px; height: 22px; border: 2px solid #dbe5df; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.table-footer { min-height: 42px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-top: 1px solid var(--line); color: #7c857f; font-size: 11px; }
.table-footer span { display: flex; align-items: center; gap: 6px; }
.fixed-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.copy-toast { position: fixed; z-index: 1100; left: 50%; bottom: 28px; padding: 10px 16px; border-radius: 9px; background: #173d2d; color: #fff; box-shadow: 0 10px 28px rgba(21,52,39,.22); font-size: 13px; font-weight: 600; transform: translateX(-50%); }
.copy-toast[hidden] { display: none; }

@media (max-width: 760px) {
  .page-shell { width: 100%; padding: 20px 12px; }
  .topbar { align-items: flex-start; flex-direction: column; margin-bottom: 18px; }
  .meta-chips { justify-content: flex-start; }
  .content-card { border-radius: 12px; }
  .toolbar { align-items: flex-start; flex-direction: column; padding: 16px; }
  .toolbar-guide { width: 100%; }
  .toolbar-guide p { flex-wrap: wrap; white-space: normal; }
  .toolbar-actions { width: 100%; justify-content: flex-end; flex-wrap: wrap; }
  .column-menu { width: min(390px, calc(100vw - 48px)); }
  .table-wrap { max-height: calc(100vh - 360px); }
  .table-footer { align-items: flex-start; flex-direction: column; gap: 5px; padding: 10px 14px; }
  .trend-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
