:root {
  --bg: #f5fbff;
  --surface: #ffffff;
  --surface-blue: #eef8ff;
  --ink: #0a1f33;
  --muted: #536879;
  --line: #d7e6f1;
  --blue: #0ea5e9;
  --blue-dark: #0369a1;
  --green: #0f9f6e;
  --orange: #f97316;
  --orange-dark: #c2410c;
  --shadow: 0 28px 90px rgba(10, 31, 51, 0.16);
  --radius: 28px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% 12%, rgba(14, 165, 233, 0.2), transparent 28rem),
    radial-gradient(circle at 86% 78%, rgba(15, 159, 110, 0.16), transparent 30rem),
    linear-gradient(135deg, #ffffff 0%, var(--bg) 58%, #eef8ff 100%);
  color: var(--ink);
  font-family: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(14, 165, 233, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(14, 165, 233, 0.055) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: linear-gradient(to bottom, #000 0%, transparent 80%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
a,
input {
  -webkit-tap-highlight-color: transparent;
}

svg {
  display: block;
}

.calculator-app {
  display: grid;
  min-height: 100svh;
  place-items: center;
  padding: clamp(18px, 4vw, 48px);
}

.calculator-shell {
  display: grid;
  width: min(1120px, 100%);
  gap: 22px;
}

.app-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: end;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  color: var(--ink);
  font-size: 0.96rem;
  font-weight: 800;
  grid-column: 1 / -1;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--green));
  color: #ffffff;
  box-shadow: 0 14px 28px rgba(14, 165, 233, 0.28);
}

.brand-mark svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.headline-block {
  max-width: 760px;
}

h1 {
  max-width: 820px;
  margin: 0;
  color: var(--ink);
  font-size: clamp(2.35rem, 6vw, 5rem);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 0.96;
}

.headline-block p {
  max-width: 680px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.4vw, 1.2rem);
}

.quick-presets {
  display: inline-flex;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 14px 34px rgba(10, 31, 51, 0.08);
  padding: 6px;
}

.preset-button {
  min-height: 40px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 800;
  padding: 0 16px;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.preset-button:hover,
.preset-button:focus-visible,
.preset-button.is-active {
  background: #ffffff;
  color: var(--blue-dark);
  box-shadow: 0 8px 18px rgba(14, 165, 233, 0.14);
}

.calculator-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.82fr);
  overflow: hidden;
  border: 1px solid rgba(215, 230, 241, 0.92);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.input-panel,
.result-panel {
  padding: clamp(22px, 4vw, 38px);
}

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

.field {
  display: grid;
  align-content: start;
  gap: 8px;
}

.field > span {
  color: var(--ink);
  font-size: 0.96rem;
  font-weight: 800;
}

.field small {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.field input {
  width: 100%;
  min-height: 62px;
  border: 1px solid #cfe0ee;
  border-radius: 16px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-size: 1.25rem;
  font-weight: 800;
  padding: 0 16px;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.field input:hover {
  border-color: rgba(14, 165, 233, 0.5);
}

.field input:focus-visible,
.button:focus-visible,
.preset-button:focus-visible {
  outline: 3px solid rgba(14, 165, 233, 0.32);
  outline-offset: 3px;
}

.input-prefix,
.input-suffix {
  display: flex;
  align-items: center;
  min-height: 62px;
  overflow: hidden;
  border: 1px solid #cfe0ee;
  border-radius: 16px;
  background: #ffffff;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.input-prefix:focus-within,
.input-suffix:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.12);
}

.input-prefix span,
.input-suffix span {
  flex: 0 0 auto;
  color: var(--blue-dark);
  font-size: 1.08rem;
  font-weight: 900;
  padding-inline: 16px;
}

.input-prefix input,
.input-suffix input {
  min-height: 60px;
  border: 0;
  border-radius: 0;
}

.input-prefix input {
  padding-inline: 0 16px;
}

.input-suffix input {
  padding-inline: 16px 0;
}

.input-prefix input:focus-visible,
.input-suffix input:focus-visible {
  outline: 0;
}

.result-panel {
  display: grid;
  align-content: space-between;
  gap: 22px;
  background:
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.2), transparent 17rem),
    linear-gradient(180deg, #082033 0%, #071827 100%);
  color: #ffffff;
}

.result-label {
  margin: 0 0 10px;
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.92rem;
  font-weight: 900;
  text-transform: uppercase;
}

.result-value {
  display: block;
  color: #58f0aa;
  font-size: clamp(3rem, 6vw, 5.2rem);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 0.95;
}

.result-meter {
  overflow: hidden;
  height: 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.result-meter span {
  display: block;
  width: var(--meter-width, 45%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), #facc15, var(--orange));
  transition: width 420ms ease;
}

.breakdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.breakdown-grid div {
  min-height: 104px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
  padding: 18px;
}

.breakdown-grid span {
  display: block;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.82rem;
  font-weight: 800;
}

.breakdown-grid strong {
  display: block;
  margin-top: 8px;
  color: #ffffff;
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  font-weight: 800;
  line-height: 1;
}

.formula-note {
  margin: 0;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.9rem;
}

.button {
  display: inline-flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1;
  padding: 0 22px;
  text-align: center;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.button:hover {
  transform: translateY(-2px);
}

.button-primary {
  background: linear-gradient(135deg, var(--orange), #fb923c);
  box-shadow: 0 15px 34px rgba(249, 115, 22, 0.32);
  color: #ffffff;
}

.button-primary:hover {
  background: linear-gradient(135deg, var(--orange-dark), var(--orange));
}

@media (max-width: 860px) {
  .app-intro,
  .calculator-card {
    grid-template-columns: 1fr;
  }

  .quick-presets {
    width: fit-content;
  }

  .result-panel {
    min-height: 420px;
  }
}

@media (max-width: 620px) {
  .calculator-app {
    align-items: start;
    padding: 14px;
  }

  .calculator-shell {
    gap: 16px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  h1 {
    font-size: clamp(2.22rem, 12vw, 3.4rem);
  }

  .quick-presets {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .preset-button {
    padding-inline: 8px;
  }

  .calculator-card {
    border-radius: 24px;
  }

  .input-panel {
    grid-template-columns: 1fr;
  }

  .result-panel {
    min-height: 390px;
  }

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

  .button {
    width: 100%;
  }
}

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