/* Achromatic ledger: white surfaces, ink text, grey hairlines. The only hue is Golfkuponger green on the main data series
   and a small good/bad signal on changes. Open-plane shell: white sidebar, no top bar, title row on the canvas. */
:root {
  color-scheme: light;
  --ground: #fafafa;
  --surface: #ffffff;
  --raised: #f4f4f5;
  --active: #ededee;
  --border: #e6e6e6;
  --rule: #f0f0f0;
  --control: #d4d4d4;
  --text: #0a0a0a;
  --muted: #5f6368;
  --faint: #6b6b6b;
  --primary: #141414;
  --data: #1f6b47;
  --data-soft: rgb(31 107 71 / .12);
  --compare: #a3a3a3;
  --positive: #247b50;
  --negative: #c4242a;
  --pill-positive-bg: #dcfae5; --pill-positive-ink: #04250e;
  --pill-negative-bg: #ffedea; --pill-negative-ink: #831c1e;
  --pill-neutral-bg: #eeeeee; --pill-neutral-ink: #3d3d3d;
  --notice-bg: #fffbeb; --notice-border: #fde68a; --notice-ink: #92400e;
  --grid: #ededed;
  /* series: friskvård in brand green, the other groups and platforms in their own quiet hues */
  --friskvard: #1f6b47;
  --webbshop: #d4891c;
  --foretag: #7b8aa0;
  --google: #2f6fd1;
  --meta: #e2703a;
  --fmt-image-bg: #fdf7dd; --fmt-image-ink: #6f5300;
  --fmt-video-bg: #eee8fb; --fmt-video-ink: #5631a3;
  --radius-card: 8px;
  --radius-control: 6px;
  --gap: 16px;
  --font: 'Geist', Inter, system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #0a0a0a; --surface: #111111; --raised: #1a1a1a; --active: #222222;
    --border: #262626; --rule: #1c1c1c; --control: #3d3d3d;
    --text: #fafafa; --muted: #b4b4b4; --faint: #949494; --primary: #fafafa;
    --data: #4cc38a; --data-soft: rgb(76 195 138 / .14); --compare: #6b6b6b;
    --positive: #4cc38a; --negative: #f07178;
    --pill-positive-bg: #172a1d; --pill-positive-ink: #4cc38a; --pill-negative-bg: #2c1a20; --pill-negative-ink: #f07178;
    --pill-neutral-bg: #222222; --pill-neutral-ink: #d4d4d4;
    --notice-bg: #2a2410; --notice-border: #4a3f14; --notice-ink: #f2c66d;
    --grid: #222222; --friskvard: #4cc38a; --webbshop: #e6a54a; --foretag: #95a3b8; --google: #6b9cf0; --meta: #f08a5d;
  --fmt-image-bg: #2a2410; --fmt-image-ink: #f0cd6a; --fmt-video-bg: #251c3a; --fmt-video-ink: #b9a0f2;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #0a0a0a; --surface: #111111; --raised: #1a1a1a; --active: #222222;
  --border: #262626; --rule: #1c1c1c; --control: #3d3d3d;
  --text: #fafafa; --muted: #b4b4b4; --faint: #949494; --primary: #fafafa;
  --data: #4cc38a; --data-soft: rgb(76 195 138 / .14); --compare: #6b6b6b;
  --positive: #4cc38a; --negative: #f07178;
  --pill-positive-bg: #172a1d; --pill-positive-ink: #4cc38a; --pill-negative-bg: #2c1a20; --pill-negative-ink: #f07178;
  --pill-neutral-bg: #222222; --pill-neutral-ink: #d4d4d4;
  --notice-bg: #2a2410; --notice-border: #4a3f14; --notice-ink: #f2c66d;
  --grid: #222222; --friskvard: #4cc38a; --webbshop: #e6a54a; --foretag: #95a3b8; --google: #6b9cf0; --meta: #f08a5d;
  --fmt-image-bg: #2a2410; --fmt-image-ink: #f0cd6a; --fmt-video-bg: #251c3a; --fmt-video-ink: #b9a0f2;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--ground); color: var(--text); font: 14px/20px var(--font); -webkit-font-smoothing: antialiased; font-feature-settings: 'tnum' 1; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
select, input, button { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12px; line-height: 16px; }
svg.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* Brand: the Golfkuponger.se logo, with the product's name under it in the sidebar */
.brand { display: grid; gap: 6px; justify-items: start; color: var(--text); text-decoration: none; }
.brand img { display: block; width: 196px; height: auto; }
.brand small { font-size: 12px; line-height: 16px; color: var(--muted); padding-left: 2px; }
.login-logo { display: block; width: 220px; height: auto; }

/* Login */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--ground); }
.login-card { width: min(400px, 100%); display: grid; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 28px; }
.login-card h1 { margin: 12px 0 0; font-size: 20px; line-height: 28px; font-weight: 600; }
.login-card p { margin: 0; }
.login-card label { margin-top: 6px; font-weight: 500; }
.login-card input { border: 1px solid var(--control); border-radius: var(--radius-control); padding: 8px 12px; background: var(--surface); height: 40px; }
.primary { background: var(--primary); color: var(--surface); border: 0; border-radius: var(--radius-control); height: 40px; padding: 0 16px; font-weight: 500; }
.error { color: var(--negative); }
.notice { margin: 0; padding: 10px 14px; border-radius: var(--radius-control); background: var(--notice-bg); border: 1px solid var(--notice-border); color: var(--notice-ink); font-size: 13px; }
.notice.boot { margin: 24px; }

