:root {
  --primary: #7c3aed;
  --primary-dark: #6d28d9;
  --primary-light: #f5f3ff;
  --secondary: #8b5cf6;
  --green: #059669;
  --green-light: #d1fae5;
  --text: #1f2937;
  --text-light: #6b7280;
  --border: #e5e7eb;
  --white: #ffffff;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f9fafb;
  color: var(--text);
  line-height: 1.6;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  padding: 32px 0 28px;
  text-align: center;
}
header h1 { font-size: clamp(1.5rem, 4vw, 2.2rem); font-weight: 700; margin-bottom: 8px; }
.subtitle { font-size: 0.95rem; opacity: 0.9; }

.calculator-layout {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 24px;
  margin: 32px 0 24px;
}
@media (max-width: 768px) { .calculator-layout { grid-template-columns: 1fr; } }

.input-panel, .result-panel {
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}
.panel-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary-light);
}

.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: var(--text);
}
.optional { font-weight: 400; color: var(--text-light); font-size: 0.82rem; }

.input-prefix, .input-suffix {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s;
}
.input-prefix:focus-within, .input-suffix:focus-within { border-color: var(--primary); }
.prefix, .suffix {
  padding: 10px 12px;
  background: #f3f4f6;
  color: var(--text-light);
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
}
.input-prefix input, .input-suffix input {
  flex: 1;
  border: none;
  outline: none;
  padding: 10px 12px;
  font-size: 1rem;
  width: 100%;
}
input[type="month"] {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.95rem;
  width: 100%;
  outline: none;
}
input[type="month"]:focus { border-color: var(--primary); }

.btn-calc {
  width: 100%;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 14px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.2s, transform 0.1s;
}
.btn-calc:hover { background: var(--primary-dark); }
.btn-calc:active { transform: scale(0.98); }

.scenarios { margin-top: 20px; }
.scenarios-label { font-size: 0.82rem; color: var(--text-light); margin-bottom: 8px; }
.scenario-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.scenario-btn {
  border: 1.5px solid var(--primary);
  color: var(--primary);
  background: none;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}
.scenario-btn:hover, .scenario-btn.active { background: var(--primary); color: white; }

/* Results */
.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.result-card {
  background: var(--primary-light);
  border-radius: 10px;
  padding: 14px 16px;
  text-align: center;
}
.result-card.highlight {
  background: var(--primary);
  color: white;
  grid-column: 1 / -1;
}
.card-label { font-size: 0.8rem; font-weight: 600; margin-bottom: 4px; opacity: 0.8; }
.card-value { font-size: 1.4rem; font-weight: 700; }
.result-card.highlight .card-value { font-size: 1.7rem; }

/* Savings */
.savings-box {
  background: var(--green-light);
  border: 1px solid #6ee7b7;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}
.savings-box h3 { font-size: 0.95rem; margin-bottom: 12px; color: var(--green); }
.savings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.savings-item { text-align: center; }
.savings-label { display: block; font-size: 0.78rem; color: #065f46; margin-bottom: 4px; }
.savings-value { font-size: 1.2rem; font-weight: 700; color: #065f46; }
.savings-value.green { color: var(--green); }

/* Chart */
.chart-wrap { margin-top: 8px; }

/* Amortization */
.amort-section {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 28px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.btn-amort {
  background: none;
  border: 1.5px solid var(--primary);
  color: var(--primary);
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-amort:hover { background: var(--primary); color: white; }
.table-wrapper { overflow-x: auto; margin-top: 16px; max-height: 400px; overflow-y: auto; }
.amort-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.amort-table th {
  background: var(--primary);
  color: white;
  padding: 10px 12px;
  text-align: right;
  position: sticky;
  top: 0;
}
.amort-table th:first-child, .amort-table td:first-child { text-align: left; }
.amort-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: right; }
.amort-table tr:nth-child(even) td { background: #f9fafb; }
.amort-table .balance-col { font-weight: 600; }

/* Tips */
.tips-section {
  margin-bottom: 24px;
}
.tips-section h2 { font-size: 1.2rem; margin-bottom: 16px; }
.tips-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.tip-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.tip-num {
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  margin-bottom: 10px;
}
.tip-card h3 { font-size: 0.9rem; margin-bottom: 6px; }
.tip-card p { font-size: 0.82rem; color: var(--text-light); line-height: 1.5; }

/* FAQ */
.faq-section {
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 32px;
}
.faq-section h2 { font-size: 1.1rem; margin-bottom: 16px; }
.faq-item { border-bottom: 1px solid var(--border); }
.faq-item:last-child { border-bottom: none; }
.faq-question {
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  padding: 16px 0;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text);
  gap: 12px;
}
.faq-icon { font-size: 1.2rem; color: var(--primary); min-width: 20px; text-align: center; transition: transform 0.2s; }
.faq-question.open .faq-icon { transform: rotate(45deg); }
.faq-answer { display: none; padding: 0 0 16px; font-size: 0.9rem; line-height: 1.7; color: #374151; }
.faq-answer p { margin-bottom: 8px; }

footer {
  background: #1f2937;
  color: #9ca3af;
  padding: 24px 0;
  text-align: center;
}
footer a { color: #9ca3af; text-decoration: underline; margin: 0 6px; }
.disclaimer { font-size: 0.78rem; margin-top: 8px; }
