*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ---- Marshall brand palette ----------------------------------------------- */

:root {
  /* Primary */
  --marshall-white: #FFFFFF;
  --marshall-black: #101010;

  /* Secondary — white with opacity */
  --marshall-white-70: rgba(255, 255, 255, 0.7);
  --marshall-white-50: rgba(255, 255, 255, 0.5);
  --marshall-white-30: rgba(255, 255, 255, 0.33);
  --marshall-white-15: rgba(255, 255, 255, 0.15);
  --marshall-white-5:  rgba(255, 255, 255, 0.05);

  /* Secondary — black with opacity */
  --marshall-black-70: rgba(16, 16, 16, 0.7);
  --marshall-black-50: rgba(16, 16, 16, 0.5);
  --marshall-black-30: rgba(16, 16, 16, 0.33);
  --marshall-black-15: rgba(16, 16, 16, 0.15);
  --marshall-black-5:  rgba(16, 16, 16, 0.05);

  /* Backgrounds */
  --marshall-bg-hero:        #242428;
  --marshall-bg-hero-alt:    #525355;
  --marshall-bg-modal:       #373737;
  --marshall-bg-modal-alt:   #484848;
  --marshall-bg-header:      #202022;
  --marshall-bg-carousel:    rgba(59, 60, 62, 0.98);
  --marshall-bg-home-header: #535456;
  --marshall-bg-solid-grey:  #464748;
  --marshall-bg-solid-70:    #B2B2B2;
  --marshall-bg-solid-40:    #666666;
  --marshall-bg-modal-tnb:   #363636;

  /* Extras */
  --marshall-red:         #F03F38;
  --marshall-red-light:   #F9DADA;
  --marshall-green:       #3C9059;
  --marshall-green-light: #DCEEC6;
  --marshall-yellow:      #CF9E1F;

  /* ---- Semantic tokens (dark theme) --------------------------------------- */
  --bg:      var(--marshall-bg-hero);
  --surface: var(--marshall-bg-modal);
  --border:  var(--marshall-white-15);
  --text:    var(--marshall-white);
  --muted:   var(--marshall-white-50);
}

/* ---- Base ----------------------------------------------------------------- */

body {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ---- Header --------------------------------------------------------------- */

header {
  background: var(--marshall-bg-header);
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.header-logo {
  height: 28px;
  width: auto;
  filter: brightness(0) invert(1);
  flex-shrink: 0;
}

.header-user {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--marshall-white-50);
}

.header-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding-left: 1.25rem;
  border-left: 1px solid var(--border);
}

/* ---- Layout --------------------------------------------------------------- */

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

.averages-caveat {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 3rem;
}

/* ---- Filter bar ----------------------------------------------------------- */

.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.filter-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  width: 4.5rem;
  flex-shrink: 0;
}

.filter-options {
  display: flex;
  gap: 0.5rem;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.filter-btn:hover {
  color: var(--text);
  background: var(--marshall-white-5);
}

.filter-btn.active {
  color: var(--text);
  background: var(--marshall-white-15);
  border-color: var(--marshall-white-50);
}

.filter-btn-logo {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  flex-shrink: 0;
}

.filter-btn-icon {
  width: 12px;
  height: 12px;
  opacity: 0.5;
  flex-shrink: 0;
}

.filter-btn.active .filter-btn-icon {
  opacity: 1;
}

.filter-btn.sentiment-positive.active { background: rgba(60, 144, 89, 0.2);  border-color: var(--marshall-green); color: var(--marshall-green-light); }
.filter-btn.sentiment-neutral.active  { background: var(--marshall-white-15); border-color: var(--marshall-white-50); }
.filter-btn.sentiment-negative.active { background: rgba(240, 63, 56, 0.2);  border-color: var(--marshall-red);   color: var(--marshall-red-light); }

/* ---- Rolling averages ----------------------------------------------------- */

.averages-loading {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 2rem;
}

.averages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.25rem;
  margin-bottom: 0.75rem;
}

.avg-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.avg-card-header {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.avg-app-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
}

.avg-app-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

/* Four-column grid: [store label] [90d] [180d] [360d] */
.avg-row {
  display: grid;
  grid-template-columns: 1fr repeat(2, 88px);
  align-items: center;
  padding: 0.75rem 1.5rem;
  border-top: 1px solid var(--border);
}

.avg-col-headers {
  background: var(--marshall-white-5);
}

.avg-col-label {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: right;
}

.avg-cell {
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 0.2rem;
}

