/* =========================================
   GLOBAL THEME VARIABLES
   - Shared across all pages
   - Colours and fonts match dashboard / highlights
========================================= */
:root {
  /* Base surfaces (used when no theme class is set) – neutral dark */
  --background-primary: #080808;
  --background-secondary: #0c0c0c;
  --background-tertiary: #111111;

  /* Accent palette (emerald / teal, no blue) */
  --accent-primary: #22c55e;
  --accent-secondary: #22c55e;

  /* Filters & menu use same accent as primary (emerald) – no blue */
  --filter-accent: #22c55e;
  --menu-accent: #22c55e;

  /* Text */
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;

  /* Typography */
  --font-body: 'Outfit', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-header: 'Outfit', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

/* =========================================
   GLOBAL RESET
========================================= */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-body);
  color: var(--text-primary);
  /* Themed flat background; actual colour is controlled by body.theme-dark / body.theme-light */
  background-color: var(--dashboard-bg, var(--background-primary));
  background-image: none;
  background-repeat: no-repeat;
  background-attachment: fixed;
  /* Prevents horizontal scrolling caused by the off-screen menu */
  overflow-x: hidden; 
}

html {
  box-sizing: border-box;
  height: 100%;
}

*, *::before, *::after {
  box-sizing: inherit;
}

/* =========================================
   GLOBAL DARK / LIGHT MODES
   - Apply by toggling body.theme-dark / body.theme-light
   - Dashboard and analytics pages share these tokens
========================================= */

body.theme-dark {
  /* Neutral dark – no blue tint; base, surface, elevated */
  --dashboard-bg: #080808;
  --dashboard-header-bg: #080808;
  --dashboard-card-bg: #080808;
  --dashboard-card-border: rgba(115,115,115,0.25);
  --dashboard-card-border-soft: rgba(115,115,115,0.14);
  --dashboard-card-shadow: 0 18px 45px rgba(0,0,0,0.5);
  --dashboard-accent-primary: #22c55e; /* emerald-500 */
  --dashboard-accent-secondary: #22c55e; /* same as primary – no blue */
  --dashboard-text-main: #e5e7eb;
  --dashboard-text-muted: #9ca3af;
  --dashboard-row-bg: #080808;
  /* Legacy background/text vars for dark mode */
  --background-secondary: #080808;
  --background-tertiary: #0c0c0c;
  --text-primary: #ffffff;
  --text-secondary: #b3b3b3;
}

body.theme-light {
  /* Light mode: soft grey background, white cards + light inner rows */
  --dashboard-bg: #e5e7eb; /* slate-200 */
  --dashboard-header-bg: #f9fafb;
  --dashboard-card-bg: #ffffff;
  --dashboard-card-border: rgba(148,163,184,0.5);
  --dashboard-card-border-soft: rgba(209,213,219,0.85);
  --dashboard-card-shadow: 0 16px 35px rgba(15,23,42,0.18);
  --dashboard-accent-primary: #16a34a; /* green-600 */
  --dashboard-accent-secondary: #16a34a; /* same as primary – no blue */
  --dashboard-text-main: #020617;
  --dashboard-text-muted: #6b7280;
  --dashboard-row-bg: #f4f4f5;
  /* Legacy background/text vars for light background */
  --background-secondary: #f9fafb;
  --background-tertiary: #f3f4f6;
  --text-primary: #020617;
  --text-secondary: #4b5563;
}

/* =========================================
   GLOBAL THEME TOGGLE BUTTON
   - Used on dashboard + analytics pages
========================================= */

#dashboardThemeToggle {
  background: rgba(20,20,20,0.9);
  border: 1px solid rgba(70,70,70,0.9);
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  transition:
    transform 0.15s ease-out,
    box-shadow 0.15s ease-out,
    border-color 0.15s ease-out,
    background-color 0.15s ease-out;
}

#dashboardThemeToggle:hover {
  transform: scale(1.06);
  box-shadow: 0 18px 40px rgba(0,0,0,0.6);
  border-color: rgba(248,250,252,0.5);
}

