/* Import Google Fonts and Bootstrap Icons */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Inter:wght@300;400;500;600;700&display=swap');
@import url('https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css');

/* CSS Design System and Variables */
:root {
  /* Font Family */
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Transitions */
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 30px;
  
  /* Dark Theme Palette (Default) */
  --bg-primary: #0b0f19;
  --bg-secondary: #131a2c;
  --bg-tertiary: #1b253e;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --glass-bg: rgba(19, 26, 44, 0.75);
  --glass-border: rgba(255, 255, 255, 0.05);
  --glass-blur: blur(12px);
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px rgba(59, 130, 246, 0.2);
  
  /* Instrument/Category Accents (HSL for adaptability) */
  --accent-facility: 239, 84%, 67%;
  --accent-operational: 158, 92%, 38%;
  --accent-upgrade: 222, 69%, 64%;
  --accent-sampleprep: 11, 69%, 53%;
}

/* Light Theme overrides */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-color: rgba(15, 23, 42, 0.08);
  --border-hover: rgba(15, 23, 42, 0.16);
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -1px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -2px rgba(15, 23, 42, 0.05);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.12);
}

/* Global Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--border-hover) transparent;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  overflow-x: hidden;
  transition: background-color var(--transition-smooth), color var(--transition-smooth);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* Layout Grid */
.app-container {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
}

@media (max-width: 1024px) {
  .app-container {
    grid-template-columns: 1fr;
  }
}

/* Left Sidebar / Dashboard Control */
.sidebar {
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  transition: background-color var(--transition-smooth), border-color var(--transition-smooth);
}

@media (max-width: 1024px) {
  .sidebar {
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem;
  }
}

/* Sidebar Branding */
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, hsl(var(--accent-upgrade)), hsl(var(--accent-facility)));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.3rem;
  box-shadow: var(--shadow-glow);
}

.brand-info h1 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-info span {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Navigation Menu */
.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.nav-item i {
  font-size: 1.1rem;
}

.nav-item:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.1), rgba(99, 102, 241, 0.05));
  border-color: rgba(59, 130, 246, 0.25);
  color: hsl(var(--accent-upgrade));
  font-weight: 600;
}

/* Control Panel (Filters) */
.filter-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.filter-label {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Search bar */
.search-container {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: hsl(var(--accent-upgrade));
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.search-container i {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
}

/* Checkboxes and Tags */
.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 160px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.checkbox-item:hover {
  color: var(--text-primary);
}

.checkbox-item input {
  accent-color: hsl(var(--accent-upgrade));
  cursor: pointer;
}

.clear-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.clear-btn:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

/* Theme Toggle Button */
.theme-toggle-container {
  margin-top: auto;
}

.theme-btn {
  width: 100%;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

.theme-btn:hover {
  background-color: var(--bg-primary);
  border-color: var(--border-hover);
}

/* Main Content Wrapper */
.main-content {
  padding: 2.5rem;
  overflow-y: auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

@media (max-width: 1024px) {
  .main-content {
    height: auto;
    padding: 1.5rem;
  }
}

/* Content Header */
.content-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .content-header {
    flex-direction: column;
    align-items: stretch;
  }
}

.header-title-area h2 {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-title-area p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 0.25rem;
  max-width: 600px;
}

/* Metric Banner */
.stats-banner {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.stat-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  min-width: 110px;
  flex-grow: 1;
  transition: border-color var(--transition-fast);
}

.stat-card:hover {
  border-color: var(--border-hover);
}

.stat-value {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  color: hsl(var(--accent-upgrade));
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.15rem;
}

/* View Containers */
.view-container {
  display: none;
  animation: fadeIn 0.4s ease forwards;
}

.view-container.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   VERTICAL TIMELINE VIEW
   ========================================================================== */
.timeline-wrapper {
  position: relative;
  padding: 2rem 0;
}

/* Central Line (Styled as a Road) */
.timeline-line {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 24px; /* Asphalt road width */
  background-color: var(--bg-tertiary); /* Asphalt grey background */
  border-left: 2px solid rgba(255, 255, 255, 0.15); /* White solid edge lane line left */
  border-right: 2px solid rgba(255, 255, 255, 0.15); /* White solid edge lane line right */
  transform: translateX(-50%);
  z-index: 1;
}

/* Yellow dashed center dividing line of the road */
.timeline-line::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 0;
  border-left: 2px dashed #f59e0b; /* Yellow dash dividing line */
  transform: translateX(-50%);
  z-index: 2;
  opacity: 0.8;
}

@media (max-width: 768px) {
  .timeline-line {
    left: 20px;
    transform: translateX(-50%);
  }
}

/* Year Section Headers */
.timeline-year-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 3rem;
  position: relative;
}

.timeline-year-label {
  align-self: center;
  background: linear-gradient(135deg, hsl(var(--accent-upgrade)), hsl(var(--accent-facility)));
  color: #fff;
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  padding: 0.4rem 1.25rem;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-glow);
  z-index: 2;
  position: relative;
}

