/* ========== Design Tokens ========== */
:root {
  --color-bg: #0a0e1a;
  --color-surface: #111827;
  --color-surface-2: #1a2035;
  --color-surface-3: #222940;
  --color-border: #2a3352;
  --color-text: #e8ecf4;
  --color-text-muted: #8892a8;
  --color-text-dim: #5a6480;
  --color-primary: #3b82f6;
  --color-primary-dark: #2563eb;
  --color-primary-glow: rgba(59, 130, 246, 0.15);
  --color-accent: #10b981;
  --color-accent-glow: rgba(16, 185, 129, 0.15);
  --color-warning: #f59e0b;
  --color-warning-bg: rgba(245, 158, 11, 0.1);
  --color-error: #ef4444;
  --color-error-bg: rgba(239, 68, 68, 0.1);
  --color-info: rgba(59, 130, 246, 0.1);
  --color-gradient: linear-gradient(135deg, #3b82f6, #8b5cf6, #06b6d4);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font: 'Inter', -apple-system, system-ui, sans-serif;
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 40px rgba(59, 130, 246, 0.1);
}

/* ========== Reset & Base ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  font-family: var(--font);
}
.btn-primary {
  background: var(--color-primary);
  color: white;
}
.btn-primary:hover { background: var(--color-primary-dark); transform: translateY(-1px); }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--color-border);
  color: var(--color-text);
}
.btn-outline:hover { border-color: var(--color-primary); color: var(--color-primary); }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; }
.btn-full { width: 100%; }

/* ========== Nav ========== */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 40px;
  max-width: 1200px;
  margin: 0 auto;
}
.logo { display: flex; align-items: center; gap: 8px; }
.logo-icon { font-size: 1.5rem; }
.logo-text { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.5px; }
.nav-links { display: flex; align-items: center; gap: 24px; }
.nav-links a { color: var(--color-text-muted); font-size: 0.9rem; font-weight: 500; }
.nav-links a:hover { color: var(--color-text); text-decoration: none; }

/* ========== Hero ========== */
.hero {
  background: var(--color-bg);
  padding-bottom: 80px;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -200px;
  right: -200px;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.08), transparent 70%);
  pointer-events: none;
}
.hero-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 60px 40px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  align-items: center;
}
.badge {
  display: inline-block;
  background: var(--color-primary-glow);
  color: var(--color-primary);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 20px;
  border: 1px solid rgba(59, 130, 246, 0.2);
}
.hero h1 {
  font-size: 3.2rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -1.5px;
  margin-bottom: 20px;
}
.gradient-text {
  background: var(--color-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-subtitle {
  font-size: 1.15rem;
  color: var(--color-text-muted);
  line-height: 1.7;
  margin-bottom: 32px;
  max-width: 480px;
}
.hero-stats {
  display: flex;
  gap: 32px;
}
.stat { display: flex; flex-direction: column; }
.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  background: var(--color-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.stat-label { font-size: 0.8rem; color: var(--color-text-dim); margin-top: 2px; }

/* ========== Upload Card ========== */
.upload-card {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-card);
}
.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
}
.upload-zone:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-glow);
}
.upload-zone.dragover {
  border-color: var(--color-primary);
  background: var(--color-primary-glow);
}
.upload-icon { font-size: 3rem; }
.upload-zone h3 { font-size: 1.1rem; font-weight: 600; }
.upload-zone p { color: var(--color-text-muted); font-size: 0.9rem; }
.upload-hint { font-size: 0.8rem; color: var(--color-text-dim); margin-top: 8px; }

.upload-processing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 40px;
}
.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.processing-text { color: var(--color-text-muted); font-weight: 500; }
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--color-surface-3);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--color-gradient);
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s;
}

