* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    "Noto Sans Sinhala", "Iskoola Pota", "Nirmala UI", Arial, sans-serif;
  background: linear-gradient(135deg, #eef2ff, #f8fafc);
  min-height: 100vh;
  padding: 18px;
  color: #111827;
}

.calculator-wrapper {
  width: 100%;
  max-width: 960px;
  margin: 10px auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.calculator {
  width: 100%;
  background: #ffffff;
  border-radius: 24px;
  padding: 26px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.12);
}

h1 {
  margin: 0 0 8px;
  text-align: center;
  font-size: 26px;
}

.subtitle {
  text-align: center;
  margin: 0 0 26px;
  color: #6b7280;
  font-size: 15px;
  line-height: 1.6;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
  font-size: 14px;
}

input[type="number"],
select {
  width: 100%;
  padding: 14px 15px;
  margin-bottom: 24px;
  border: 1px solid #d1d5db;
  border-radius: 13px;
  font-size: 16px;
  outline: none;
  background: #ffffff;
}

input[type="number"]:focus,
select:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.tax-box,
.bank-rate-box {
  margin-bottom: 18px;
  padding: 15px;
  border-radius: 16px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
}

.bank-rate-box {
  margin-top: 4px;
}

.bank-rate-box .bank-period-select {
  margin-bottom: 16px;
}

.bank-section-label {
  margin-bottom: 10px;
}

.bank-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
}

.bank-option {
  min-width: 0;
  margin: 0;
  padding: 7px 3px 6px;
  border: 1px solid #e5e7eb;
  border-radius: 11px;
  background: #ffffff;
  cursor: pointer;
  text-align: center;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    box-shadow 0.15s ease;
}

.bank-option:hover {
  border-color: #a5b4fc;
  background: #f8faff;
}

.bank-option:has(input:checked) {
  border-color: #4f46e5;
  background: #eef2ff;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

.bank-option-main {
  min-height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.bank-option input[type="radio"] {
  flex: 0 0 auto;
  margin: 0;
}

.bank-option img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 5px;
}

.bank-name {
  display: block;
  min-width: 0;
  margin-top: 4px;
  overflow: hidden;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.2;
  color: #374151;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bank-rate-info {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #e5e7eb;
  text-align: center;
}

.bank-rate-info strong {
  display: block;
  font-size: 14px;
  color: #111827;
}

.bank-rate-info span {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: #6b7280;
}

#ratePreset:disabled,
#requiredRatePreset:disabled {
  background: #f3f4f6;
  color: #9ca3af;
  cursor: not-allowed;
  opacity: 0.8;
}

.clear-bank-selection-btn {
  display: block;
  width: auto;
  margin: 10px auto 0;
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #ffffff;
  color: #4f46e5;
  font-size: 11px;
  font-weight: 700;
}

.clear-bank-selection-btn:hover {
  background: #eef2ff;
}

.clear-bank-selection-btn[hidden] {
  display: none;
}

.radio-row {
  display: flex;
  gap: 18px;
  margin-top: 10px;
}

.radio-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 600;
  cursor: pointer;
}

.radio-row input {
  margin: 0;
}

button {
  width: 100%;
  border: none;
  border-radius: 15px;
  padding: 15px;
  font-size: 16px;
  font-weight: 800;
  background: #4f46e5;
  color: #ffffff;
  cursor: pointer;
}

button:hover {
  background: #4338ca;
}

.error {
  display: none;
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 12px;
  background: #fee2e2;
  color: #991b1b;
  font-size: 14px;
  text-align: center;
  line-height: 1.5;
}

.result-card {
  display: none;
  margin-top: 24px;
  margin-bottom: 25px;
  background: #f3f4f6;
  border-radius: 22px;
  padding: 22px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  font-size: 15px;
  color: #374151;
}

.summary-row strong {
  font-size: 18px;
  color: #111827;
  white-space: nowrap;
}

.result-card hr {
  border: none;
  border-top: 1px solid #d1d5db;
  margin: 18px 0;
}

.result-title {
  text-align: center;
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #374151;
  line-height: 1.5;
}

.final-amount {
  text-align: center;
  margin-top: 16px;
  font-size: 38px;
  font-weight: 900;
  line-height: 1.1;
  color: #111827;
  word-break: break-word;
}

.footer {
  margin-top: 18px;
  text-align: center;
  font-size: 12px;
  color: #9ca3af;
  line-height: 1.6;
}

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

@media (max-width: 480px) {
  .calculator {
    padding: 22px;
  }
  h1 {
    font-size: 23px;
  }
  .final-amount {
    font-size: 28px;
  }
  .summary-row {
    font-size: 14px;
  }
  .summary-row strong {
    font-size: 16px;
  }
  .bank-rate-box {
    padding: 12px;
  }

  .bank-grid {
    gap: 5px;
  }

  .bank-option {
    padding: 6px 2px 5px;
  }

  .bank-option-main {
    min-height: 30px;
    gap: 3px;
  }

  .bank-option img {
    width: 27px;
    height: 27px;
  }

  .bank-name {
    font-size: 8px;
  }
}

.site-logo {
  display: block;
  width: 200px;
  height: auto;
  margin: 0 auto 20px;
}

.footer-links {
  margin-top: 40px;
  padding: 20px;
  text-align: center;
  font-size: 14px;
}

.footer-links a {
  color: #4f46e5;
  text-decoration: none;
  margin: 0 8px;
}

.footer-links a:hover {
  text-decoration: underline;
}
