/* Supermarket price tracker — a dense, data-first interface.
   Light is the base palette; dark is a token swap under prefers-color-scheme, with an
   explicit [data-theme] override so the toggle wins in both directions. */

:root {
  --bg:        #f6f7f9;
  --panel:     #ffffff;
  --panel-2:   #fbfbfd;
  --ink:       #16181d;
  --ink-2:     #5b6270;
  --ink-3:     #888f9d;
  --line:      #e2e5ea;
  --line-2:    #eef0f4;
  --accent:    #2c5fd6;
  --accent-in: #ffffff;
  --ok:        #15803d;
  --warn:      #b45309;
  --bad:       #be123c;
  --up:        #be123c;
  --down:      #15803d;
  --migros:    #f26f21;
  --coop:      #b3151b;
  --aldi:      #1f4b9b;
  --band:      rgba(44, 95, 214, .10);
  --shadow:    0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --radius:    9px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:      #0f1216;
    --panel:   #171b21;
    --panel-2: #1c2129;
    --ink:     #e8eaee;
    --ink-2:   #a3abb8;
    --ink-3:   #79818f;
    --line:    #262c35;
    --line-2:  #1f242c;
    --accent:  #6d97f5;
    --accent-in: #0f1216;
    --ok:      #4ade80;
    --warn:    #fbbf24;
    --bad:     #fb7185;
    --up:      #fb7185;
    --down:    #4ade80;
    --band:    rgba(109, 151, 245, .14);
    --shadow:  0 1px 2px rgba(0,0,0,.4);
  }
}

:root[data-theme="dark"] {
  --bg:      #0f1216;
  --panel:   #171b21;
  --panel-2: #1c2129;
  --ink:     #e8eaee;
  --ink-2:   #a3abb8;
  --ink-3:   #79818f;
  --line:    #262c35;
  --line-2:  #1f242c;
  --accent:  #6d97f5;
  --accent-in: #0f1216;
  --ok:      #4ade80;
  --warn:    #fbbf24;
  --bad:     #fb7185;
  --up:      #fb7185;
  --down:    #4ade80;
  --band:    rgba(109, 151, 245, .14);
  --shadow:  0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .92em; }

/* ---------------------------------------------------------------- chrome */

.topbar {
  display: flex; align-items: center; gap: 22px;
  padding: 0 20px; height: 54px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.brand { font-weight: 650; color: var(--ink); font-size: 15px; white-space: nowrap; }
.brand span { margin-left: 2px; }

.mainnav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.mainnav a {
  padding: 6px 11px; border-radius: 7px; color: var(--ink-2); font-weight: 500;
}
.mainnav a:hover { background: var(--line-2); color: var(--ink); text-decoration: none; }
.mainnav a.on { background: var(--accent); color: var(--accent-in); }

.topright { display: flex; align-items: center; gap: 10px; }
.who { color: var(--ink-3); font-size: 12.5px; max-width: 200px; overflow: hidden;
       text-overflow: ellipsis; white-space: nowrap; }
.inline { display: inline; }

button, .btn {
  font: inherit; cursor: pointer; border-radius: 7px; padding: 6px 12px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
}
button:hover, .btn:hover { border-color: var(--ink-3); text-decoration: none; }
button.primary, .btn.primary {
  background: var(--accent); color: var(--accent-in); border-color: transparent; font-weight: 550;
}
button.ghost { border-color: transparent; background: none; color: var(--ink-2); padding: 5px 9px; }
button.ghost:hover { background: var(--line-2); color: var(--ink); }
button.danger { color: var(--bad); }

.page { max-width: 1380px; margin: 0 auto; padding: 22px 20px 60px; }
.foot { text-align: center; color: var(--ink-3); font-size: 12px; padding: 0 20px 30px; }

h1 { font-size: 20px; margin: 0 0 4px; font-weight: 620; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
.sub { color: var(--ink-2); margin: 0 0 20px; }

/* ---------------------------------------------------------------- panels */

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px;
}
.panel > h2 {
  padding: 13px 16px; margin: 0; border-bottom: 1px solid var(--line-2);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.panel > h2 .aside { font-weight: 400; color: var(--ink-3); font-size: 12.5px; }
.panel .body { padding: 16px; }

.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); }
.grid.tiles { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

/* ---------------------------------------------------------------- tiles */

.tile { padding: 16px; }
.tile .label { color: var(--ink-2); font-size: 12.5px; text-transform: uppercase;
               letter-spacing: .04em; font-weight: 600; }
.tile .value { font-size: 26px; font-weight: 640; letter-spacing: -.02em; margin: 6px 0 2px;
               font-variant-numeric: tabular-nums; }
.tile .cap  { color: var(--ink-3); font-size: 12.5px; }
/* .note is the alert box below; the tile caption needs its own name, or every
   stat tile renders its subtitle inside an amber warning panel. */
.tile .statrow { display: flex; gap: 18px; margin-top: 10px; flex-wrap: wrap; }
.tile .statrow div { font-size: 12.5px; color: var(--ink-2); }
.tile .statrow b { display: block; color: var(--ink); font-size: 15px; font-weight: 600;
                   font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- tables */

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line-2); }
th {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-3); font-weight: 620; white-space: nowrap;
  background: var(--panel); z-index: 5;
  /* top:0, not the height of the topbar. Every table sits inside .scroll, and
     `overflow-x: auto` makes that element a scroll container on BOTH axes - so a sticky
     offset here is measured from the top of that container, not from the viewport. With
     top:54px the header had nothing to stick under and was simply pushed 54px down onto
     the first rows of data on every table page. */
  position: sticky; top: 0;
}
th a { color: inherit; }
th a:hover { color: var(--accent); }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
td.mono { font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); }
td.name { font-weight: 500; }
td.tight { white-space: nowrap; }
.muted { color: var(--ink-3); }
.empty { color: var(--ink-3); padding: 26px 16px; text-align: center; }

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-block; padding: 1.5px 7px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
  border: 1px solid transparent;
}
.badge.migros { background: color-mix(in srgb, var(--migros) 16%, transparent); color: var(--migros);
                border-color: color-mix(in srgb, var(--migros) 32%, transparent); }
