/* ============================================================
   Price Intelligence — UI theme
   A restrained, data-dense retail-analytics look: slate neutrals,
   one confident blue (aligned to the chart palette), soft elevation.
   ============================================================ */

:root {
  /* Surfaces & ink */
  --bg: #f4f6f9;
  --panel: #ffffff;
  --surface: #f8fafc;        /* inner cards (KPIs), table header */
  --ink: #0f172a;            /* primary text */
  --ink-2: #334155;          /* secondary text */
  --muted: #64748b;          /* labels, meta */
  --faint: #94a3b8;          /* axis, de-emphasised */
  --line: #e7ebf1;           /* hairline borders */
  --line-2: #d7dee8;         /* stronger dividers, scrollbars */

  /* Brand / semantic (the chart's series colours live in Go; keep these in family) */
  --self: #0050aa;
  --self-ink: #0a4f9e;
  --self-bg: #eef4fc;
  --undercut: #c81e2c;
  --undercut-bg: #fcebed;
  --cheap: #15803d;
  --cheap-bg: #e9f6ee;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .18);
  --ring: 0 0 0 3px rgba(0, 80, 170, .16);

  /* Shape */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  --content-max: 1400px; /* shared width band: content cards + header align to this */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.55 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
}
a { color: var(--self); text-decoration: none; }
a:hover { color: var(--self-ink); text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3 { letter-spacing: -.01em; }
.muted { color: var(--muted); font-size: 12px; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

/* ---- View transitions (cross-document, full-page navigation) ----
   Opt every page into the View Transitions API so navigating Dashboard ↔ Products
   ↔ detail cross-fades instead of hard-cutting. Pure CSS; browsers without support
   navigate normally. */
@view-transition { navigation: auto; }
/* Hold the header steady across navigations; only the page body cross-fades. */
.topbar { view-transition-name: topbar; }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 220ms; animation-timing-function: ease; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* ---- Top bar ----
   The bar background + border span the full viewport, but its content sits in the
   same centered max-width band as the cards so the brand/nav align with the
   content edges on wide screens. */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 6px 16px;
  max-width: var(--content-max); margin: 0 auto;
  padding: 12px 14px;
}
.brand {
  font-weight: 700; font-size: 16px; letter-spacing: -.02em; color: var(--ink);
  display: flex; align-items: center; gap: 8px;
}
.brand:hover { color: var(--ink); text-decoration: none; opacity: .8; }
/* Compact "P.I." mark on mobile so the brand + nav stay on one line; full name ≥640px. */
.brand-full { display: none; }
.brand-short { display: inline; }
.topnav { display: flex; gap: 2px; align-items: center; flex-wrap: nowrap; font-size: 13px; }
.topnav a {
  color: var(--muted); font-weight: 500; padding: 6px 10px; border-radius: 8px;
  transition: background-color .12s ease, color .12s ease;
}
.topnav a:hover { color: var(--ink); background: var(--surface); text-decoration: none; }

/* ---- Layout ---- */
.dashboard { padding: 14px; max-width: var(--content-max); margin: 0 auto; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow-sm);
}
.panel h2 {
  margin: 0 0 12px; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted);
}

.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: start; }
.grid > * { min-width: 0; } /* allow grid items to shrink so the board scrolls instead of stretching the page */

