/* Omni (All Channels) dashboard — scoped overrides.
   Loaded after styles.css; every rule is prefixed .omni-page so the Shopee,
   Lazada and TikTok pages are untouched.

   Series colors come from the validated default dataviz palette (see the
   dataviz skill, references/palette.md). Do not hand-pick replacements —
   re-run scripts/validate_palette.js if a slot has to change. */

.omni-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);

  /* categorical slots */
  --s-gmv: #2a78d6; /* slot 1 */
  --s-cost: #eb6834; /* slot 2 */
  --s-roas: #008300; /* slot 6 — its own single-series plot */

  --ch-shopee: #2a78d6; /* slot 1 */
  --ch-tiktok: #eb6834; /* slot 2 */
  --ch-lazada: #1baf7a; /* slot 3 — sub-3:1, always direct-labeled */

  --viz-deemph: #c9c8c1; /* sparkline de-emphasis */
  --viz-good: #006300; /* delta up, 7.54:1 as text */
  --viz-bad: #d03b3b; /* delta down, 4.80:1 as text */

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

/* ---------- filter row + coverage ---------- */

.omni-page .filter-bar.omni-filter {
  align-items: flex-end;
  gap: 18px;
}

.omni-page .omni-filter select {
  min-width: 172px;
}

.omni-page .coverage-note {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--viz-ink-2);
}

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

.omni-page .cov-chip i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.omni-page .cov-chip.is-partial {
  border-color: rgba(208, 59, 59, 0.35);
  color: var(--viz-bad);
}

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

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

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

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

.omni-page .omni-kpis .kpi-value {
  margin-top: 6px;
  font-size: 30px;
  line-height: 1.1;
  font-weight: 680;
  letter-spacing: -0.02em;
  color: var(--viz-ink);
  /* proportional figures on a standalone value — never tabular-nums here */
  font-variant-numeric: proportional-nums;
}

.omni-page .omni-kpis .kpi-sub {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--viz-ink-muted);
}

.omni-page .kpi-delta {
  font-weight: 640;
  font-variant-numeric: tabular-nums;
}

.omni-page .kpi-delta.up {
  color: var(--viz-good);
}

.omni-page .kpi-delta.down {
  color: var(--viz-bad);
}

.omni-page .kpi-delta.flat {
  color: var(--viz-ink-muted);
}

.omni-page .kpi-spark {
  margin-top: auto;
  padding-top: 12px;
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.omni-page .kpi-spark .spark-line {
  fill: none;
  stroke: var(--viz-deemph);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.omni-page .kpi-spark .spark-dot {
  fill: var(--s-gmv);
  stroke: var(--viz-surface);
  stroke-width: 2; /* surface ring */
}

/* ---------- panels ---------- */

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

.omni-page .viz-panel {
  padding: 18px 20px 14px;
}

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

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

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

/* legend — always present for >= 2 series */
.omni-page .viz-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12.5px;
  color: var(--viz-ink-2);
}

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

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

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

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

/* ---------- trend chart (two stacked plots, one y-scale each) ---------- */

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

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

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

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

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

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

.omni-page .viz-svg .bar-gmv {
  fill: var(--s-gmv);
}

.omni-page .viz-svg .bar-cost {
  fill: var(--s-cost);
}

.omni-page .viz-svg .roas-line {
  fill: none;
  stroke: var(--s-roas);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

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

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

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

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

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

.omni-page .viz-tip {
  position: absolute;
  z-index: 20;
  min-width: 250px;
  padding: 11px 14px;
  white-space: nowrap;
  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);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s ease;
}

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

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

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

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

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

/* ---------- two panels side by side (channel split + channel table) ------- */

.omni-page .section.omni-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.omni-page .omni-pair > .panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* The table sits in half the width now — drop the wide min-width and let the
   four columns fit, so nothing scrolls sideways inside the card. */
.omni-page .omni-pair .table-wrap {
  margin-top: auto;
  border: 0;
  border-radius: 0;
  overflow-x: auto;
}

.omni-page .omni-pair table.omni-table {
  min-width: 0;
}

.omni-page .omni-pair .omni-table th {
  padding: 10px 10px 10px 0;
}

.omni-page .omni-pair .omni-table td {
  padding: 12px 10px 12px 0;
}

.omni-page .omni-pair .omni-table th:first-child,
.omni-page .omni-pair .omni-table td:first-child {
  padding-left: 0;
}

.omni-page .omni-pair .omni-table th:last-child,
.omni-page .omni-pair .omni-table td:last-child {
  padding-right: 0;
}

/* ---------- channel split ---------- */

.omni-page .split-list {
  display: grid;
  gap: 2px;
  margin-top: 10px;
}

.omni-page .split-row {
  display: grid;
  grid-template-columns: 186px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 11px 8px;
  border-radius: 8px;
  cursor: default;
}

.omni-page .split-row:hover {
  background: rgba(11, 11, 11, 0.025);
}

.omni-page .split-name {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 640;
  font-size: 13.5px;
  color: var(--viz-ink);
}

.omni-page .split-track {
  position: relative;
  height: 20px;
  border-radius: 0;
  background: none;
}

.omni-page .split-track i {
  position: absolute;
  inset: 0 auto 0 0;
  display: block;
  border-radius: 0 4px 4px 0; /* rounded data-end, square at baseline */
  background: currentColor;
}

.omni-page .split-value {
  min-width: 96px;
  text-align: right;
  font-size: 13.5px;
  font-weight: 680;
  color: var(--viz-ink);
  font-variant-numeric: tabular-nums;
}

.omni-page .split-meta {
  margin-top: 3px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--viz-ink-muted);
  white-space: nowrap;
}

