/* Shopee report — scoped overrides.
   Loaded after styles.css; every rule is prefixed .shopee-page so the other
   report pages are untouched.

   Series colors come from the validated default dataviz palette, kept in the
   documented slot order (that order is the colorblind-safety mechanism).
   Re-run scripts/validate_palette.js before changing any hex. */

.shopee-page {
  --viz-surface: #ffffff;
  --viz-plane: #f7f8f5;

  --viz-ink: #0b0b0b;
  --viz-ink-2: #52514e;
  --viz-ink-muted: #6f6e69; /* 5.11:1 on white — safe for axis ticks */

  --viz-grid: #e1e0d9;
  --viz-axis: #c3c2b7;
  --viz-hairline: rgba(11, 11, 11, 0.1);

  --viz-good: #006300; /* 7.54:1 as text */
  --viz-bad: #d03b3b; /* 4.80:1 as text */

  background: var(--viz-plane);
}

/* ---------- deltas: the old greens/reds failed text contrast ---------- */

.shopee-page .trend.up,
.shopee-page .cell-delta.up,
.shopee-page .share-delta b.up,
.shopee-page .kpi-deltas b.up {
  color: var(--viz-good);
}

.shopee-page .trend.down,
.shopee-page .cell-delta.down,
.shopee-page .share-delta b.down,
.shopee-page .kpi-deltas b.down {
  color: var(--viz-bad);
}

/* ---------- coverage chips ---------- */

.shopee-page .coverage-note {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 18px;
  font-size: 12.5px;
  color: var(--viz-ink-2);
}

.shopee-page .cov-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 5px 11px;
  border: 1px solid var(--viz-hairline);
  border-radius: 999px;
  background: var(--viz-surface);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.shopee-page .cov-chip strong {
  font-weight: 640;
  color: var(--viz-ink);
}

/* ---------- stat tiles ---------- */

.shopee-page .overall-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.62fr) minmax(280px, 0.52fr);
  gap: 14px;
  align-items: start;
}

.shopee-page .kpi-grid.compact-kpis {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.shopee-page .kpi {
  display: flex;
  flex-direction: column;
  padding: 16px 16px 14px;
  border: 1px solid var(--viz-hairline);
  border-radius: 12px;
  background: var(--viz-surface);
  box-shadow: none;
}

.shopee-page .kpi-label {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--viz-ink-muted);
}

.shopee-page .kpi-value {
  margin-top: 6px;
  font-size: 30px;
  line-height: 1.1;
  font-weight: 680;
  letter-spacing: -0.02em;
  color: var(--viz-ink);
  font-variant-numeric: proportional-nums;
}

.shopee-page .kpi-scope {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--viz-ink-muted);
}

.shopee-page .kpi-deltas {
  display: flex;
  gap: 14px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--viz-grid);
  font-size: 12px;
  color: var(--viz-ink-muted);
}

.shopee-page .kpi-deltas b {
  font-weight: 660;
  font-variant-numeric: tabular-nums;
}

/* ---------- share: 100% stacked bar + labeled list ---------- */

.shopee-page .panel.share-panel {
  padding: 16px 18px 18px;
  border: 1px solid var(--viz-hairline);
  border-radius: 12px;
  background: var(--viz-surface);
  box-shadow: none;
}

.shopee-page .share-title {
  font-size: 13px;
  font-weight: 660;
  color: var(--viz-ink);
}

.shopee-page .share-total {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 10px;
}

.shopee-page .share-total strong {
  font-size: 26px;
  font-weight: 680;
  letter-spacing: -0.02em;
  color: var(--viz-ink);
}

.shopee-page .share-total span {
  font-size: 12px;
  color: var(--viz-ink-muted);
}

.shopee-page .share-bar {
  display: flex;
  gap: 2px; /* 2px of surface separates the segments — never a stroke */
  height: 26px;
  margin: 12px 0 14px;
  border-radius: 4px;
  overflow: hidden;
}

.shopee-page .share-bar i {
  display: block;
  min-width: 2px;
  height: 100%;
}

.shopee-page .share-list {
  display: grid;
  gap: 9px;
}

.shopee-page .share-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: baseline;
  gap: 4px 12px;
  font-size: 12.5px;
  color: var(--viz-ink-2);
}

.shopee-page .share-key {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--viz-ink);
}

