/* ==========================================================================
   Analytics, consent banner, cookie settings and seller marketing.
   Chart colours: validated categorical slots 1-2 (dark steps) against the
   chart palette (blue and orange) chosen to read on both light and dark panels.
   ========================================================================== */
:root {
  --viz-s1: #3987e5; /* blue */
  --viz-s2: #d95926; /* orange */
  --viz-grid: var(--line);
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ---- Cookie banner ------------------------------------------------------- */
.consent { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 60; display: flex; justify-content: center; pointer-events: none; }
.consent-inner { pointer-events: auto; width: min(980px, 100%); margin: 0; display: flex; gap: 20px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: var(--bg-2); border: 1px solid var(--line-2); border-top: 2px solid var(--accent); border-radius: var(--radius); padding: 18px 20px; box-shadow: 0 18px 48px rgba(70, 50, 35, 0.12); }
.consent-copy { flex: 1 1 420px; }
.consent-copy strong { display: block; font-family: var(--font-display); font-size: 0.98rem; margin-bottom: 4px; }
.consent-copy p { margin: 0; color: var(--muted); font-size: 0.88rem; }
.consent-copy p strong { display: inline; font-family: var(--font-body); font-size: inherit; color: var(--ink); margin: 0; }
.consent-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 560px) {
  .consent { left: 8px; right: 8px; bottom: 8px; }
  .consent-actions { width: 100%; }
  .consent-actions .btn { flex: 1; }
}

/* ---- Cookie settings page ----------------------------------------------- */
.consent-status .badge { margin-right: 4px; }
.cookie-cat { padding: 16px 0; border-bottom: 1px solid var(--line); }
.cookie-cat:first-of-type { padding-top: 0; }
.cookie-cat h2 { margin-bottom: 6px; }
.cookie-cat p { margin: 0; max-width: 62ch; }
.cookie-cat-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.toggle-row { font-weight: 400; margin: 0; cursor: pointer; }
.switch { position: relative; flex-shrink: 0; width: 48px; height: 28px; margin-top: 2px; }
.switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--bg-3); border: 1px solid var(--line-2); transition: background 0.15s, border-color 0.15s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: transform 0.15s, background 0.15s; }
.switch input:checked + span { background: var(--accent-soft); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); background: var(--accent); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Filters & KPI tiles ----------------------------------------------- */
.an-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.an-filters .muted { margin-left: 6px; }
.an-kpis .stat .value { font-family: var(--font-body); font-weight: 650; font-variant-numeric: proportional-nums; letter-spacing: -0.02em; }
.an-delta { margin-top: 6px; font-size: 0.8rem; display: flex; gap: 6px; align-items: center; color: var(--muted); }
.an-delta.up { color: var(--ok); }
.an-delta.down { color: var(--danger); }
.an-delta span { font-size: 0.7rem; }
.an-hint { margin-top: 4px; font-size: 0.86rem; color: var(--muted); line-height: 1.35; }

.an-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 18px; }
.an-charts .panel + .panel { margin-top: 0; }
.an-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.an-two > .panel + .panel { margin-top: 0; }
@media (max-width: 900px) { .an-charts, .an-two { grid-template-columns: 1fr; } }

/* Source tables with a share bar */
.an-sources td { font-variant-numeric: tabular-nums; }
.an-bar-col { width: 40%; }
.an-bar-col .small { margin-left: 8px; display: inline-block; min-width: 3ch; }
.an-bar { display: inline-block; vertical-align: middle; width: calc(100% - 48px); height: 8px; border-radius: 999px; background: var(--bg-3); overflow: hidden; }
.an-bar span { display: block; height: 100%; background: var(--viz-s1); border-radius: 999px; }

.an-events td { vertical-align: top; }
.an-props { font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted); max-width: 320px; word-break: break-all; }

/* ---- Charts ------------------------------------------------------------- */
.viz { margin: 0; }
.viz-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.viz-title { font-family: var(--font-display); font-weight: 700; font-size: 1rem; letter-spacing: -0.02em; }
.viz-legend { list-style: none; margin: 0; padding: 0; display: flex; gap: 14px; font-size: 0.82rem; color: var(--muted); }
.viz-legend li { display: inline-flex; align-items: center; gap: 6px; }
.viz-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.viz-swatch.viz-s1 { background: var(--viz-s1); }
.viz-swatch.viz-s2 { background: var(--viz-s2); }
.viz-empty { padding: 48px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line-2); border-radius: var(--radius-sm); margin-top: 10px; }

