:root {
  /* Modern Color Palette - Merged with Vibrant Tones */
  --primary: #667eea;
  /* Indigo from old CSS */
  --primary-dark: #5a67d8;
  --secondary: #ec4899;
  /* Pink 500 */
  --accent: #764ba2;
  /* Purple from old CSS */
  --success: #48bb78;
  /* Green from old CSS */
  --warning: #ed8936;
  /* Orange from old CSS */
  --danger: #f56565;
  /* Red from old CSS */
  --info: #3b82f6;
  /* Blue 500 */

  /* Gradients */
  --header-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --highlight-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --pro-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  /* Gold for margins */

  /* Backgrounds & Surfaces */
  --bg-body: #f5f7fa;
  /* Light gray from old CSS */
  --bg-surface: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.9);
  /* Less transparent for better readability */

  /* Text */
  --text-main: #2d3748;
  /* Dark gray from old CSS */
  --text-muted: #4a5568;
  /* Medium gray from old CSS */
  --text-light: #718096;

  /* Shadows - Hybrid Approach */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-hover: 0 8px 16px rgba(0, 0, 0, 0.1);

  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 12px;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.dashboard {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* User Roles */
.role-indicator {
  background: rgba(255, 255, 255, 0.15);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Log Out Button */
.logout-btn {
  background: rgba(255, 99, 71, 0.2);
  border: 1px solid rgba(255, 99, 71, 0.3);
  color: white;
}

.logout-btn:hover {
  background: rgba(255, 99, 71, 0.3);
}

/* Header */
.header {
  background: var(--header-gradient);
  color: white;
  padding: 30px;
  border-radius: var(--radius-md);
  margin-bottom: 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 20px;
  z-index: 100;
  transition: transform 0.3s ease-in-out;
  overflow: hidden;
}

.header.hidden {
  transform: translateY(-150%);
}

.header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 100%);
  pointer-events: none;
}

.header h1 {
  font-size: 28px;
  font-weight: 600;
  position: relative;
  z-index: 1;
}

.header-info {
  display: flex;
  align-items: center;
  gap: 15px;
  position: relative;
  z-index: 1;
}

.update-time {
  font-size: 14px;
  opacity: 0.9;
}

.btn-refresh {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s;
}

.btn-refresh:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Filters */
.filters {
  background: var(--bg-surface);
  padding: 20px;
  border-radius: var(--radius-md);
  margin-bottom: 30px;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(226, 232, 240, 0.6);
}

.filter-group {
  flex: 1;
  min-width: 200px;
}

.filter-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 14px;
}

.filter-group select {
  width: 100%;
  padding: 10px;
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  font-size: 14px;
  background: white;
  margin: -15px 0 30px 0;
  border-radius: 4px;
  font-size: 14px;
  color: #856404;
}

.coverage-warning strong {
  color: #664d03;
}

/* Performance Scorecard */
.scorecard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 15px;
  margin-bottom: 30px;
  padding: 20px;
  background: var(--header-gradient);
  /* Consistent with header */
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.score-item {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  padding: 15px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: opacity 0.3s;
}

.score-item[style*="display: none"] {
  display: none;
}

.score-label {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 8px;
}

.score-value {
  font-size: 18px;
  font-weight: 700;
  color: white;
}

/* KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.kpi-card {
  background: var(--bg-surface);
  padding: 25px;
  /* Restored padding */
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(226, 232, 240, 0.6);
  transition: transform 0.3s, box-shadow 0.3s;
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: var(--primary);
}

.kpi-card.highlight {
  background: var(--highlight-gradient);
  color: white;
  border: none;
}

/* Margin KPI Special Style */
.kpi-card.margin-kpi {
  background: linear-gradient(135deg, #fff 0%, #fffbeb 100%);
  border: 1px solid var(--warning);
}

.kpi-card.margin-kpi .kpi-label {
  color: var(--warning);
  font-weight: 700;
}

.kpi-card.margin-kpi .kpi-value {
  color: var(--warning);
}

.kpi-label {
  font-size: 14px;
  font-weight: 500;
  opacity: 0.8;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
}

.kpi-value.long-text {
  font-size: 24px;
}

.kpi-change {
  font-size: 13px;
  opacity: 0.7;
}

.kpi-change.positive {
  color: var(--success);
}

.kpi-change.negative {
  color: var(--danger);
}

.kpi-change-secondary {
  font-size: 11px;
  opacity: 0.55;
  margin-top: 2px;
}

.kpi-change-secondary.positive {
  color: var(--success);
}

.kpi-change-secondary.negative {
  color: var(--danger);
}

/* Charts */
.chart-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.chart-container {
  background: var(--bg-surface);
  padding: 25px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(226, 232, 240, 0.6);
  transition: box-shadow 0.3s ease;
}

.chart-container:hover {
  box-shadow: var(--shadow-md);
}

.chart-container.full-width {
  grid-column: 1 / -1;
}

.chart-container h3 {
  margin-bottom: 20px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-main);
}

