/* feedmycart.ai/stats — live inzichten uit de aanbiedingen van alle ketens.
   Bouwt op styles.css (kleuren, nav, knoppen); hier alleen wat de grafieken
   nodig hebben. Kleuren per rol, gevalideerd tegen het kaartvlak (#14211D):
   - categorisch (wie/wat): vaste volgorde c1..c4, "rest" in grijs;
   - ordinaal/sequentieel (hoeveel): één tint, donker = weinig, licht = veel. */
.viz {
  --surface: #14211D;
  --text: #EDF3F0;
  --text-2: #9DB0A9;
  --muted: #7C9089;
  --grid: rgba(255, 255, 255, 0.07);
  --axis: rgba(255, 255, 255, 0.16);
  --one: #2FB5A6;          /* één reeks */
  --c1: #3987E5; --c2: #D95926; --c3: #199E70; --c4: #C98500; --c5: #D55181;
  --rest: #55655F;         /* "overig" / geen expliciet mechanisme */
  --o1: #1F6F66; --o2: #239286; --o3: #2FB5A6; --o4: #62D2C4; --o5: #A2E8DE;
}

.stats-hero { padding: 64px 0 28px; position: relative; overflow: hidden; }
.stats-hero::before {
  content: ""; position: absolute; inset: -60% -20% auto; height: 150%;
  background: radial-gradient(ellipse at 75% 10%, rgba(35,179,164,0.14), transparent 55%);
  pointer-events: none;
}
.stats-hero .container { position: relative; }
.stats-hero h1 { font-size: clamp(30px, 5vw, 46px); line-height: 1.1; letter-spacing: -0.02em; font-weight: 800; max-width: 760px; }
.stats-hero h1 em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stats-hero p { margin-top: 16px; color: var(--ink-soft); max-width: 660px; font-size: 17px; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 8px; box-shadow: 0 0 0 4px rgba(53,200,120,0.18); vertical-align: 1px; }