.avg-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.avg-trend {
  order: -1;
  font-size: 0.65rem;
  font-weight: 700;
  align-self: flex-start;
  line-height: 1;
}

.trend-up   { color: var(--marshall-green-light); }
.trend-flat { color: var(--muted); }
.trend-down { color: var(--marshall-red-light); }

.avg-combined-row {
  background: var(--marshall-white-5);
}

.avg-combined-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---- Stat cards ----------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1.75rem 2rem;
}

.card h2 {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1rem;
}

.count {
  font-size: 3.25rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin-bottom: 0.5rem;
  text-align: right;
}

.label {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: right;
}

.updated {
  margin-top: 1.5rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: right;
}

/* ---- Shared --------------------------------------------------------------- */

.error {
  color: var(--marshall-red);
  font-size: 0.875rem;
  padding: 1rem 0;
}

.section-title {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.25rem;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

.loading .count {
  animation: pulse 1.5s ease-in-out infinite;
}

/* ---- Reviews section ------------------------------------------------------ */

.reviews-section {
  margin-top: 3rem;
}

.reviews-section-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.reviews-section-header .section-title {
  margin-bottom: 0;
}

.reviews-section-subtitle {
  font-size: 0.7rem;
  color: var(--muted);
}

@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}

.skeleton-card {
  background: var(--marshall-white-5);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}

.skeleton-meta,
.skeleton-line {
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--marshall-white-5) 25%,
    var(--marshall-white-10, rgba(255,255,255,0.1)) 50%,
    var(--marshall-white-5) 75%
  );
  background-size: 600px 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}

.skeleton-meta   { height: 12px; width: 40%; margin-bottom: 0.75rem; }
.skeleton-line   { height: 12px; margin-bottom: 0.5rem; }
.skeleton-line:last-child { margin-bottom: 0; }
.skeleton-line.wide   { width: 90%; }
.skeleton-line.medium { width: 65%; }
.skeleton-line.narrow { width: 40%; }

.no-reviews {
  font-size: 0.875rem;
  color: var(--muted);
  padding: 1rem 0;
  padding-left: 1.25rem;
}

.reviews-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.review-card {
  background: var(--surface);
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.review-card:last-child {
  border-bottom: none;
}

.review-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.app-logo {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  flex-shrink: 0;
}

.store-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 2px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.store-icon {
  width: 11px;
  height: 11px;
  opacity: 0.5;
  flex-shrink: 0;
}

.stars {
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}

.sentiment-badge {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 2px;
}

.sentiment-badge.positive { background: rgba(60, 144, 89, 0.2);  color: var(--marshall-green-light); }
.sentiment-badge.neutral  { background: var(--marshall-white-5);  color: var(--muted); }
.sentiment-badge.negative { background: rgba(240, 63, 56, 0.2);   color: var(--marshall-red-light); }

.review-date {
  font-size: 0.75rem;
  color: var(--muted);
  margin-left: auto;
}

.review-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.review-body {
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--marshall-white-70);
  white-space: pre-wrap;
}

.review-original {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
  color: var(--muted);
}

.review-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.review-categories {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.category-tag {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--muted);
}

.product-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.45rem 0.15rem 0.35rem;
  border: 1px solid rgba(207, 158, 31, 0.35);
  border-radius: 2px;
  color: #d4a72c;
  background: rgba(207, 158, 31, 0.07);
}

.product-tag::before {
  content: '';
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: var(--marshall-yellow);
  flex-shrink: 0;
}

.review-translation {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
  flex-shrink: 0;
}

.review-flag {
  font-size: 0.875rem;
}

.toggle-original {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.75rem;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.toggle-original:hover {
  color: var(--text);
}

.stats-section {
  margin-top: 3rem;
}

/* ---- Category chart ------------------------------------------------------- */

.category-chart-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.category-chart-header .section-title {
  margin-bottom: 0;
}

.category-chart-total {
  font-size: 0.7rem;
  color: var(--muted);
}

.category-chart {
  margin-bottom: 1.5rem;
}

.category-chart-loading {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.category-bar-row {
  display: grid;
  grid-template-columns: 120px 1fr 36px;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.45rem;
}

.category-bar-name {
  font-size: 0.72rem;
  color: var(--marshall-white-70);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-bar-track {
  height: 6px;
  background: var(--marshall-white-5);
  border-radius: 3px;
  overflow: hidden;
}

.category-bar-fill {
  height: 100%;
  background: var(--marshall-white-30);
  border-radius: 3px;
}

.category-bar-fill.top {
  background: var(--marshall-white-70);
}

.category-bar-count {
  font-size: 0.7rem;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}