/* ==========================================================================
   ANALYTICS-SHOPIFY-2 — Analytics filter row + KPI tiles, matched to the Shopify reference screenshot.
   Scope: #view-analytics only (and the grey canvas for body[data-route="analytics"]). Presentation only.
   Loaded after shopify-shell.css, before press-effect.css (so the "button sinks" :active effect still applies).
   Roll back: remove this <link> and js/an-range-picker.js; restore the old toolbar markup from the previous zip.

   How the numbers were obtained: the reference is a 150% display (1 CSS px = 1.5 screenshot px — the same scale the
   SHOPIFY-SHELL-1 phase measured). Every value below = screenshot pixels / 1.5, then checked by rendering this CSS in
   Chromium and diffing against the screenshot:
     canvas        #F1F1F1
     pill          28px high, radius 8, white, 12px / 500 #303030, 20px icons #4A4A4A, 8px side padding, 8px gap between pills
                   edge = Polaris button bevel: bottom 1px #B5B5B5, 1px rgba(0,0,0,.1) ring, 0.5px white highlight
     tile          radius 12, 1px #E3E3E3 border (bottom #CCCCCC), soft 1px drop shadow, padding 16 (12 at the bottom), 12px gap between tiles
     tile label    12px / 670 #303030, 2px dotted #CCCCCC underline on the words only
     tile value    12px / 700 #303030 (same size as the label in the reference; bump --an-kpi-val to enlarge)
   ========================================================================== */

#view-analytics {
  --an-kpi-val: 12px;           /* tile value size (reference = 12px; raise to 16-20px for a bolder look) */
  --an-ink: #303030;
  --an-ink-2: #616161;
  --an-icon: #4A4A4A;
}

/* Grey Shopify canvas behind the Analytics page */
body[data-route="analytics"] .main,
body[data-route="analytics"] .content { background: #F1F1F1; }

/* ------------------------------ Filter row ------------------------------ */
#view-analytics .an-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 8px 12px; margin: 0; }
#view-analytics .an-dpk { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#view-analytics .an-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 12px; margin-left: auto; }

#view-analytics .dpk-pill,
#view-analytics .an-cur-pill {
  display: inline-flex; align-items: center; gap: 2px; height: 28px; margin: 0; padding: 0 6px 0 7px;
  border: 0; border-radius: 8px; background: #fff; color: var(--an-ink);
  font-family: inherit; font-size: 12px; font-weight: 500; line-height: 16px; letter-spacing: 0; white-space: nowrap;
  box-shadow: inset 0 -1px 0 0 #B5B5B5, inset 0 0 0 1px rgba(0, 0, 0, .1), inset 0 .5px 0 1.5px #fff;
}
#view-analytics .dpk-pill:hover { background: #FAFAFA; }
#view-analytics .dpk-pill[aria-expanded="true"] { background: #F7F7F7; box-shadow: inset 0 -1px 0 0 #B5B5B5, inset 0 0 0 1px rgba(0, 0, 0, .12), inset 0 1px 2px 0 rgba(0, 0, 0, .1); }
#view-analytics .dpk-pill:focus-visible { outline: 2px solid #168A4E; outline-offset: 1px; }
#view-analytics .an-cur-pill { padding: 0 12px 0 7px; cursor: default; }
#view-analytics .an-cur-pill:hover { background: #fff; }
#view-analytics .an-ic { display: block; flex: none; width: 20px; height: 20px; color: var(--an-icon); }
#view-analytics .dpk-pill .an-ic { margin: 0; }
#view-analytics .dpk-pill > span { padding: 0; }

/* Compare chip + "Last refreshed" read as plain secondary text, like the reference header */
#view-analytics .an-compare { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; border-radius: 0; background: transparent; font-size: 13px; line-height: 20px; font-weight: 400; color: var(--an-ink-2); }
#view-analytics .an-compare-k { color: var(--an-ink-2); font-weight: 400; }
#view-analytics .an-refreshed { font-size: 13px; line-height: 20px; color: var(--an-ink-2); white-space: nowrap; }
#view-analytics .an-refreshed:empty { display: none; }

/* Menu + calendar popovers keep the Dashboard look (date-picker.css); only the pill styling above differs. */
#view-analytics .dpk-menu, #view-analytics .dpk-pop { top: calc(100% + 4px); }

