:root {
  color-scheme: light only;
  --app-bg: #eef2f8;
  --content-bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f0f3f8;
  --text: #111c31;
  --text-secondary: #667287;
  --text-tertiary: #929cad;
  --accent: #1768e5;
  --accent-deep: #0b3f9c;
  --accent-soft: #eaf2ff;
  --line: rgba(17, 35, 65, 0.09);
  --danger: #d83956;
  --radius-panel: 22px;
  --radius-control: 15px;
  --tap-size: 44px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

html {
  background: var(--app-bg);
}

body {
  color: var(--text);
  background: var(--app-bg);
  overscroll-behavior-y: none;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button {
  border: 0;
}

.app-shell {
  position: relative;
  width: 100%;
  min-height: 100svh;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 88% 3%, rgba(84, 151, 255, 0.34), transparent 16rem),
    linear-gradient(145deg, #0a347d 0%, #0d50bd 52%, #1973ec 100%);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(106px + env(safe-area-inset-top));
  padding: calc(10px + env(safe-area-inset-top)) 18px 25px;
  color: #fff;
  animation: fade-in 420ms ease both;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  display: block;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  box-shadow: 0 10px 24px rgba(0, 19, 63, 0.24);
}

.brand-copy {
  display: grid;
  gap: 2px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: -0.035em;
}

h1 {
  color: #fff;
  font-size: 22px;
  font-weight: 760;
  line-height: 1.05;
}

.app-subtitle {
  margin: 0;
  color: rgba(255, 255, 255, 0.70);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

h2 {
  font-size: 21px;
  line-height: 1.1;
}

.icon-button,
.delete-button {
  display: grid;
  place-items: center;
  width: var(--tap-size);
  height: var(--tap-size);
  min-width: var(--tap-size);
  padding: 0;
  border-radius: 50%;
  transition: transform 150ms ease, background 150ms ease;
}

.icon-button {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.17);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.icon-button:active,
.delete-button:active {
  transform: scale(0.93);
}

.icon-button svg,
.delete-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-main {
  position: relative;
  display: grid;
  gap: 12px;
  min-height: calc(100svh - 88px);
  margin-top: -18px;
  padding: 16px 15px calc(20px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.43), transparent 10rem),
    var(--content-bg);
  box-shadow: 0 -12px 34px rgba(0, 27, 83, 0.12);
}

.card,
.result-card,
.target-card {
  border: 1px solid rgba(17, 35, 65, 0.065);
  background: var(--surface);
  box-shadow: 0 9px 26px rgba(29, 50, 87, 0.055), 0 1px 3px rgba(29, 50, 87, 0.04);
}

.card {
  padding: 15px 15px 14px;
  border-radius: var(--radius-panel);
  animation: rise-in 440ms cubic-bezier(.22, .8, .25, 1) both;
}

.card:nth-of-type(2) {
  animation-delay: 55ms;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 14px;
}

.section-number {
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 15px;
  font-weight: 800;
}

.section-kicker,
.result-label {
  margin: 0;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 720;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.section-kicker {
  margin-bottom: 2px;
  font-size: 9.5px;
  letter-spacing: 0.12em;
}

.field-stack {
  display: grid;
  gap: 11px;
}

.field,
.tax-field,
.claim-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.field-label,
.claim-label {
  display: block;
  margin: 0 0 6px 2px;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 680;
}

.input-shell {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 50px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: #fbfcfe;
  box-shadow: inset 0 1px 1px rgba(17, 35, 65, 0.02);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.input-shell:focus-within {
  border-color: rgba(23, 104, 229, 0.72);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(23, 104, 229, 0.12), 0 7px 18px rgba(23, 104, 229, 0.07);
}

.input-shell input,
.input-shell select {
  width: 100%;
  min-width: 0;
  height: 50px;
  margin: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 18px;
  font-weight: 680;
  letter-spacing: -0.02em;
  appearance: none;
  -webkit-appearance: none;
}

.input-shell input {
  padding: 0 48px 0 15px;
}

.input-shell input::placeholder {
  color: #a4adbb;
  opacity: 1;
}

.input-shell select {
  padding: 0 44px 0 15px;
}

.input-suffix {
  position: absolute;
  right: 15px;
  color: var(--text-tertiary);
  font-size: 16px;
  font-weight: 720;
  pointer-events: none;
}

.select-chevron {
  position: absolute;
  right: 14px;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--text-tertiary);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  min-height: 50px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface-soft);
}

.segmented-control label {
  position: relative;
  display: block;
  min-width: 0;
}

.segmented-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  display: grid;
  place-items: center;
  width: 100%;
  height: 44px;
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 730;
  transition: color 170ms ease, background 170ms ease, box-shadow 170ms ease, transform 140ms ease;
}

.segmented-control input:checked + span {
  color: var(--accent-deep);
  background: #fff;
  box-shadow: 0 3px 10px rgba(25, 43, 74, 0.10), inset 0 0 0 1px rgba(25, 43, 74, 0.035);
}

.segmented-control label:active span {
  transform: scale(0.97);
}

.segmented-control input:focus-visible + span {
  outline: 3px solid rgba(23, 104, 229, 0.17);
}

.claims-list {
  display: grid;
  gap: 10px;
}

.claim-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: end;
  gap: 9px;
  animation: claim-in 230ms cubic-bezier(.22, .8, .25, 1) both;
}

