@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-card-hover: rgba(30, 41, 59, 0.9);
  --border-color: rgba(148, 163, 184, 0.1);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-violet: #8b5cf6;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --gradient-1: linear-gradient(135deg, #3b82f6, #8b5cf6);
  --gradient-2: linear-gradient(135deg, #06b6d4, #10b981);
  --gradient-3: linear-gradient(135deg, #f59e0b, #f43f5e);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 40px rgba(59, 130, 246, 0.1);
  --radius: 16px;
  --radius-sm: 10px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* Background pattern */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(6, 182, 212, 0.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

/* Header */
.header {
  padding: 48px 0 32px;
  text-align: center;
}

.header__badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-blue);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 20px;
}

.header__badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-emerald);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

.header h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
  line-height: 1.2;
}

.header p {
  color: var(--text-secondary);
  font-size: 1.05rem;
  max-width: 600px;
  margin: 0 auto;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.kpi-card:nth-child(1)::before {
  background: var(--gradient-1);
}

.kpi-card:nth-child(2)::before {
  background: var(--gradient-2);
}

.kpi-card:nth-child(3)::before {
  background: var(--gradient-3);
}

.kpi-card:nth-child(4)::before {
  background: linear-gradient(135deg, #8b5cf6, #06b6d4);
}

.kpi-card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.kpi-card__label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.kpi-card__value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 6px;
}

.kpi-card__change {
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
}

.kpi-card__change.positive {
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.1);
}

.kpi-card__change.negative {
  color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.1);
}

.kpi-card__sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Chart Grid */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-bottom: 32px;
}

.chart-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-card);
  transition: all 0.3s ease;
}

.chart-card:hover {
  border-color: rgba(148, 163, 184, 0.2);
}

.chart-card.full-width {
  grid-column: 1 / -1;
}

.chart-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.chart-card__title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.chart-card__subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.chart-card__icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.chart-card__icon.blue {
  background: rgba(59, 130, 246, 0.15);
}

.chart-card__icon.cyan {
  background: rgba(6, 182, 212, 0.15);
}

.chart-card__icon.violet {
  background: rgba(139, 92, 246, 0.15);
}

.chart-card__icon.emerald {
  background: rgba(16, 185, 129, 0.15);
}

.chart-card__icon.amber {
  background: rgba(245, 158, 11, 0.15);
}

.chart-wrap {
  position: relative;
  height: 320px;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Insights section */
.insights {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 48px;
  box-shadow: var(--shadow-card);
}

.insights h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.insight-item {
  padding: 16px;
  background: rgba(15, 23, 42, 0.5);
  border-radius: var(--radius-sm);
  border-left: 3px solid;
}

.insight-item:nth-child(1) {
  border-color: var(--accent-blue);
}

.insight-item:nth-child(2) {
  border-color: var(--accent-amber);
}

.insight-item:nth-child(3) {
  border-color: var(--accent-emerald);
}

.insight-item:nth-child(4) {
  border-color: var(--accent-violet);
}

.insight-item h3 {
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.insight-item p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Loading states */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 0.9rem;
  gap: 10px;
}

.loading .spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Footer */
.footer {
  text-align: center;
  padding: 24px 0 48px;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.footer a {
  color: var(--accent-blue);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 0 16px;
  }

  .header {
    padding: 32px 0 24px;
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .chart-wrap {
    height: 260px;
  }
}

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

/* Error state */
.error-msg {
  color: var(--accent-rose);
  font-size: 0.85rem;
  text-align: center;
  padding: 20px;
}

/* Rose icon */
.chart-card__icon.rose {
  background: rgba(244, 63, 94, 0.15);
}

/* Section headers */
.section-header {
  padding: 32px 0 12px;
}

.section-header h2 {
  font-size: 1.4rem;
  font-weight: 800;
  background: var(--gradient-3);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* Alert banners */
.alert-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.alert-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  animation: slideIn 0.4s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alert-banner--danger {
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.25);
  color: #fda4af;
}

.alert-banner--warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: #fcd34d;
}

.alert-banner--info {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  color: #93c5fd;
}

.alert-banner__icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* Scenario table */
.scenario-table-wrap {
  padding: 8px;
}

.scenario-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.scenario-table th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.scenario-table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.05);
  color: var(--text-secondary);
}

.scenario-table td:first-child {
  font-weight: 600;
  color: var(--text-primary);
}

.scenario-table .conservative {
  color: var(--accent-rose);
}

.scenario-table .base {
  color: var(--accent-amber);
}

.scenario-table .optimistic {
  color: var(--accent-emerald);
}

.scenario-table tr:hover td {
  background: rgba(148, 163, 184, 0.04);
}

/* Market sizing 3-column */
.kpi-grid--three {
  grid-template-columns: repeat(3, 1fr);
}

.kpi-card--tam::before {
  background: linear-gradient(135deg, #f59e0b, #f43f5e);
}

.kpi-card--sam::before {
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
}

.kpi-card--som::before {
  background: linear-gradient(135deg, #10b981, #06b6d4);
}

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