:root {
  --bg: #0f1220;
  --bg-elev: #181c2e;
  --bg-card: #1f2438;
  --border: #2c3252;
  --text: #eef1ff;
  --text-muted: #9aa3c7;
  --accent: #ffb000;
  --accent-strong: #ff8200;
  --good: #38d39f;
  --warn: #ffb86b;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2140 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.page {
  max-width: 820px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

.hero {
  text-align: center;
  margin-bottom: 2rem;
}

.hero h1 {
  margin: 0;
  font-size: 2.6rem;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, var(--accent) 0%, var(--accent-strong) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  color: var(--text-muted);
  margin: 0.5rem 0 0;
  font-size: 1.05rem;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
  flex: 1;
}

.field-row {
  display: flex;
  gap: 1rem;
}

label {
  font-weight: 600;
  font-size: 0.92rem;
}

.optional {
  color: var(--text-muted);
  font-weight: 400;
}

input,
select {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  color: var(--text);
  font-size: 1rem;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 176, 0, 0.18);
}

.hint {
  font-size: 0.85rem;
  color: var(--accent);
  margin: 0;
  min-height: 1rem;
}

.btn-primary {
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.85rem 1rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1a1300;
  background: linear-gradient(120deg, var(--accent) 0%, var(--accent-strong) 100%);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease;
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-primary:active {
  transform: translateY(1px);
}

.results {
  margin-top: 2rem;
}

.results h2 {
  font-size: 1.15rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 1rem;
}

.results-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.result {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.25rem 1rem;
  align-items: center;
}

.result.top {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset, var(--shadow);
}

.rank {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-muted);
  width: 2.4rem;
  text-align: center;
}

.result.top .rank {
  color: var(--accent);
}

.card-name {
  font-weight: 700;
  font-size: 1.1rem;
}

.card-issuer {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.card-links {
  display: flex;
  gap: 0.85rem;
  margin-top: 0.45rem;
}

.card-links a {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}

.card-links a:hover {
  border-bottom-color: var(--accent);
}

.kf-note {
  font-size: 0.8rem;
  color: var(--warn);
  margin-top: 0.3rem;
}

.miles {
  text-align: right;
}

.miles-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--good);
}

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

.miles-secondary {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  opacity: 0.9;
}

.mpd-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: rgba(56, 211, 159, 0.15);
  color: var(--good);
  margin-left: 0.5rem;
}

.mpd-badge.base {
  background: rgba(154, 163, 199, 0.15);
  color: var(--text-muted);
}

.caveats {
  grid-column: 1 / -1;
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.caveats li {
  font-size: 0.82rem;
  color: var(--warn);
  padding-left: 1.1rem;
  position: relative;
}

.caveats li::before {
  content: "⚠";
  position: absolute;
  left: 0;
}

.fee {
  font-size: 0.8rem;
  color: var(--text-muted);
  grid-column: 2 / 3;
}

.empty-state {
  margin-top: 2rem;
  text-align: center;
  color: var(--text-muted);
}

.footer {
  margin-top: 3rem;
  text-align: center;
  color: var(--text-muted);
}

.disclaimer {
  font-size: 0.85rem;
}

.small {
  font-size: 0.78rem;
  opacity: 0.8;
}

@media (max-width: 540px) {
  .field-row {
    flex-direction: column;
    gap: 0;
  }
  .result {
    grid-template-columns: auto 1fr;
  }
  .miles {
    grid-column: 1 / -1;
    text-align: left;
    margin-top: 0.4rem;
  }
}

/* Phase 2: exclusions, conditional upside, and the all-excluded case. */
.results-notice {
  margin: 0 0 0.75rem;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  background: #fff8e1;
  border: 1px solid #f0d99b;
  font-size: 0.9rem;
}

.result.excluded {
  opacity: 0.62;
}

.exclusion-note {
  margin-top: 0.3rem;
  font-size: 0.85rem;
  color: #a03030;
}

.miles-upside {
  margin-top: 0.2rem;
  font-size: 0.8rem;
  color: #666;
  font-style: italic;
}
