:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1a1d23;
  --text-muted: #5c6270;
  --border: #e1e3e8;
  --primary: #1f5eff;
  --primary-dark: #143fbf;
  --highlight-bg: #eef2ff;
  --total-bg: #f8f9fb;
  --radius: 10px;
  --content-max: 720px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 32px 16px 48px;
}

/* Site chrome: header brand/nav bar and footer, full-bleed with content-aligned inner wrappers */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
}

.brand-icon svg {
  width: 20px;
  height: 20px;
}

.brand-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.site-nav {
  display: flex;
  gap: 20px;
}

.site-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.site-nav a:hover {
  color: var(--primary);
}

.site-footer {
  margin-top: 24px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.site-footer-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 32px 16px 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 24px;
}

.footer-brand {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 420px;
}

.footer-title {
  margin: 0;
  font-weight: 700;
}

.footer-tagline {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px 24px;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.footer-links a:hover {
  color: var(--primary);
}

.footer-bottom {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 16px 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 24px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.footer-bottom p {
  margin: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-header h1 {
  font-size: 1.75rem;
  margin: 0 0 8px;
}

.subtitle {
  color: var(--text-muted);
  margin: 0 0 28px;
  line-height: 1.5;
}

.calculator {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.form {
  display: grid;
  gap: 16px;
  margin-bottom: 8px;
}

.field-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0;
  display: grid;
  gap: 16px;
}

.field-group legend {
  padding: 0 6px;
  font-weight: 700;
  font-size: 0.95rem;
}

/* Quick calc hero: minimal-friction primary input + Calculate button */
.quick-calc label {
  display: block;
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: 10px;
}

.quick-calc-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.amount-input {
  position: relative;
  flex: 1 1 200px;
  display: flex;
  align-items: center;
}

.amount-input .currency-prefix {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  font-weight: 600;
  pointer-events: none;
}

.amount-input input {
  width: 100%;
  padding: 12px 12px 12px 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1.1rem;
  background: var(--surface);
  color: var(--text);
}

.amount-input input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.calculate-btn-primary {
  margin-top: 0;
  padding: 12px 28px;
  font-size: 1.05rem;
}

.info-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: help;
}

/* Progressive disclosure: "More options" reveals everything beyond the quick calc */
.more-options {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.more-options > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
  list-style: none;
}

.more-options > summary::-webkit-details-marker {
  display: none;
}

.more-options > summary::after {
  content: " ▾";
}

.more-options[open] > summary::after {
  content: " ▴";
}

.options-panel {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

/* Accordion "tabs" for each optional section, echoing a colour-block accordion pattern */
.option-tab {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.option-tab > summary {
  padding: 12px 16px;
  background: var(--highlight-bg);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.option-tab > summary::-webkit-details-marker {
  display: none;
}

.option-tab > summary::after {
  content: "+";
  font-weight: 700;
  color: var(--primary);
}

.option-tab[open] > summary::after {
  content: "−";
}

.option-tab-content {
  padding: 16px;
  display: grid;
  gap: 16px;
}

.frequency-group {
  gap: 12px;
}

.frequency-group-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.frequency-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.freq-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 400;
  cursor: pointer;
  background: var(--surface);
}

.freq-chip:has(input:checked) {
  background: var(--highlight-bg);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.hint {
  margin: -8px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.9rem;
  font-weight: 600;
}

.field input[type="number"],
.field select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
}

.field input[type="number"]:focus,
.field select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.checkbox-field label {
  font-weight: 400;
}

.calculate-btn {
  margin-top: 8px;
  padding: 12px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.calculate-btn:hover {
  background: var(--primary-dark);
}

.results {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.results h3 {
  font-size: 1rem;
  margin: 24px 0 8px;
}

.bonus-comparison {
  margin-top: 24px;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.result-card {
  background: var(--total-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.result-card.highlight {
  background: var(--highlight-bg);
  border-color: #c7d4ff;
}

.result-label {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.result-value {
  font-size: 1.4rem;
  font-weight: 700;
}

.breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.breakdown-table td {
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}

.breakdown-table td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.total-row td {
  font-weight: 700;
  border-bottom: none;
  border-top: 2px solid var(--border);
}

.disclaimer {
  margin-top: 20px;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.info-section {
  margin-top: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.info-section h2 {
  font-size: 1.25rem;
  margin: 0 0 12px;
}

.info-section p {
  line-height: 1.6;
  color: var(--text);
}

.info-section ul {
  padding-left: 20px;
  line-height: 1.7;
}

.faq-item {
  margin-top: 18px;
}

.faq-item h3 {
  font-size: 1rem;
  margin: 0 0 4px;
}

.faq-item p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Tablet: more breathing room, still a single column */
@media (min-width: 700px) {
  :root {
    --content-max: 900px;
  }

  .calculator {
    padding: 32px;
  }
}

/* Desktop: put the form and results side by side to use the extra width */
@media (min-width: 1080px) {
  :root {
    --content-max: 1240px;
  }

  .site-header-inner {
    padding-top: 16px;
    padding-bottom: 16px;
  }

  .app-header h1 {
    font-size: 2.1rem;
  }

  .subtitle {
    max-width: 70ch;
  }

  .calculator {
    display: grid;
    grid-template-columns: minmax(380px, 460px) 1fr;
    align-items: start;
    gap: 40px;
    padding: 36px;
  }

  .results {
    margin-top: 0;
    padding-top: 0;
    padding-left: 40px;
    border-top: none;
    border-left: 1px solid var(--border);
  }

  .info-section {
    padding: 36px;
  }

  .info-section p,
  .info-section li {
    max-width: 70ch;
  }

  .faq {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px 40px;
  }

  .faq h2 {
    grid-column: 1 / -1;
  }
}