@media (max-width: 768px) {
  .timeline-year-label {
    align-self: flex-start;
    margin-left: 0;
  }
}

/* Timeline Cards container */
.timeline-events-container {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  position: relative;
}

/* Timeline Row */
.timeline-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  position: relative;
  width: 100%;
}

@media (max-width: 768px) {
  .timeline-row {
    grid-template-columns: 1fr;
    gap: 0;
    padding-left: 50px;
  }
}

/* Timeline Card */
.timeline-card-wrapper {
  display: flex;
  justify-content: flex-end;
  width: 100%;
}

.timeline-row:nth-child(even) .timeline-card-wrapper {
  grid-column: 2;
  justify-content: flex-start;
}

@media (max-width: 768px) {
  .timeline-card-wrapper,
  .timeline-row:nth-child(even) .timeline-card-wrapper {
    grid-column: 1;
    justify-content: flex-start;
  }
}

/* Main Interactive Card */
.timeline-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  position: relative;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-spring);
  opacity: 0;
  transform: translateY(30px);
}

.timeline-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.timeline-card:hover {
  transform: translateY(-5px) scale(1.01);
  border-color: var(--card-accent);
  box-shadow: 0 12px 25px rgba(0, 0, 0, 0.2), 0 0 15px var(--card-accent-alpha);
}

/* Connector Dot on Timeline Line (Snowflake icon) */
.timeline-dot {
  position: absolute;
  left: 50%;
  top: 1.55rem;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-primary);
  border-radius: 50%;
  border: 1px solid var(--border-color);
  color: var(--card-accent);
  transform: translateX(-50%);
  z-index: 2;
  font-size: 1.05rem;
  box-shadow: 0 0 10px var(--card-accent-alpha);
  transition: all var(--transition-smooth);
}

@media (max-width: 768px) {
  .timeline-dot {
    left: 20px;
    transform: translateX(-50%);
  }
}

.timeline-card:hover + .timeline-dot {
  transform: translateX(-50%) scale(1.35) rotate(45deg); /* Rotating snowflake on hover! */
  color: #fff;
  background-color: var(--card-accent);
  border-color: var(--card-accent);
  box-shadow: 0 0 18px var(--card-accent);
}

/* Card Content Header */
.card-header-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.card-date {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.card-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--card-accent-alpha);
  background-color: var(--card-accent-bg);
  color: var(--card-accent);
}

/* Card Body */
.timeline-card h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  line-height: 1.3;
}

.timeline-card p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.75rem;
}

