*, *::before, *::after { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
}

:root {
  --bg-page: #1c1e21;
  --bg-card: #242628;
  --bg-bar: #32353a;
  --border: rgba(255,255,255,0.07);
  --text-1: #f0ede8;
  --text-2: #c6c6c6;
  --text-3: #7f7f7f;
  --accent-green: #8dc63f;
  --accent-gold: #feca57;
  --accent-ember: #c06040;
  --accent-line: #e8e0d0;
}

body {
  font-family: 'Roboto', sans-serif;  
  background: var(--bg-page);
  color: var(--text-1);
  padding: 2rem 1.5rem;
  min-height: 100vh;
}

.dash { 
  max-width: 980px; 
  margin: 0 auto; 
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: center; /* centers the text block */
  position: relative; /* allows absolute positioning of logo on desktop */
  margin: 0 0 2rem 0;
  /* deleted the duplicate display, align-items, justify-content: space-between */
}

.header-title { 
  font-size: 1.5rem; 
  font-weight: normal; 
  color: var(--text-1); 
  letter-spacing: 0.025em;
  margin: 0;
}

.header-sub { 
  font-size: 1.0rem; 
  color: var(--text-2); 
  margin-top: 5px; 
  font-family: 'Roboto Condensed', 'Roboto', sans-serif; 
  letter-spacing: 0.04em;
  margin-bottom: 0;
}

.listing-badge {
  position: absolute;
  left: 0;
  display: inline-flex;
  align-items: center;
  background: transparent;
  padding: 0;
  margin: 0;
}

.listing-badge img {
  width: 50%;
  display: block;
}

.header-text {
  text-align: center;
}

/* Mobile: stack logo on top, text below, all centered */
@media (max-width: 768px) {
  .header-row {
    flex-direction: column;
    position: static;
    gap: 12px;
    align-items: center; /* ensures children center */
  }

  .listing-badge {
    position: static;
    width: 50%; /* logo container is 50% of screen */
    max-width: 200px; /* prevents it getting huge on tablets */
    justify-content: center; /* centers img inside the badge */
  }
  
  .listing-badge img {
    width: 100%; /* fills the 50% container */
    height: auto; /* maintains aspect ratio */
    max-height: 35px; /* safety cap so it doesn't get too tall */
  }
}


.filter-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 1rem 0;
  gap: 16px;
}

.filter-header-row .section-label {
  margin: 0;
  text-align: left; /* Left align on desktop */
}

.date-filter-wrap {
  display: flex;
  align-items: center;
  margin-left: auto; /* Push filter to right on desktop */
}

.date-filter-wrap select {
  padding: 8px 12px;
  background: #1a1a1a;
  color: #c6c6c6;
  border: 1px solid #444;
  border-radius: 6px;
  outline: none;
}

.date-filter-wrap select:focus {
  border-color: #5a9e74;
}

/* Mobile: filter top, title bottom, both centered */
@media (max-width: 640px) {
  .filter-header-row {
    flex-direction: column;
    align-items: center;
    gap: 16px;
  }
  
  .date-filter-wrap {
    order: 1; /* Filter first on mobile */
    width: 100%;
    justify-content: center;
    padding: 0 16px;
    margin-left: 0; /* Reset desktop margin */
  }
  
  .filter-header-row .section-label {
    order: 2; /* Title second on mobile */
    text-align: center;
  }
  
  .date-filter-wrap select {
    flex: 1;
    max-width: 280px;
  }
}

.section-label {
  font-size: 1.0rem; 
  color:#d7ab52;
  letter-spacing: 0.14em;
  text-transform: uppercase; 
  margin: 0; 
  font-family: 'Roboto Condensed', 'Roboto', sans-serif;
  text-align:left;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 1.5rem;
}

.card { 
  background: var(--bg-card); 
  border: 1px solid #7c7c7c;
  border-radius: 0.5rem; 
  padding: 16px; 
}

.card.hero { 
  border-left: 3px solid var(--accent-green); 
}

.card-label { 
  font-size: 0.9rem; 
  color: var(--text-2); 
  margin-bottom: 8px; 
  letter-spacing: 0.07em; 
  text-transform: uppercase; 
  font-family: 'Roboto Condensed', 'Roboto', sans-serif; 
}

.card-value { 
  font-size: 1.05rem; 
  font-weight: 500; 
  color: var(--text-1); 
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif; 
  line-height: 1; 
}

.card-delta { 
  font-size: 1.0rem; 
  color: var(--accent-green); 
  margin-top: 6px; 
  font-family: 'Roboto Condensed', 'Roboto', sans-serif; 
}

.card-delta.warn { 
  color: var(--accent-gold); 
}

/* ROW 2 - 2 COLUMNS DESKTOP */
.graph-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  width: 100%; 
  margin: 2% 0 2% 0;
  box-sizing: border-box;
}