.viz-svg { width: 100%; height: auto; display: block; overflow: visible; font-family: var(--font-body); }
.viz-svg text { fill: var(--muted); font-size: 11px; }
.viz-grid line { stroke: var(--viz-grid); stroke-width: 1; shape-rendering: crispEdges; }
.viz-grid text, .viz-x text { font-family: var(--font-mono); font-size: 10.5px; fill: var(--faint); font-variant-numeric: tabular-nums; }
.viz-x line { stroke: var(--line-2); stroke-width: 1; shape-rendering: crispEdges; }

path.viz-s1, tspan.viz-s1 { fill: var(--viz-s1); }
path.viz-s2, tspan.viz-s2 { fill: var(--viz-s2); }
.viz-bar { transition: filter 0.12s; }
.viz-hit { fill: transparent; }
.viz-col { cursor: default; outline: none; }
.viz-col:hover .viz-bar, .viz-col:focus .viz-bar { filter: brightness(1.25); }
.viz-col:focus-visible .viz-hit { stroke: var(--accent); stroke-width: 1; }
.viz-guide { stroke: var(--line-2); stroke-width: 1; opacity: 0; shape-rendering: crispEdges; }
.viz-col:hover .viz-guide, .viz-col:focus .viz-guide { opacity: 1; }

.viz-tip, .viz-default { transition: opacity 0.1s; }
.viz-tip { opacity: 0; pointer-events: none; }
.viz-tip rect { fill: var(--bg-3); stroke: var(--line-2); stroke-width: 1; }
.viz-col:hover .viz-tip, .viz-col:focus .viz-tip { opacity: 1; }
.viz-svg:has(.viz-col:hover) .viz-default, .viz-svg:has(.viz-col:focus) .viz-default { opacity: 0; }
.viz-svg .viz-tip-title { fill: var(--muted); font-size: 11px; }
.viz-svg .viz-v { fill: var(--ink); font-weight: 650; font-size: 13px; }
.viz-svg .viz-n { fill: var(--muted); font-size: 12px; }
.viz-svg .viz-key { font-size: 12px; }

.viz-table { margin-top: 10px; }
.viz-table summary { font-size: 0.82rem; font-weight: 500; color: var(--muted); }
.viz-table summary:hover { color: var(--ink); }
.viz-table .table-wrap { max-height: 280px; overflow: auto; margin-top: 8px; }

/* ---- Funnels ----------------------------------------------------------- */
.funnel { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 14px; }
.funnel-label { display: flex; justify-content: space-between; gap: 12px; font-size: 0.92rem; margin-bottom: 6px; }
.funnel-label strong { font-variant-numeric: tabular-nums; font-weight: 650; }
.funnel-track { height: 16px; background: var(--bg-3); border-radius: 0 4px 4px 0; overflow: hidden; }
.funnel-track span { display: block; height: 100%; background: var(--viz-s1); border-radius: 0 4px 4px 0; }
.funnel-meta { margin-top: 4px; }

/* ---- Seller marketing ------------------------------------------------- */
.mk-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.mk-grid > div > .panel + .panel { margin-top: 18px; }
@media (max-width: 900px) { .mk-grid { grid-template-columns: 1fr; } }
.copy-row { display: flex; gap: 8px; align-items: stretch; }
.copy-row input { font-family: var(--font-mono); font-size: 0.85rem; min-width: 0; }
.copy-row .btn { flex-shrink: 0; }
.btn.copied, .btn.copied:hover { background: var(--ok); color: var(--accent-ink); border-color: var(--ok); }
.mk-list { margin: 0 0 14px; padding-left: 20px; color: var(--muted); }
.mk-list li + li { margin-top: 6px; }
.mk-list strong { color: var(--ink); }
.mk-tips { margin: 0 0 12px; padding-left: 20px; }
.mk-tips li { color: var(--muted); }
.mk-tips li + li { margin-top: 8px; }
.mk-tips strong { color: var(--ink); }
.field-error { color: var(--danger); font-size: 0.84rem; margin: 6px 0 2px; }
input[aria-invalid="true"] { border-color: var(--danger); }