.claim-input-shell input {
  font-size: 17px;
}

.delete-button {
  color: var(--danger);
  background: rgba(216, 57, 86, 0.075);
  box-shadow: inset 0 0 0 1px rgba(216, 57, 86, 0.10);
}

.delete-button:focus-visible,
.icon-button:focus-visible {
  outline: 3px solid rgba(23, 104, 229, 0.18);
  outline-offset: 2px;
}

.results {
  display: grid;
  gap: 10px;
  padding-bottom: 2px;
  animation: rise-in 470ms 100ms cubic-bezier(.22, .8, .25, 1) both;
}

.result-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
  min-height: 124px;
  overflow: hidden;
  border-radius: var(--radius-panel);
}

.result-card-primary {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.13);
  background:
    radial-gradient(circle at 92% 13%, rgba(91, 163, 255, 0.50), transparent 13rem),
    linear-gradient(135deg, #082d70 0%, #0d4db8 49%, #176fe7 100%);
  box-shadow: 0 15px 32px rgba(10, 67, 159, 0.23);
}

.result-card-primary::after {
  content: "";
  position: absolute;
  width: 126px;
  height: 126px;
  right: -72px;
  top: -67px;
  border: 20px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
}

.result-block {
  position: relative;
  z-index: 1;
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: space-between;
  padding: 17px 16px 16px;
}

.result-block-secondary {
  border-left: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.055);
}

.result-card-primary .result-label {
  color: rgba(255, 255, 255, 0.68);
  line-height: 1.3;
}

.result-value {
  position: relative;
  z-index: 1;
  display: block;
  color: inherit;
  font-size: clamp(34px, 10.4vw, 43px);
  font-weight: 790;
  line-height: .98;
  letter-spacing: -0.052em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: opacity 130ms ease, transform 130ms ease;
}

.result-value-currency {
  font-size: clamp(24px, 7vw, 30px);
  letter-spacing: -0.045em;
}

.result-value.is-updating {
  opacity: 0.45;
  transform: translateY(2px);
}

.target-results {
  display: block;
}

.target-results[hidden] {
  display: none;
}

.target-results.is-revealing {
  animation: reveal-targets 260ms cubic-bezier(.22, .8, .25, 1) both;
}

.target-card {
  padding: 4px 16px;
  border-radius: var(--radius-panel);
}

.target-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 66px;
}

.target-row + .target-row {
  border-top: 1px solid var(--line);
}

.target-row .result-label {
  max-width: 175px;
  color: var(--text-secondary);
  font-size: 10.5px;
  line-height: 1.35;
}

.result-value-compact {
  color: var(--text);
  font-size: 21px;
  font-weight: 760;
  letter-spacing: -0.035em;
}

.safe-area-spacer {
  display: none;
}

noscript {
  display: block;
  margin: 20px;
  padding: 16px;
  border-radius: 14px;
  background: #fff;
}

@media (min-width: 521px) {
  body {
    display: grid;
    place-items: start center;
    padding: 24px;
    background: #dfe5ee;
  }

  .app-shell {
    width: min(100%, 620px);
    border-radius: 34px;
    box-shadow: 0 28px 80px rgba(16, 34, 67, 0.20);
  }
}

@media (min-width: 860px) {
  body {
    padding: 32px;
  }

  .app-shell {
    width: min(100%, 980px);
  }

  .app-header {
    padding-inline: 28px;
  }

  .app-main {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
    gap: 16px;
    padding: 22px 22px 28px;
  }

  .card {
    min-height: 100%;
    padding: 20px;
  }

  .results {
    grid-column: 1 / -1;
  }
}

@media (max-width: 359px) {
  .app-main {
    padding-inline: 12px;
  }

  .card {
    padding-inline: 13px;
  }

  .segmented-control span {
    font-size: 13px;
  }

  .result-block {
    padding-inline: 13px;
  }
}

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

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes claim-in {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes reveal-targets {
  from {
    opacity: 0;
    transform: translateY(-7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