body.theme-light #dashboardThemeToggle {
  background: rgba(250,250,250,0.9);
  border-color: rgba(209,213,219,0.9);
  box-shadow: 0 10px 24px rgba(15,23,42,0.18);
}

body.theme-light #dashboardThemeToggle:hover {
  background: rgba(255,255,255,1);
  box-shadow: 0 16px 32px rgba(15,23,42,0.22);
  border-color: rgba(148,163,184,0.9);
}

/* =========================================
   FILTER BUTTONS (Time filters + Analytics filters)
   - Dashboard source of truth styling
========================================= */

.time-filter-bar {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin: 0.75rem auto 1.25rem;
  flex-wrap: wrap;
}

.analytics-filter-bar {
  display: flex !important;
  justify-content: center !important;
  gap: 0.4rem !important;
  margin: 0 auto 2rem auto !important;
  max-width: 900px !important;
  flex-wrap: wrap !important;
  /* Match dashboard: no enclosing card background */
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.time-filter-bar button,
.analytics-filter-bar .filter-btn {
  background: var(--dashboard-card-bg, var(--background-tertiary)) !important;
  color: var(--dashboard-text-muted, var(--text-secondary)) !important;
  border: 1px solid var(--dashboard-card-border-soft, rgba(148,163,184,0.18)) !important;
  border-radius: 999px !important;
  padding: 0.45rem 0.9rem !important;
  font-size: 0.75rem !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
  font-family: var(--font-body) !important;
}

.time-filter-bar button:hover,
.analytics-filter-bar .filter-btn:hover {
  color: var(--dashboard-text-main, var(--text-primary)) !important;
  border-color: var(--filter-accent) !important;
  transform: translateY(-1px) !important;
}

.time-filter-bar button.active,
.analytics-filter-bar .filter-btn.active {
  background: var(--filter-accent) !important;
  color: #000 !important;
  border-color: var(--filter-accent) !important;
}

/* =========================================
   PAGE CONTAINER (General)
========================================= */
.container {
  width: 100%;
  max-width: 1100px;
  padding: 0 20px;
  margin: 0 auto; 
}

/* ⭐️ ANALYTICS PAGES SPECIFIC CONTAINER FIX ⭐️ */
/* Provides top clearance for absolute positioned buttons and large header */
.page-container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  /* Increased top padding to ensure clearance for the large logo */
  padding: 7rem 20px 0 20px; 
}

/* =========================================
   HEADINGS (General)
========================================= */
h1, h2 {
  font-family: var(--font-header);
  /* Let pages control casing explicitly; no global forced uppercase */
  text-transform: none;
  letter-spacing: 0.02em;
}

h1 {
  color: var(--text-primary);
  font-size: 3rem;
  text-align: center;
  margin: 2rem 0;
}

h2 {
  color: var(--text-secondary);
  font-size: 1.5rem;
  border-bottom: 1px solid var(--background-tertiary);
  padding-bottom: 0.5rem;
  margin-top: 2.5rem;
}

/* =========================================
   ANALYTICS PAGE HEADER STYLES
========================================= */

.analytics-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

/* Logo size for all analytics pages */
.analytics-header img {
    /* ⭐️ MODIFIED: Increased logo size ⭐️ */
    height: 8rem; 
    /* ⭐️ CRUCIAL FIX: Increased margin-top to push the 6rem logo below the button ⭐️ */
    margin-top: 2.5rem; 
    margin-bottom: 0.5rem;
}

/* Dark mode: logo slightly desaturated and soft (saturate-75 opacity-90) */
body.theme-dark .analytics-header img {
  filter: saturate(0.75);
  opacity: 0.9;
  transition: filter 0.25s ease-out, opacity 0.25s ease-out;
}
body.theme-dark .analytics-header img:hover {
  filter: saturate(1);
  opacity: 1;
}

/* The main H1 title element (analytics pages)
   - Override global uppercase so analytics titles are sentence-case */
.analytics-header h1#pageTitle {
  font-family: var(--font-header);
  font-size: 3rem; 
  font-weight: 600; 
  letter-spacing: 0.02em;
  text-transform: none;
  margin: 0.5rem 0 0.5rem 0;
  line-height: 1.1;
}