.badge.coop   { background: color-mix(in srgb, var(--coop) 16%, transparent); color: var(--coop);
                border-color: color-mix(in srgb, var(--coop) 34%, transparent); }
.badge.aldi   { background: color-mix(in srgb, var(--aldi) 15%, transparent); color: var(--aldi);
                border-color: color-mix(in srgb, var(--aldi) 32%, transparent); }
.badge.promo  { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad);
                border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.badge.ok     { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.badge.warn   { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.badge.bad    { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.badge.plain  { background: var(--line-2); color: var(--ink-2); }

.delta.up   { color: var(--up); font-weight: 560; }
.delta.down { color: var(--down); font-weight: 560; }

/* ---------------------------------------------------------------- filters */

.filters {
  display: flex; flex-wrap: wrap; gap: 9px; align-items: flex-end;
  padding: 13px 16px; border-bottom: 1px solid var(--line-2);
}
.filters .field { display: flex; flex-direction: column; gap: 4px; }
.filters label { font-size: 11.5px; color: var(--ink-3); font-weight: 600;
                 text-transform: uppercase; letter-spacing: .04em; }
input[type=text], input[type=number], input[type=email], input[type=password], select {
  font: inherit; padding: 6px 9px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
  min-width: 0;
}
input:focus, select:focus, button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 1px;
}
.filters .check { display: flex; align-items: center; gap: 6px; padding-bottom: 7px; }
.filters .check label { text-transform: none; letter-spacing: 0; font-size: 13px;
                        color: var(--ink); font-weight: 400; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
  background: var(--line-2); color: var(--ink-2); padding: 3px 6px 3px 9px; border-radius: 20px;
}
.chip a { color: var(--ink-3); font-weight: 700; line-height: 1; }
.chip a:hover { color: var(--bad); text-decoration: none; }

/* ---------------------------------------------------------------- breadcrumb */

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 14px;
          font-size: 13.5px; }
.crumbs a { color: var(--ink-2); padding: 3px 8px; border-radius: 6px; background: var(--panel);
            border: 1px solid var(--line); }
.crumbs a:hover { color: var(--accent); text-decoration: none; border-color: var(--accent); }
.crumbs .sep { color: var(--ink-3); }
.crumbs .here { padding: 3px 8px; font-weight: 600; }

.retailer-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 8px;
                   overflow: hidden; }
.retailer-switch a { padding: 5px 14px; color: var(--ink-2); font-weight: 550; font-size: 13px; }
.retailer-switch a.on { background: var(--accent); color: var(--accent-in); }
.retailer-switch a:hover { text-decoration: none; }

/* group cards */
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); gap: 12px; }
.gcard {
  display: block; padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); color: var(--ink);
}
.gcard:hover { border-color: var(--accent); text-decoration: none; box-shadow: var(--shadow); }
.gcard .gname { font-weight: 570; margin-bottom: 7px; }
.gcard .gstats { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2);
                 font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.gcard .gstats b { color: var(--ink); font-weight: 600; }

/* ---------------------------------------------------------------- charts */

