/* Dashboard layout on the DFI Interface tokens (tokens.css): colours only from tokens, Arial. */
:root {
  --panel-radius: 12px;
  --panel-shadow: 0 1px 3px color-mix(in srgb, var(--ink) 16%, transparent);
}
* { box-sizing: border-box; }
html { background: var(--surface-tint); color: var(--ink); }
body { margin: 0; overflow-wrap: anywhere; background: var(--surface-tint); }
a { color: var(--ink); text-underline-offset: 0.2em; }
a:focus-visible, summary:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
h1, h2, h3 { margin-block: var(--space-4) var(--space-3); }
p { margin-block: var(--space-2); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: var(--space-3); top: var(--space-3); background: var(--surface); padding: var(--space-2); z-index: 10; }

/* App bar */
.app-bar { background: var(--surface-inverse); color: var(--ink-inverse); }
.app-bar-inner { max-width: 80rem; margin-inline: auto; padding: var(--space-3) var(--space-4); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-5); }
.app-bar .brand { margin: 0; line-height: 0; }
.brand-logo { display: block; height: 28px; width: auto; }
.app-bar a { color: var(--ink-inverse); }
.app-bar nav { display: flex; gap: var(--space-2); flex: 1; }
.app-bar nav { flex-wrap: wrap; }
.app-bar nav a { padding: var(--space-2) var(--space-3); border-radius: var(--space-2); text-decoration: none; white-space: nowrap; }
.app-bar nav a[aria-current] { background: var(--ink-inverse); color: var(--ink); font-weight: 700; }
.account-bar { display: flex; align-items: center; gap: var(--space-3); margin: 0; }
.account-bar button { font: inherit; color: var(--ink-inverse); background: transparent; border: 1px solid var(--ink-inverse); border-radius: var(--space-2); padding: var(--space-1) var(--space-3); cursor: pointer; }

main, footer { width: 100%; max-width: 80rem; margin-inline: auto; padding-inline: var(--space-4); min-width: 0; }
footer { margin-block: var(--space-6); }
.page-head { margin-block: var(--space-4); max-width: 60rem; }
.page-head h1 { margin-block: var(--space-4) var(--space-2); }