/* Page title same colour as main section headers (h2) */
body.theme-dark .analytics-header h1#pageTitle {
  color: var(--dashboard-text-muted, var(--text-secondary));
}

body.theme-light .analytics-header h1#pageTitle {
  color: var(--dashboard-text-muted, var(--text-secondary));
}

/* The date line element, hidden by default */
#event-date-display {
  text-align: center;
  color: var(--text-secondary);
  margin-top: 0;
  font-size: 1.2rem;
  font-family: var(--font-header);
  line-height: 1;
  display: none; 
}

/* The Back to Summary button (Absolute position, hidden by default) */
#backToSummaryBtn {
    position: absolute;
    top: 1.5rem; 
    left: 1.5rem;
    background: var(--background-tertiary);
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary);
    /* ⭐️ MODIFIED: Smaller font size ⭐️ */
    font-size: 0.8rem; 
    /* ⭐️ MODIFIED: Smaller padding ⭐️ */
    padding: 0.3rem 0.6rem; 
    border-radius: 4px;
    cursor: pointer;
    z-index: 1001;
    text-transform: uppercase;
    font-weight: bold;
    display: none; 
    text-decoration: none;
}
#backToSummaryBtn:hover {
    background: rgba(0, 163, 255, 0.1);
}
/* ⭐️ END ANALYTICS PAGE HEADER STYLES ⭐️ */


/* =========================================
   LOGO (General, for non-analytics pages)
========================================= */
.logo-container {
  text-align: center;
  margin-top: 1.5rem;
}

.header-logo {
  height: 13rem; 
  width: auto;
}

header.sticky-header {
  position: relative;
}

/* Dashboard page title under logo */
h1#pageTitle {
  text-align: center;
  margin-top: 1rem;
  font-size: 2rem;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--text-primary);
}

/* Page title same colour as main section headers (h2) */
body.theme-dark h1#pageTitle,
body.theme-light h1#pageTitle {
  color: var(--dashboard-text-muted, var(--text-secondary));
}

h1#pageTitle span {
  color: inherit;
}

/* =========================================
   FILTERS
========================================= */
.filters {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem;
  background-color: var(--background-secondary);
  border: 1px solid var(--background-tertiary);
  border-radius: 8px;
  margin-bottom: 2rem;
}

select, button {
  background: var(--background-tertiary);
  color: var(--text-primary);
  border: 1px solid #444;
  border-radius: 4px;
  padding: .7rem;
  font-size: 0.9rem;
  font-family: var(--font-body);
}

button {
  background: var(--accent-primary);
  color: #000;
  font-weight: bold;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s;
}

button:hover {
  background: var(--accent-secondary);
}

button:disabled {
  background: var(--background-tertiary);
  color: var(--text-secondary);
  cursor: not-allowed;
}

/* =========================================
   STAT CARDS
========================================= */
.stats-grid {
  display: grid;
  /* 160px min keeps two cards per row on mobile like before,
     while still allowing 3–4 across on wider screens */
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1.25rem;
  margin: 1.25rem 0 1.5rem;
}

.stat-card {
  position: relative;
  background: var(--dashboard-card-bg, rgba(15, 23, 42, 0.88));
  border-radius: 12px;
  padding: 1.1rem 1.3rem;
  text-align: left;
}

/* Key Stats grid: centre all text inside the cards (horizontal and vertical) */
.stats-grid .stat-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  border: 1px solid var(--dashboard-card-border-soft, rgba(148, 163, 184, 0.18));
  box-shadow: var(--dashboard-card-shadow, 0 18px 45px rgba(0, 0, 0, 0.5));
  transition: transform 0.18s ease-out,
              box-shadow 0.18s ease-out,
              border-color 0.18s ease-out,
              background 0.18s ease-out;
  overflow: hidden;
}

/* Key Stats card order: description (top), value (middle), Tap for Details (bottom) */
.stats-grid .stat-card .stat-label {
  order: 1;
}
.stats-grid .stat-card .stat-value {
  order: 2;
}
.stats-grid .stat-card .tap-hint {
  order: 3;
}