.chart { display: block; max-width: 100%; }
.chart .grid  { stroke: var(--line); stroke-width: 1; }
.chart .axis  { fill: var(--ink-3); font-size: 11px; font-family: var(--sans); }
.chart .band  { fill: var(--band); }
.chart .line  { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot   { stroke: var(--panel); stroke-width: 1.5; }
.chart .s0 { stroke: var(--accent); } .chart circle.s0 { fill: var(--accent); }
.chart .s1 { stroke: #e8590c; }       .chart circle.s1 { fill: #e8590c; }
.chart .s2 { stroke: #2f9e44; }       .chart circle.s2 { fill: #2f9e44; }
.chart .s3 { stroke: #9c36b5; }       .chart circle.s3 { fill: #9c36b5; }
.chart .s4 { stroke: #0c8599; }       .chart circle.s4 { fill: #0c8599; }
.chart .s5 { stroke: #c2255c; }       .chart circle.s5 { fill: #c2255c; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 10px 4px 0; font-size: 12.5px;
          color: var(--ink-2); }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 11px; height: 3px; border-radius: 2px; background: currentColor; }
.legend .s0 { color: var(--accent); } .legend .s1 { color: #e8590c; }
.legend .s2 { color: #2f9e44; }       .legend .s3 { color: #9c36b5; }
.legend .s4 { color: #0c8599; }       .legend .s5 { color: #c2255c; }

.spark { display: block; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.6; }

/* ---------------------------------------------------------------- selection bar */

.selbar {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(140%);
  bottom: 22px; z-index: 60;
  display: flex; align-items: center; gap: 14px;
  background: var(--ink); color: var(--bg);
  padding: 10px 14px; border-radius: 11px;
  box-shadow: 0 8px 26px rgba(0,0,0,.28);
  transition: transform .16s ease;
}
.selbar.show { transform: translateX(-50%) translateY(0); }
.selbar .count { font-weight: 620; font-variant-numeric: tabular-nums; }
.selbar .btn { background: transparent; color: var(--bg); border-color: rgba(255,255,255,.28); }
.selbar .btn:hover { border-color: var(--bg); }
.selbar .btn.off { opacity: .45; pointer-events: none; }

/* ---------------------------------------------------------------- pagination */

.pager { display: flex; align-items: center; justify-content: space-between; gap: 14px;
         padding: 12px 16px; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.pager .range { color: var(--ink-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.pager .steps { display: flex; gap: 6px; align-items: center; }

/* ---------------------------------------------------------------- detail */

.detail-head { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.detail-head img { width: 116px; height: 116px; object-fit: contain; border-radius: 9px;
                   background: var(--panel-2); border: 1px solid var(--line); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.facts div { font-size: 12.5px; color: var(--ink-2); }
.facts b { display: block; color: var(--ink); font-size: 15px; font-weight: 600; margin-top: 2px;
           font-variant-numeric: tabular-nums; }
.pricebig { font-size: 30px; font-weight: 660; letter-spacing: -.02em;
            font-variant-numeric: tabular-nums; }
.strike { text-decoration: line-through; color: var(--ink-3); font-weight: 400; font-size: 17px; }

.note {
  background: color-mix(in srgb, var(--warn) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 26%, transparent);
  color: var(--ink); padding: 10px 13px; border-radius: 8px; font-size: 13px; margin: 0 0 14px;
}
.note.info {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-color: color-mix(in srgb, var(--accent) 24%, transparent);
}
.note.error {
  background: color-mix(in srgb, var(--bad) 9%, transparent);
  border-color: color-mix(in srgb, var(--bad) 30%, transparent);
}

.help { cursor: help; border-bottom: 1px dotted var(--ink-3); }

/* ---------------------------------------------------------------- calendar */

.cal { border-collapse: separate; border-spacing: 3px; }
.cal td { padding: 0; border: 0; }
.cal .cell { width: 34px; height: 26px; border-radius: 5px; background: var(--line-2);
             display: block; }
.cal th { position: static; background: none; }
.cal th.rot { font-size: 10.5px; }

/* ---------------------------------------------------------------- login */

.loginwrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.loginbox { width: 100%; max-width: 372px; }
.loginbox .panel { margin: 0; }
.loginbox .body { padding: 22px; }
.loginbox h1 { text-align: center; margin-bottom: 4px; }
.loginbox .sub { text-align: center; font-size: 13px; margin-bottom: 20px; }
.field-block { margin-bottom: 13px; }
.field-block label { display: block; font-size: 12px; color: var(--ink-2); font-weight: 600;
                     margin-bottom: 4px; }
.field-block input { width: 100%; }
.loginbox button { width: 100%; padding: 9px; }

@media (max-width: 760px) {
  .mainnav a { padding: 6px 8px; font-size: 13px; }
  .who { display: none; }
}
