:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #101828;
  --muted: #667085;
  --primary: #4c5fd5;
  --accent: #7c3aed;
  --border: #e4e7ec;
  --input-bg: #f9f9ff;
  --shadow-card: 0 12px 30px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100vh;
}

body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

main.page {
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 2rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
}

h1 {
  margin: 0;
  text-align: center;
  color: var(--primary);
  font-size: 2rem;
  font-weight: 700;
}

h2 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--muted);
}

.muted {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.card {
  background: var(--surface);
  border-radius: 18px;
  padding: 1.75rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

/* Parameters Section */
.parameters {
  width: 100%;
}

.parameter-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--input-bg);
  color: var(--text);
  transition: all 0.2s ease;
}

.input-with-format {
  position: relative;
  width: 100%;
}

.formatted-number {
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: transparent;
}

.formatted-number.show-caret {
  caret-color: var(--text);
}

.formatted-number::placeholder {
  color: transparent;
}

.input-formatted {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  padding: 0 0.8rem;
  padding-right: 2.5rem;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
}

.field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(76, 95, 213, 0.15);
  background: #fff;
}

.tooltip {
  display: none;
}

/* Cost Cards Section */

.cards-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: stretch;
  /* Fix: ensure children stretch fully */
}

.cards-columns>.cost-card {
  height: 100%;
  /* Robust fill for the cards */
}

.cost-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  /* Stretches the card to fill its container */
  justify-content: space-between;
}


.cost-breakdown {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  flex: 1;
  /* Allows the list to expand */
  justify-content: center;
  /* Centers list items vertically if there is extra space */
}

.cost-breakdown li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  padding: 0.25rem 0;
}

.cost-breakdown li span:first-child {
  color: var(--muted);
}

.cost-breakdown li span:last-child {
  color: var(--text);
  font-weight: 600;
  font-size: 1rem;
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 2px solid var(--border);
}

.total-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
}

.total-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

/* Results Section */
.results {
  width: 100%;
}

.results-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.result-item {
  padding: 1.5rem;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(76, 95, 213, 0.08), rgba(124, 58, 237, 0.08));
  border: 1px solid var(--border);
  text-align: center;
}

.result-item .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.result-item .value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
  line-height: 1.2;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
  .parameter-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  main.page {
    /* On mobile, disable full-screen fit to allow natural scrolling */
    min-height: auto;
    height: auto;
    display: block;
    padding: 1.5rem 1rem;
  }

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

  .cards-columns {
    grid-template-columns: 1fr;
    flex: none;
  }

  .results-row {
    grid-template-columns: 1fr;
  }

  .card {
    margin-bottom: 1rem;
  }
}