:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-soft: #fbfbfd;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --border: rgba(0, 0, 0, 0.1);
  --border-soft: rgba(0, 0, 0, 0.06);
  --blue: #0071e3;
  --blue-soft: #e8f2ff;
  --green: #34c759;
  --green-soft: #eaf8ef;
  --red: #ff3b30;
  --red-soft: #fff0ee;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top right, rgba(0, 113, 227, 0.08), transparent 35%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  line-height: 1.4;
}

.app {
  width: min(760px, calc(100% - 32px));
  min-height: 100svh;
  margin: 0 auto;
  padding: 30px 0 34px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(3.2rem, 9vw, 6.8rem);
  font-weight: 800;
  letter-spacing: -0.06em;
  line-height: 0.95;
}

.data-status {
  flex: 0 0 auto;
  max-width: 170px;
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.04);
  padding: 9px 13px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

.result-panel {
  border: 1px solid var(--border-soft);
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  padding: 30px;
  backdrop-filter: blur(20px);
}

.input-panel {
  margin-top: 16px;
  border: 1px solid var(--border-soft);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.06);
  padding: 22px;
}

.verdict-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.verdict-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 800;
}

.verdict-pill.saved {
  background: var(--green-soft);
  color: #137a3a;
}

.verdict-pill.loss {
  background: var(--red-soft);
  color: var(--red);
}

.period {
  max-width: 270px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-align: right;
}

.result-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 17px;
  font-weight: 700;
}

.result-amount {
  margin: 0;
  color: var(--blue);
  font-size: clamp(5rem, 16vw, 10rem);
  font-weight: 850;
  letter-spacing: -0.08em;
  line-height: 0.9;
  white-space: nowrap;
}

.result-amount.loss {
  color: var(--red);
}

.result-amount.neutral {
  color: var(--text);
}

.result-copy {
  margin: 18px 0 28px;
  color: var(--text);
  font-size: clamp(1.25rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.18;
}

.totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}

.totals div {
  min-width: 0;
  padding: 15px 14px;
}

.totals div:first-child {
  padding-left: 0;
}

.totals div:last-child {
  padding-right: 0;
}

.totals div + div {
  border-left: 1px solid var(--border-soft);
}

.totals span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.totals strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.coverage {
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
}

.usage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

label {
  display: grid;
  gap: 9px;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

input {
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 16px 18px;
  font: inherit;
  font-size: 22px;
  font-weight: 700;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

input:focus {
  outline: none;
  border-color: var(--blue);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.14);
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

button {
  min-height: 40px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  padding: 8px 12px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

button:hover {
  border-color: rgba(0, 113, 227, 0.25);
  background: var(--blue-soft);
}

button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.14);
}

button.is-active,
button[aria-pressed="true"] {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.breakdown {
  margin-top: 20px;
  border-top: 1px solid var(--border-soft);
}

.breakdown-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 58px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text);
  font-size: 18px;
  font-weight: 650;
}

.breakdown-row strong {
  color: var(--blue);
  font-weight: 800;
  text-align: right;
}

.breakdown-row strong.loss {
  color: var(--red);
}

.breakdown-row strong.neutral {
  color: var(--muted);
}

.assumptions {
  margin-top: 16px;
}

summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--muted);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  cursor: pointer;
}

summary::-webkit-details-marker {
  display: none;
}

summary::before {
  content: "▸";
  margin-right: 8px;
  color: var(--muted);
  transition: transform 160ms ease;
}

.assumptions[open] summary::before {
  transform: rotate(90deg);
}

.assumption-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  border-radius: 18px;
  background: var(--bg);
  padding: 18px;
}

.assumption-grid label {
  font-size: 14px;
  color: var(--muted);
}

.assumption-grid input {
  min-height: 48px;
  border-color: var(--border-soft);
  font-size: 16px;
  padding: 11px 12px;
}

.footnote {
  margin: 16px 4px 0;
  color: var(--muted);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.45;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 700px) {
  .app {
    width: min(100% - 22px, 760px);
    padding-top: 18px;
  }

  .topbar {
    display: block;
    margin-bottom: 18px;
  }

  h1 {
    font-size: clamp(3.2rem, 17vw, 5.2rem);
  }

  .data-status {
    display: inline-flex;
    max-width: none;
    margin-top: 14px;
    text-align: left;
  }

  .result-panel {
    border-radius: 28px;
    padding: 22px;
  }

  .verdict-row {
    display: grid;
    gap: 8px;
    margin-bottom: 20px;
  }

  .period {
    max-width: none;
    text-align: left;
  }

  .result-amount {
    font-size: clamp(4.4rem, 18vw, 7.4rem);
    letter-spacing: -0.075em;
  }

  .result-copy {
    margin-bottom: 22px;
  }

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

  .totals div {
    padding: 13px 0;
  }

  .totals div + div {
    border-left: 0;
    border-top: 1px solid var(--border-soft);
  }

  .input-panel {
    border-radius: 26px;
    padding: 18px;
  }

  .usage-grid,
  .assumption-grid {
    grid-template-columns: 1fr;
  }

  .preset-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .footnote {
    font-size: 16px;
  }
}