/* Panels, tiles, chips */
.panel { background: var(--surface-panel); color: var(--ink-on-panel); border-radius: var(--panel-radius); box-shadow: var(--panel-shadow); padding: var(--space-4); margin-block: var(--space-4); min-width: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: var(--space-3); margin-block: var(--space-4); }
.tile { background: var(--surface-panel); border-radius: var(--panel-radius); box-shadow: var(--panel-shadow); padding: var(--space-3) var(--space-4); }
.tile p { margin: 0; }
.tile-number { font-variant-numeric: tabular-nums; }
.tile-of { color: var(--ink-muted); font-weight: 400; }
.collection-panel summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-3); }
.summary-figure { color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.chip { display: inline-block; padding: 0 var(--space-2); border-radius: 999px; background: var(--surface-subtle); color: var(--ink); white-space: nowrap; }
.chip-out { background: var(--border); color: var(--ink); }
.lowest { display: inline-block; padding: var(--space-1) var(--space-3); border-radius: 999px; background: var(--surface-inverse); color: var(--ink-inverse); font-size: 15px; line-height: 20px; letter-spacing: 0.04em; }
.mark { display: inline-block; padding: 0 var(--space-2); border-radius: 999px; background: var(--surface-tint); color: var(--ink-muted); }
.index { font-variant-numeric: tabular-nums; font-weight: 700; }
.index-down { color: var(--ink-accent); background: var(--surface-tint); border: 1px solid var(--ink-accent); }
.index-up, .index-same, .index-ref { color: var(--ink); }
.no-index, .desc, .pack, .last-price { color: var(--ink-muted); }
.assumption { color: var(--ink-muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Pack price: Basic bold and larger with the RSP struck through beside it, or one plain price */
.price-line { margin-block: var(--space-1); }
.price-strong { font-size: 20px; line-height: 26px; font-weight: 700; }
.rsp { color: var(--ink-muted); }
.store-card { position: relative; padding: var(--space-2) var(--space-6) var(--space-2) var(--space-3); border-radius: var(--space-2); }
.listing { position: relative; }
.listing .card-head { padding-right: var(--space-6); }

/* (i) notes: open on hover, keyboard focus and tap with no script */
.info { position: absolute; top: var(--space-2); right: var(--space-2); }
.info.inline { position: relative; top: auto; right: auto; display: inline-block; vertical-align: middle; }
.info-icon { min-width: 24px; min-height: 24px; padding: 0; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); font: italic 700 13px/1 var(--font-sans); cursor: pointer; transition: background-color 0.15s, color 0.15s; }
.info:hover .info-icon, .info:focus-within .info-icon { background: var(--surface-inverse); color: var(--ink-inverse); }
.info-box { position: absolute; right: 0; top: 100%; z-index: 6; width: max-content; max-width: min(18rem, calc(100vw - 3rem)); background: var(--surface-panel); color: var(--ink-on-panel); border: 1px solid var(--border-strong); border-radius: var(--space-2); box-shadow: var(--panel-shadow); padding: var(--space-2) var(--space-3); font-weight: 400; letter-spacing: normal; text-align: left; visibility: hidden; opacity: 0; transition: opacity 0.15s, visibility 0.15s; }
.info:hover .info-box, .info:focus-within .info-box { visibility: visible; opacity: 1; }
.info-box p, .info-box ul { margin-block: var(--space-1); }
.info-box ul { padding-left: var(--space-4); }
.index-note { display: none; }

/* Tables: compact, sticky headers, tabular figures */
.mobile-label { display: none; }
table { width: 100%; table-layout: fixed; border-collapse: collapse; font-variant-numeric: tabular-nums; }
caption { text-align: left; margin-block: var(--space-3); }
th, td { padding: var(--space-2) var(--space-3); text-align: left; vertical-align: top; border: 0; }
thead th { position: sticky; top: 0; background: var(--surface-panel); border-bottom: 1px solid var(--border-strong); z-index: 1; }
tbody tr { border-bottom: 1px solid var(--border); }
.amount, .numeric { text-align: right; font-variant-numeric: tabular-nums; }
.latest-table .item-heading { width: 20%; }
.latest-table td p, .weekly-table td p { margin-block: var(--space-1); }
.item-id { display: flex; gap: var(--space-3); align-items: flex-start; }
.item-id p { margin: 0; }
.store-card.is-out, .retailer.is-out .listing { color: var(--ink-muted); }
.is-out .amount, .is-out .per-unit { color: var(--ink-muted); }
.is-out .mark { background: var(--border); }

/* Photos */
.photo { width: 48px; height: 48px; flex: none; border-radius: var(--space-2); object-fit: contain; background: var(--surface); border: 1px solid var(--border); }
.photo-empty { display: inline-flex; align-items: center; justify-content: center; text-align: center; color: var(--ink-muted); background: var(--surface-tint); font-size: 9px; }
.card-head { display: flex; gap: var(--space-3); align-items: flex-start; }
.card-head .photo { width: 64px; height: 64px; }
.card-head p { margin-block: var(--space-1); }
.is-out .photo { opacity: 0.5; }

/* Filters and switches */
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-4); margin-block: var(--space-3); }
.search-filter label { display: block; }
.search-filter input { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--space-2); padding: var(--space-2) var(--space-3); min-width: min(20rem, 100%); }
.overlay-switch { display: flex; gap: var(--space-2); align-items: center; }
.overlay-only { display: none; }
main:has(#show-overlay:checked) .overlay-only { display: block; }
[hidden] { display: none !important; }

/* Item page */
.store-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: var(--space-4); align-items: start; }
.store-grid .panel { margin-block: 0; }
.detail-columns { display: block; }
.detail-columns > * { min-width: 0; }
.prices { margin: var(--space-3) 0; }
.prices > div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: var(--space-2); padding-block: var(--space-1); border-bottom: 1px solid var(--border); }
.prices dd { margin: 0; text-align: right; min-width: 0; }
.promotion { padding: var(--space-3); background: var(--surface-tint); border-radius: var(--space-2); margin-block: var(--space-3); }
.overlay-offers { border-left: 3px solid var(--rule-accent); padding-left: var(--space-3); margin-block: var(--space-3); }
.wording { white-space: pre-wrap; }
summary { cursor: pointer; }
.before-after-table td, .before-after-table th { white-space: normal; }
.week-links { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-block: var(--space-3); }
.week-links a, .week-links span { padding: var(--space-1) var(--space-3); border-radius: 999px; background: var(--surface-panel); border: 1px solid var(--border); text-decoration: none; font-variant-numeric: tabular-nums; }
.week-links [aria-current] { background: var(--ink); color: var(--ink-inverse); border-color: var(--ink); font-weight: 700; }