.chart-container canvas {
  cursor: pointer;
}

/* Tables */
.table-container,
.freshness-container {
  background: var(--bg-surface);
  padding: 25px;
  border-radius: var(--radius-md);
  margin-bottom: 30px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(226, 232, 240, 0.6);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  background: #f7fafc;
  padding: 12px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-muted);
  border-bottom: 2px solid #e2e8f0;
}

td {
  padding: 12px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 14px;
}

table tbody tr:nth-child(even) {
  background: #f7fafc;
}

table tbody tr:hover {
  background: #edf2f7;
  transform: scale(1.01);
  transition: all 0.2s;
}

tr:hover td {
  background: #f7fafc;
}

.status-ok {
  color: var(--success);
  font-weight: 600;
}

.status-stale {
  color: var(--danger);
  font-weight: 600;
}

.status-partial {
  color: var(--warning);
  font-weight: 600;
}

.status-critical {
  color: #e53e3e;
  font-weight: 700;
}

/* Loading state */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 15px;
  }

  .header h1 {
    font-size: 20px;
  }

  .filters {
    flex-direction: column;
  }

  .chart-row {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .kpi-value {
    font-size: 24px;
  }

  .scorecard {
    grid-template-columns: 1fr;
  }
}

/* Info icons and disclaimers */
.info-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  background: rgba(102, 126, 234, 0.2);
  color: #667eea;
  border-radius: 50%;
  font-size: 12px;
  cursor: help;
  margin-left: 4px;
  transition: all 0.2s;
}

.info-icon:hover {
  background: rgba(102, 126, 234, 0.3);
  transform: scale(1.1);
}

.estimate-tag {
  font-size: 11px;
  color: var(--warning);
  vertical-align: super;
  cursor: help;
  opacity: 0.7;
}

.estimate-note {
  font-size: 11px;
  color: var(--warning);
  font-weight: normal;
  opacity: 0.8;
}

table th .estimate-note {
  margin-left: 4px;
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px);
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: white;
  padding: 30px;
  border-radius: 12px;
  max-width: 600px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  position: relative;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-close {
  color: #aaa;
  float: right;
  font-size: 32px;
  font-weight: bold;
  line-height: 20px;
  cursor: pointer;
  transition: color 0.2s;
}

.modal-close:hover,
.modal-close:focus {
  color: #000;
}

.modal-content h3 {
  margin-top: 0;
  margin-bottom: 15px;
  color: var(--text-main);
  font-size: 20px;
  padding-right: 30px;
}

.modal-content p {
  color: var(--text-muted);
  line-height: 1.8;
  font-size: 15px;
}

/* Improve info icon visibility in h3 */
.chart-container h3 .info-icon,
.table-container h3 .info-icon,
.freshness-container h3 .info-icon {
  font-size: 14px;
  width: 18px;
  height: 18px;
  line-height: 18px;
  vertical-align: middle;
}

/* Estimate indicators in table */
table .estimate-tag {
  font-size: 10px;
  margin-left: 2px;
}

/* YoY Disclaimer */
.yoy-disclaimer {
  background: #fff3cd;
  border-left: 4px solid #ffc107;
  padding: 12px 16px;
  margin: -15px 0 30px 0;
  border-radius: 4px;
  font-size: 13px;
  color: #856404;
}

.yoy-disclaimer strong {
  color: #664d03;
}

/* Footer Copyright */
.footer-copyright {
  text-align: center;
  padding: 30px 20px;
  color: #718096;
  font-size: 13px;
  border-top: 1px solid #e2e8f0;
  margin-top: 40px;
}