/* Shell: white sidebar with one hairline, canvas on the ground */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; display: flex; flex-direction: column; gap: 20px; }
.sidebar > .brand { padding: 4px 8px; }
.nav-group { display: grid; gap: 2px; }
.nav-group + .nav-group { margin-top: 20px; }
.nav-label { margin: 0 0 6px 10px; font-size: 12px; line-height: 16px; color: var(--muted); }
.nav-item { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; border-radius: var(--radius-control); color: var(--muted); text-decoration: none; font-size: 14px; border: 0; background: none; width: 100%; text-align: left; }
.nav-item:hover { background: var(--raised); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--active); color: var(--text); font-weight: 500; }
.sidebar-foot { margin-top: auto; display: grid; gap: 12px; padding-top: 12px; border-top: 1px solid var(--rule); }
#freshness { display: grid; gap: 6px; padding: 0 10px; font-size: 12px; line-height: 16px; color: var(--muted); }
.src { display: flex; align-items: center; gap: 8px; }
.src::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--compare); flex: none; }
.src.ok::before { background: var(--positive); }
.src.warn::before { background: #d4a017; }
.src.bad::before { background: var(--negative); }

.main { min-width: 0; display: flex; flex-direction: column; }
.title-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 4px 16px; width: 100%; max-width: 1280px; margin: 0 auto; padding: 32px 32px 0; }
.title-text { min-width: 0; }
.title-row h1 { margin: 0; font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -.01em; }
.title-row .sub { margin: 4px 0 0; font-size: 14px; line-height: 20px; color: var(--muted); max-width: 72ch; }
.title-row .meta { grid-column: 1 / -1; margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12px; line-height: 16px; color: var(--muted); }
.title-row .meta strong { color: var(--text); font-weight: 500; }
.controls { display: flex; align-items: center; gap: 8px; }
.period select { appearance: none; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%235f6368' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 12px center; border: 1px solid var(--control); border-radius: var(--radius-control); padding: 0 32px 0 12px; height: 36px; font-size: 14px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-control); border: 1px solid var(--control); background: var(--surface); color: var(--muted); padding: 0; }
.icon-btn:hover { color: var(--text); border-color: var(--muted); }
.menu-btn { display: none; }
.content { width: 100%; max-width: 1280px; margin: 0 auto; padding: 24px 32px 64px; display: grid; gap: 32px; outline: none; }
.notice:not(.boot) { max-width: 1216px; margin: 16px auto 0; width: calc(100% - 64px); }
.content > *, .block > *, .card > *, .grid2 > * { min-width: 0; }

/* Sections and cards */
.block { display: grid; gap: 12px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 16px; flex-wrap: wrap; }
.block-head > div:first-child { min-width: 0; flex: 1 1 320px; }
.block-head h3 { margin: 0; font-size: 16px; line-height: 24px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.block-head p { margin: 2px 0 0; color: var(--muted); max-width: 80ch; }
.scope { font-size: 12px; line-height: 16px; color: var(--muted); white-space: nowrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 20px; display: grid; gap: 16px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: var(--gap); align-items: start; }

/* KPIs: one container split by hairlines */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; }
.kpi { padding: 16px 20px; display: flex; flex-direction: column; gap: 4px; min-width: 0; background: var(--surface); }
.kpi-label { margin: 0; font-size: 13px; line-height: 18px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi-value { margin: 2px 0 0; font-size: 24px; line-height: 32px; font-weight: 500; letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi.lead .kpi-value { font-size: 30px; line-height: 38px; font-weight: 700; }
.delta { margin: 0; font-size: 12px; line-height: 16px; color: var(--muted); font-variant-numeric: tabular-nums; }
.delta b { font-weight: 500; color: var(--text); }
.delta b.good { color: var(--positive); }
.delta b.bad { color: var(--negative); }
.foot { margin: auto 0 0; padding-top: 4px; font-size: 12px; line-height: 16px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; flex: none; vertical-align: 1px; }
.dot.google { background: var(--google); }
.dot.meta { background: var(--meta); }
.dot.friskvard { background: var(--friskvard); }
.dot.webbshop { background: var(--webbshop); }
.dot.foretag { background: var(--foretag); }

/* Findings: a plain list, colour only on the marker */
.insights { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); }
.insight { display: grid; grid-template-columns: 8px minmax(0, 1fr); gap: 14px; padding: 14px 20px; }
.insight + .insight { border-top: 1px solid var(--rule); }
.insight .mark-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: var(--compare); }
.insight.good .mark-dot { background: var(--positive); }
.insight.bad .mark-dot { background: var(--negative); }
.insight p { margin: 0; }
.insight strong { font-weight: 500; }
.insight span { display: block; color: var(--muted); }

/* Charts */
.chart-wrap { position: relative; height: 260px; }
.chart-wrap.short { height: 200px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; line-height: 16px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.legend i.dash { width: 14px; height: 2px; border-radius: 0; background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px); }
.chart-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12px; line-height: 16px; color: var(--muted); }
.seg { display: inline-flex; padding: 2px; border-radius: var(--radius-control); background: var(--raised); gap: 2px; }
.seg button { border: 0; background: none; padding: 0 10px; height: 28px; border-radius: 4px; font-size: 13px; color: var(--muted); }
.seg button { border: 1px solid transparent; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 500; border-color: var(--border); }