.week-select { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-block: var(--space-3); }
.week-select select { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--space-2); padding: var(--space-1) var(--space-3); }
.week-select select:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* Switches: real radio inputs, the page reacts through :has(), so they work without script */
.seg-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented { position: relative; display: inline-flex; border: 1px solid var(--border-strong); border-radius: 999px; overflow: hidden; margin-block: var(--space-2); }
.segmented label { padding: var(--space-1) var(--space-4); cursor: pointer; }
.seg-input:checked + label { background: var(--ink); color: var(--ink-inverse); }
.seg-input:focus-visible + label { outline: 2px solid var(--focus-ring); outline-offset: -3px; }
.item-view:has(#measure-pack:checked) .m-unit, .item-view:has(#measure-unit:checked) .m-pack,
.item-view:has(#basis-overlay:checked) .b-basic, .item-view:has(#basis-basic:checked) .b-overlay,
.item-view:has(#mode-weekly:checked) .p-daily, .item-view:has(#mode-daily:checked) .p-weekly { display: none; }
.item-no { color: var(--ink-muted); margin-block: 0; }
.lowest-now { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-5); margin-block: var(--space-3); }
.lowest-store { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.price-tag { position: relative; display: inline-block; padding: var(--space-1) var(--space-3) var(--space-1) var(--space-5); border-radius: var(--space-2); background: var(--surface-inverse); color: var(--ink-inverse); font-variant-numeric: tabular-nums; }
.price-tag::before { content: ""; position: absolute; left: var(--space-2); top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--surface-tint); }
.chart-controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-4); }
.export-link { margin-left: auto; }
.head-dates { display: block; font-weight: 400; color: var(--ink-muted); }
.legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); list-style: none; padding: 0; margin: var(--space-2) 0; }
.swatch { display: inline-block; width: 18px; height: 4px; margin-right: var(--space-2); vertical-align: middle; border-radius: 2px; background: var(--data-1); }
.chart-values table { margin-top: var(--space-2); }
.chart-values td, .chart-values th { padding: var(--space-1) var(--space-2); }
svg:not(.chart-plot) { display: block; width: 100%; max-width: 100%; height: auto; }
svg text { fill: var(--ink); font-variant-numeric: tabular-nums; }
svg .type-axis-label { fill: var(--ink-muted); }
.gridline, .baseline { stroke: var(--axis-line); stroke-width: 1; }
.series .line { fill: none; stroke-width: 2; stroke-linejoin: round; }
.series.alt .line { stroke-dasharray: 6 4; }
.series .dot { stroke: none; }
.series .line { stroke: var(--data-1); } .series .dot { fill: var(--data-1); }
/* Store colours (--store-*) come from the logos: see stores.css. */
.store-well .line { stroke: var(--store-well); } .store-well .dot { fill: var(--store-well); } .swatch.store-well { background: var(--store-well); }
.store-pns .line { stroke: var(--store-pns); } .store-pns .dot { fill: var(--store-pns); } .swatch.store-pns { background: var(--store-pns); }
.store-hktv .line { stroke: var(--store-hktv); } .store-hktv .dot { fill: var(--store-hktv); } .swatch.store-hktv { background: var(--store-hktv); }
.chart { position: relative; }
/* The Y axis is its own SVG (one eleventh of the width) beside a scroller that shows 14 days or 13
   weeks (ten elevenths); both scale alike. The scroller is right-to-left so it opens on the newest
   dates with no script; the plot inside is left-to-right. */