.footer-copyright p {
  margin: 0;
  line-height: 1.8;
}

.rotating-text {
  display: inline-block;
  transition: opacity 0.3s;
  font-weight: 600;
  color: #667eea;
}

.subtle-brag {
  opacity: 0.7;
  font-style: italic;
}

/* Celebration Toast */
.celebration-toast {
  position: fixed;
  top: 100px;
  right: 20px;
  padding: 20px 30px;
  color: white;
  background: var(--header-gradient);
  font-weight: 600;
  font-size: 16px;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  z-index: 10001;
  transform: translateX(400px);
  transition: transform 0.3s ease-out;
}

.celebration-toast.show {
  transform: translateX(0);
}

/* Confetti */
.confetti {
  position: fixed;
  width: 10px;
  height: 10px;
  top: -10px;
  z-index: 9999;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  to {
    transform: translateY(100vh) rotate(360deg);
    opacity: 0;
  }
}

/* Shimmer effect */
.header.shimmer {
  animation: shimmer 2s ease-in-out;
}

@keyframes shimmer {

  0%,
  100% {
    filter: brightness(1);
  }

  50% {
    filter: brightness(1.3);
  }
}

/* Firework */
.firework {
  position: fixed;
  font-size: 40px;
  z-index: 9999;
  animation: firework-burst 2s ease-out forwards;
  pointer-events: none;
}

@keyframes firework-burst {
  0% {
    transform: scale(0);
    opacity: 1;
  }

  50% {
    transform: scale(1.5);
    opacity: 1;
  }

  100% {
    transform: scale(2) translateY(-100px);
    opacity: 0;
  }
}

/* Falling emoji (Black Friday) */
.falling-emoji {
  position: fixed;
  top: -50px;
  z-index: 9999;
  animation: fall 4s linear forwards;
  pointer-events: none;
}

@keyframes fall {
  to {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* Rainbow background (epic mode) */
@keyframes rainbow-bg {
  0% {
    filter: hue-rotate(0deg);
  }

  100% {
    filter: hue-rotate(360deg);
  }
}

/* Secret stats panel */
#secretStats {
  display: none;
  background: linear-gradient(135deg, #0a0a0a, #1a1a2e);
  color: #0f0;
  padding: 25px;
  border-radius: 12px;
  margin: 20px 0;
  font-family: 'Courier New', monospace;
  border: 2px solid #0f0;
  box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

#secretStats h3 {
  color: #0f0;
  text-shadow: 0 0 10px #0f0;
  margin-bottom: 20px;
  font-size: 20px;
}

#secretStats h4 {
  color: #0f0;
  margin: 20px 0 10px 0;
  font-size: 16px;
}

.secret-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.secret-stat {
  background: rgba(0, 255, 0, 0.05);
  padding: 12px;
  border-radius: 6px;
  border: 1px solid rgba(0, 255, 0, 0.2);
}

.secret-label {
  font-size: 11px;
  color: #0a0;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.secret-value {
  font-size: 18px;
  color: #0f0;
  font-weight: bold;
}

.secret-links {
  border-top: 1px solid rgba(0, 255, 0, 0.2);
  padding-top: 15px;
}

.secret-links p {
  margin: 8px 0;
}

.secret-links a {
  color: #0f0;
  text-decoration: none;
  transition: all 0.2s;
}

.secret-links a:hover {
  color: #0ff;
  text-shadow: 0 0 5px #0ff;
}

.secret-btn {
  background: rgba(0, 255, 0, 0.1);
  border: 1px solid #0f0;
  color: #0f0;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  transition: all 0.2s;
}

.secret-btn:hover {
  background: rgba(0, 255, 0, 0.2);
  box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
}

kbd {
  background: rgba(0, 255, 0, 0.1);
  border: 1px solid #0f0;
  border-radius: 3px;
  padding: 2px 6px;
  font-size: 11px;
  font-family: 'Courier New', monospace;
}

.filter-subtext {
  font-size: 0.85rem;
  color: #666;
  margin-top: 4px;
  font-style: italic;
}
/* Warning Banner */
.warning-banner {
  background: rgba(237, 137, 54, 0.1);
  border: 1px solid rgba(237, 137, 54, 0.3);
  color: var(--warning);
  padding: 12px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.warning-banner strong {
  color: var(--warning);
  font-weight: 600;
}