/* ---------- channel dot ---------- */

.omni-page .ch-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
  display: inline-block;
}

.omni-page .ch-shopee {
  color: var(--ch-shopee);
  background: var(--ch-shopee);
}

.omni-page .ch-tiktok {
  color: var(--ch-tiktok);
  background: var(--ch-tiktok);
}

.omni-page .ch-lazada {
  color: var(--ch-lazada);
  background: var(--ch-lazada);
}

.omni-page .split-track i.ch-shopee,
.omni-page .split-track i.ch-tiktok,
.omni-page .split-track i.ch-lazada {
  background: currentColor;
}

/* ---------- tables ---------- */

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

.omni-page table.omni-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.omni-page .omni-table th {
  padding: 12px 18px;
  border-bottom: 1px solid var(--viz-grid);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--viz-ink-muted);
  text-align: right;
  white-space: nowrap;
}

.omni-page .omni-table th:first-child,
.omni-page .omni-table th.col-text {
  text-align: left;
}

.omni-page .omni-table td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--viz-grid);
  font-size: 13.5px;
  text-align: right;
  color: var(--viz-ink);
  vertical-align: middle;
}

.omni-page .omni-table td.col-text {
  text-align: left;
  color: var(--viz-ink-2);
}

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

/* identity comes from a colored chip, never a row wash */
.omni-page .omni-table tr.channel-row {
  background: none;
}

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

.omni-page .cell-main {
  font-weight: 660;
  font-variant-numeric: tabular-nums;
}

.omni-page .cell-delta {
  margin-top: 2px;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.omni-page .cell-delta.up {
  color: var(--viz-good);
}

.omni-page .cell-delta.down {
  color: var(--viz-bad);
}

.omni-page .cell-delta.flat {
  color: var(--viz-ink-muted);
}

.omni-page .th-sub {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--viz-ink-muted);
  text-transform: none;
}

/* ---------- remarks + source ---------- */

.omni-page .omni-remarks {
  display: grid;
  gap: 7px;
  margin: 0 0 14px;
  padding: 14px 18px;
  border: 1px solid var(--viz-hairline);
  border-radius: 12px;
  background: var(--viz-surface);
  color: var(--viz-ink-2);
  font-size: 13px;
  line-height: 1.5;
}

.omni-page .omni-source {
  padding: 16px 20px;
  color: var(--viz-ink-muted);
  font-size: 12.5px;
  line-height: 1.55;
}

.omni-page .section-head {
  margin-bottom: 14px;
}

/* while data reloads: hold the previous render, no skeleton flash */
.omni-page .is-refetching {
  opacity: 0.45;
  transition: opacity 0.15s ease;
}

@media (max-width: 1180px) {
  .omni-page .kpi-grid.omni-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .omni-page .section.omni-pair {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 720px) {
  .omni-page .kpi-grid.omni-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .omni-page .split-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 12px;
  }

  .omni-page .split-track {
    grid-column: 1 / -1;
    order: 3;
  }
}

@media (prefers-reduced-motion: reduce) {
  .omni-page .viz-tip,
  .omni-page .is-refetching {
    transition: none;
  }
}