.chart-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 10fr); align-items: start; }
.chart-scroll { direction: rtl; overflow-x: auto; overflow-y: hidden; min-width: 0; }
.chart-scroll:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.chart-plot { display: block; direction: ltr; max-width: none; height: auto; }
.store-well .low-label { fill: var(--store-well); } .store-pns .low-label { fill: var(--store-pns); } .store-hktv .low-label { fill: var(--store-hktv); }
.low-label { font-weight: 700; paint-order: stroke; stroke: var(--surface-panel); stroke-width: 3px; stroke-linejoin: round; }
.chart-tip { position: absolute; z-index: 5; width: max-content; max-width: min(18rem, 100%); background: var(--surface-panel); color: var(--ink-on-panel); border: 1px solid var(--border-strong); border-radius: var(--space-2); box-shadow: var(--panel-shadow); padding: var(--space-2) var(--space-3); pointer-events: none; }
.chart-tip .tip-head { font-weight: 700; }
.series .dot.dot-hollow { fill: var(--surface); stroke: var(--ink-muted); stroke-width: 2; }
.series .dot:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; stroke: var(--ink); stroke-width: 2; }

/* Store logos, collection progress, category filter, lowest marks */
.store-logo { height: 22px; width: auto; vertical-align: middle; }
.progress-list { list-style: none; padding: 0; margin: var(--space-3) 0; display: grid; gap: var(--space-2); }
.progress-row { display: grid; grid-template-columns: 8rem minmax(8rem, 20rem) 1fr; gap: var(--space-3); align-items: center; }
.progress-bar { width: 100%; height: 14px; border-radius: 7px; overflow: hidden; }
.bar-back { fill: var(--border); } .bar-done { fill: var(--data-positive); } .bar-failed { fill: var(--data-negative); } .bar-pending { fill: var(--border-strong); }
.category-filter { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-3); min-width: 0; }
.category-filter fieldset { border: 1px solid var(--border); border-radius: var(--space-2); display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin: 0; padding: var(--space-2) var(--space-3); min-width: 0; }
.category-filter .category-group { border: 0; padding: 0; }
.category-filter .category-group legend { padding: 0; color: var(--ink-muted); }
.category-option { display: inline-flex; gap: var(--space-1); align-items: center; }
.filter-button { display: inline-block; text-decoration: none; font: inherit; color: var(--ink-inverse); background: var(--surface-inverse); border: 0; border-radius: var(--space-2); padding: var(--space-2) var(--space-3); cursor: pointer; }
.is-lowest { background: var(--surface-subtle); box-shadow: inset 3px 0 0 var(--rule-accent); }
.panel.is-lowest { box-shadow: inset 3px 0 0 var(--rule-accent), var(--panel-shadow); }
.weekly-table .lowest { text-align: right; }
/* The (i) icon (24 px, 8 px from the edge) gets its own strip with a gap, also on the phone. */
.weekly-table .store-week { position: relative; padding-right: calc(var(--space-6) + var(--space-2)); }
.pack-price { display: inline-block; color: var(--ink-muted); white-space: nowrap; }
.title-row { display: flex; align-items: center; gap: var(--space-3); }
.title-row h1 { margin-block: var(--space-4) var(--space-2); }
.title-row { position: relative; }
.title-row .info.inline { position: static; }
.info-start .info-box { left: 0; right: auto; }