/* Tables */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
th { text-align: left; font-size: 12px; line-height: 16px; font-weight: 400; color: var(--muted); padding: 0 10px 8px; white-space: nowrap; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
th .sub { display: block; }
td { padding: 11px 10px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tr.total td { font-weight: 500; border-top: 1px solid var(--border); }
.n { text-align: right; white-space: nowrap; }
td .sub { display: block; font-size: 12px; line-height: 16px; color: var(--muted); }
td.good { color: var(--positive); }
td.bad { color: var(--negative); }
td.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 16px 0; }
.tag { display: inline-block; flex: none; white-space: nowrap; padding: 1px 8px; border-radius: 4px; background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); font-size: 12px; line-height: 18px; font-weight: 500; vertical-align: 1px; }
.tag.good { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.tag.bad { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.bar { position: relative; height: 6px; border-radius: 3px; background: var(--raised); min-width: 60px; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--text); }
.bar.data i { background: var(--data); }

/* Year table */
.years td { padding-block: 6px; }
.stat-cell { display: flex; align-items: center; gap: 2px; }
.stat { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px 0 0; border: 0; background: none; font-weight: 500; text-align: left; white-space: nowrap; }
.stat::after { content: ""; width: 6px; height: 6px; margin-left: 2px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg) translateY(-2px); }
.stat[aria-expanded="true"]::after { transform: rotate(-135deg) translate(-2px, 0); border-color: var(--text); }
.stat:hover { text-decoration: underline; text-underline-offset: 3px; }
.years tr.active td { background: var(--raised); }
.years tr.active td:first-child { box-shadow: inset 2px 0 0 var(--data); padding-left: 8px; }
.drill { display: grid; gap: 12px; padding-top: 20px; border-top: 1px solid var(--border); }
.drill h4 { margin: 0; font-size: 15px; line-height: 22px; font-weight: 600; display: flex; align-items: center; gap: 6px; }