/* filterrij: één rij boven alles wat ze aanstuurt */
.scopebar {
  position: sticky; top: 64px; z-index: 40;
  background: rgba(11, 18, 16, 0.92); backdrop-filter: blur(12px);
  border-block: 1px solid var(--border); padding: 12px 0;
}
.scopebar__row { display: flex; flex-wrap: wrap; gap: 8px 8px; align-items: center; }
.scopebar__label { font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft); margin-right: 4px; }
.chip {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-soft); cursor: pointer;
  background: transparent; border: 1px solid var(--border); border-radius: 999px; padding: 5px 13px;
}
.chip:hover { color: var(--ink); border-color: rgba(255,255,255,0.25); }
.chip[aria-pressed="true"] { background: var(--ink); color: #0B1210; border-color: var(--ink); }
.chip--sub { border-style: dashed; }
.chip:focus-visible, .tile:focus-visible, .mark:focus-visible, .tbl-toggle:focus-visible, .seg button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.scopebar__sep { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }

.kpis-live { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin: 28px 0 8px; }
@media (max-width: 900px) { .kpis-live { grid-template-columns: repeat(2, 1fr); } }
.kpi-live { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 18px 18px 16px; }
.kpi-live b { display: block; font-size: 28px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); }
.kpi-live span { display: block; font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.kpi-live small { display: block; font-size: 11.5px; color: #7C9089; margin-top: 6px; }

.stats-section { padding: 34px 0 6px; }
.stats-section h2 { font-size: clamp(21px, 3vw, 27px); letter-spacing: -0.02em; margin: 6px 0 6px; }
.stats-section > .container > p.lead { color: var(--ink-soft); max-width: 700px; margin-bottom: 20px; font-size: 15px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-map { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 900px) { .grid2, .grid-map { grid-template-columns: 1fr; } }

/* grafiekkaart */
.fig { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 20px 20px 18px; margin: 0; min-width: 0; }
.fig__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.fig h3 { font-size: 15.5px; font-weight: 700; color: var(--text); }
.fig__sub { font-size: 12.5px; color: var(--text-2); margin-bottom: 16px; }
.fig__note { font-size: 11.5px; color: var(--muted); margin-top: 14px; }
.tbl-toggle { font: inherit; font-size: 11.5px; color: var(--text-2); background: transparent; border: 1px solid var(--border); border-radius: 8px; padding: 3px 9px; cursor: pointer; white-space: nowrap; }
.tbl-toggle:hover { color: var(--text); }
.fig table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 12px; font-variant-numeric: tabular-nums; }
.fig th, .fig td { text-align: right; padding: 5px 8px; border-bottom: 1px solid var(--grid); color: var(--text-2); }
.fig th:first-child, .fig td:first-child { text-align: left; color: var(--text); }
.fig thead th { font-weight: 600; color: var(--muted); font-size: 11.5px; }
.tbl-wrap { overflow-x: auto; }
[hidden] { display: none !important; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 14px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* tegelkaart */
.map { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.map__label { font-size: 10.5px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); align-self: end; padding-bottom: 2px; }
.tile {
  font: inherit; cursor: pointer; border: 0; border-radius: 12px; aspect-ratio: 1 / 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: #fff; transition: transform 0.12s, filter 0.12s, opacity 0.2s; padding: 2px;
}
.tile:hover { transform: translateY(-2px); filter: brightness(1.12); }
.tile b { font-size: 13px; font-weight: 800; letter-spacing: 0.02em; }
.tile span { font-size: 11px; font-variant-numeric: tabular-nums; opacity: 0.95; }
.tile--dark-ink { color: #0B1210; }
.tile--out { opacity: 0.38; }
.tile--sel { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.tile--none { background: transparent !important; border: 1px dashed var(--border); color: var(--muted); cursor: default; }
@media (max-width: 520px) { .tile span { font-size: 9.5px; } .tile b { font-size: 11.5px; } }
.scale { display: flex; align-items: center; gap: 4px; margin-top: 14px; font-size: 11px; color: var(--muted); }
.scale i { width: 26px; height: 8px; border-radius: 2px; display: inline-block; }
.scale em { font-style: normal; margin: 0 4px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { font: inherit; font-size: 12.5px; color: var(--ink-soft); background: transparent; border: 0; padding: 5px 11px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: rgba(35,179,164,0.18); color: var(--ink); }

/* liggende staven */
.hbars { display: grid; gap: 9px; }
.hbar { display: grid; grid-template-columns: minmax(96px, 34%) 1fr; gap: 10px; align-items: center; font-size: 12.5px; }
.hbar__name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar__name small { color: var(--muted); font-size: 11px; margin-left: 6px; }
.hbar__track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hbar__fill { height: 14px; background: var(--one); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar__val { color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12px; }
.hbar--hi .hbar__name { color: var(--text); font-weight: 600; }

/* gestapelde rijen (100%) */
.srows { display: grid; gap: 8px; }
.srow { display: grid; grid-template-columns: minmax(84px, 26%) 1fr auto; gap: 10px; align-items: center; font-size: 12.5px; }
.srow__name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow--hi .srow__name { color: var(--text); font-weight: 600; }
.srow--ctx .srow__name { font-style: italic; }
.srow__bar { display: flex; gap: 2px; height: 16px; min-width: 0; }
.srow__seg { height: 100%; min-width: 0; }
.srow__seg:first-child { border-radius: 4px 0 0 4px; }
.srow__seg:last-child { border-radius: 0 4px 4px 0; }
.srow__end { color: var(--text); font-variant-numeric: tabular-nums; font-size: 12px; white-space: nowrap; min-width: 54px; text-align: right; }
.mark { cursor: default; }
.mark:hover { filter: brightness(1.18); }

/* kolommen (histogram) */
.cols { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; align-items: end; height: 150px; border-bottom: 1px solid var(--axis); }
.col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 5px; }
.col__fill { width: min(24px, 70%); background: var(--one); border-radius: 4px 4px 0 0; min-height: 2px; }
.col__val { font-size: 11.5px; color: var(--text); font-variant-numeric: tabular-nums; }
.cols-x { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; margin-top: 6px; font-size: 11px; color: var(--muted); text-align: center; }

/* merken */
.brands { display: grid; gap: 8px; }
.brand { display: grid; grid-template-columns: minmax(90px, 22%) minmax(60px, 26%) 1fr; gap: 10px; align-items: center; font-size: 12.5px; }
.brand__name { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand__codes { color: var(--muted); font-size: 11px; letter-spacing: 0.04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* tijdreeksen */
.ts { position: relative; }
.ts svg { display: block; width: 100%; height: auto; overflow: visible; }
.ts text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.ts .grid { stroke: var(--grid); stroke-width: 1; }
.ts .axis { stroke: var(--axis); stroke-width: 1; }
.ts .line { fill: none; stroke: var(--one); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ts .area { fill: var(--one); opacity: 0.1; }
.ts .dot { fill: var(--one); stroke: var(--surface); stroke-width: 2; }
.ts .cross { stroke: var(--axis); stroke-width: 1; }
.ts .endlabel { fill: var(--text); font-size: 12px; font-weight: 600; }
.empty { border: 1px dashed var(--border); border-radius: 12px; padding: 22px 18px; color: var(--text-2); font-size: 13px; }
.empty b { color: var(--text); }

.tip {
  position: fixed; z-index: 100; pointer-events: none; max-width: 260px;
  background: #0B1210; border: 1px solid rgba(255,255,255,0.16); border-radius: 10px; padding: 8px 11px;
  font-size: 12px; color: var(--ink-soft); box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.tip b { display: block; color: var(--ink); font-size: 13px; }
.tip i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: 3px; }

.method { margin: 34px 0 70px; font-size: 12.5px; color: var(--ink-soft); }
.method h3 { font-size: 13px; color: var(--ink); margin-bottom: 8px; }
.method ul { padding-left: 18px; display: grid; gap: 5px; }
.stats-error { margin: 60px 0; }
@media (prefers-reduced-motion: reduce) { .tile { transition: none; } }

/* aanvullingen bij de logica */
.srow__link { font: inherit; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; }
.srow__link:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.srow__link:focus-visible, .ts svg:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
.brand .hbar__track { min-width: 0; }
@media (max-width: 720px) {
  .scopebar { top: 64px; padding: 9px 0; }
  .scopebar__row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .scopebar__row::-webkit-scrollbar { display: none; }
  .chip, .scopebar__label { flex: none; white-space: nowrap; }
  .fig { padding: 16px 14px 14px; }
  .map { gap: 4px; }
  .tile { border-radius: 8px; }
  .legend { gap: 5px 10px; font-size: 11.5px; }
}
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stack > .fig:last-child { flex: 1; }
button.hbar__name { text-align: left; }
@media (max-width: 900px) { .kpi-live:first-child { grid-column: 1 / -1; } }