/* Sign in */
.auth-logo { display: block; width: min(100%, 200px); height: auto; margin: 0 auto var(--space-4); }
.auth-form .remember { display: flex; gap: var(--space-2); align-items: center; }
.auth-form .remember input { width: auto; }
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: var(--space-4); }
.auth-panel { width: 100%; max-width: 24rem; padding: var(--space-6) var(--space-5); }
.auth-form label { display: block; margin-bottom: var(--space-1); }
.auth-form input { width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--space-2); padding: var(--space-2) var(--space-3); }
.button { font: inherit; font-weight: 700; width: 100%; color: var(--ink-inverse); background: var(--surface-inverse); border: 0; border-radius: var(--space-2); padding: var(--space-3); cursor: pointer; }
.sign-in-error { color: var(--ink-accent); font-weight: 700; }

/* Motion: page changes cross-fade, toggles and notes ease; none of it under reduced motion. */
@keyframes fade-in { from { opacity: 0; } }
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.18s; }
  a, button, .chip, .segmented label, .week-links a, .week-links span, .overlay-switch input { transition: background-color 0.15s, color 0.15s, border-color 0.15s; }
  details[open] > :not(summary), main:has(#show-overlay:checked) .overlay-only { animation: fade-in 0.2s ease-out; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media (max-width: 48rem) {
  .brand-logo { height: 24px; }
  .index-note { display: block; }
  main, footer { padding-inline: var(--space-3); }
  .app-bar-inner { padding: var(--space-2) var(--space-3); gap: var(--space-1) var(--space-3); }
  .app-bar .brand { font-size: 16px; line-height: 22px; }
  .app-bar nav { flex: 0 1 auto; gap: var(--space-1); }
  .app-bar nav a { padding: var(--space-1) var(--space-2); }
  .account-bar { flex-basis: 100%; justify-content: space-between; }
  .responsive-table, .responsive-table tbody, .responsive-table tr,
  .responsive-table td, .responsive-table tbody th { display: block; width: 100%; }
  .responsive-table caption { display: block; }
  .responsive-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .responsive-table th, .responsive-table td { padding: var(--space-2) var(--space-3); }
  .latest-table .item-block { padding: var(--space-3); margin-block: var(--space-3); border: 1px solid var(--border); border-radius: var(--panel-radius); }
  .mobile-label { display: block; margin-bottom: var(--space-1); }
  .latest-table .item-block, .latest-table .item-heading,
  .latest-table .retailer-block { display: block; width: 100%; }
  .latest-table .retailer-block { border-top: 1px solid var(--border); }
  .prices > div { grid-template-columns: max-content minmax(0, 1fr); }
  .prices dt, .prices dd { width: 100%; }
  .weekly-table .numeric { text-align: right; }
  .weekly-table tbody tr { padding: var(--space-2); margin-block: var(--space-3); border: 1px solid var(--border); border-radius: var(--panel-radius); }
  .filters { display: block; }
  /* Phone charts keep a readable scale (12 px text draws at 11 px or more): the plot never shrinks
     below 0.92 of its drawing size, so the container scrolls. The axis column is one eleventh of the
     width, no less than 0.92 of its drawing size, so axis and plot always share one scale. */
  .chart-body { grid-template-columns: minmax(calc(56px * 0.92), 1fr) minmax(0, 10fr); }
  .chart-track { min-width: calc(560px * 0.92); }
  .search-filter input { width: 100%; }
  .panel { padding: var(--space-3); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .store-grid { grid-template-columns: minmax(0, 1fr); }
  .progress-row { grid-template-columns: minmax(0, 1fr); gap: var(--space-1); }
  .before-after-table tbody tr { padding: var(--space-2); margin-block: var(--space-3); border: 1px solid var(--border); border-radius: var(--panel-radius); }
}
