:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #252542;
  --bg-input: #16162a;
  --accent-primary: #00d4aa;
  --accent-primary-hover: #00e8bb;
  --accent-secondary: #7c3aed;
  --accent-tertiary: #f59e0b;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-tertiary: #6b6b7b;
  --text-muted: #4b4b5b;
  --border: #2a2a4a;
  --border-light: #3a3a5a;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: all 0.2s ease;
  --scrollbar-thumb: #3a3a5a;
  --scrollbar-track: #1a1a2e;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: var(--radius);
}

*::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius);
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

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

html {
  height: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.header {
  padding: 30px 0;
  text-align: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: 30px;
}

.header h1 {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.header p {
  color: var(--text-secondary);
  font-size: 1rem;
}

.calculator-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 30px;
  flex-wrap: wrap;
  justify-content: center;
}

.tab-button {
  padding: 12px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.tab-button:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.tab-button.active {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  border-color: transparent;
  box-shadow: var(--shadow);
}

.calculator-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: visible;
  contain: layout;
}

.calculator-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.calculator-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.calculator-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.calculator-body {
  display: grid;
  grid-template-columns: 0.75fr 1.25fr;
  gap: 0;
  align-items: start;
}

.input-section {
  padding: 24px;
  border-right: 1px solid var(--border);
}

.results-section {
  padding: 24px;
  background: var(--bg-tertiary);
  position: -webkit-sticky;
  position: sticky;
  top: 110px;
  align-self: flex-start;
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  z-index: 10;
  box-sizing: border-box;
  border-radius: 0 0 var(--radius-lg) 0;
}

.step-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
}

.step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
}

.step-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 1rem;
}

.step-divider {
  height: 1px;
  background: var(--border);
  flex: 1;
  margin-left: 8px;
}

.form-group {
  margin-bottom: 20px;
  transition: all 0.3s ease;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.form-group .help-text {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-top: 4px;
  line-height: 1.4;
}

.form-group.target-field {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(0, 212, 170, 0.05));
  border: 1px dashed var(--accent-secondary);
  border-radius: var(--radius);
  padding: 12px;
  margin-left: -12px;
  margin-right: -12px;
  opacity: 0.8;
}

.form-group[data-field="futureValue"] {
  background: linear-gradient(135deg, rgba(0, 212, 170, 0.15), rgba(124, 58, 237, 0.1));
  border: 2px solid var(--accent-primary);
  border-radius: var(--radius);
  padding: 16px;
  margin-left: -16px;
  margin-right: -16px;
  margin-bottom: 24px;
}

.form-group.target-field .target-label {
  color: var(--accent-primary);
  font-weight: 600;
}

.form-group.target-field input:disabled {
  background: var(--bg-input);
  border-color: var(--accent-secondary);
  color: var(--accent-primary);
  font-weight: 600;
  opacity: 1;
  cursor: default;
}

.solve-for-banner {
  background: linear-gradient(135deg, var(--accent-secondary), var(--accent-primary));
  color: white;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 0.9rem;
  font-weight: 500;
}

.solve-for-banner strong {
  font-size: 1rem;
}

.mode-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(124, 58, 237, 0.2);
  color: var(--accent-primary);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.input-wrapper {
  position: relative;
}

.input-wrapper .prefix {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-weight: 500;
}

.input-wrapper .suffix {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-weight: 500;
}

.form-input {
  width: 100%;
  padding: 12px 12px 12px 28px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 1rem;
  transition: var(--transition);
  font-family: inherit;
}

.form-input.has-suffix {
  padding-right: 36px;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.1);
}

.form-input.error {
  border-color: var(--error);
}

.form-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-select {
  width: 100%;
  padding: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 1rem;
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23a0a0b0'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
}

.form-select:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.error-message {
  color: var(--error);
  font-size: 0.8rem;
  margin-top: 4px;
}

.button-group {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.btn {
  flex: 1;
  padding: 14px 24px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  box-shadow: var(--shadow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.result-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  border-left: 4px solid var(--accent-primary);
}

.result-card.primary {
  background: linear-gradient(135deg, rgba(0, 212, 170, 0.1), rgba(124, 58, 237, 0.1));
  border-left-color: var(--accent-secondary);
}

.result-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.result-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}

.result-value.large {
  font-size: 2.5rem;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.result-item {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 14px;
}

.result-item .label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.result-item .value {
  font-size: 1.2rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

.language-switcher {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  gap: 4px;
}

.lang-btn {
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}

.lang-btn:hover {
  border-color: var(--accent-primary);
}

.lang-btn.active {
  background: var(--accent-primary);
  color: var(--bg-primary);
  border-color: var(--accent-primary);
}

.solve-for-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(124, 58, 237, 0.1);
  border: 1px solid var(--accent-secondary);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.solve-for-toggle label {
  color: var(--accent-secondary);
  font-weight: 500;
  font-size: 0.9rem;
  margin: 0;
}

.solve-for-toggle select {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.9rem;
}

.chart-container {
  margin-top: 24px;
  padding: 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
}

.projection-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  font-size: 0.85rem;
}

.projection-table th,
.projection-table td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

.projection-table th:first-child,
.projection-table td:first-child {
  text-align: left;
}

.projection-table th {
  color: var(--text-secondary);
  font-weight: 500;
  background: var(--bg-tertiary);
}

.projection-table tr:hover td {
  background: rgba(0, 212, 170, 0.05);
}

@media (max-width: 900px) {
  .calculator-body {
    grid-template-columns: 1fr;
  }

  .input-section {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .results-section {
    position: static;
    max-height: none;
  }

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

  .result-value.large {
    font-size: 2rem;
  }
}

@media (max-width: 600px) {
  .header h1 {
    font-size: 1.5rem;
  }

  .calculator-tabs {
    flex-direction: column;
  }

  .tab-button {
    text-align: center;
  }

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

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

  .language-switcher {
    position: static;
    justify-content: center;
    margin-bottom: 20px;
  }
}