/* ---- KPIs ---- */
.kpis { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: stretch; }
.kpi {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px;
  background: var(--surface); display: flex; flex-direction: column; gap: 2px;
}
.kpi-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted);
}
.kpi-value { font-size: 36px; line-height: 1.1; font-weight: 700; letter-spacing: -.02em; color: var(--ink); margin-top: 4px; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.kpi-chart { margin-top: 6px; }
.kpi-chart svg { width: 100%; height: auto; }
.movers { list-style: none; margin: 8px 0 0; padding: 0; }
.movers li { display: flex; gap: 8px; align-items: baseline; padding: 5px 0; font-size: 12px; border-top: 1px solid var(--line); }
.movers li:first-child { border-top: 0; }
.movers .m-prod { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.movers .m-store { color: var(--muted); }
.movers .m-pct { font-weight: 600; font-variant-numeric: tabular-nums; }
.movers .down .m-pct, .ticker .down .t-pct, .alert.drop .a-kind { color: var(--cheap); }
.movers .up .m-pct, .ticker .up .t-pct { color: var(--undercut); }

/* ---- Board (data grid) ---- */
.board-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -2px; border-radius: var(--radius-sm); }
.board { width: 100%; min-width: 540px; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
/* The live board uses table-layout: fixed so every store column is the SAME width
   (auto layout sizes each to its own content — prices/labels differ, columns end up
   uneven). The product column is pinned; the stores split the rest equally. The
   exceptions tables are excluded — they have many content-sized columns and scroll. */
.board:not(.exceptions) { table-layout: fixed; }
.board:not(.exceptions) th.prodcol, .board:not(.exceptions) td.prodcol { width: 240px; white-space: normal; }
.board th, .board td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.board th.prodcol, .board td.prodcol { text-align: left; }
.board thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); border-bottom: 1px solid var(--line-2);
}
.board tbody tr { transition: background-color .1s ease; }
.board tbody tr:hover { background: var(--surface); }
.board tbody tr:last-child td { border-bottom: 0; }
/* Keep the product name visible while scrolling competitor columns. */
.board th.prodcol, .board td.prodcol {
  position: sticky; left: 0; z-index: 1; background: var(--panel);
  box-shadow: 1px 0 0 var(--line);
}
.board tbody tr:hover td.prodcol { background: var(--surface); }
.board thead th.prodcol { z-index: 3; background: var(--surface); }
.board th.selfcol { color: var(--self); }
/* Freeze our own (LIDL) column right after the product column, so competitors scroll
   against it on mobile. left = the product column's fixed width (240px). */
.board:not(.exceptions) th.selfcol, .board:not(.exceptions) td.cell.self { position: sticky; left: 240px; z-index: 1; }
.board:not(.exceptions) thead th.selfcol { z-index: 3; }
/* Product name is the row's link to its detail page. A persistent blue +
   underline reads as clickable on any device (no hover needed, works on touch);
   the underline simply darkens on hover. */
.prodlink { font-weight: 600; color: var(--self); text-decoration: underline; text-decoration-color: rgba(0, 80, 170, .35); text-underline-offset: 2px; }
.prodlink:hover { text-decoration-color: var(--self); }
.prodmeta { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
.cell .price { font-weight: 600; }
.cell .asof { display: block; font-size: 10px; color: var(--faint); margin-top: 1px; font-variant-numeric: tabular-nums; }
/* Cell colour = competitive outcome: blue = ours, red = a rival below our price.
   Tinted cell + matching price colour on the table; fills are dropped on phones,
   where the cards use the price colour alone. */
.cell.self { background: var(--self-bg); box-shadow: inset 0 0 0 1px rgba(0, 80, 170, .08); }
.cell.self .price { color: var(--self); }
.cell.undercut { background: var(--undercut-bg); }
.cell.undercut .price { color: var(--undercut); }
/* Cheapest in the row (several on a tie) is flagged with a green dot before the
   price — independent of the cell's own colour, so it shows even on a red (undercut)
   or blue (our) cell. */
.cell.cheapest .price::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--cheap); margin-right: 5px; vertical-align: middle;
}

/* ---- Ticker + alerts ----
   Fixed height (not max-height) so the cards reserve their space upfront and scroll
   internally — prepending rows must not grow the panel and shift the page. */