/* Controls inside pages */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar input[type="search"], .toolbar select { border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--surface); padding: 0 12px; height: 36px; }
.toolbar input[type="search"] { flex: 1; min-width: 200px; max-width: 320px; }
.toolbar label.check { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.toolbar .spacer { flex: 1; }
.ghost { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--control); background: var(--surface); border-radius: var(--radius-control); height: 36px; padding: 0 12px; font-weight: 500; }
.ghost:hover { border-color: var(--muted); }

/* Explanations */
.info { display: inline-grid; place-items: center; width: 16px; height: 16px; padding: 0; border: 1px solid var(--control); border-radius: 50%; background: transparent; color: var(--muted); font: 600 10px/1 var(--font); cursor: help; flex: none; }
.info:hover, .info[aria-expanded="true"] { border-color: var(--text); color: var(--text); }
.tip { position: fixed; z-index: 50; max-width: min(320px, calc(100vw - 24px)); padding: 8px 10px; border-radius: var(--radius-control); background: var(--text); color: var(--surface); font: 400 13px/18px var(--font); box-shadow: 0 4px 16px rgb(0 0 0 / .12); pointer-events: none; }
.callout { display: flex; gap: 12px; padding: 12px 16px; border-radius: var(--radius-card); background: var(--raised); }
.callout svg { color: var(--muted); margin-top: 2px; }
.callout p { margin: 0; }
.defs { margin: 0; padding-left: 18px; display: grid; gap: 8px; max-width: 85ch; color: var(--muted); }
.defs strong { color: var(--text); font-weight: 500; }
code { font-size: 13px; background: var(--raised); padding: 1px 4px; border-radius: 4px; }