.graph-container {
  min-width: 0;
  padding: 24px;
  padding-bottom: 2%;
  border: 1px solid #7c7c7c; 
  border-radius: 12px;
  background: var(--bg-card);
  box-sizing: border-box;
  overflow: hidden;
}

.graph-container h3 {
  font-size: 1.2rem;
  color: var(--text-1);
  margin-bottom: 12px;
  font-family: 'Roboto Condensed', 'Roboto', sans-serif;
  font-weight: 500;
}

.graph-container > div {
  position: relative;
  width: 100%;
  height: 250px;
}

.graph-container canvas {
  max-width: 100% !important;
  max-height: 100% !important;
}

/* ROW 3 - 3 COLUMNS DESKTOP */
.row-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  width: 100%;
  margin-top: 24px;
  box-sizing: border-box;
}

.small-card {
  min-width: 0;
  padding: 20px;
  padding-bottom: 2%;
  border: 1px solid #7c7c7c;
  border-radius: 12px;
  background: var(--bg-card);
  box-sizing: border-box;
  overflow: hidden;
}

.small-card h3 {
  font-size: 1.2rem;
  color: var(--text-1);
/*  margin-bottom: 12px;*/
  font-family: 'Roboto Condensed', 'Roboto', sans-serif;
  font-weight: 500;
}

.small-card > div {
  position: relative;
  width: 100%;
  height: 300px;
}

.small-card:nth-child(2) > div,
.small-card:nth-child(3) > div {
  height: 220px;
}

.small-card canvas {
  max-width: 100% !important;
  max-height: 100% !important;
}

.chart-sub { 
  font-size: 1.0rem; 
  color: var(--text-2); 
  margin-bottom: 14px; 
  font-family: 'Roboto Condensed', 'Roboto', sans-serif;  
  letter-spacing: 0.04em; 
}

.stats-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: 'Roboto Condensed', 'Roboto', sans-serif;
  font-size: 0.9rem;
  color: var(--text-2);
}

.footer { 
  margin-top: 1.5rem; 
  text-align: center; 
  font-size: 0.9rem; 
  color: var(--text-3); 
  letter-spacing: 0.08em; 
  font-family: 'Roboto Condensed', 'Roboto', sans-serif;  
}

.footer a {
  color: var(--text-2);
  text-decoration: none;
}

/* MOBILE ≤ 768px - STACK EVERYTHING */
@media (max-width: 768px) {
  body { padding: 1.25rem 1rem; }
  .cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .graph-row { grid-template-columns: 1fr; }
  .row-3 { grid-template-columns: 1fr; }
  .graph-container > div { height: 220px; }
  .small-card > div { height: 280px; }
}

/* SMALL MOBILE ≤ 480px */
@media (max-width: 480px) {
  body { padding: 1rem 0.75rem; }
  .cards-grid { gap: 8px; }
  .card { padding: 12px; }
  .card-value { font-size: 21px; }
  .card-label { font-size: 0.85rem; }
  .header-title { font-size: 1.2rem; }
/*  .listing-badge {padding: 4px 10px; }*/
  .small-card { padding: 16px; }
  .graph-container > div { height: 200px; }
  .small-card > div { height: 260px; }
}

/* VERY SMALL ≤ 360px */
@media (max-width: 360px) {
  .cards-grid { grid-template-columns: 1fr; }
}

/* MOBILE FIXES ≤ 768px */
@media (max-width: 768px) {
  
  /* 1. Fix heading sizes on mobile - keep them consistent */
  .graph-container h3,
  .small-card h3 {
    font-size: 1.1rem !important; /* same as desktop */
    margin-bottom: 1px; /* 2. Remove gap after heading */
      text-transform: uppercase;
  }

  /* 2. Delta/subheading should sit tight under h3 */
  .chart-sub {
    font-size: 1.0rem;
    color: var(--text-2);
    margin-top: 0; /* no gap above */
    margin-bottom: 22px; /* 3. Gap between delta and legends = 22px */
    font-family: 'Roboto Condensed', 'Roboto', sans-serif;  
    letter-spacing: 0.04em; 
  }

  /* 4. Gap between legends and chart canvas = 25px */
  .graph-container > div {
    margin-top: 25px; /* pushes chart down from legend */
    height: 220px;
  }

  /* 5. Viewer locations - remove fixed height, use content height + padding */
  .small-card:nth-child(3) {
    height: auto !important;
    min-height: 0 !important;
  }
  .small-card:nth-child(3) > div {
    height: auto !important;
    min-height: 0 !important;
    padding-bottom: 16px; /* bottom padding you wanted */
  }
  
  /* Also fix the small card chart wrappers on mobile */
  .small-card > div {
    height: 280px;
  }
  .small-card:nth-child(2) > div {
    height: 220px; /* Traffic source */
  }
}