/* ============================================================================
   WayUp Sports — Stock & Sales dashboard
   Brand-matched to wayupsports.com: RED #da2036 + ORANGE #f97316 + ink black,
   Poppins, bold uppercase, angular sport-retail energy. Light data surfaces for
   readability; dark, energetic chrome.
   ============================================================================ */
:root {
  --red: #da2036;
  --red-dark: #b01329;
  --red-soft: #fdecee;
  --orange: #f97316;
  --orange-dark: #ea580c;
  --orange-soft: #fff3e9;
  --ink: #16171c;          /* near-black chrome */
  --ink-2: #1f2128;
  --ink-3: #2a2d36;

  --bg: #eef0f4;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --tint: #f9fafb;
  --border: #e4e7ec;
  --border-strong: #cfd4dc;
  --text: #16171c;
  --muted: #6a7180;

  /* categorical chart palette — validated (CVD worst adjacent ΔE 28.4 on #fff;
     orange sits at 2.8:1 so every chart ships visible value labels as relief) */
  --c1: #da2036;
  --c2: #0d9488;
  --c3: #f97316;
  --c4: #4f46e5;
  --c5: #16a34a;
  --c6: #c026d3;

  --green: #16a34a;
  --green-bg: #e7f7ec;
  --amber: #c2680a;
  --amber-bg: #fff1e0;
  --redx: #d4183a;
  --redx-bg: #fde8ec;
  --gray: #6a7180;
  --gray-bg: #eef1f4;

  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(20,22,28,.05), 0 8px 24px rgba(20,22,28,.07);
  --shadow-lg: 0 16px 40px rgba(218,32,54,.16);
  --shadow-ink: 0 10px 30px rgba(20,22,28,.18);
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
body {
  min-height: 100vh; display: flex; flex-direction: column;
  background-image:
    radial-gradient(900px 420px at 100% -5%, rgba(249,115,22,.07), transparent 60%),
    radial-gradient(900px 460px at -5% 0%, rgba(218,32,54,.06), transparent 55%);
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 26px; background: linear-gradient(100deg, var(--ink) 0%, var(--ink-2) 60%, #25272f 100%);
  color: #fff; position: sticky; top: 0; z-index: 30;
  border-bottom: 3px solid var(--red);
  box-shadow: 0 4px 22px rgba(20,22,28,.28);
}
.brand { display: flex; align-items: center; gap: 13px; }
.logo {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 32% 28%, #ff3a50, var(--red) 70%);
  color: #fff; font-weight: 800; font-size: 1.02rem; letter-spacing: -.02em;
  box-shadow: 0 6px 16px rgba(218,32,54,.45), inset 0 0 0 2px rgba(255,255,255,.18);
  font-style: italic;
}
.topbar h1 { font-size: 1.04rem; margin: 0; font-weight: 700; letter-spacing: .01em; text-transform: uppercase; }
.topbar h1 b { color: #fff; font-weight: 800; }
.topbar h1 .accent { color: #ff5468; }
.sub { margin: 2px 0 0; color: rgba(255,255,255,.6); font-size: .74rem; font-weight: 400; text-transform: none; letter-spacing: 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.legend { display: inline-flex; align-items: center; gap: 7px; font-size: .72rem; color: rgba(255,255,255,.7); font-weight: 500; }
.dot-src { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-src.shopify { background: #95bf47; box-shadow: 0 0 0 3px rgba(149,191,71,.22); }
.dot-src.ga4 { background: #f9a825; box-shadow: 0 0 0 3px rgba(249,168,37,.22); }
.ghost-btn {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.16); color: #fff;
  width: 40px; height: 40px; border-radius: 10px; font-size: 1.05rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
  transition: transform .35s cubic-bezier(.2,.8,.2,1), background .15s, border-color .15s;
}
.ghost-btn:hover { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.3); }
#refreshBtn:active { transform: rotate(360deg); }
.ghost-btn.text { width: auto; padding: 0 15px; height: 40px; font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Layout ---------- */
main { flex: 1; width: 100%; max-width: 1320px; margin: 0 auto; padding: 22px 24px 40px; display: flex; flex-direction: column; gap: 18px; }

/* ---------- Date controls (sticky command bar) ---------- */
.date-controls {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 22px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 15px 20px; position: sticky; top: 70px; z-index: 18;
}
.date-controls::before { content: ""; width: 4px; align-self: stretch; border-radius: 4px; background: linear-gradient(var(--red), var(--orange)); margin: 2px 4px 2px 0; }
.dc-group { display: flex; flex-direction: column; gap: 7px; }
.dc-group > label { font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; display: flex; align-items: center; gap: 8px; }
.dc-inputs { display: flex; align-items: center; gap: 8px; }
.dc-inputs input, #invDate {
  font-family: inherit; font-size: .86rem; font-weight: 500; color: var(--text); background: var(--surface-2);
  border: 1.5px solid var(--border-strong); border-radius: 9px; padding: 9px 11px;
}
.dc-inputs input:focus, #invDate:focus, .field input:focus, .field select:focus, #search:focus {
  outline: none; border-color: var(--red); background: #fff; box-shadow: 0 0 0 3px rgba(218,32,54,.14);
}
.dc-inputs .dash { color: var(--orange); font-weight: 700; }
.src-tag { font-size: .58rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--gray-bg); color: var(--muted); }
.src-tag.shopify { background: #eef7e0; color: #4a7c0f; }
.dc-spacer { flex: 1; }

/* ---------- KPI cards ---------- */
.kpi-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.kpi-dots { display: inline-flex; align-items: center; gap: 4px; }
.kpi-card {
  position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 20px 20px 18px;
  display: flex; flex-direction: column; gap: 10px;
  transition: transform .2s cubic-bezier(.2,.8,.2,1), box-shadow .2s;
}
.kpi-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--accent, var(--red)); }
.kpi-card::after { content: ""; position: absolute; right: -40px; top: -60px; width: 150px; height: 150px; border-radius: 50%; background: radial-gradient(circle, var(--accent-glow, rgba(218,32,54,.12)), transparent 70%); pointer-events: none; }
.kpi-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.kpi-card:nth-child(1) { --accent: var(--red);    --accent-glow: rgba(218,32,54,.14); }
.kpi-card:nth-child(2) { --accent: var(--orange); --accent-glow: rgba(249,115,22,.15); }
.kpi-card:nth-child(3) { --accent: #4f46e5;       --accent-glow: rgba(79,70,229,.14); }   /* Total Views (GA4) */
.kpi-card:nth-child(4) { --accent: #0d9488;       --accent-glow: rgba(13,148,136,.14); }  /* Conversion */
.kpi-card:nth-child(5) { --accent: #d97706;       --accent-glow: rgba(217,119,6,.14); }   /* Add to Cart Rate */
.kpi-card:nth-child(6) { --accent: #be123c;       --accent-glow: rgba(190,18,60,.14); }   /* Bounce Rate */
.kpi-card:nth-child(7) { --accent: var(--green);  --accent-glow: rgba(22,163,74,.14); }
.kpi-card:nth-child(8) { --accent: #0891b2;       --accent-glow: rgba(8,145,178,.14); }   /* Stock Quantity */
.kpi-card:nth-child(9) { --accent: var(--ink);    --accent-glow: rgba(20,22,28,.12); }
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.kpi-label { font-size: .68rem; font-weight: 700; color: var(--muted); line-height: 1.35; text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-size: 2.1rem; font-weight: 800; letter-spacing: -.03em; color: var(--text); line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .7rem; color: var(--muted); font-weight: 500; }

/* ---------- Panels / section heads ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
.panel-head { padding: 16px 20px; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, var(--tint), var(--surface)); }
.panel-head.stack { display: flex; flex-direction: column; gap: 14px; }
.th-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-head h2 { font-size: .92rem; margin: 0; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--text); display: inline-flex; align-items: center; gap: 10px; }
.panel-head h2::before { content: ""; width: 5px; height: 18px; border-radius: 3px; background: linear-gradient(var(--red), var(--orange)); display: inline-block; }
.count { color: var(--muted); font-weight: 600; font-size: .82rem; }

/* ---------- Filters ---------- */
.filters-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.filters-grid .field.grow { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: .62rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.field input, .field select {
  font-family: inherit; font-size: .84rem; color: var(--text); background: var(--surface-2);
  border: 1.5px solid var(--border-strong); border-radius: 9px; padding: 9px 11px; font-weight: 500; width: 100%;
}
#search::placeholder { color: var(--muted); }

/* demo build marker (sample-data deployment only) */
.demo-badge {
  font-size: .62rem; font-weight: 800; letter-spacing: .09em; color: #fff;
  background: linear-gradient(135deg, var(--orange), var(--red)); padding: 4px 9px;
  border-radius: 6px; white-space: nowrap; box-shadow: 0 1px 4px rgba(218,32,54,.35);
}
@media (max-width: 760px) { .demo-badge { display: none; } }

/* type-to-search dimension filters (used where a dropdown would be unusably long) */
.field .dim-search::placeholder { color: var(--muted); font-weight: 400; }
.field .dim-search.invalid { border-color: var(--redx); background: var(--redx-bg); }
.dim-count { font-weight: 600; color: var(--border-strong); letter-spacing: 0; }
/* keep the clear "x" from overlapping the text on WebKit */
.field .dim-search::-webkit-search-cancel-button { cursor: pointer; }

/* active-filter chips */
.active-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.active-chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; font-size: .74rem; font-weight: 600;
  background: var(--ink); color: #fff; border-radius: 999px; padding: 6px 8px 6px 12px;
  animation: chipPop .25s cubic-bezier(.2,1.3,.5,1) both;
}
.chip .chip-k { color: rgba(255,255,255,.55); font-weight: 500; text-transform: uppercase; font-size: .62rem; letter-spacing: .04em; }
.chip button { border: none; background: rgba(255,255,255,.16); color: #fff; width: 18px; height: 18px; border-radius: 50%; cursor: pointer; font-size: .8rem; line-height: 1; display: grid; place-items: center; }
.chip button:hover { background: var(--red); }
@keyframes chipPop { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: scale(1); } }

/* buttons */
.reset-btn, .action-btn {
  font-family: inherit; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  border-radius: 9px; padding: 9px 15px; cursor: pointer; border: 1.5px solid var(--border-strong);
  background: #fff; color: var(--text); transition: all .15s;
}
.reset-btn:hover { color: var(--red); border-color: var(--red); background: var(--red-soft); }
.action-btn { background: var(--ink); border-color: var(--ink); color: #fff; }
.action-btn:hover { background: var(--red); border-color: var(--red); transform: translateY(-1px); }
.table-actions { display: flex; gap: 8px; }

/* ---------- Table ---------- */
.table-panel { scroll-margin-top: 130px; }
/* Vertical scroll lives on this container (not the page) so the sticky thead below
   actually freezes — with only overflow-x, this element is the sticky containing block
   while the page does the vertical scrolling, and the header never sticks. */
.table-scroll { overflow: auto; max-height: calc(100vh - 240px); }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
thead th {
  text-align: left; color: var(--muted); font-weight: 700; font-size: .64rem; text-transform: uppercase; letter-spacing: .06em;
  padding: 13px 14px; white-space: nowrap; background: var(--surface-2);
  position: sticky; top: 0; z-index: 5;
  /* box-shadow, not border-bottom: with border-collapse the border detaches from a
     sticky cell and disappears while scrolling. */
  box-shadow: inset 0 -2px 0 var(--border);
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--orange-soft); }
tbody tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.sortable { cursor: pointer; user-select: none; transition: color .12s; }
.sortable:hover { color: var(--red); }
.sortable.asc::after { content: " ▲"; font-size: .58em; color: var(--red); }
.sortable.desc::after { content: " ▼"; font-size: .58em; color: var(--red); }
.prod-title { font-weight: 600; color: var(--text); }
.prod-variant { color: var(--muted); font-size: .76rem; display: block; }
.sku-cell { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .76rem; color: var(--muted); }

/* product rows expand into per-size sub-rows */
tr.prod-row[data-expandable="1"] { cursor: pointer; }
.caret { display: inline-block; width: 14px; margin-right: 4px; color: var(--muted); font-size: .7rem; transition: transform .15s; }
.caret.empty::before { content: ""; }
tr.prod-row.open .caret { transform: rotate(90deg); color: var(--red); }
.size-chip { margin-left: 8px; font-size: .66rem; font-weight: 700; color: var(--red); background: rgba(218,32,54,.08); border-radius: 10px; padding: 2px 8px; white-space: nowrap; vertical-align: middle; }
tr.size-row td { background: rgba(20,22,28,.025); font-size: .8rem; padding-top: 7px; padding-bottom: 7px; }
tr.size-row .size-name { padding-left: 34px; color: var(--text); font-weight: 500; }
tr.size-row:hover { background: var(--orange-soft); }

/* ---- merchandising snapshot charts ---- */
.charts-note { font-size: .68rem; font-weight: 500; color: var(--muted); text-transform: none; letter-spacing: 0; margin-left: 10px; }
.charts-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; }
.chart-card { padding: 18px 20px 20px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); min-width: 0; display: flex; flex-direction: column; }

/* Quantity | Value | Stock */
.view-toggle { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.view-toggle button {
  font-family: inherit; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); background: none; border: 0; border-radius: 7px; padding: 6px 13px; cursor: pointer; transition: background .15s, color .15s;
}
.view-toggle button:hover { color: var(--text); }
.view-toggle button.active { background: var(--red); color: #fff; box-shadow: 0 1px 3px rgba(218,32,54,.35); }

/* month-over-month change pill — arrow + sign carry direction, colour only reinforces */
.delta { font-size: .66rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; padding: 1px 5px; border-radius: 5px; flex: 0 0 auto; }
.delta.up { color: var(--green); background: var(--green-bg); }
.delta.down { color: var(--redx); background: var(--redx-bg); }
.delta.new { color: var(--amber); background: var(--amber-bg); letter-spacing: .04em; }
.chart-card:nth-child(3n) { border-right: none; }
.chart-card h3 { margin: 0 0 14px; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text); }
.chart-empty { color: var(--muted); font-size: .82rem; margin: 24px 0; }

/* donut + legend */
.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut-wrap svg { width: 140px; height: 140px; flex: 0 0 auto; }
.donut-total { font-size: 20px; font-weight: 700; fill: var(--text); text-anchor: middle; }
.donut-cap { font-size: 9px; font-weight: 600; fill: var(--muted); text-anchor: middle; text-transform: uppercase; letter-spacing: .06em; }
.donut-wrap path, .donut-wrap circle { cursor: default; }
.chart-legend { list-style: none; margin: 0; padding: 0 4px 0 0; flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; max-height: 190px; overflow-y: auto; }
.chart-legend li { display: flex; align-items: center; gap: 8px; font-size: .76rem; min-width: 0; }
.chart-legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.chart-legend .lg-k { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.chart-legend .lg-v { color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-legend .lg-p { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; width: 46px; text-align: right; }

/* horizontal bars — nominal single hue; 4px rounded data-end, square baseline.
   Scrolls so the full vendor / category list is reachable at a fixed card height. */
.hbars { display: flex; flex-direction: column; gap: 9px; max-height: 210px; overflow-y: auto; overflow-x: hidden; padding-right: 6px; }
.hbars::-webkit-scrollbar, .chart-legend::-webkit-scrollbar { width: 8px; }
.hbars::-webkit-scrollbar-thumb, .chart-legend::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.hbars::-webkit-scrollbar-track, .chart-legend::-webkit-scrollbar-track { background: transparent; }
.hbar-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hbar-k { flex: 0 0 108px; font-size: .72rem; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.hbar-track { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.hbar-fill { height: 16px; background: var(--c1); border-radius: 0 4px 4px 0; flex: 0 0 auto; transition: width .4s cubic-bezier(.2,.8,.2,1); }
.hbar-fill.other { background: var(--gray); opacity: .55; }
.hbar-v { font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* shared chart tooltip */
.chart-tooltip { position: fixed; z-index: 60; pointer-events: none; background: var(--ink); color: #fff; font-size: .74rem; font-weight: 500; padding: 7px 11px; border-radius: 8px; box-shadow: var(--shadow-ink); max-width: 320px; }

/* status badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 6px; font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.badge.active { background: var(--green-bg); color: var(--green); }
.badge.draft { background: var(--amber-bg); color: var(--amber); }
.badge.archived { background: var(--gray-bg); color: var(--gray); }

/* conversion cell color cues */
.conv-hi { color: var(--green); font-weight: 700; }
.conv-mid { color: var(--amber); font-weight: 600; }
.conv-lo { color: var(--muted); }

/* low-stock flags + zebra rows */
.flag { font-size: .7rem; vertical-align: middle; margin-left: 2px; }
.flag.red { color: var(--redx); }
.flag.amber { color: var(--orange); }
tr.row-out td { box-shadow: inset 3px 0 0 var(--redx); }
tr.row-low td { box-shadow: inset 3px 0 0 var(--orange); }
.ext { color: var(--red); text-decoration: none; font-weight: 700; font-size: 1rem; }
.ext:hover { color: var(--orange); }

/* pager */
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 16px 18px; border-top: 1px solid var(--border); background: var(--tint); }
.pg-btn { font-family: inherit; font-size: .8rem; font-weight: 600; border: 1.5px solid var(--border-strong); background: #fff; color: var(--text); border-radius: 8px; padding: 7px 12px; cursor: pointer; transition: all .12s; }
.pg-btn:hover:not(:disabled) { border-color: var(--red); color: var(--red); }
.pg-btn.active { background: var(--red); border-color: var(--red); color: #fff; }
.pg-btn:disabled { opacity: .4; cursor: default; }
.pg-gap { color: var(--muted); padding: 0 2px; }
.pg-info { margin-left: auto; font-size: .74rem; color: var(--muted); font-weight: 500; }

/* ---------- States ---------- */
.loading { position: fixed; inset: 0; display: grid; place-items: center; align-content: center; gap: 16px; background: var(--bg); z-index: 50; }
.spinner { width: 44px; height: 44px; border: 4px solid var(--red-soft); border-top-color: var(--red); border-right-color: var(--orange); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading p { color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; font-size: .76rem; }
.error-box { margin: 24px; padding: 18px 20px; background: var(--redx-bg); border: 1px solid #f5b8c4; border-left: 4px solid var(--red); border-radius: var(--radius); color: var(--text); }
.error-box code { background: #fff; border: 1px solid var(--border); padding: 2px 6px; border-radius: 5px; }
.empty { text-align: center; color: var(--muted); padding: 36px; font-weight: 600; }
.foot { padding: 20px 24px; border-top: 1px solid var(--border); color: var(--muted); font-size: .74rem; text-align: center; }

/* ---------- Load-in animation ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.date-controls, .kpi-cards, .filter-panel, .table-panel { animation: rise .5s ease both; }
.kpi-cards { animation-delay: .06s; }
.filter-panel { animation-delay: .12s; }
.table-panel { animation-delay: .18s; }
.kpi-card { animation: rise .5s ease both; }
.kpi-card:nth-child(1){animation-delay:.06s} .kpi-card:nth-child(2){animation-delay:.12s}
.kpi-card:nth-child(3){animation-delay:.18s} .kpi-card:nth-child(4){animation-delay:.24s}
.kpi-card:nth-child(5){animation-delay:.30s} .kpi-card:nth-child(6){animation-delay:.36s}
.kpi-card:nth-child(7){animation-delay:.42s} .kpi-card:nth-child(8){animation-delay:.48s}
.kpi-card:nth-child(9){animation-delay:.54s}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Mobile (390×844) ---------- */
@media (max-width: 820px) {
  .kpi-cards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 1080px) {
  .charts-grid { grid-template-columns: 1fr 1fr; }
  .chart-card:nth-child(3n) { border-right: 1px solid var(--border); }
  .chart-card:nth-child(2n) { border-right: none; }
}
@media (max-width: 760px) {
  .topbar { padding: 12px 16px; }
  .charts-grid { grid-template-columns: 1fr; }
  .chart-card { border-right: none !important; }
  .donut-wrap { flex-direction: row; }
  .topbar h1 { font-size: .9rem; }
  .legend { display: none; }
  main { padding: 16px; gap: 14px; }
  .date-controls { position: static; gap: 12px; padding: 14px; }
  .kpi-value { font-size: 1.7rem; }
  .pg-info { width: 100%; margin: 6px 0 0; }
  .variants thead { display: none; }
  .variants, .variants tbody, .variants tr, .variants td { display: block; width: 100%; }
  .variants tr { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 12px; padding: 6px 4px; background: var(--surface); box-shadow: var(--shadow); }
  .variants td { border: none; padding: 7px 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
  .variants td::before { content: attr(data-label); color: var(--muted); font-size: .66rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
  .variants td.num { text-align: right; }
  tr.row-out td, tr.row-low td { box-shadow: none; }
  tr.size-row td:empty { display: none; }
  tr.size-row { margin-left: 14px; width: calc(100% - 14px); }
  tr.size-row .size-name { padding-left: 14px; }
}
@media (max-width: 460px) { .kpi-cards { grid-template-columns: 1fr; } }