/* Narrow screens: the sidebar folds into a sheet behind a menu button */
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(290px, 86vw); transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: none; box-shadow: 0 8px 32px rgb(0 0 0 / .16); }
  .backdrop { position: fixed; inset: 0; z-index: 30; background: rgb(0 0 0 / .3); }
  .menu-btn { display: inline-grid; grid-row: 1; grid-column: 1; justify-self: start; margin-bottom: 8px; }
  .title-row { grid-template-columns: minmax(0, 1fr); padding: 16px 16px 0; }
  .title-text { grid-row: 2; }
  .controls { grid-row: 3; margin-top: 12px; }
  .period { flex: 1; }
  .period select { width: 100%; }
  .content { padding: 20px 16px 48px; gap: 28px; }
  .notice:not(.boot) { width: calc(100% - 32px); }
  .card { padding: 16px; }
  .kpi { padding: 14px 16px; }
  .chart-wrap { height: 220px; }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-value { font-size: 20px; line-height: 28px; }
  .kpi.lead .kpi-value { font-size: 26px; line-height: 34px; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* Grid helpers: KPI columns follow the item count; overview puts the findings in a fixed rail */
.kpis { grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--gap); align-items: start; }
.split > * { min-width: 0; }
.split > .block { gap: 8px; }
@media (max-width: 1180px) { .split { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 960px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpis.odd > .kpi.lead:first-child { grid-column: 1 / -1; } }
.split { align-items: stretch; }
.card.fill { grid-template-rows: auto auto minmax(260px, 1fr) auto; }
.card.fill .chart-wrap { height: auto; min-height: 260px; }
.card.fill .chart-wrap canvas { position: absolute; inset: 0; }

/* Strong or weak against last year: a quiet tint and a thin top edge in the same hue. */
.kpi { position: relative; }
.kpi.good { background: #f4faf6; }
.kpi.bad { background: #fdf5f4; }
.kpi.good::before, .kpi.bad::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; background: var(--positive); }
.kpi.bad::before { background: var(--negative); }
.kpi.good .kpi-value { color: #14532d; }
.kpi.bad .kpi-value { color: #7f1d1d; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .kpi.good { background: #13201a; }
  :root:not([data-theme="light"]) .kpi.bad { background: #23161a; }
  :root:not([data-theme="light"]) .kpi.good .kpi-value, :root:not([data-theme="light"]) .kpi.bad .kpi-value { color: var(--text); }
}
:root[data-theme="dark"] .kpi.good { background: #13201a; }
:root[data-theme="dark"] .kpi.bad { background: #23161a; }
:root[data-theme="dark"] .kpi.good .kpi-value, :root[data-theme="dark"] .kpi.bad .kpi-value { color: var(--text); }

/* Changes against last year: arrow and percent, weighted so they read at a glance */
td.change { font-weight: 500; }
td.change.muted { font-weight: 400; }
.delta b { font-weight: 600; }
.block-head p b.good { color: var(--positive); }
.block-head p b.bad { color: var(--negative); }
td .sub.delta-sub { font-weight: 500; }
td .sub.delta-sub.good { color: var(--positive); }
td .sub.delta-sub.bad { color: var(--negative); }
.platform { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.split > .block { align-content: start; }

/* Ads: creative miniature in the table and the ad dialog */
.ad-open { display: flex; align-items: center; gap: 12px; min-width: 240px; max-width: 360px; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; }
.ad-open:hover .ad-name-text { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--control); }
.ad-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ad-name .sub { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; line-height: 16px; color: var(--muted); }
.thumb { position: relative; flex: none; display: grid; place-items: center; width: 48px; height: 48px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--raised); }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb .text-ad { font-size: 13px; font-weight: 600; color: var(--google); }
.thumb.broken img, .ad-visual.broken img { visibility: hidden; }
.play { position: absolute; right: 4px; bottom: 4px; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: rgb(0 0 0 / .62); }
.play svg.i { width: 10px; height: 10px; fill: #fff; stroke: none; }
.ad-dialog { width: min(940px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); color: var(--text); box-shadow: 0 24px 64px rgb(0 0 0 / .2); overflow: hidden; }
.ad-dialog::backdrop { background: rgb(10 10 10 / .5); }
.ad-dialog-inner { display: grid; grid-template-columns: minmax(0, 1fr) 380px; max-height: calc(100dvh - 34px); }
.ad-stage { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 380px; padding: 24px; background: var(--raised); border-right: 1px solid var(--border); }
.ad-visual { position: relative; min-width: 120px; min-height: 120px; margin: 0; border-radius: var(--radius-control); overflow: hidden; background: var(--active); }
.ad-visual img { display: block; max-width: 100%; max-height: min(560px, calc(100dvh - 140px)); }
.ad-visual .play { right: 12px; bottom: 12px; width: 40px; height: 40px; }
.ad-visual .play svg.i { width: 18px; height: 18px; }
.ad-note { margin: 0; max-width: 460px; font-size: 12px; line-height: 16px; color: var(--muted); text-align: center; }
.serp { display: flex; flex-direction: column; gap: 2px; width: min(520px, 100%); padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); }
.serp-label { font-size: 12px; font-weight: 600; }
.serp-url { font-size: 12px; color: var(--muted); }
.serp-title { margin-top: 4px; font-size: 18px; line-height: 24px; color: var(--google); }
.serp p { margin: 4px 0 0; color: var(--muted); }
.ad-side { display: flex; flex-direction: column; gap: 18px; min-width: 0; padding: 20px 24px 24px; overflow-y: auto; }
.ad-side header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ad-side header .icon-btn { width: 32px; height: 32px; flex: none; }
.ad-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 6px; font-size: 12px; line-height: 16px; color: var(--muted); }
.ad-side h2 { margin: 0; font-size: 16px; line-height: 22px; font-weight: 600; overflow-wrap: anywhere; }
.ad-campaign { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.pill { display: inline-block; padding: 0 6px; border-radius: 4px; font-size: 12px; line-height: 18px; font-weight: 500; }
.pill.positive { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.pill.neutral { background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); }
.ad-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--border); }
.ad-stats div { padding: 8px 10px; background: var(--surface); }
.ad-stats dt { font-size: 12px; line-height: 16px; color: var(--muted); }
.ad-stats dd { margin: 2px 0 0; font-weight: 500; }
.ad-copy h4 { margin: 0 0 6px; font-size: 12px; line-height: 16px; font-weight: 400; color: var(--muted); }
.ad-copy h4 span { color: var(--faint); }
.ad-copy h4 + p, .ad-copy ul { margin: 0 0 14px; }
.ad-copy > :last-child { margin-bottom: 0; }
.ad-title { font-weight: 600; }
.ad-body { white-space: pre-line; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; list-style: none; }
.chips li { padding: 2px 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 13px; line-height: 18px; }
.lines { display: flex; flex-direction: column; gap: 8px; padding: 0; list-style: none; }
.lines li { padding-left: 10px; border-left: 2px solid var(--border); }
.ad-links { display: flex; flex-wrap: wrap; gap: 8px; }
.ad-links a { height: 32px; color: var(--text); text-decoration: none; font-size: 13px; }
@media (max-width: 760px) {
  .ad-dialog { overflow-y: auto; }
  .ad-dialog-inner { grid-template-columns: 1fr; max-height: none; }
  .ad-stage { min-height: 0; padding: 16px; border-right: 0; border-bottom: 1px solid var(--border); }
  .ad-visual img { max-height: 52dvh; }
  .ad-side { padding: 16px; overflow: visible; }
}

/* Ads table: filter, sort and summary */
.ad-toolbar { margin-bottom: 12px; }
.ad-toolbar .seg button { height: 30px; }
.toolbar label.field { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.ad-summary { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.ad-summary p { margin: 0; }
.good-text { color: var(--positive); font-weight: 500; }
.bad-text { color: var(--negative); font-weight: 500; }
button.link { padding: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 500; text-decoration: underline; text-decoration-color: var(--control); text-underline-offset: 3px; cursor: pointer; }
button.link:hover { text-decoration-color: currentColor; }
.th-sort { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: inherit; font: inherit; white-space: nowrap; cursor: pointer; }
.th-sort:hover, .th-sort.on { color: var(--text); }
.th-sort span { display: inline-block; min-width: 8px; }
.ad-table td.rank { width: 1%; color: var(--faint); }
@media (max-width: 760px) {
  .ad-toolbar input[type="search"] { max-width: none; min-width: 0; width: 100%; flex-basis: 100%; }
  .ad-toolbar label.field { flex-basis: 100%; min-width: 0; }
  .ad-toolbar label.field select { flex: 1; min-width: 0; width: 100%; }
}
.ad-table td.campaign { max-width: 150px; overflow-wrap: break-word; font-size: 13px; line-height: 18px; color: var(--muted); }

/* Ads: format chips, days run and the format filter */
.platform-name { display: inline-flex; align-items: center; gap: 6px; }
.ad-name .sub { flex-wrap: wrap; gap: 4px 8px; }
.fmt { display: inline-flex; align-items: center; gap: 4px; padding: 0 6px; border-radius: 4px; font-size: 12px; line-height: 18px; font-weight: 500; background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); }
.fmt svg.i { width: 11px; height: 11px; stroke-width: 2; }
.fmt-video svg.i { fill: currentColor; stroke: none; }
.fmt-bild { background: var(--fmt-image-bg); color: var(--fmt-image-ink); }
.fmt-video { background: var(--fmt-video-bg); color: var(--fmt-video-ink); }
.ad-meta .fmt { margin-left: 2px; }
td .sub.per-day { white-space: nowrap; }
td .sub.per-day.hl { color: var(--text); font-weight: 500; }
.ad-run { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.ad-table .ad-open { min-width: 220px; max-width: 320px; }
.ad-table td.campaign { max-width: 132px; }

/* Ads: best and worst right now */
.ad-count { font-size: 13px; color: var(--muted); }
.ad-count strong { color: var(--text); font-weight: 600; }
.ad-picks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.pick { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 12px 14px; border: 1px solid var(--border); border-top-width: 3px; border-radius: var(--radius-card); background: var(--surface); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.pick:hover { border-color: var(--control); }
.pick.good { border-top-color: var(--positive); background: #f4faf6; }
.pick.bad { border-top-color: var(--negative); background: #fdf5f4; }
.pick-label { font-size: 12px; line-height: 16px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.pick.good .pick-label { color: var(--positive); }
.pick.bad .pick-label { color: var(--negative); }
.pick-body { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.pick-body .thumb { width: 56px; height: 56px; }
.pick-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pick-name { font-weight: 500; overflow-wrap: anywhere; }
.pick-value { font-size: 20px; line-height: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pick.good .pick-value { color: var(--positive); }
.pick.bad .pick-value { color: var(--negative); }
.pick-why { font-size: 13px; line-height: 18px; color: var(--text); }
.pick-facts { font-size: 12px; line-height: 16px; color: var(--muted); }
@media (max-width: 760px) { .ad-picks { grid-template-columns: 1fr; } }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pick.good { background: #13201a; }
  :root:not([data-theme="light"]) .pick.bad { background: #23161a; }
}
:root[data-theme="dark"] .pick.good { background: #13201a; }
:root[data-theme="dark"] .pick.bad { background: #23161a; }