/* Slightly smaller font in Key Stats cards (Tap for Details unchanged) */
.stats-grid .stat-card .stat-value {
  font-size: 2rem;
}
.stats-grid .stat-card .stat-label {
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

/* Key Stats & clickable cards: blue border so they stand out (dark = bright, light = muted) */
body.theme-dark .stat-card.interactive-card {
  border-color: rgba(34, 197, 94, 0.65); /* emerald-500 */
}
body.theme-light .stat-card.interactive-card {
  border-color: rgba(34, 197, 94, 0.5); /* emerald */
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: -30%;
  opacity: 0;
  background: radial-gradient(circle at 0% 0%, rgba(56, 189, 248, 0.18), transparent 55%);
  transition: opacity 0.25s ease-out;
  pointer-events: none;
}

.interactive-card {
  cursor: pointer;
}

.interactive-card:hover {
  transform: translateY(-3px);
  border-color: var(--dashboard-card-border, rgba(115, 115, 115, 0.4));
  box-shadow: var(--dashboard-card-shadow, 0 22px 55px rgba(15, 23, 42, 0.9));
  /* Dark vs light hover backgrounds */
  background: linear-gradient(
    145deg,
    rgba(15, 23, 42, 0.98),
    rgba(24, 35, 52, 0.96)
  );
}

.interactive-card:hover::before {
  opacity: 1;
}

.interactive-card:active {
  transform: translateY(-1px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.75);
}

/* Light-mode specific tweaks: softer hover background */
body.theme-light .interactive-card:hover {
  background: linear-gradient(
    145deg,
    #ffffff,
    #e5e7eb
  );
}

.tap-hint {
  font-size: 0.65rem;
  color: var(--text-secondary);
  margin-top: 0.45rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0.2px;
  font-style: italic;
  display: block;
  opacity: 0.85;
}

.stat-value {
  font-family: var(--font-header);
  font-size: 2.3rem;
  color: var(--dashboard-accent-primary, var(--accent-secondary));
  line-height: 1.1;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--dashboard-text-muted, var(--text-secondary));
  margin-top: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Chart card (for dashboard trend charts) */
.chart-card {
  background: var(--dashboard-card-bg, var(--background-secondary));
  border: 1px solid var(--dashboard-card-border-soft, var(--background-tertiary));
  border-radius: 12px;
  padding: 0.9rem 0.9rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 300px;
  box-shadow: var(--dashboard-card-shadow, 0 14px 30px rgba(0,0,0,0.55));
}

@media (max-width: 700px) {
  .chart-card {
    min-height: 280px;
  }
}

/* =========================================
   TABLES
========================================= */
.table-container {
  background: var(--background-secondary);
  border: 1px solid var(--background-tertiary);
  border-radius: 8px;
  padding: 1.5rem;
  margin-top: 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: .8rem 1rem;
  text-align: left;
  font-size: .95rem;
  border-bottom: 1px solid var(--background-tertiary);
}

th {
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: bold;
  font-size: .8rem;
}

/* =========================================
   LINKS
========================================= */
a {
  color: var(--accent-primary);
  text-decoration: none;
  font-weight: bold;
}

/* =========================================
   MODALS
========================================= */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.modal-content {
  background: var(--background-secondary);
  border: 1px solid var(--background-tertiary);
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--background-tertiary);
}

.modal-header h3 {
  color: var(--accent-primary);
  margin: 0;
  font-family: var(--font-header);
  font-size: 1.8rem;
}

.modal-scroll {
  overflow-y: auto;
  padding: 1.5rem;
}

.tooltip {
  position: absolute;
  background: var(--background-tertiary);
  border: 1px solid #444;
  color: white;
  padding: .5rem .8rem;
  font-size: .85rem;
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  max-width: 240px;
  z-index: 10001;
}

/* =========================================
   SIDE MENU
========================================= */

/* 1. The Hamburger Icon Button */
.menu-toggle {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  background: var(--dashboard-card-bg, var(--background-tertiary));
  border: 1px solid var(--dashboard-card-border-soft, rgba(148,163,184,0.2));
  color: var(--dashboard-text-main, var(--text-primary));
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  line-height: 40px;
  padding: 0;
  border-radius: 8px;
  cursor: pointer;
  z-index: 1001;
  transition: all 0.15s ease;
}
.menu-toggle:hover {
  border-color: var(--dashboard-accent-primary, var(--accent-primary));
  transform: scale(1.05);
}

