* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Inter", sans-serif;
}

.container {
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a1a, #05223f);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.calculator {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 800px;
  overflow: hidden;
}

.calculator-header {
  background: #072038;
  padding: 30px;
  text-align: center;
  color: white;
}

.calculator-header h2 {
  font-size: 2rem;
  margin-bottom: 10px;
}

.subtitle {
  color: #a0aec0;
  font-size: 1rem;
}

.calculator-body {
  padding: 30px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

.input-section {
  padding-right: 30px;
  border-right: 1px solid #e2e8f0;
}

.input-group {
  margin-bottom: 20px;
  position: relative;
}

.input-group label {
  display: block;
  color: #4a5568;
  margin-bottom: 8px;
  font-size: 0.9rem;
  font-weight: 500;
}

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

.input-group input:focus {
  outline: none;
  border-color: #2c3e50;
  box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.1);
}

.input-icon {
  position: absolute;
  right: 15px;
  top: 40px;
  color: #718096;
}

button {
  width: 100%;
  padding: 15px;
  background: #042241;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

button:hover {
  background: #1a252f;
  transform: translateY(-2px);
}

.results {
  padding: 20px;
}

.results h3 {
  color: #2d3748;
  margin-bottom: 20px;
  font-size: 1.5rem;
}

.result-grid {
  display: grid;
  gap: 20px;
}

.result-item {
  background: #f7fafc;
  padding: 20px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.result-label {
  display: block;
  color: #718096;
  font-size: 0.9rem;
  margin-bottom: 5px;
}

.result-value {
  display: block;
  color: #2d3748;
  font-size: 1.5rem;
  font-weight: bold;
}

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

  .input-section {
    padding-right: 0;
    border-right: none;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 30px;
  }
}

/* Make table horizontally scrollable inside a wrapper so it doesn't push the whole page */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.breakdown-table {
  width: 100%;
  border-collapse: collapse; /* avoid extra spacing that causes overflow */
  min-width: 560px; /* ensures the table can scroll on small screens */
}

.breakdown-table th,
.breakdown-table td {
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  text-align: left;
}

.breakdown-table thead th {
  background-color: #072038;
  color: #fff;
}

@media (max-width: 480px) {
  .table-wrapper {
    padding-bottom: 8px;
  }
  .breakdown-table {
    min-width: 520px;
  }
}

/* removed .table-actions usage — export button now lives inside .input-section */

.btn-export {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px; /* fixed height */
  min-height: 40px;
  padding: 0 14px; /* horizontal padding only */
  background: #042241;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  width: 100%; /* full width inside the input column */
  margin-top: 12px;
}

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

@media (max-width: 480px) {
  .btn-export {
    height: 36px;
    min-height: 36px;
    padding: 0 12px;
    font-size: 0.85rem;
  }
}

/* Hide loader by default until a calculation starts */
.loader-wrapper {
  display: none; /* hidden initially */
  justify-content: center;
  align-items: center;
  min-height: 240px; /* reserve space for the chart */
  width: 100%;
}






.chart-section {
  background: #fff;
  padding: 20px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.chart-section h3 {
  width: 100%;
  color: #2d3748;
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.loader-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 240px; /* reserve the same area as the chart */
  width: 100%;
}

.infinity-loader {
  width: 120px;
  height: 60px;
  position: relative;
}

.infinity-loader::before,
.infinity-loader::after {
  content: "";
  position: absolute;
  width: 40px;
  height: 40px;
  border: 5px solid #2563eb;
  border-radius: 50%;
  animation: pulse 1.5s infinite ease-in-out;
}

.infinity-loader::after {
  left: 45px;
  animation-delay: 0.75s;
}

@keyframes pulse {
  0% { transform: scale(0.5); opacity: 0.3; }
  50% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.5); opacity: 0.3; }
}

/* Scope hiding to the specific chart so other canvases aren't affected */
#loanChart {
  display: none; /* hide until chart loads */
  width: 100%;
  max-width: 320px;
  height: auto; /* let Chart.js control canvas height with aspectRatio */
}

@media (max-width: 768px) {
  #loanChart {
    max-width: 280px;
  }
}