.shopee-page .share-key i {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.shopee-page .share-pct {
  font-weight: 680;
  color: var(--viz-ink);
  font-variant-numeric: tabular-nums;
}

.shopee-page .share-abs {
  min-width: 66px;
  text-align: right;
  color: var(--viz-ink-muted);
  font-variant-numeric: tabular-nums;
}

.shopee-page .share-delta {
  grid-column: 1 / -1;
  display: flex;
  gap: 12px;
  padding-left: 17px;
  font-size: 11.5px;
  color: var(--viz-ink-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- chart chrome ---------- */

.shopee-page .metric-chart {
  margin: 4px 0 18px;
}

.shopee-page .viz-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.shopee-page .viz-title {
  margin: 0;
  font-size: 15px;
  font-weight: 680;
  letter-spacing: -0.01em;
  color: var(--viz-ink);
}

.shopee-page .viz-sub {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--viz-ink-muted);
}

.shopee-page .viz-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12.5px;
  color: var(--viz-ink-2);
}

.shopee-page .viz-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.shopee-page .viz-legend i {
  flex: none;
  border-radius: 2px;
}

.shopee-page .viz-legend i.key-rect {
  width: 11px;
  height: 11px;
}

.shopee-page .viz-legend i.key-line {
  width: 16px;
  height: 2px;
}

.shopee-page .viz-figure {
  position: relative;
}

.shopee-page .viz-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.shopee-page .viz-svg .grid-line {
  stroke: var(--viz-grid);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.shopee-page .viz-svg .axis-line {
  stroke: var(--viz-axis);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.shopee-page .viz-svg .tick-text {
  fill: var(--viz-ink-muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.shopee-page .viz-svg .plot-name {
  fill: var(--viz-ink-2);
  font-size: 12px;
  font-weight: 650;
}

.shopee-page .viz-svg .viz-line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.shopee-page .viz-svg .viz-dot {
  stroke: var(--viz-surface);
  stroke-width: 2; /* surface ring */
}

.shopee-page .viz-svg .end-label {
  fill: var(--viz-ink);
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.shopee-page .viz-svg .crosshair {
  stroke: var(--viz-ink);
  stroke-width: 1;
  opacity: 0.28;
  pointer-events: none;
}

.shopee-page .viz-svg .hit-band {
  fill: transparent;
  cursor: crosshair;
}

.shopee-page .viz-svg .hit-band.is-active {
  fill: rgba(11, 11, 11, 0.035);
}

/* ---------- tooltip ---------- */

.shopee-page .viz-tip {
  position: absolute;
  z-index: 20;
  min-width: 220px;
  padding: 11px 14px;
  border: 1px solid var(--viz-hairline);
  border-radius: 10px;
  background: var(--viz-surface);
  box-shadow: 0 10px 28px rgba(11, 11, 11, 0.12);
  font-size: 12.5px;
  color: var(--viz-ink-2);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s ease;
}

.shopee-page .viz-tip[data-open="true"] {
  opacity: 1;
}

.shopee-page .viz-tip-head {
  margin-bottom: 7px;
  font-weight: 650;
  color: var(--viz-ink);
}

.shopee-page .viz-tip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
}

.shopee-page .viz-tip-row i {
  flex: none;
  width: 14px;
  height: 2px;
  border-radius: 2px;
}

/* values lead, labels follow */
.shopee-page .viz-tip-row b {
  margin-left: auto;
  padding-left: 18px;
  font-weight: 680;
  color: var(--viz-ink);
  font-variant-numeric: tabular-nums;
}

/* ---------- panels & tables ---------- */

.shopee-page .panel.report-block {
  padding: 20px 22px;
  border: 1px solid var(--viz-hairline);
  border-radius: 14px;
  background: var(--viz-surface);
  box-shadow: none;
}

.shopee-page .table-wrap {
  border: 1px solid var(--viz-hairline);
  border-radius: 12px;
  background: var(--viz-surface);
  overflow-x: auto;
}

.shopee-page .table-wrap table {
  border-collapse: collapse;
  width: 100%;
}

.shopee-page .table-wrap th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 11px 14px;
  border-bottom: 1px solid var(--viz-grid);
  background: var(--viz-surface);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--viz-ink-muted);
  text-align: right;
  white-space: nowrap;
}

.shopee-page .table-wrap th:first-child,
.shopee-page .table-wrap th:nth-child(2) {
  text-align: left;
}

.shopee-page .table-wrap td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--viz-grid);
  font-size: 12.5px;
  text-align: right;
  color: var(--viz-ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.shopee-page .table-wrap td:first-child,
.shopee-page .table-wrap td:nth-child(2) {
  text-align: left;
}

.shopee-page .table-wrap tbody tr:hover {
  background: rgba(11, 11, 11, 0.02);
}

.shopee-page .table-wrap tbody tr:last-child td {
  border-bottom: 0;
}

.shopee-page .cell-delta {
  margin-top: 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--viz-ink-muted);
  font-variant-numeric: tabular-nums;
}

.shopee-page tr.total-row td {
  border-top: 1px solid var(--viz-axis);
  background: #f7f8f5;
  font-weight: 680;
}

.shopee-page .campaign-cell,
.shopee-page .product-cell {
  white-space: normal;
  color: var(--viz-ink-2);
}

.shopee-page .product-cell strong {
  font-weight: 600;
  color: var(--viz-ink);
}

.shopee-page .product-performance-table {
  min-width: 1180px;
}

.shopee-page .product-performance-wrap {
  max-height: 620px;
  overflow-y: auto;
}

/* ---------- filters & tabs ---------- */

.shopee-page .filter-bar {
  padding: 14px 16px;
  border: 1px solid var(--viz-hairline);
  border-radius: 12px;
  background: var(--viz-surface);
  box-shadow: none;
}

.shopee-page .filter-bar.slim {
  padding: 10px 12px;
  background: #fbfbf9;
}

.shopee-page .metric-tabs {
  display: flex;
  gap: 4px;
  margin: 12px 0;
  padding: 3px;
  border: 1px solid var(--viz-hairline);
  border-radius: 9px;
  background: #f2f2ef;
  width: fit-content;
}

.shopee-page .metric-tab {
  padding: 6px 14px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--viz-ink-2);
  font-size: 12.5px;
  font-weight: 620;
  cursor: pointer;
}

.shopee-page .metric-tab.active {
  background: var(--viz-surface);
  color: var(--viz-ink);
  box-shadow: 0 1px 2px rgba(11, 11, 11, 0.08);
}

.shopee-page .subsection-head {
  margin: 26px 0 10px;
}

@media (max-width: 1280px) {
  .shopee-page .overall-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .shopee-page .kpi-grid.compact-kpis {
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .shopee-page .overall-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .shopee-page .kpi-grid.compact-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .shopee-page .viz-tip {
    transition: none;
  }
}
