:root {
  --primary-color: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary-color: #10b981;
  --accent-color: #f59e0b;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-card: #ffffff;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --border-color: #e5e7eb;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --radius: 8px;
  --transition: all 0.3s ease;
}

[data-theme="dark"] {
  --primary-color: #3b82f6;
  --primary-dark: #2563eb;
  --secondary-color: #10b981;
  --accent-color: #f59e0b;
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --border-color: #475569;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: var(--transition);
}

.container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header Styles */
.header {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  padding: 2rem 0;
  position: relative;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  text-align: center;
  position: relative;
}

.header h1 {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.header p {
  font-size: 1.2rem;
  opacity: 0.9;
}

.theme-toggle {
  position: absolute;
  top: 0;
  right: 1rem;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  padding: 0.75rem;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  font-size: 1.2rem;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

/* Main Content */
.main-content {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
  width: 100%;
}

/* Calculator Section */
.calculator-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 3rem;
}

.calculator-card, .results-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.calculator-card:hover, .results-card:hover {
  box-shadow: var(--shadow-lg);
}

.calculator-card h2, .results-card h2 {
  color: var(--primary-color);
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
}

/* Investment Type Toggle */
.investment-type-toggle {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  background: var(--bg-secondary);
  padding: 0.25rem;
  border-radius: var(--radius);
}

.toggle-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
}

.toggle-btn.active {
  background: var(--primary-color);
  color: white;
  box-shadow: var(--shadow);
}

.toggle-btn:hover:not(.active) {
  background: var(--border-color);
  color: var(--text-primary);
}

/* Form Styles */
.calculator-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

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

.input-group label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.input-group input {
  padding: 0.75rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 1rem;
  transition: var(--transition);
}

.input-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.button-group {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

.calculate-btn, .reset-btn, .export-btn, .add-comparison-btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
}

.calculate-btn {
  background: var(--primary-color);
  color: white;
  flex: 1;
}

.calculate-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

.reset-btn {
  background: var(--text-secondary);
  color: white;
  flex: 1;
}

.reset-btn:hover {
  background: var(--text-primary);
  transform: translateY(-2px);
}

/* Results Styles */
.results-grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 2rem;
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border-left: 4px solid var(--primary-color);
}

.result-item.highlight {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  border-left-color: var(--accent-color);
}

.result-label {
  font-weight: 600;
}

.result-value {
  font-size: 1.2rem;
  font-weight: 700;
}

.export-btn {
  background: var(--secondary-color);
  color: white;
  width: 100%;
}

.export-btn:hover {
  background: #059669;
  transform: translateY(-2px);
}

/* Charts Section */
.charts-section {
  margin-bottom: 3rem;
}

.charts-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.chart-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
}

.chart-card h3 {
  color: var(--primary-color);
  margin-bottom: 1rem;
  text-align: center;
}

.chart-card canvas {
  max-height: 300px;
}

/* Comparison Section */
.comparison-section {
  margin-bottom: 3rem;
}

.comparison-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
}

.comparison-card h2 {
  color: var(--primary-color);
  margin-bottom: 1.5rem;
}

.comparison-table-container {
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-primary);
  border-radius: var(--radius);
  overflow: hidden;
}

.comparison-table th,
.comparison-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.comparison-table th {
  background: var(--primary-color);
  color: white;
  font-weight: 600;
}

.comparison-table tr:hover {
  background: var(--bg-secondary);
}

.add-comparison-btn {
  background: var(--accent-color);
  color: white;
  width: 100%;
}

.add-comparison-btn:hover {
  background: #d97706;
  transform: translateY(-2px);
}

/* Formula Section */
.formula-section {
  margin-bottom: 3rem;
}

.formula-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
}

.formula-card h2 {
  color: var(--primary-color);
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.formula-content {
  display: grid;
  gap: 2rem;
}

.formula-box {
  background: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: var(--radius);
  border-left: 4px solid var(--primary-color);
}

.formula {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--primary-color);
  background: var(--bg-primary);
  padding: 1rem;
  border-radius: var(--radius);
  text-align: center;
  font-family: 'Courier New', monospace;
  margin-top: 0.5rem;
}

.formula-explanation ul {
  list-style: none;
  padding-left: 0;
}

.formula-explanation li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
}

.formula-explanation li:last-child {
  border-bottom: none;
}

.monthly-return-formula {
  background: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: var(--radius);
  border-left: 4px solid var(--secondary-color);
}

.example-calculation {
  background: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: var(--radius);
  border-left: 4px solid var(--accent-color);
}

/* Footer */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 2rem 0;
  margin-top: auto;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  text-align: center;
}

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

.credits a {
  color: var(--primary-color);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.credits a:hover {
  color: var(--primary-dark);
  transform: translateY(-1px);
}

/* Responsive Design */
@media (max-width: 768px) {
  .header h1 {
    font-size: 2rem;
  }

  .header p {
    font-size: 1rem;
  }

  .calculator-section {
    grid-template-columns: 1fr;
  }

  .charts-container {
    grid-template-columns: 1fr;
  }

  .button-group {
    flex-direction: column;
  }

  .investment-type-toggle {
    flex-direction: column;
  }

  .toggle-btn {
    flex: none;
  }

  .credits {
    font-size: 0.9rem;
  }

  .theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: 1rem 0.5rem;
  }

  .calculator-card, .results-card, .chart-card, .comparison-card, .formula-card {
    padding: 1rem;
  }

  .formula {
    font-size: 1rem;
  }

  .result-item {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
  }
}

/* Animation Classes */
.fade-in {
  animation: fadeIn 0.5s ease-in-out;
}

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

.scale-in {
  animation: scaleIn 0.3s ease-out;
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Loading States */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--primary-color);
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 1s linear infinite;
}

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