/* 2. The Dimmed Overlay */
.side-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 9998;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* 3. The Side Menu Panel */
.side-menu {
  position: fixed;
  top: 0;
  right: 0;
  width: 280px;
  max-width: 80%;
  height: 100%;
  background: var(--dashboard-card-bg, var(--background-secondary));
  border-left: 1px solid var(--dashboard-card-border, rgba(148,163,184,0.28));
  box-shadow: var(--dashboard-card-shadow, 0 18px 45px rgba(15,23,42,0.9));
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

/* 4. The "Open" State */
body.side-menu-open .side-menu {
  transform: translateX(0);
}
body.side-menu-open .side-menu-overlay {
  display: block;
  opacity: 1;
}

/* 5. Menu Contents */
.side-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--dashboard-card-border-soft, rgba(148,163,184,0.18));
  padding-bottom: 0.5rem;
  margin-bottom: 0.5rem;
}
.side-menu-header h3 {
  margin: 0;
  font-family: var(--font-header);
  font-size: 1.8rem;
  color: var(--menu-accent, var(--filter-accent));
  font-weight: 600;
}
.menu-close {
  background: var(--dashboard-card-bg, var(--background-tertiary));
  border: 1px solid var(--dashboard-card-border-soft, rgba(148,163,184,0.2));
  border-radius: 6px;
  color: var(--dashboard-text-main, var(--text-primary));
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  line-height: 1;
  transition: all 0.15s ease;
}
.menu-close:hover {
  border-color: var(--dashboard-accent-primary, var(--accent-primary));
  transform: scale(1.1);
}

/* 6. Menu Links & Buttons */
.side-menu a,
.side-menu button {
  text-decoration: none;
  color: var(--dashboard-text-main, var(--text-primary));
  background: var(--dashboard-card-bg, var(--background-tertiary));
  padding: 0.8rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--dashboard-card-border-soft, rgba(148,163,184,0.18));
  text-align: left;
  font-size: 1rem;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.side-menu a:hover,
.side-menu button:hover {
  border-color: var(--dashboard-accent-primary, var(--accent-primary));
  transform: translateX(2px);
  background: var(--dashboard-card-bg, var(--background-tertiary));
}

/* Refresh button special styling */
.side-menu #refreshBtn {
  background: var(--dashboard-card-bg, var(--background-tertiary));
  border: 1px solid var(--menu-accent, var(--filter-accent));
  color: var(--dashboard-text-main, var(--text-primary));
  margin-bottom: 0.5rem;
}
.side-menu #refreshBtn:hover {
  background: var(--dashboard-accent-primary, var(--accent-primary));
  color: #000;
  transform: translateX(0) scale(1.02);
}

/* Style the logout button differently */
.side-menu #logoutBtn {
  background: var(--menu-accent, var(--filter-accent));
  color: #000;
  font-weight: bold;
  text-align: center;
  margin-top: auto;
  border: none;
}
.side-menu #logoutBtn:hover {
  background: var(--dashboard-accent-secondary, var(--accent-secondary));
  transform: translateX(0) scale(1.02);
}