/* ========== Dashboard ========== */
.dashboard {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px;
}
.dashboard-header { margin-bottom: 40px; }
.bill-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding: 24px;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}
.bill-provider { display: flex; align-items: center; gap: 16px; }
.provider-logo { font-size: 2rem; }
.bill-provider h2 { font-size: 1.3rem; font-weight: 700; }
.bill-period { color: var(--color-text-muted); font-size: 0.85rem; }
.bill-total { text-align: right; }
.total-label { display: block; color: var(--color-text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; }
.total-amount { display: block; font-size: 2.2rem; font-weight: 800; }
.total-change { font-size: 0.85rem; font-weight: 600; }
.total-change.negative { color: var(--color-error); }
.total-change.positive { color: var(--color-accent); }

/* Score Cards */
.score-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.score-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.score-card.highlight {
  border-color: var(--color-accent);
  background: var(--color-accent-glow);
}
.score-ring { width: 64px; height: 64px; flex-shrink: 0; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--color-surface-3); stroke-width: 3; }
.ring-fill { fill: none; stroke: var(--color-warning); stroke-width: 3; stroke-linecap: round; }
.ring-text {
  fill: var(--color-text);
  font-size: 10px;
  font-weight: 700;
  text-anchor: middle;
  transform: rotate(90deg);
  transform-origin: 18px 18px;
}
.score-label { font-weight: 600; font-size: 0.9rem; }
.score-desc { font-size: 0.8rem; color: var(--color-text-muted); }
.score-info { display: flex; flex-direction: column; gap: 2px; }
.savings-amount {
  font-size: 2rem;
  font-weight: 800;
  color: var(--color-accent);
}
.savings-period { font-size: 1rem; font-weight: 500; opacity: 0.7; }
.anomaly-count {
  font-size: 2rem;
  font-weight: 800;
  color: var(--color-warning);
  width: 64px;
  text-align: center;
  flex-shrink: 0;
}
.neighbor-rank {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-primary);
  width: 64px;
  text-align: center;
  flex-shrink: 0;
}

/* ========== Sections ========== */
.section { margin-bottom: 40px; }
.section-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}

/* Line Items */
.line-items { display: flex; flex-direction: column; gap: 8px; }
.line-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: start;
  gap: 16px;
  padding: 16px 20px;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: all 0.2s;
}
.line-item:hover { border-color: var(--color-primary); }
.line-item.expanded { border-color: var(--color-primary); }
.item-name { font-weight: 600; font-size: 0.95rem; }
.item-amount { font-weight: 700; font-size: 0.95rem; text-align: right; white-space: nowrap; }
.item-percent {
  color: var(--color-text-dim);
  font-size: 0.8rem;
  text-align: right;
  white-space: nowrap;
}
.item-explain {
  grid-column: 1 / -1;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
  display: none;
}
.line-item.expanded .item-explain { display: block; }
.item-flag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 8px;
}
.flag-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.flag-error { background: var(--color-error-bg); color: var(--color-error); }

/* Rate Comparison */
.rate-comparison {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.rate-card {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px;
  position: relative;
}
.rate-card.recommended {
  border-color: var(--color-accent);
  background: var(--color-accent-glow);
}
.rate-card.current { opacity: 0.8; }
.rate-badge {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}
.recommended-badge { color: var(--color-accent) !important; }
.rate-card h4 { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; }
.rate-price { font-size: 1.8rem; font-weight: 800; margin-bottom: 4px; }
.rate-price span { font-size: 0.9rem; font-weight: 500; color: var(--color-text-muted); }
.rate-savings { color: var(--color-accent); font-weight: 600; font-size: 0.9rem; margin-bottom: 12px; }
.rate-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.rate-features li { font-size: 0.85rem; color: var(--color-text-muted); }
.feature-match { color: var(--color-accent) !important; font-weight: 500; }
.feature-miss { color: var(--color-error) !important; font-weight: 500; }

/* Chart */
.chart-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px;
}
.chart-bar-group {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 200px;
  padding-bottom: 8px;
}
.chart-bar-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}
.chart-bar {
  width: 100%;
  max-width: 48px;
  border-radius: 6px 6px 0 0;
  position: relative;
  transition: all 0.3s;
  cursor: pointer;
}
.chart-bar:hover { opacity: 0.8; }
.chart-bar-value {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
}
.chart-labels {
  display: flex;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
}
.chart-label {
  flex: 1;
  text-align: center;
  font-size: 0.75rem;
  color: var(--color-text-dim);
}

