:root {
  --ground: #f6f4f0;
  --paper: #ffffff;
  --oat: #ece6dc;
  --ink: #141414;
  --ink-2: #55524c;
  --ink-3: #87827a;
  --line: #e3ded5;
  --line-strong: #cfc8bc;
  --ty: #141414;
  --cmp: #b3a996;
  --goal: #6d7f91;
  --good: #2f7a4b;
  --bad: #b4382f;
  --good-bg: #e6f0e9;
  --bad-bg: #f6e4e1;
  --banner: #efe7d6;
  --font: "Hanken Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #121211; --paper: #1b1b19; --oat: #26241f; --ink: #f2efe9; --ink-2: #bcb6ab; --ink-3: #8a857c;
    --line: #2d2b27; --line-strong: #3d3a34; --ty: #f2efe9; --cmp: #8a7f6b; --goal: #93a5b8;
    --good: #62c28a; --bad: #ee7065; --good-bg: #1c2c22; --bad-bg: #33201d; --banner: #2a261d;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #121211; --paper: #1b1b19; --oat: #26241f; --ink: #f2efe9; --ink-2: #bcb6ab; --ink-3: #8a857c;
  --line: #2d2b27; --line-strong: #3d3a34; --ty: #f2efe9; --cmp: #8a7f6b; --goal: #93a5b8;
  --good: #62c28a; --bad: #ee7065; --good-bg: #1c2c22; --bad-bg: #33201d; --banner: #2a261d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--ground); color: var(--ink); font: 400 14px/1.45 var(--font); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.wrap { max-width: 1320px; margin: 0 auto; padding-inline: 24px; }
@media (max-width: 640px) { .wrap { padding-inline: 16px; } }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Masthead */
.masthead { background: var(--paper); border-bottom: 1px solid var(--line); }
.masthead-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 18px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 14px; }
.wordmark { font-weight: 700; font-size: 20px; letter-spacing: 0.26em; }
.brand-sub { font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-3); border-left: 1px solid var(--line-strong); padding-left: 14px; }
.masthead-meta { display: flex; gap: 14px; align-items: center; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.view-label { text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600; color: var(--ink); }
.sample-banner { background: var(--banner); font-size: 13px; }
.sample-banner .wrap { padding-block: 8px; }

/* Controls */
.controls { position: static; top: env(safe-area-inset-top, 0px); z-index: 10; background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.controls .wrap { display: grid; gap: 10px; padding-block: 12px; }
.controls-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; }
.seg { display: inline-flex; flex-wrap: wrap; max-width: 100%; border: 1px solid var(--ink); }
.seg button { border: 0; background: transparent; padding: 7px 14px; font-size: 12px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg button:hover:not([aria-pressed="true"]) { background: var(--oat); }
.seg.small { border-color: var(--line-strong); }
.seg.small button { padding: 5px 10px; font-size: 11px; }
.seg.small button + button { border-left-color: var(--line-strong); }
.field { display: grid; gap: 3px; min-width: 0; }
.field > span { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.field.inline { display: flex; align-items: center; gap: 8px; }
.field .to { font-size: 12px; color: var(--ink-3); letter-spacing: 0; text-transform: none; font-weight: 400; }
select, input[type="date"] { background: var(--paper); border: 1px solid var(--line-strong); border-radius: 0; padding: 6px 8px; font-size: 13px; min-width: 0; max-width: 100%; }
select:hover, input[type="date"]:hover { border-color: var(--ink-2); }
.selectors .field { flex: 1 1 130px; }
.selectors .field select, .selectors .field input { width: 100%; }
.reset { background: none; border: 0; border-bottom: 1px solid var(--ink); padding: 4px 0; font-size: 12px; cursor: pointer; align-self: center; white-space: nowrap; }
.reset:hover { color: var(--ink-2); }
.exports { display: flex; gap: 8px; align-self: center; margin-left: auto; }
.export { background: var(--ink); color: var(--paper); border: 1px solid var(--ink); padding: 6px 12px; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600; cursor: pointer; white-space: nowrap; }
.export:hover { background: var(--ink-2); border-color: var(--ink-2); }
.export:disabled { opacity: 0.6; cursor: progress; }

main.wrap { display: grid; gap: 20px; padding-block: 12px 40px; }
.tabbar { display: grid; gap: 10px; padding-block: 16px 0; }
.tabs { display: flex; gap: 28px; border-bottom: 1px solid var(--line-strong); overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: 8px 0 10px; font-size: 12px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs button:hover { color: var(--ink); }
.tab-note { margin: 0; font-size: 12.5px; color: var(--ink-2); background: var(--oat); padding: 10px 14px; }
.tab-note:empty { display: none; }
.kpis.kpis-5 { display: flex; flex-wrap: wrap; }
.kpis.kpis-5 > .kpi { flex: 1 1 210px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; align-items: start; }
@media (max-width: 980px) { .grid-3 { grid-template-columns: 1fr; } }
.funnel { display: grid; gap: 10px; }
.funnel .step { display: grid; grid-template-columns: 130px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.funnel .bar { height: 22px; background: var(--oat); position: relative; }
.funnel .bar span { position: absolute; inset: 0 auto 0 0; background: var(--ty); }
.funnel .rate { font-size: 12px; color: var(--ink-2); text-align: right; white-space: nowrap; }
.heat { display: grid; grid-template-columns: 44px repeat(24, minmax(22px, 1fr)); gap: 2px; font-size: 10.5px; min-width: 640px; }
.heat .hd { color: var(--ink-3); text-align: center; }
.heat .rl { color: var(--ink-2); display: flex; align-items: center; }
.heat .c { height: 22px; background: var(--ty); }
.bar-cell { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.bar-cell .b { flex: 1; height: 6px; background: var(--oat); position: relative; min-width: 60px; }
.bar-cell .b span { position: absolute; inset: 0 auto 0 0; background: var(--ty); }
.pill { display: inline-block; font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700; padding: 2px 6px; background: var(--oat); color: var(--ink-2); }
.pill.live { background: var(--good-bg); color: var(--good); }
td .thumb-s { width: 30px; aspect-ratio: 3 / 4; object-fit: cover; vertical-align: middle; margin-right: 8px; background: var(--oat); }
.conv-figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 22px; }
.conv-figs .lbl { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.conv-figs .val { font-size: 24px; font-weight: 600; line-height: 1.2; }
.conv-figs .sub { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.range-line { margin: 0; font-size: 13px; color: var(--ink-2); }
.range-line strong { color: var(--ink); font-weight: 600; }

/* KPIs */
.kpis { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); }
@media (max-width: 980px) { .kpis { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .kpis { grid-template-columns: 1fr; } }
.kpi { background: var(--paper); padding: 18px 20px; display: grid; gap: 6px; align-content: start; }
.kpi h3 { margin: 0; font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.kpi .value { font-size: 30px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.1; }
.kpi-lead .value { font-size: 40px; }
.value-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.vs-goal, .vs-ly { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.vs-goal .delta { font-size: 13px; padding: 2px 8px; }
.kpi .sub { font-size: 12.5px; color: var(--ink-2); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-size: 12px; padding: 1px 6px; }
.delta.good { color: var(--good); background: var(--good-bg); }
.delta.bad { color: var(--bad); background: var(--bad-bg); }
.delta.flat { color: var(--ink-2); background: var(--oat); }
.goalbar { margin-top: 6px; display: grid; gap: 5px; }
.goalbar .track { position: relative; height: 6px; background: var(--oat); }
.goalbar .fill { position: absolute; inset: 0 auto 0 0; background: var(--ty); }
.goalbar .mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--goal); }
.goalbar .labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); gap: 8px; }

/* Panels */
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }
.panel { background: var(--paper); border: 1px solid var(--line); padding: 18px 20px; display: grid; gap: 12px; align-content: start; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px 16px; flex-wrap: wrap; }
.panel h2 { margin: 0; font-size: 13px; letter-spacing: 0.18em; text-transform: uppercase; font-weight: 700; }
.panel-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.panel-note { margin: 0; font-size: 12.5px; color: var(--ink-2); }
.sort { background: none; border: 1px solid var(--line-strong); padding: 5px 10px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; cursor: pointer; }
.sort:hover { border-color: var(--ink-2); }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); text-decoration: underline; cursor: pointer; }
.check { font-size: 12.5px; color: var(--ink-2); display: flex; gap: 6px; align-items: center; cursor: pointer; }
.empty { color: var(--ink-3); font-size: 13px; padding: 18px 0; list-style: none; }

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 6px; }
.legend i.dash { background: repeating-linear-gradient(90deg, var(--goal) 0 4px, transparent 4px 7px) !important; }
.chart-box { position: relative; height: 300px; }
.table-toggle summary { cursor: pointer; font-size: 12px; color: var(--ink-2); }
.scroll-x { overflow-x: auto; }

/* International */
.intl { list-style: none; margin: 0; padding: 0; display: grid; }
.intl li { display: grid; grid-template-columns: 26px 1fr auto; gap: 4px 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.intl li:first-child { border-top: 0; }
.flag { width: 24px; height: 18px; object-fit: cover; box-shadow: 0 0 0 1px var(--line); display: block; }
.flag-emoji { font-size: 18px; line-height: 18px; }
.intl .name { font-weight: 500; }
.intl .amt { text-align: right; font-weight: 600; }
.intl .bar { grid-column: 2 / 4; height: 3px; background: var(--oat); position: relative; }
.intl .bar span { position: absolute; inset: 0 auto 0 0; background: var(--ty); }
.intl .meta { grid-column: 2 / 4; display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3); gap: 8px; }

/* Redo */
.panel h2 { display: flex; align-items: center; gap: 8px; }
.redo-mark { width: 22px; height: 22px; display: block; }
.redo-figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px 24px; }
.redo-figs .lbl { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.redo-figs .val { font-size: 24px; font-weight: 600; line-height: 1.2; }
.redo-figs .sub { font-size: 12px; color: var(--ink-2); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 2px; }

/* Products */
.products { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px 14px; }
.product { display: grid; gap: 6px; align-content: start; }
.product .img { position: relative; aspect-ratio: 3 / 4; background: var(--oat); overflow: hidden; max-width: 100%; }
.product .img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.product .rank { position: absolute; top: 0; left: 0; background: var(--paper); color: var(--ink); font-size: 11px; font-weight: 700; padding: 3px 7px; letter-spacing: 0.06em; }
.product .tag { position: absolute; bottom: 6px; left: 6px; background: color-mix(in srgb, var(--paper) 88%, transparent); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; padding: 2px 6px; font-weight: 600; }
.product .pname { font-size: 12.5px; font-weight: 500; line-height: 1.3; text-transform: uppercase; letter-spacing: 0.03em; }
.product .pname a { color: inherit; text-decoration: none; }
.product .pname a:hover { text-decoration: underline; }
.product .sku { font-size: 11px; color: var(--ink-3); }
.product .nums { display: flex; justify-content: space-between; gap: 6px; font-size: 13px; align-items: baseline; flex-wrap: wrap; }
.product .nums strong { font-size: 15px; font-weight: 600; }
.product .nums span { color: var(--ink-2); font-size: 12px; }

.returns { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 0 28px; }
@media (max-width: 520px) { .returns { grid-template-columns: 1fr; } }
.returns li { display: grid; grid-template-columns: 22px 44px 1fr auto; gap: 12px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.returns .rk { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.returns .thumb { width: 44px; aspect-ratio: 3 / 4; background: var(--oat); overflow: hidden; }
.returns .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.returns .pname { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.03em; font-weight: 500; line-height: 1.3; }
.returns .sku { font-size: 11px; color: var(--ink-3); }
.returns .fig { text-align: right; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.returns .fig strong { display: block; font-size: 15px; color: var(--ink); font-weight: 600; }

/* Tables */
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; border-bottom-color: var(--line-strong); }
thead th button { all: unset; cursor: pointer; }
thead th button:hover, thead th button[aria-sort] { color: var(--ink); }
tfoot td { font-weight: 700; border-top: 1px solid var(--line-strong); border-bottom: 0; }
td .chan { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); margin-left: 6px; }
.pos { color: var(--good); } .neg { color: var(--bad); }

.foot { font-size: 12px; color: var(--ink-3); }

@media (min-width: 1100px) { .controls { position: sticky; } }
@media (max-width: 640px) { .kpi-lead .value { font-size: 32px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Print / Save as PDF: the report, without the controls */
@media print {
  @page { size: letter landscape; margin: 12mm; }
  :root { --ground: #fff; --paper: #fff; --oat: #efebe4; --ink: #111; --ink-2: #444; --ink-3: #777; --line: #ddd; --line-strong: #bbb; --ty: #111; --cmp: #a89e8b; --goal: #5e7082; color-scheme: light; }
  body { background: #fff; font-size: 11px; }
  .controls, .sample-banner, .sort, .seg, .panel-tools, .check, .table-toggle summary, #intlShow, .tabs { display: none !important; }
  .table-toggle[open] > div, .table-toggle > div { display: block; }
  .wrap { max-width: none; padding-inline: 0; }
  .masthead { border: 0; }
  main.wrap { gap: 12px; padding-block: 8px 0; }
  .panel, .kpis { break-inside: avoid; box-shadow: none; }
  .products { grid-template-columns: repeat(6, 1fr); gap: 10px 8px; }
  .product { break-inside: avoid; }
  .returns { grid-template-columns: 1fr 1fr; }
  .chart-box { height: 240px; }
  a { color: inherit; text-decoration: none; }
}

/* Sign-in screen */
body.auth-locked > :not(.auth-gate):not(script) { display: none !important; }
.auth-gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--ground); }
.auth-card { background: var(--paper); border: 1px solid var(--line); padding: 36px 32px; max-width: 380px; width: 100%; display: grid; gap: 12px; text-align: center; justify-items: center; }
.auth-title { margin: 0; font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.auth-text { margin: 8px 0 4px; color: var(--ink-2); }
.auth-btn { padding: 10px 18px; font-size: 12px; }
.auth-msg { margin: 4px 0 0; font-size: 12.5px; color: var(--bad); }
.account { font-size: 12px; color: var(--ink-2); }