.card-instrument {
  color: var(--text-muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.card-instrument i {
  color: var(--card-accent);
}

.read-more {
  color: hsl(var(--accent-upgrade));
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  transition: gap var(--transition-fast);
}

.timeline-card:hover .read-more {
  gap: 0.4rem;
}

/* No results fallback style */
.no-results {
  text-align: center;
  padding: 4rem 2rem;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 600px;
  margin: 2rem auto;
}

.no-results i {
  font-size: 3rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.no-results h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.no-results p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ==========================================================================
   INSTRUMENT LIFECYCLE GRID VIEW
   ========================================================================== */
.lifecycle-intro {
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  max-width: 800px;
}

.lifecycle-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.lifecycle-row {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: grid;
  grid-template-columns: 280px 1fr; /* Increased to 280px for clear label visibility */
  min-height: 120px;
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.lifecycle-row:hover {
  border-color: var(--row-accent);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

@media (max-width: 768px) {
  .lifecycle-row {
    grid-template-columns: 1fr;
  }
}

/* Left Label Panel of Lifecycle row */
.lifecycle-label {
  padding: 1.5rem;
  background-color: var(--bg-tertiary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.25rem;
  transition: background-color var(--transition-fast);
}

@media (max-width: 768px) {
  .lifecycle-label {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
}

.lifecycle-label h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lifecycle-label h3 i {
  color: var(--row-accent);
}

.lifecycle-label span {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Right Track Area */
.lifecycle-track {
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  position: relative;
  overflow-x: auto;
}

/* Track Line background: Solid portion for past/present */
.track-line-solid {
  position: absolute;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.4), rgba(59, 130, 246, 0.5));
  z-index: 1;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 1px;
}

/* Track Line background: Dotted portion for future */
.track-line-dotted {
  position: absolute;
  height: 2px;
  border-top: 2px dotted var(--text-muted);
  z-index: 1;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.6;
}

/* Vertical Divider Lines */
.track-grid-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  border-left: 1px dashed var(--border-color);
  z-index: 1;
  pointer-events: none;
  opacity: 0.45;
}

/* Track Grid Container */
.track-grid-container {
  display: grid;
  grid-template-columns: repeat(10, 1fr); /* 10 columns for 2018-2027 */
  width: 100%;
  height: 100%;
  min-width: 1050px; /* Increased to accommodate the extra year column */
  z-index: 2;
  position: relative;
}

/* Year Cell containing stacked event chips */
.year-cell {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 0.75rem 0.25rem;
  height: 100%;
  min-height: 120px;
}

/* Interactive Event Chip */
.lifecycle-chip {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--chip-accent);
  border-radius: var(--radius-sm);
  padding: 5px 6px;
  width: 100%;
  max-width: 95px;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.lifecycle-chip:hover {
  transform: translateY(-2px) scale(1.03);
  border-color: var(--chip-accent);
  background-color: var(--bg-primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2), 0 0 8px var(--chip-accent)40;
}

.chip-text {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  line-height: 1.2;
  word-break: break-word;
}

.chip-date {
  font-size: 0.52rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Tooltip/Popover info on hover */
.node-tooltip {
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%) scale(0.9) translateY(5px);
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  width: 220px;
  pointer-events: none;
  opacity: 0;
  transition: all var(--transition-fast);
  z-index: 100;
  text-align: left;
}

.lifecycle-chip:hover .node-tooltip {
  opacity: 1;
  transform: translateX(-50%) scale(1) translateY(0);
}

.node-tooltip h4 {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.node-tooltip p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.node-tooltip .tooltip-date {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 0.4rem;
  display: block;
}

/* ==========================================================================
   ANALYTICS DASHBOARD VIEW
   ========================================================================== */
.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

@media (max-width: 768px) {
  .analytics-grid {
    grid-template-columns: 1fr;
  }
}

.chart-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 320px;
}

.chart-card h3 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chart-card h3 i {
  color: hsl(var(--accent-upgrade));
}

.chart-container {
  position: relative;
  flex-grow: 1;
  width: 100%;
  height: 240px;
}

/* Custom Table/Overview of upgrade cycles for tabular view */
.analytics-summary-table {
  grid-column: 1 / -1;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.analytics-summary-table h3 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.data-table th {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background-color: var(--bg-tertiary);
}

/* ==========================================================================
   INTERACTIVE MODAL COMPONENT
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(11, 15, 25, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-smooth);
  padding: 1.5rem;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(20px) scale(0.95);
  transition: transform var(--transition-spring);
  position: relative;
}

.modal-overlay.active .modal-box {
  transform: translateY(0) scale(1);
}

.modal-close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all var(--transition-fast);
}

.modal-close-btn:hover {
  background-color: var(--border-hover);
  color: #fff;
  transform: rotate(90deg);
}

.modal-hero {
  height: 120px;
  background: linear-gradient(135deg, var(--modal-accent-bg, #3b82f6), var(--bg-tertiary));
  padding: 1.5rem;
  display: flex;
  align-items: flex-end;
  position: relative;
}

.modal-hero-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background-color: var(--bg-secondary);
  border: 2px solid var(--modal-accent-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--modal-accent-color);
  font-size: 1.75rem;
  box-shadow: var(--shadow-md);
  position: absolute;
  bottom: -28px;
  left: 1.5rem;
}

.modal-body {
  padding: 3rem 1.5rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-header-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
}

.modal-badges {
  display: flex;
  gap: 0.5rem;
}

.modal-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--modal-accent-alpha);
  background-color: var(--modal-accent-bg);
  color: var(--modal-accent-color);
}

.modal-badge.category-badge {
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.modal-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.modal-title h3 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.3;
}

.modal-description {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Modal tech highlight cards */
.modal-tech-highlight {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.modal-tech-highlight i {
  font-size: 1.5rem;
  color: var(--modal-accent-color);
}

.modal-tech-highlight div h5 {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--text-primary);
}

.modal-tech-highlight div p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ==========================================================================
   FOOTER SECTION
   ========================================================================== */
.footer {
  margin-top: auto;
  padding: 2rem 0;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer a:hover {
  color: hsl(var(--accent-upgrade));
}