.ticker, .alerts { list-style: none; margin: 0; padding: 0; height: 280px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.ticker li, .alerts li { display: flex; gap: 10px; align-items: baseline; padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 13px; }
.ticker li:last-child, .alerts li:last-child { border-bottom: 0; }
.ticker .t-store { font-weight: 600; min-width: 64px; }
.ticker .t-prod { flex: 1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticker .t-price { font-variant-numeric: tabular-nums; font-weight: 600; }
.ticker .t-pct { font-variant-numeric: tabular-nums; }
.alert .a-kind {
  font-weight: 700; font-size: 10px; letter-spacing: .04em; padding: 3px 7px;
  border-radius: var(--radius-pill); background: var(--undercut-bg); color: var(--undercut);
  white-space: nowrap; text-transform: uppercase;
}
.alert.drop .a-kind { background: var(--cheap-bg); }
.alert .a-body { flex: 1; }
.alert { animation: flash 1.1s ease-out; }
@keyframes flash { from { background: var(--self-bg); } to { background: transparent; } }

/* The Alerts page is a dedicated full-height feed (not the cramped Home card). */
.alerts.full { height: clamp(420px, calc(100vh - 320px), 720px); }
/* The full list re-renders wholesale on every filter/page/morph; replaying the
   arrival flash on all rows reads as a flicker. The flash is for genuinely new live
   rows (Home ticker/latest-alerts), so suppress it here — load stable like the board. */
.alerts.full .alert { animation: none; }

/* Full-viewport "app" view (body.fullview, used by the Alerts page): the card fills
   the height under the topbar and the alert list scrolls INSIDE it — the page itself
   never scrolls. Setting the card to 100dvh directly would overflow past the topbar +
   padding and bring back page scroll; instead the page is a 100dvh flex column and the
   card flexes into the leftover space. dvh (dynamic viewport height) tracks the mobile
   browser chrome, so it stays correct as the address bar shows/hides. */
body.fullview { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
body.fullview .topbar { flex: none; }
body.fullview .dashboard { flex: 1 1 auto; min-height: 0; width: 100%; max-width: 100%; display: flex; flex-direction: column; }
body.fullview .panel { flex: 1 1 auto; min-height: 0; width: 100%; max-width: var(--content-max); margin: 0 auto; display: flex; flex-direction: column; }
body.fullview #alerts-list { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
body.fullview .alerts.full { flex: 1 1 auto; min-height: 0; height: auto; }
body.fullview .pager { flex: none; }
/* Home's "Latest alerts" shows only ~3 rows — size to content, no scrollbar. */
.alerts.compact { height: auto; overflow: visible; }

/* Actionable alert rows: the whole row links (stretched overlay anchor) without
   disturbing the badge/body/age flex layout. */
.alert.linked { position: relative; cursor: pointer; }
.alert.linked:hover { background: var(--surface); }
.alert .a-stretch { position: absolute; inset: 0; z-index: 1; }
.alert .a-stretch:hover { text-decoration: none; }

/* ---- Pagination footer ---- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.pager-nav { display: flex; align-items: center; gap: 10px; }
.pager-count, .pager-page { font-size: 12px; }
.pager-page { min-width: 78px; text-align: center; }
.pager .filter { cursor: pointer; }
.pager .filter:disabled { opacity: .45; cursor: default; }
.pager .filter:disabled:hover { border-color: var(--line-2); }

/* ---- Board filters ---- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
/* Mobile-first: the board's bar (2 selects + search + clear) stacks full-width, each
   control — Clear included — on its own line; the Alerts bar (range + search + clear)
   stays on a single line. Both become a normal row at ≥640px (see media query). */
/* Board + Alerts filter bars: stacked full-width on mobile, a single row ≥640px
   (see the media query). */
.filters-stack { flex-direction: column; align-items: stretch; }
.filters-stack .filter { width: 100%; }
.filter {
  font: inherit; font-size: 13px; padding: 8px 11px; line-height: 1.2;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--ink);
  transition: border-color .12s ease, box-shadow .12s ease;
}
.filter:hover { border-color: var(--muted); }
.filter:focus-visible { border-color: var(--self); box-shadow: var(--ring); outline: none; }
select.filter { cursor: pointer; -webkit-appearance: none; appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.filter.search { flex: 1; min-width: 160px; }
.filter.clear { cursor: pointer; color: var(--muted); background: transparent; border-color: var(--line); }
.filter.clear:hover { color: var(--ink); border-color: var(--muted); background: var(--surface); }

/* ---- Charts ---- */
.chart { width: 100%; height: auto; }
.chart-axis { font-size: 11px; fill: var(--faint); }
.chart-legend { font-size: 11px; fill: var(--ink-2); }
.spark { width: 64px; height: 20px; vertical-align: middle; }

/* ---- Product detail page (reuses the .dashboard container + .panel cards) ---- */
.back { font-size: 13px; display: inline-block; padding: 4px 0; margin-bottom: 6px; color: var(--muted); }
.back:hover { color: var(--self); }
.page-title { margin: 0; font-size: 22px; letter-spacing: -.02em; color: var(--ink); }
.page-title + .prodmeta { font-size: 13px; margin-top: 4px; }

/* ---- Refined scrollbars on the scrolling regions ---- */
.ticker, .alerts, .board-wrap { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.ticker::-webkit-scrollbar, .alerts::-webkit-scrollbar, .board-wrap::-webkit-scrollbar { width: 9px; height: 9px; }
.ticker::-webkit-scrollbar-thumb, .alerts::-webkit-scrollbar-thumb, .board-wrap::-webkit-scrollbar-thumb {
  background: var(--line-2); border-radius: var(--radius-pill); border: 2px solid var(--panel);
}
.ticker::-webkit-scrollbar-thumb:hover, .alerts::-webkit-scrollbar-thumb:hover, .board-wrap::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ============================================================
   Home: KPI strip, category matrix, briefing, alerts
   ============================================================ */
.kpi-strip { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 14px; }
.kpi-strip .kpi { background: var(--panel); box-shadow: var(--shadow-sm); }

/* Briefing · matrix · alerts. Mobile: a single stack (briefing first). Desktop: a
   3-column row (see the ≥1024px block). */
.home-grid { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start; }
.home-grid > * { min-width: 0; }
/* Home panels sit inside a gap'd grid, so the default .panel margin-bottom would
   double the spacing. Drop it — the 14px grid gap owns the spacing. */
.home-grid > * { margin-bottom: 0; }

/* Category matrix — the hero. Shares the board's data-grid look. table-layout:fixed
   gives the Category + LIDL columns known widths so they can stay frozen on the left
   (sticky) while you scroll competitors on mobile — the key comparison. */
.matrix { width: 100%; min-width: 560px; table-layout: fixed; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.matrix th, .matrix td { padding: 12px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.matrix th.prodcol, .matrix td.prodcol {
  text-align: left; width: 132px; white-space: normal;
  position: sticky; left: 0; z-index: 1; background: var(--panel); box-shadow: 1px 0 0 var(--line);
}
.matrix th.selfcol, .matrix td.mcell.self { position: sticky; left: 132px; z-index: 1; }
.matrix thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); border-bottom: 1px solid var(--line-2);
}
.matrix thead th.prodcol, .matrix thead th.selfcol { z-index: 3; }
.matrix th.selfcol { color: var(--self); }
.matrix tbody tr:last-child td { border-bottom: 0; }
.matrix .catname { font-weight: 600; display: block; }
.mcell { font-weight: 600; }
.mcell .mgap { display: block; font-size: 15px; }
.mcell .mund { display: block; font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.mcell.self { background: var(--self-bg); box-shadow: inset 0 0 0 1px rgba(0, 80, 170, .08); }
.mcell.self .mlead { display: block; font-size: 16px; color: var(--self-ink); }
.mcell.self .muted { font-size: 11px; }
.mcell.win .mgap { color: var(--cheap); }   /* competitor dearer than us = we win */
.mcell.lose .mgap { color: var(--undercut); } /* competitor cheaper = we lose */
.mcell.win { background: var(--cheap-bg); }
.mcell.lose { background: var(--undercut-bg); }
.mcell.even .mgap { color: var(--ink-2); }

/* Briefing panel */
.briefing .brief-headline { font-size: 15px; font-weight: 600; margin: 0 0 10px; color: var(--ink); line-height: 1.45; }
.brief-time { font-weight: 500; color: var(--faint); font-size: 11px; letter-spacing: 0; text-transform: none; }
.brief-points { list-style: none; margin: 0; padding: 0; }
.brief-points li { font-size: 13px; color: var(--ink-2); padding: 6px 0 6px 16px; position: relative; border-top: 1px solid var(--line); }
.brief-points li:first-child { border-top: 0; }
.brief-points li::before { content: "›"; position: absolute; left: 0; color: var(--self); font-weight: 700; }

/* Alerts feed (shared by Home + Alerts page) */
.panel h2 .more { float: right; font-size: 11px; font-weight: 600; color: var(--self); letter-spacing: 0; text-transform: none; }
.a-age { margin-left: auto; font-size: 11px; white-space: nowrap; }
.alert .a-body { display: flex; flex-direction: column; gap: 1px; }
.alert .a-body strong { font-weight: 600; font-size: 13px; }
.alert .a-body .muted { font-size: 11px; }
/* Badge colour by anomaly kind. */
.alert.leadership_lost .a-kind { background: var(--undercut-bg); color: var(--undercut); }
.alert.magnitude .a-kind { background: #fef3c7; color: #b45309; }
.alert.cluster .a-kind { background: #ede9fe; color: #6d28d9; }
.alert.mapping_suspect .a-kind, .alert.gap .a-kind { background: #e2e8f0; color: var(--ink-2); }

/* Exceptions tables */
.section-note { margin: -4px 0 12px; font-size: 12px; }
.exceptions .xtitle { font-weight: 600; }
.exceptions .xbrand { font-weight: 600; margin-right: 6px; }
.exceptions .xconf { font-weight: 600; }
.exceptions .xparsed { text-align: left; }
.method { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 3px 7px; border-radius: var(--radius-pill); }
.method.ean { background: var(--cheap-bg); color: var(--cheap); }
.method.vector { background: var(--self-bg); color: var(--self-ink); }
.method.none { background: #e2e8f0; color: var(--ink-2); }
.exceptions th, .exceptions td { text-align: left; }
/* Action legend: maps each button to its outcome, shown above the table so the
   effect is clear before clicking (and on mobile, where button tooltips don't show). */
.action-legend { list-style: none; margin: 0 0 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.action-legend li { display: flex; gap: 10px; align-items: baseline; font-size: 12px; }
.al-chip { flex: none; cursor: default; margin: 0; }
.al-text { color: var(--muted); }

/* Decision buttons (confirm / reject a mapping) */
.xact { white-space: nowrap; }
.act { font: inherit; font-size: 12px; line-height: 1; padding: 5px 10px; margin-right: 6px; border-radius: var(--radius-pill); border: 1px solid var(--line); background: #fff; cursor: pointer; }
.act:last-child { margin-right: 0; }
.act.ok { color: var(--cheap); border-color: var(--cheap-bg); }
.act.ok:hover { background: var(--cheap-bg); }
.act.no { color: var(--undercut); border-color: var(--undercut-bg); }
.act.no:hover { background: var(--undercut-bg); }

/* ===========================================================
   Progressive enhancement for larger screens.
   =========================================================== */

/* Tablet: KPIs and ticker/alerts gain breathing room. */
@media (min-width: 640px) {
  .dashboard { padding: 20px; }
  .topbar-inner { padding: 14px 20px; }
  .brand-full { display: inline; }
  .brand-short { display: none; }
  .topnav { gap: 4px; }
  .kpis { grid-template-columns: 220px 1fr; }
  .kpis .kpi:nth-child(3) { grid-column: 1 / -1; } /* movers span full width */
  /* Enough width for the board's filter bar to lay out as a normal row again. */
  .filters-stack { flex-direction: row; align-items: center; }
  .filters-stack .filter { width: auto; }
}

/* Wide KPI row: position | index chart | movers side by side. */
@media (min-width: 900px) {
  .kpis { grid-template-columns: 220px 1fr 260px; }
  .kpis .kpi:nth-child(3) { grid-column: auto; }
  .kpi-strip { grid-template-columns: repeat(3, 1fr); }
}

/* Desktop: dashboard's alerts + ticker sit side by side. */
@media (min-width: 980px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  /* On its own full-width page the board fits; drop the sticky-column overhead. */
  .board { min-width: 0; }
  .board th.prodcol, .board td.prodcol { position: static; box-shadow: none; }
  .board:not(.exceptions) th.selfcol, .board:not(.exceptions) td.cell.self { position: static; }
}

/* Home as 3 columns: briefing · matrix · alerts. Below this it's a single stack
   (briefing first). The matrix keeps its min-width + frozen Category/LIDL columns,
   so a narrow middle column scrolls rather than cramping. */
@media (min-width: 1024px) {
  .home-grid { grid-template-columns: 300px minmax(0, 1fr) 320px; }
}

/* ===========================================================
   Small screens: the dense exceptions tables become stacked cards, and the wide
   product chart scrolls instead of shrinking to an unreadable size.
   =========================================================== */
@media (max-width: 760px) {
  /* Each row becomes a card; each cell a label/value line (label from data-label). */
  .board.exceptions { min-width: 0; }
  .exceptions thead { display: none; }
  .exceptions, .exceptions tbody { display: block; width: 100%; }
  .exceptions tr { display: block; padding: 12px; margin-bottom: 10px;
    border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--panel); }
  .exceptions td { display: flex; justify-content: space-between; gap: 14px; align-items: baseline;
    padding: 5px 0; border: 0; text-align: right; white-space: normal; }
  .exceptions td::before { content: attr(data-label); flex: none; font-weight: 600; color: var(--muted); text-align: left; }
  .exceptions td.prodcol { display: block; position: static; box-shadow: none; text-align: left;
    font-size: 14px; padding: 0 0 8px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
  .exceptions td.prodcol::before { content: none; }
  .exceptions td.xact { padding-top: 10px; }
  .exceptions td.xact::before { content: none; }
  .exceptions td.xact .act { flex: 1; margin: 0; }
  .exceptions td.xact .act + .act { margin-left: 6px; }
}

@media (max-width: 700px) {
  .chart-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .chart-scroll .chart { min-width: 600px; }
}

/* Alerts as cards on phones — easier to scan and tap than the cramped
   badge | body | age row. Pure CSS via grid areas; no markup change. The kind badge
   and age sit on a top row, the headline + detail span below. */
@media (max-width: 600px) {
  .alerts li.alert {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "kind age" "body body";
    gap: 6px 10px; align-items: center;
    padding: 12px; margin-bottom: 10px; border-bottom: 0;
    border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--panel);
  }
  .alerts li.alert:last-child { margin-bottom: 0; }
  .alert .a-kind { grid-area: kind; justify-self: start; }
  .alert .a-age { grid-area: age; justify-self: end; margin-left: 0; }
  .alert .a-body { grid-area: body; }
}

/* Board → per-product cards on phones. The matrix can't show two dimensions in
   ~360px (the pinned product + self columns alone fill the screen and competitors
   scroll off blind), so each product becomes a card with its stores stacked as
   labeled rows — store name via data-label, our row + any undercut keep their tint.
   Mirrors the exceptions/alerts card treatment; the wide table returns above 600px. */
@media (max-width: 600px) {
  .board-panel .board-wrap { overflow-x: visible; margin: 0; }
  .board:not(.exceptions) { display: block; min-width: 0; table-layout: auto; font-size: 13px; }
  .board:not(.exceptions) thead { display: none; }
  .board:not(.exceptions) tbody { display: block; }
  /* card = 2-col grid: header row is product (left) + our price (right); each
     competitor spans the full width on its own row below. Everything is IN FLOW
     (no absolute), so our price can't escape the card; price + age sit in
     fixed-width right-aligned columns so they line up down the whole card. */
  .board:not(.exceptions) tbody tr {
    display: grid; grid-template-columns: 1fr auto; gap: 0 10px;
    padding: 12px; margin-bottom: 10px;
    border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--panel);
  }
  /* product name = top-left of the header row */
  .board:not(.exceptions) td.prodcol {
    grid-column: 1; align-self: start; position: static; box-shadow: none; width: auto;
    display: block; text-align: left; border: 0; padding: 0 0 10px;
  }
  /* our (Lidl) price = top-right of the header row, in flow, no label/tint */
  .board:not(.exceptions) td.cell.self {
    grid-column: 2; grid-row: 1; align-self: start; justify-content: flex-end;
    position: static; padding: 0; background: none; box-shadow: none; border: 0;
  }
  .board:not(.exceptions) td.cell.self::before { content: none; }
  /* prominence only — colour comes from the shared cascade (green when we're cheapest) */
  .board:not(.exceptions) td.cell.self .price { font-size: 15px; }
  /* competitor stores = full-width rows below the header, divided by a top rule */
  .board:not(.exceptions) td.cell:not(.self) {
    grid-column: 1 / -1; border-top: 1px solid var(--line); padding: 8px 0;
  }
  /* shared cell layout: label left, then right-aligned fixed-width price + age.
     No table fills on phones — the colour lives in the price number. */
  .board:not(.exceptions) td.cell {
    position: static; display: flex; align-items: baseline; gap: 8px;
    background: none; border-bottom: 0; text-align: right; white-space: nowrap;
  }
  .board:not(.exceptions) td.cell::before {
    content: attr(data-label); margin-right: auto;
    font-weight: 600; color: var(--muted); text-align: left;
  }
  .board:not(.exceptions) td.cell .price { min-width: 64px; text-align: right; }
  .board:not(.exceptions) td.cell .asof { min-width: 30px; text-align: right; display: inline; margin-top: 0; }
}