/* ------------------------------ KPI tiles ------------------------------ */
#view-analytics .dash-kpis.an-perf-strip {
  gap: 12px; background: transparent; border: 0; border-radius: 0; box-shadow: none; overflow: visible;
}
#view-analytics .an-perf-strip .dash-kpi,
#view-analytics .an-perf-strip .dash-kpi:nth-child(n) {
  position: relative; display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  grid-template-areas: "label label" "val cmp"; align-content: start; align-items: center; column-gap: 8px; row-gap: 4px;
  min-width: 0; min-height: 75px; padding: 16px 16px 12px; overflow: hidden;
  background: #fff; border: 1px solid #E3E3E3; border-bottom-color: #CCCCCC; border-radius: 12px;
  box-shadow: 0 1px 0 0 rgba(26, 26, 26, .07);
  cursor: default;
}
#view-analytics .an-perf-strip .dash-kpi:hover { background: #fff; }

#view-analytics .an-perf-strip .dash-kpi-label {
  grid-area: label; display: block; min-width: 0; max-width: 100%; margin: 0;
  font-size: 12px; font-weight: 670; line-height: 20px; letter-spacing: 0; color: var(--an-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#view-analytics .an-kpi-term { padding-bottom: 1px; border-bottom: 2px dotted #CCCCCC; cursor: help; }

#view-analytics .an-perf-strip .dash-kpi-val {
  grid-area: val; min-width: 0; margin: 0;
  font-size: var(--an-kpi-val); font-weight: 700; line-height: 20px; letter-spacing: 0; color: var(--an-ink);
}
@media (min-width: 640px) { #view-analytics .an-perf-strip .dash-kpi-val { font-size: var(--an-kpi-val); } }
#view-analytics .an-perf-strip .dash-kpi-val.is-muted { color: var(--an-ink-2); font-weight: 550; }
#view-analytics .an-perf-strip .dash-dash { color: var(--an-ink); }
#view-analytics .an-perf-strip .dash-kpi.is-muted-cell .dash-kpi-label { color: var(--an-ink); }
#view-analytics .an-perf-strip .skel-row { width: 56px; height: 12px; margin: 4px 0; }

/* Change vs previous period: plain coloured text next to the value (no tinted chip) */
#view-analytics .an-perf-strip .dash-kpi-cmp { grid-area: cmp; min-width: 0; min-height: 0; margin: 0; gap: 4px; overflow: hidden; }
#view-analytics .an-perf-strip .dash-kpi-spacer { display: none; }
#view-analytics .an-perf-strip .dash-pill { padding: 0; background: none; border-radius: 0; font-size: 12px; font-weight: 550; line-height: 20px; }
#view-analytics .an-perf-strip .dash-pill.is-up { background: none; color: #047B5D; }
#view-analytics .an-perf-strip .dash-pill.is-down { background: none; color: #C70A24; }

/* Sparkline sits at the right of the tile instead of under the value */
#view-analytics .an-perf-strip .an-spark { position: absolute; right: 14px; bottom: 10px; width: 64px; height: 28px; margin: 0; pointer-events: none; }
@media (max-width: 1180px) { #view-analytics .an-perf-strip .an-spark { visibility: hidden; } }

@media (max-width: 480px) { #view-analytics .an-perf-strip .dash-kpi, #view-analytics .an-perf-strip .dash-kpi:nth-child(n) { min-height: 75px; } }

/* ------------------------------ Phones ------------------------------ */
@media (max-width: 720px) {
  #view-analytics .an-tools { width: 100%; margin-left: 0; justify-content: space-between; }
}
@media (max-width: 640px) {
  /* The two-month calendar becomes a one-month bottom sheet (js/an-range-picker.js draws a single month here). */
  #view-analytics .dpk-pop {
    position: fixed; left: 12px; right: 12px; top: auto; bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    width: auto; max-width: none; z-index: 1000; box-shadow: 0 -8px 28px rgba(15, 23, 42, .2);
  }
  #view-analytics .dpk-cals { display: block; }
  #view-analytics .dpk-cal { width: 100%; }
  #view-analytics .dpk-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  #view-analytics .dpk-d { width: 100%; height: 36px; }
  #view-analytics .dpk-foot .btn { height: 32px; min-height: 32px; }
}


/* ==========================================================================
   ANALYTICS-SALES-CARD-2 — "Total sales over time" + "Total sales breakdown", matched to the Shopify reference screenshot.
   Scope: #view-analytics .an-sales-pair only. Same 150% display as above: every value = screenshot px / 1.5.
   Replaces the SALES-CARD-1 styling (channel toggle, metric dropdown, caption, sub-lines and alternate row tints are gone with their markup).
     card          radius 12, 1px #E3E3E3 border, bottom #CCCCCC with a short soft shadow, padding 17px (16.3 + 1px border)
     title         12px / 650 #303030, 2px dotted #CCCCCC underline on the words only
     headline      20px / 650 #303030, letter-spacing -.4px
     chart         grid #EEEEEF 1px at KES 0 / 5 / 10, axis text 10.4px #70707B, line #13ACF0 2px (set in js/ed-charts.js + admin.js)
     legend        8px dots, 10.4px #70707B, centred under the chart
     breakdown     8 rows x 41px, labels 12px #168A4E, values 12px / 650 #303030, change column #8A8A8A, even rows tinted #F7F7F7 (radius 6)
   The chart box height (257.5px) is set in ed-charts.css next to the other fixed chart boxes.
   ========================================================================== */
#view-analytics .an-dotted { display: inline; padding-bottom: 1.7px; border-bottom: 2px dotted #CCCCCC; cursor: default; }

/* Pair: chart 2.04 : breakdown 1, 13px apart (measured from the screenshot); stacked on small screens */
#view-analytics .an-sales-pair { grid-template-columns: minmax(0, 1fr); gap: 13px; }
@media (min-width: 1024px) {
  #view-analytics .an-sales-pair { grid-template-columns: minmax(0, 2.04fr) minmax(0, 1fr); }
  #view-analytics .an-sales-pair > .dash-stats-card { grid-column: auto; }
}
#view-analytics .an-sales-pair > .card {
  display: flex; flex-direction: column; justify-content: flex-start; height: auto; min-width: 0; margin: 0; padding: 17.3px 16.3px 17.3px;
  background: #fff; border: 1px solid #E3E3E3; border-bottom-color: #CCCCCC; border-radius: 12px; box-shadow: 0 2px 4px -2px rgba(26, 26, 26, .16);
}
#view-analytics .an-sales-pair .dash-card-head { display: block; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; }
#view-analytics .an-sales-pair .dash-card-head h3 { margin: 0; font-size: 12px; font-weight: 650; line-height: 16px; letter-spacing: 0; color: #303030; }

/* Headline under the chart title: just the amount (a change badge only appears when there is a previous period to compare with) */
#view-analytics #anStatsSummary { display: flex; align-items: center; flex-wrap: wrap; gap: 0 8px; min-height: 28px; margin: 6.4px 0 9.3px; padding: 0; }
#view-analytics #anStatsSummary .an-stat-val { font-size: 22px; font-weight: 650; line-height: 28px; letter-spacing: -1px; color: #303030; }

/* Legend: current (dark blue) and previous (light blue) range, centred under the chart */
#view-analytics .an-legend { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 0 18.5px; height: 20px; margin: 16.8px 0 0; font-size: 10.4px; line-height: 20px; color: #70707B; font-variant-numeric: tabular-nums; white-space: nowrap; }
#view-analytics .an-legend span { display: inline-flex; align-items: center; gap: 10.5px; }
#view-analytics .an-legend i { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* Breakdown: eight plain rows, label | value | change */
#view-analytics #biSalesBreakdown { display: flex; flex-direction: column; margin: 12.6px 0 0; }
#view-analytics .an-bd-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 38.7px; align-items: center; column-gap: 10px; height: 41px; padding: 0 6.3px; border-radius: 6px; font-size: 12px; line-height: 16px; color: #303030; }
#view-analytics .an-bd-row:nth-child(even) { background: #F7F7F7; }
#view-analytics .an-bd-k { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 450; color: #168A4E; }
#view-analytics .an-bd-v { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; color: #303030; }
#view-analytics .an-bd-d { text-align: center; font-size: 12px; font-weight: 550; font-variant-numeric: tabular-nums; white-space: nowrap; color: #616161; }
#view-analytics .an-bd-d.is-nil { color: #8A8A8A; font-weight: 400; }
#view-analytics .an-bd-d.is-up { color: #047B5D; }
#view-analytics .an-bd-d.is-down { color: #C70A24; }
#view-analytics .an-bd-note { padding: 6px; font-size: 12px; line-height: 18px; color: #616161; }