/* Light mode: side menu panel and item cards – subtle grey gradient (not flat white) */
body.theme-light .side-menu {
  background: linear-gradient(180deg, #fafafa 0%, #f1f3f4 100%);
}
body.theme-light .side-menu a,
body.theme-light .side-menu button:not(#logoutBtn) {
  background: linear-gradient(180deg, #f8f9fa 0%, #f0f1f3 100%) !important;
  border-color: rgba(0,0,0,0.08);
}
body.theme-light .side-menu a:hover,
body.theme-light .side-menu button:hover:not(#logoutBtn) {
  background: linear-gradient(180deg, #f0f1f3 0%, #e8eaed 100%) !important;
}
body.theme-light .side-menu .menu-close {
  background: linear-gradient(180deg, #f8f9fa 0%, #f0f1f3 100%);
}
body.theme-light .side-menu #refreshBtn {
  background: linear-gradient(180deg, #f8f9fa 0%, #f0f1f3 100%) !important;
}
body.theme-light .side-menu #refreshBtn:hover {
  background: var(--dashboard-accent-primary, var(--accent-primary)) !important;
}

/* ... (analytics-section, etc. remain unchanged) ... */
.analytics-section canvas {
  width: 100% !important;
  max-width: 900px;
  height: 350px !important;
  margin: 0 auto;
  display: block;
}
.analytics-section {
  width: 100%;
  max-width: 900px;
  margin: 2rem auto;
  padding: 1rem;
}

/* =========================================
   ANALYTICS PAGE COMPONENTS
   - Shared styles for scoring/checkouts/first9/heatmap/pace
   - Matches dashboard card aesthetic
========================================= */

/* Description text block */
.analytics-description {
  max-width: 900px;
  margin: 0 auto 2rem auto;
  padding: 1.25rem 1.5rem;
  background: var(--dashboard-card-bg, var(--background-secondary));
  border: 1px solid var(--dashboard-card-border-soft, rgba(148,163,184,0.18));
  border-radius: 12px;
  color: var(--dashboard-text-muted, var(--text-secondary));
  font-size: 0.95rem;
  line-height: 1.6;
  box-shadow: var(--dashboard-card-shadow, 0 14px 30px rgba(0,0,0,0.55));
}

/* Main analytics card container (blue glow matches dashboard/events cards) */
.analytics-card {
  max-width: 900px;
  margin: 0 auto 2rem auto;
  padding: 1.5rem;
  background: var(--dashboard-card-bg, var(--background-secondary));
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 12px;
  box-shadow: var(--dashboard-card-shadow, 0 14px 30px rgba(0,0,0,0.55)), 0 0 28px rgba(56, 189, 248, 0.22);
}

.analytics-card h2 {
  text-align: center;
  /* Match dashboard: headings use muted text, not bright green */
  color: var(--dashboard-text-muted, var(--text-secondary));
  margin-bottom: 1.5rem;
  font-family: var(--font-header);
  font-size: 1.5rem;
  font-weight: 600;
  /* Lowercase / sentence-case headings for analytics cards */
  text-transform: none !important;
  letter-spacing: 0.02em;
}

/* Force lowercase/sentence-case titles on analytics pages regardless of global heading rules */
body.analytics-theme h1#pageTitle,
body.analytics-theme .analytics-card h2 {
  text-transform: none !important;
}

/* Extra safety: on analytics pages, card section titles should never use the bright accent colour.
   This overrides any older, more specific rules that might still exist in page-local <style> blocks. */
body.analytics-theme .analytics-card > h2 {
  color: var(--dashboard-text-muted, var(--text-secondary)) !important;
}

/* Chart wrapper inside analytics cards */
.chart-wrapper {
  width: 100%;
  height: 360px;
  background: transparent;
  border-radius: 8px;
  padding: 1rem;
}

.chart-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Analytics table styles */
.score-table,
.checkout-table,
.finish-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.score-table th,
.checkout-table th,
.finish-table th {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--dashboard-card-border-soft, var(--background-tertiary));
  color: var(--dashboard-accent-primary, var(--accent-primary));
  text-transform: uppercase;
  font-size: 0.85rem;
  text-align: left;
  font-weight: 600;
}

.score-table td,
.checkout-table td,
.finish-table td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--dashboard-card-border-soft, var(--background-tertiary));
  color: var(--dashboard-text-main, var(--text-primary));
  font-size: 1rem;
}

/* Analytics-specific tiles (checkouts, pace) – blue glow matches dashboard cards */
.checkout-tile,
.pace-tile {
  background: var(--dashboard-row-bg, var(--dashboard-card-bg, var(--background-secondary)));
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 10px;
  padding: 1rem;
  box-shadow: var(--dashboard-card-shadow, 0 10px 26px rgba(15,23,42,0.85)), 0 0 28px rgba(56, 189, 248, 0.22);
}

/* Light mode: lighten tiles so they don't look like dark blocks */
body.theme-light .checkout-tile,
body.theme-light .pace-tile {
  background: #ffffff !important; /* clear light card */
  box-shadow: 0 8px 18px rgba(15,23,42,0.10);
}

