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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 40px rgb(0 0 0 / 10%);
  overflow: hidden;
}

.header {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
  padding: 30px;
  text-align: center;
}

.header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  font-weight: 700;
}

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

.clear-button {
  background: #ff6b6b;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  font-size: 0.9rem;
  box-shadow: 0 2px 10px rgb(255 107 107 / 30%);
}

.clear-button:hover {
  background: #ff4757;
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgb(255 107 107 / 35%);
}

.main-content {
  padding: 30px;
}

.section {
  margin-bottom: 40px;
}

.section-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 3px solid #667eea;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mode-selector {
  display: flex;
  gap: 20px;
  margin-bottom: 30px;
  justify-content: center;
}

.mode-btn {
  padding: 12px 24px;
  border: 2px solid #667eea;
  background: white;
  color: #667eea;
  border-radius: 25px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
}

.mode-btn.active {
  background: #667eea;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgb(102 126 234 / 30%);
}

.mode-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgb(102 126 234 / 20%);
}

.input-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 25px;
  margin-bottom: 30px;
}

.category-card {
  background: #f8fafc;
  border-radius: 15px;
  padding: 25px;
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

.category-card:hover {
  border-color: #667eea;
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgb(0 0 0 / 10%);
}

.category-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
}

.category-title-with-button {
  justify-content: space-between;
}

.category-icon {
  font-size: 1.5rem;
}

.input-group {
  margin-bottom: 15px;
}

.input-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  color: #4a5568;
}

.input-group input,
.input-group select {
  width: 100%;
  padding: 12px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.3s ease;
}

.input-group input:focus,
.input-group select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgb(102 126 234 / 10%);
}

.expand-btn {
  background: #e2e8f0;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.9rem;
  color: #4a5568;
  transition: all 0.3s ease;
  margin-top: 10px;
}

.expand-btn:hover {
  background: #cbd5e0;
}

.detailed-inputs {
  display: none;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #e2e8f0;
}

.detailed-inputs.show {
  display: block;
}

.summary-section {
  background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
  border-radius: 15px;
  padding: 25px;
  margin-top: 30px;
}

.summary-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 20px;
  text-align: center;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.summary-item {
  background: rgb(255 255 255 / 70%);
  padding: 15px;
  border-radius: 10px;
  text-align: center;
  transition: background-color 0.3s ease; /* Added for smooth transition */
}

.summary-item:hover {
  background-color: rgb(255 255 255 / 90%); /* Slightly darker on hover */
}

.summary-label {
  font-size: 0.9rem;
  color: #4a5568;
  margin-bottom: 5px;
}

.summary-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: #2d3748;
}

.remainder-positive {
  color: #38a169;
}

.remainder-negative {
  color: #e53e3e;
}

.house-section {
  background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
  border-radius: 15px;
  padding: 25px;
  margin-top: 30px;
}

.affordability-result {
  background: white;
  border-radius: 15px;
  padding: 25px;
  margin-top: 20px;
  text-align: center;
}

.affordability-status {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 15px;
}

.affordable {
  color: #38a169;
}

.not-affordable {
  color: #e53e3e;
}

.scenario-comparison {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.scenario-card {
  background: #f7fafc;
  border-radius: 10px;
  padding: 20px;
  border: 2px solid #e2e8f0;
}

.scenario-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 15px;
  color: #2d3748;
}

.scenario-detail {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.9rem;
  padding: 2px 5px; /* Add some padding for better hover area */
  border-radius: 5px; /* Slightly rounded corners */
  transition: background-color 0.3s ease;
}

.pmi-value-display {
  border-bottom: 1px dashed #2d3748; /* Underline for PMI value */
  padding-bottom: 1px; /* Small padding for visual separation */
}

.scenario-detail:hover {
  background-color: rgb(0 0 0 / 5%); /* Subtle hover effect */
}

.collapsible-section {
  cursor: pointer;
  user-select: none;
  justify-content: space-between !important;
  text-align: left;
}

.collapsible-section:hover {
  background-color: rgb(0 0 0 / 8%);
}

.collapse-toggle {
  font-weight: bold;
  transition: transform 0.3s ease;
  color: #667eea;
  font-size: 0.8rem;
  margin-right: 8px;
  width: 12px;
  display: inline-block;
}

.collapsible-content {
  margin-left: 20px;
  margin-top: 5px;
  border-left: 2px solid #e2e8f0;
  padding-left: 15px;
}

.scenario-total {
  border-top: 2px solid #e2e8f0;
  padding-top: 10px;
  margin-top: 10px;
  font-weight: 700;
}

.cash-requirements {
  background: #fff5f5;
  border: 2px solid #feb2b2;
  border-radius: 10px;
  padding: 20px;
  margin-top: 20px;
}

.cash-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #c53030;
  margin-bottom: 15px;
}

.tips-section {
  background: #e6fffa;
  border-radius: 15px;
  padding: 20px;
  margin-top: 30px;
  border-left: 4px solid #38b2ac;
}

.tips-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 10px;
}

.tip {
  margin-bottom: 8px;
  color: #4a5568;
}

@media (width <= 768px) {
  .mode-selector {
    flex-direction: column;
    align-items: center;
  }

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

  .summary-grid,
  .scenario-comparison {
    grid-template-columns: 1fr;
  }
}