/* Alerts */
.alerts { display: flex; flex-direction: column; gap: 12px; }
.alert {
  display: flex;
  gap: 16px;
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid;
}
.alert-warning { background: var(--color-warning-bg); border-color: rgba(245, 158, 11, 0.2); }
.alert-error { background: var(--color-error-bg); border-color: rgba(239, 68, 68, 0.2); }
.alert-info { background: var(--color-info); border-color: rgba(59, 130, 246, 0.2); }
.alert-icon { font-size: 1.3rem; flex-shrink: 0; padding-top: 2px; }
.alert-content strong { display: block; margin-bottom: 4px; }
.alert-content p { font-size: 0.9rem; color: var(--color-text-muted); line-height: 1.5; }

/* ========== Features Section ========== */
.features-section, .how-section, .pricing-section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 80px 40px;
  text-align: center;
}
.features-section h2, .how-section h2, .pricing-section h2 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 12px;
}
.section-subtitle {
  color: var(--color-text-muted);
  font-size: 1.1rem;
  margin-bottom: 48px;
}
.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  text-align: left;
}
.feature-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 28px;
  transition: all 0.2s;
}
.feature-card:hover { border-color: var(--color-primary); transform: translateY(-2px); }
.feature-icon { font-size: 2rem; margin-bottom: 12px; }
.feature-card h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 8px; }
.feature-card p { font-size: 0.9rem; color: var(--color-text-muted); line-height: 1.5; }

/* ========== How It Works ========== */
.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}
.step {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 32px 28px;
  flex: 1;
  max-width: 300px;
}
.step-number {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 16px;
}
.step h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 8px; }
.step p { font-size: 0.9rem; color: var(--color-text-muted); }
.step-arrow { font-size: 1.5rem; color: var(--color-text-dim); }

/* ========== Pricing ========== */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  text-align: left;
}
.pricing-card {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 32px;
  position: relative;
}
.pricing-card.popular {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-glow);
}
.popular-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-primary);
  color: white;
  padding: 4px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}
.pricing-card h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 8px; }
.price { font-size: 2.5rem; font-weight: 800; margin-bottom: 24px; }
.price span { font-size: 1rem; font-weight: 500; color: var(--color-text-muted); }
.pricing-card ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}
.pricing-card li { font-size: 0.9rem; color: var(--color-text-muted); }

/* ========== Footer ========== */
.footer {
  border-top: 1px solid var(--color-border);
  padding: 40px;
  max-width: 1200px;
  margin: 0 auto;
}
.footer-content { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.footer-brand p { color: var(--color-text-dim); font-size: 0.85rem; margin-top: 4px; }
.footer-links { display: flex; gap: 24px; }
.footer-links a { color: var(--color-text-muted); font-size: 0.85rem; }
.footer-bottom { text-align: center; padding-top: 24px; border-top: 1px solid var(--color-border); }
.footer-bottom p { font-size: 0.8rem; color: var(--color-text-dim); }
.footer-note { color: var(--color-text-muted); }

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .hero-content { grid-template-columns: 1fr; gap: 32px; padding: 32px 20px 0; }
  .hero h1 { font-size: 2.2rem; }
  .hero-stats { gap: 20px; }
  .stat-value { font-size: 1.4rem; }
  .nav { padding: 12px 20px; }
  .nav-links a:not(.btn) { display: none; }
  .score-cards { grid-template-columns: repeat(2, 1fr); }
  .features-grid, .rate-comparison, .pricing-grid { grid-template-columns: 1fr; }
  .steps { flex-direction: column; }
  .step-arrow { transform: rotate(90deg); }
  .dashboard { padding: 20px; }
  .bill-summary-row { flex-direction: column; gap: 16px; text-align: center; }
  .bill-total { text-align: center; }
  .features-section, .how-section, .pricing-section { padding: 48px 20px; }
}