.checkout-tile h3,
.pace-tile h3 {
  color: var(--dashboard-accent-primary, var(--accent-primary));
  margin: 0 0 0.5rem 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.checkout-tile .value,
.pace-tile .value {
  color: var(--dashboard-text-main, var(--text-primary));
  font-size: 1.5rem;
  font-weight: 700;
}

.checkout-tile .label,
.pace-tile .label {
  color: var(--dashboard-text-muted, var(--text-secondary));
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

/* Heatmap cells – blue glow matches dashboard cards */
.heatmap-cell {
  background: var(--dashboard-card-bg, var(--background-secondary));
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 8px;
  padding: 0.75rem;
  box-shadow: var(--dashboard-card-shadow, 0 8px 20px rgba(15,23,42,0.85)), 0 0 28px rgba(56, 189, 248, 0.22);
}

.heatmap-cell strong {
  color: var(--dashboard-accent-primary, var(--accent-primary));
  display: block;
  margin-bottom: 0.25rem;
}

.card-subtext,
.status-text {
  color: var(--dashboard-text-muted, var(--text-secondary));
  font-size: 0.85rem;
}

/* =========================================
   RESPONSIVE RULES
========================================= */
@media (max-width: 700px) {
  /* ⭐️ MODIFIED: Reduced padding from 7.5rem to 6.5rem to pull content up ⭐️ */
  .page-container {
    padding: 6.5rem 1rem 0 1rem; 
  }

  .header-logo {
    height: 7.5rem;
  }

  /* ⭐️ MODIFIED: Reduced margin-top from 1.5rem to 0.75rem to close the gap ⭐️ */
  .analytics-header img {
    height: 6rem; 
    margin-top: 0.75rem; 
    margin-bottom: 0.25rem;
  }

  .filters {
    flex-direction: column;
    gap: .5rem;
  }

  .filters select,
  .filters button {
    width: 100%;
  }

  table thead,
  .score-table thead,
  .checkout-table thead,
  .finish-table thead {
    display: none;
  }

  table tr,
  .score-table tr,
  .checkout-table tr,
  .finish-table tr {
    display: block;
    margin-bottom: 1rem;
    background: var(--dashboard-row-bg, var(--background-tertiary));
    border-radius: 6px;
  }

  table td,
  .score-table td,
  .checkout-table td,
  .finish-table td {
    display: block;
    text-align: right;
    padding: 0.75rem 1rem;
    position: relative;
    padding-left: 50%;
  }

  table td::before,
  .score-table td::before,
  .checkout-table td::before,
  .finish-table td::before {
    content: attr(data-label);
    float: left;
    font-weight: bold;
    color: var(--dashboard-accent-primary, var(--accent-primary));
    text-align: left;
    width: 45%;
  }

  /* Analytics pages: keep tables as tables on mobile (no card layout) */
  body.analytics-theme .score-table thead,
  body.analytics-theme .checkout-table thead,
  body.analytics-theme .finish-table thead {
    display: table-header-group !important;
  }
  body.analytics-theme .score-table tr,
  body.analytics-theme .checkout-table tr,
  body.analytics-theme .finish-table tr {
    display: table-row !important;
    margin-bottom: 0 !important;
    background: transparent !important;
    border-radius: 0 !important;
  }
  body.analytics-theme .score-table td,
  body.analytics-theme .checkout-table td,
  body.analytics-theme .finish-table td {
    display: table-cell !important;
    text-align: center !important;
    padding: 0.6rem 0.25rem !important;
    padding-left: 0.6rem !important;
    position: static !important;
  }
  body.analytics-theme .score-table td::before,
  body.analytics-theme .checkout-table td::before,
  body.analytics-theme .finish-table td::before {
    display: none !important;
    content: none !important;
    float: none !important;
    width: auto !important;
  }

  /* Responsive adjustments for header text */
  .analytics-header h1#pageTitle {
    font-size: 2rem; 
    margin: 0.25rem 0;
  }
  
  #event-date-display {
    font-size: 1rem;
  }

  .chart-wrapper {
    height: 300px;
  }
}